diff --git a/app/src/main/java/org/nuclearfog/twidda/activity/AppSettings.java b/app/src/main/java/org/nuclearfog/twidda/activity/AppSettings.java
index 0135d92a..acc6cb60 100644
--- a/app/src/main/java/org/nuclearfog/twidda/activity/AppSettings.java
+++ b/app/src/main/java/org/nuclearfog/twidda/activity/AppSettings.java
@@ -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) {
diff --git a/app/src/main/java/org/nuclearfog/twidda/backend/engine/ProxySetup.java b/app/src/main/java/org/nuclearfog/twidda/backend/engine/ProxySetup.java
index 013057ca..1901d3ca 100644
--- a/app/src/main/java/org/nuclearfog/twidda/backend/engine/ProxySetup.java
+++ b/app/src/main/java/org/nuclearfog/twidda/backend/engine/ProxySetup.java
@@ -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
}
}
diff --git a/app/src/main/java/org/nuclearfog/twidda/backend/engine/TwitterEngine.java b/app/src/main/java/org/nuclearfog/twidda/backend/engine/TwitterEngine.java
index 6add696a..7ce64c9a 100644
--- a/app/src/main/java/org/nuclearfog/twidda/backend/engine/TwitterEngine.java
+++ b/app/src/main/java/org/nuclearfog/twidda/backend/engine/TwitterEngine.java
@@ -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());
diff --git a/app/src/main/java/org/nuclearfog/twidda/database/GlobalSettings.java b/app/src/main/java/org/nuclearfog/twidda/database/GlobalSettings.java
index 09277d80..9ec59d8b 100644
--- a/app/src/main/java/org/nuclearfog/twidda/database/GlobalSettings.java
+++ b/app/src/main/java/org/nuclearfog/twidda/database/GlobalSettings.java
@@ -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);
}
diff --git a/app/src/main/res/values-de-rDE/strings.xml b/app/src/main/res/values-de-rDE/strings.xml
index 0efd932d..6e676951 100644
--- a/app/src/main/res/values-de-rDE/strings.xml
+++ b/app/src/main/res/values-de-rDE/strings.xml
@@ -148,4 +148,5 @@
Bild konnte nicht geladen werden!
Bild speichern
Video kann nicht abgespielt werden!
+ Ungültiger Port!
\ No newline at end of file
diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml
index 5e0e29fe..50f8139d 100644
--- a/app/src/main/res/values/strings.xml
+++ b/app/src/main/res/values/strings.xml
@@ -151,4 +151,5 @@
Could not load image!
save image
Could not play video!
+ Invalid port!
\ No newline at end of file