diff --git a/app/build.gradle b/app/build.gradle index b0db6d827..0f7ddf9ce 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -10,7 +10,7 @@ def getVersionName = { -> } return stdout.toString().trim() } - +1 configurations { all*.exclude group: 'xpp3', module: 'xpp3' @@ -22,7 +22,7 @@ android { defaultConfig { applicationId 'im.zom.messenger' - versionCode 1560014 + versionCode 1560015 versionName getVersionName() archivesBaseName = "Zom-$versionName" minSdkVersion project.ext.minSdkVersion diff --git a/app/src/main/assets/transports/ss b/app/src/main/assets/transports/ss deleted file mode 100755 index b5c61459e..000000000 Binary files a/app/src/main/assets/transports/ss and /dev/null differ diff --git a/app/src/main/java/org/awesomeapp/messenger/crypto/omemo/Omemo.java b/app/src/main/java/org/awesomeapp/messenger/crypto/omemo/Omemo.java index e02ebee2b..0a6149708 100644 --- a/app/src/main/java/org/awesomeapp/messenger/crypto/omemo/Omemo.java +++ b/app/src/main/java/org/awesomeapp/messenger/crypto/omemo/Omemo.java @@ -51,6 +51,11 @@ public Omemo (XMPPTCPConnection connection, BareJid user) { } + public void purgeDeviceKeys () + { + mOmemoStore.purgeOwnDeviceKeys(mOmemoManager); + } + private OmemoManager initOMemoManager(XMPPTCPConnection conn, BareJid altUser) { BareJid user; diff --git a/app/src/main/java/org/awesomeapp/messenger/plugin/xmpp/XmppConnection.java b/app/src/main/java/org/awesomeapp/messenger/plugin/xmpp/XmppConnection.java index 860cf9366..611817bc7 100644 --- a/app/src/main/java/org/awesomeapp/messenger/plugin/xmpp/XmppConnection.java +++ b/app/src/main/java/org/awesomeapp/messenger/plugin/xmpp/XmppConnection.java @@ -1717,10 +1717,8 @@ public void setProxy(String type, String host, int port) { if (type == null) { mProxyInfo = null; } else { - ProxyInfo.ProxyType pType = ProxyInfo.ProxyType.valueOf(type); mProxyInfo = new ProxyInfo(pType, host, port, null, null); - } } @@ -2002,8 +2000,73 @@ private AbstractXMPPConnection initConnection(Imps.ProviderSettings.QueryMap pro } else if (doAdvancedNetworking) { - RemoteImService.activateAdvancedNetworking(mContext); - setProxy("SOCKS5","127.0.0.1",31059); + /** + //if we don't use DNS lookup, see if we have info from the server json + Server serverConfig = Server.getServer(mContext,domain); + if (serverConfig != null) + { + if (serverConfig.ip != null) + server = serverConfig.ip; + else + server = serverConfig.server; + + serverPort = serverConfig.port; + + mConfig.setHost(server); + mConfig.setPort(serverPort); + + try { + + String[] addressParts = server.split("\\."); + if (Integer.parseInt(addressParts[0]) != -1) { + byte[] parts = new byte[addressParts.length]; + for (int i = 0; i < 4; i++) + parts[i] = (byte) Integer.parseInt(addressParts[i]); + + byte[] ipAddr = new byte[]{parts[0], parts[1], parts[2], parts[3]}; + InetAddress addr = InetAddress.getByAddress(ipAddr); + mConfig.setHostAddress(addr); + + } else { + mConfig.setHostAddress(InetAddress.getByName(server)); + } + } catch (Exception e) { + debug(TAG, "error parsing server as IP address; using as hostname instead"); + mConfig.setHostAddress(InetAddress.getByName(server)); + + } + + + }**/ + + // RemoteImService.activateAdvancedNetworking(mContext); + // setProxy(AdvancedNetworking.DEFAULT_PROXY_TYPE,AdvancedNetworking.DEFAULT_SERVER,AdvancedNetworking.DEFAULT_PORT); + + server = AdvancedNetworking.DEFAULT_SERVER; + serverPort = AdvancedNetworking.DEFAULT_PORT; + mConfig.setHost(server); + + mConfig.setPort(serverPort); + try { + + String[] addressParts = server.split("\\."); + if (Integer.parseInt(addressParts[0]) != -1) { + byte[] parts = new byte[addressParts.length]; + for (int i = 0; i < 4; i++) + parts[i] = (byte) Integer.parseInt(addressParts[i]); + + byte[] ipAddr = new byte[]{parts[0], parts[1], parts[2], parts[3]}; + InetAddress addr = InetAddress.getByAddress(ipAddr); + mConfig.setHostAddress(addr); + + } else { + mConfig.setHostAddress(InetAddress.getByName(server)); + } + } catch (Exception e) { + debug(TAG, "error parsing server as IP address; using as hostname instead"); + mConfig.setHostAddress(InetAddress.getByName(server)); + + } } else { mProxyInfo = null; @@ -2106,7 +2169,6 @@ else if (domain.contains("google.com")||domain.contains("gmail.com")) //if not g while (true) { try { - if (Build.VERSION.SDK_INT >= 20) { sslContext.getDefaultSSLParameters().setCipherSuites(XMPPCertPins.SSL_IDEAL_CIPHER_SUITES_API_20); @@ -2163,7 +2225,7 @@ else if (domain.contains("google.com")||domain.contains("gmail.com")) //if not g mConfig.setCustomSSLContext(sslContext); mConfig.setSecurityMode(ConnectionConfiguration.SecurityMode.required); mConfig.setHostnameVerifier( - mMemTrust.wrapHostnameVerifier(new org.apache.http.conn.ssl.StrictHostnameVerifier())); + mMemTrust.wrapHostnameVerifier(new org.apache.http.conn.ssl.StrictHostnameVerifier())); mConfig.setSendPresence(true); @@ -2820,6 +2882,7 @@ public void sendMessageAsync(ChatSession session, final Message message) { org.jivesoftware.smack.packet.Message msgEncrypted = getOmemo().getManager().encrypt(muc, msgXmpp.getBody()); + msgEncrypted.addExtension(new DeliveryReceiptRequest()); msgEncrypted.setStanzaId(msgXmpp.getStanzaId()); String deliveryReceiptId = DeliveryReceiptRequest.addTo(msgEncrypted); @@ -5125,7 +5188,7 @@ private String uploadFile(long fileSize, InputStream fis, Slot slot, UploadProgr if (!isReachable(putUrl.getHost(),putUrl.getPort())) useAdvancedNetworking = true; - + //urlconnection socks proxying only works on SDK 23+ if (!TextUtils.isEmpty(Preferences.getProxyServerHost())) { @@ -5134,8 +5197,8 @@ private String uploadFile(long fileSize, InputStream fis, Slot slot, UploadProgr } else if (useAdvancedNetworking) { //setProxy("SOCKS5","127.0.0.1",31059); - java.net.Proxy proxy =new java.net.Proxy(java.net.Proxy.Type.SOCKS,new InetSocketAddress("127.0.0.1",31059)); - urlConnection = (HttpURLConnection) putUrl.openConnection(proxy); + // java.net.Proxy proxy =new java.net.Proxy(java.net.Proxy.Type.SOCKS,new InetSocketAddress(AdvancedNetworking.DEFAULT_SERVER,AdvancedNetworking.DEFAULT_PORT)); + // urlConnection = (HttpURLConnection) putUrl.openConnection(proxy); } else { diff --git a/app/src/main/java/org/awesomeapp/messenger/service/AdvancedNetworking.java b/app/src/main/java/org/awesomeapp/messenger/service/AdvancedNetworking.java index 193d2b79c..d5e309f85 100644 --- a/app/src/main/java/org/awesomeapp/messenger/service/AdvancedNetworking.java +++ b/app/src/main/java/org/awesomeapp/messenger/service/AdvancedNetworking.java @@ -19,16 +19,25 @@ public class AdvancedNetworking { private File mFileTransport = null; private Thread mTransportThread = null; - public void installTransport (Context context, String assetKey) + public final static String TRANSPORT_SS2 = "ss2"; + + public final static String DEFAULT_PROXY_TYPE = "SOCKS5"; + public final static String DEFAULT_SERVER = "172.104.48.102"; + public final static int DEFAULT_PORT = 80; + + public boolean installTransport (Context context, String assetKey) { BinaryInstaller bi = new BinaryInstaller(context,context.getFilesDir()); try { - mFileTransport = bi.installResource("transports", assetKey, false); + mFileTransport = bi.installResource("transports", assetKey, true); + return mFileTransport.exists(); } catch (Exception ioe) { debug("Couldn't install transport: " + ioe); } + + return false; } public void startTransport () @@ -58,22 +67,32 @@ private void startTransportSync () { String serverAddress = "172.104.48.102"; - String serverPort = "443"; + String serverPort = "80"; String serverPassword = "zomzom123"; - String serverCipher = "aes-128-cfb"; + String serverCipher = "AEAD_CHACHA20_POLY1305";//"aes-128-cfb"; String localAddress = "127.0.0.1"; String localPort = "31059"; StringBuffer cmd = new StringBuffer(); cmd.append(mFileTransport.getCanonicalPath()).append(' '); + + /** cmd.append("-s ").append(serverAddress).append(' '); cmd.append("-p ").append(serverPort).append(' '); cmd.append("-k ").append(serverPassword).append(' '); cmd.append("-m ").append(serverCipher).append(' '); cmd.append("-b ").append(localAddress).append(' '); cmd.append("-l ").append(localPort).append(' '); + **/ + + cmd.append(" -c ").append("'ss://").append(serverCipher).append(":"); + cmd.append(serverPassword).append("@"); + cmd.append(serverAddress).append(":").append(serverPort).append("'"); + cmd.append(" -socks :").append(localPort); + + //disable for now + // exec(cmd.toString(), false); - exec(cmd.toString(), false); } } catch (Exception ioe) diff --git a/app/src/main/java/org/awesomeapp/messenger/service/RemoteImService.java b/app/src/main/java/org/awesomeapp/messenger/service/RemoteImService.java index cf0704e49..3443c0e4e 100644 --- a/app/src/main/java/org/awesomeapp/messenger/service/RemoteImService.java +++ b/app/src/main/java/org/awesomeapp/messenger/service/RemoteImService.java @@ -82,6 +82,8 @@ import info.guardianproject.cacheword.CacheWordHandler; import info.guardianproject.cacheword.ICacheWordSubscriber; +import static org.awesomeapp.messenger.service.AdvancedNetworking.TRANSPORT_SS2; + public class RemoteImService extends Service implements ImService, ICacheWordSubscriber { @@ -623,7 +625,7 @@ public static void installTransports (Context context) } aNetworking = new AdvancedNetworking(); - aNetworking.installTransport(context,"ss"); + aNetworking.installTransport(context,AdvancedNetworking.TRANSPORT_SS2); aNetworking.startTransport(); } @@ -807,7 +809,7 @@ public static void activateAdvancedNetworking (Context context) else { aNetworking = new AdvancedNetworking(); - aNetworking.installTransport(context,"ss"); + aNetworking.installTransport(context,TRANSPORT_SS2); } aNetworking.startTransport();