fixed crash, bug fix

This commit is contained in:
nuclearfog 2020-06-24 01:00:39 +02:00
parent 4c37aee5bd
commit 42fffe957b
No known key found for this signature in database
GPG Key ID: ED35E22099354A64
6 changed files with 19 additions and 3 deletions

View File

@ -397,6 +397,17 @@ public class AppSettings extends AppCompatActivity implements OnClickListener, O
String errMsg = getString(R.string.error_empty_port);
proxyPort.setError(errMsg);
success = false;
} else if (editPort.length() > 5) {
String errMsg = getString(R.string.error_invalid_port);
proxyPort.setError(errMsg);
success = false;
} else {
int port = Integer.parseInt(editPort.toString());
if (port < 0 || port > 65535) {
String errMsg = getString(R.string.error_invalid_port);
proxyPort.setError(errMsg);
success = false;
}
}
}
if (editUser != null && editUser.length() > 0) {

View File

@ -65,8 +65,10 @@ abstract class ProxySetup {
int proxyPort = settings.getProxyPortNumber();
InetSocketAddress socket = new InetSocketAddress(proxyHost, proxyPort);
Proxy httpsProxy = new Proxy(Proxy.Type.HTTP, socket);
proxyList = new ArrayList<>(1);
Proxy socksProxy = new Proxy(Proxy.Type.SOCKS, socket);
proxyList = new ArrayList<>(2);
proxyList.add(httpsProxy);
proxyList.add(socksProxy);
}
@Override
@ -76,6 +78,7 @@ abstract class ProxySetup {
@Override
public void connectFailed(URI uri, SocketAddress sa, IOException ioe) {
// ignore to force using proxy and avoid data leak
}
}

View File

@ -79,7 +79,7 @@ public class TwitterEngine {
// Twitter4J has its own proxy settings
if (settings.isProxyServerSet()) {
builder.setHttpProxyHost(settings.getProxyHost());
builder.setHttpProxyPort(Integer.parseInt(settings.getProxyPort()));
builder.setHttpProxyPort(settings.getProxyPortNumber());
if (settings.isProxyLoginSet()) {
builder.setHttpProxyUser(settings.getProxyUser());
builder.setHttpProxyPassword(settings.getProxyPass());

View File

@ -300,7 +300,7 @@ public class GlobalSettings {
* @return proxy port integer
*/
public int getProxyPortNumber() {
if (proxyPort.isEmpty())
if (proxyPort.isEmpty() || proxyPort.length() > 5)
return 0;
return Integer.parseInt(proxyPort);
}

View File

@ -148,4 +148,5 @@
<string name="error_image_loading">Bild konnte nicht geladen werden!</string>
<string name="item_image_save">Bild speichern</string>
<string name="error_cant_load_video">Video kann nicht abgespielt werden!</string>
<string name="error_invalid_port">Ungültiger Port!</string>
</resources>

View File

@ -151,4 +151,5 @@
<string name="error_image_loading">Could not load image!</string>
<string name="item_image_save">save image</string>
<string name="error_cant_load_video">Could not play video!</string>
<string name="error_invalid_port">Invalid port!</string>
</resources>