|
7 | 7 | import com.xabber.android.data.SettingsManager;
|
8 | 8 |
|
9 | 9 | import org.jivesoftware.smack.SASLAuthentication;
|
| 10 | +import org.jivesoftware.smack.proxy.ProxyInfo; |
10 | 11 | import org.jivesoftware.smack.sasl.provided.SASLPlainMechanism;
|
11 | 12 | import org.jivesoftware.smack.tcp.XMPPTCPConnection;
|
12 | 13 | import org.jivesoftware.smack.tcp.XMPPTCPConnectionConfiguration;
|
@@ -61,6 +62,48 @@ public class ConnectionBuilder {
|
61 | 62 | return new XMPPTCPConnection(builder.build());
|
62 | 63 | }
|
63 | 64 |
|
| 65 | + private static ProxyInfo getProxyInfo(ConnectionSettings connectionSettings) { |
| 66 | + |
| 67 | + ProxyInfo proxyInfo; |
| 68 | + |
| 69 | + ProxyType proxyType = connectionSettings.getProxyType(); |
| 70 | + |
| 71 | + String proxyHost = connectionSettings.getProxyHost(); |
| 72 | + int proxyPort = connectionSettings.getProxyPort(); |
| 73 | + String proxyPassword = connectionSettings.getProxyPassword(); |
| 74 | + String proxyUser = connectionSettings.getProxyUser(); |
| 75 | + |
| 76 | + if (proxyType == null) { |
| 77 | + proxyInfo = ProxyInfo.forDefaultProxy(); |
| 78 | + } else { |
| 79 | + switch (proxyType) { |
| 80 | + case none: |
| 81 | + proxyInfo = ProxyInfo.forNoProxy(); |
| 82 | + break; |
| 83 | + case http: |
| 84 | + proxyInfo = ProxyInfo.forHttpProxy(proxyHost, proxyPort, proxyUser, proxyPassword); |
| 85 | + break; |
| 86 | + case socks4: |
| 87 | + proxyInfo = ProxyInfo.forSocks4Proxy(proxyHost, proxyPort, proxyUser, proxyPassword); |
| 88 | + break; |
| 89 | + case socks5: |
| 90 | + proxyInfo = ProxyInfo.forSocks5Proxy(proxyHost, proxyPort, proxyUser, proxyPassword); |
| 91 | + break; |
| 92 | + case orbot: |
| 93 | + proxyHost = "localhost"; |
| 94 | + proxyPort = 9050; |
| 95 | + proxyPassword = ""; |
| 96 | + proxyUser = ""; |
| 97 | + proxyInfo = ProxyInfo.forSocks5Proxy(proxyHost, proxyPort, proxyUser, proxyPassword); |
| 98 | + break; |
| 99 | + default: |
| 100 | + proxyInfo = ProxyInfo.forDefaultProxy(); |
| 101 | + } |
| 102 | + } |
| 103 | + |
| 104 | + return proxyInfo; |
| 105 | + } |
| 106 | + |
64 | 107 | private static void setUpSasl() {
|
65 | 108 | if (SettingsManager.connectionUsePlainTextAuth()) {
|
66 | 109 | final Map<String, String> registeredSASLMechanisms = SASLAuthentication.getRegisterdSASLMechanisms();
|
|
0 commit comments