diff --git a/build.gradle b/build.gradle index b566f316..3d047dd4 100644 --- a/build.gradle +++ b/build.gradle @@ -35,6 +35,9 @@ android { pickFirst "META-INF/DEPENDENCIES" pickFirst "META-INF/LICENSE" pickFirst "META-INF/NOTICE" + pickFirst "META-INF/BCKEY.SF" + pickFirst "META-INF/BCKEY.DSA" + pickFirst "META-INF/INDEX.LIST" } lintOptions { abortOnError false @@ -54,14 +57,14 @@ dependencies { } compile 'com.android.support:support-v4:22.2.0' compile 'com.android.support:appcompat-v7:22.2.0' - compile 'com.madgag.spongycastle:pkix:1.52.0.0' compile 'org.apache.sshd:sshd-core:0.8.0' - compile 'org.bouncycastle:bcprov-jdk16:1.46' - // compile 'io.netty:netty-all:4.0.29.Final' // We use a custom build netty in libs directory due to ssl related bug -// compile fileTree(include: '*.jar', dir: 'libs') + compile 'org.bouncycastle:bcpkix-jdk15on:1.52' + compile 'org.bouncycastle:bcprov-jdk15on:1.52' +// compile 'io.netty:netty-handler:4.0.25.Final' // We use a custom build netty in libs directory due to ssl related bug + compile fileTree(include: '*.jar', dir: 'libs') + androidTestCompile 'org.mockito:mockito-core:1.10.19' // Because mockito has some problems with dex environment androidTestCompile 'com.google.dexmaker:dexmaker:1.1' androidTestCompile 'com.google.dexmaker:dexmaker-mockito:1.1' - compile files('libs/netty-handler.jar') } diff --git a/src/org/kde/kdeconnect/Backends/LanBackend/LanLinkProvider.java b/src/org/kde/kdeconnect/Backends/LanBackend/LanLinkProvider.java index 37c350b0..fdf72ec0 100644 --- a/src/org/kde/kdeconnect/Backends/LanBackend/LanLinkProvider.java +++ b/src/org/kde/kdeconnect/Backends/LanBackend/LanLinkProvider.java @@ -88,6 +88,11 @@ public class LanLinkProvider extends BaseLinkProvider { private TcpHandler tcpHandler = new TcpHandler(); private UdpHandler udpHandler = new UdpHandler(); + // To prevent infinte loop if both device can only broadcast identity package but cannot connect via TCO + private ArrayList reverseConnectionBlackList = new ArrayList<>(); + private Timer reverseConnectionTimer; + + @ChannelHandler.Sharable private class TcpHandler extends SimpleChannelInboundHandler{ @Override @@ -257,7 +262,17 @@ public class LanLinkProvider extends BaseLinkProvider { if (!future.isSuccess()) { Log.e("KDE/LanLinkProvider", "Cannot connect to " + identityPackage.getString("deviceId")); // Try reverse connection - onNetworkChange(); + if (!reverseConnectionBlackList.contains(identityPackage.getString("deviceId"))) { + reverseConnectionBlackList.add(identityPackage.getString("deviceId")); + reverseConnectionTimer = new Timer(); + reverseConnectionTimer.schedule(new TimerTask() { + @Override + public void run() { + reverseConnectionBlackList.add(identityPackage.getString("deviceId")); + } + }, 5*1000); + onNetworkChange(); + } return; } diff --git a/src/org/kde/kdeconnect/Device.java b/src/org/kde/kdeconnect/Device.java index 4f2095bc..f5d2e54f 100644 --- a/src/org/kde/kdeconnect/Device.java +++ b/src/org/kde/kdeconnect/Device.java @@ -35,15 +35,15 @@ import android.support.v4.app.NotificationCompat; import android.util.Base64; import android.util.Log; +import org.bouncycastle.cert.X509CertificateHolder; +import org.bouncycastle.cert.jcajce.JcaX509CertificateConverter; +import org.bouncycastle.jce.provider.BouncyCastleProvider; import org.kde.kdeconnect.Backends.BaseLink; import org.kde.kdeconnect.Backends.BasePairingHandler; import org.kde.kdeconnect.Plugins.Plugin; import org.kde.kdeconnect.Plugins.PluginFactory; import org.kde.kdeconnect.UserInterface.PairActivity; import org.kde.kdeconnect_tp.R; -import org.spongycastle.cert.X509CertificateHolder; -import org.spongycastle.cert.jcajce.JcaX509CertificateConverter; -import org.spongycastle.jce.provider.BouncyCastleProvider; import java.security.KeyFactory; import java.security.PrivateKey; diff --git a/src/org/kde/kdeconnect/Helpers/SecurityHelpers/SslHelper.java b/src/org/kde/kdeconnect/Helpers/SecurityHelpers/SslHelper.java index c2e41132..60e88151 100644 --- a/src/org/kde/kdeconnect/Helpers/SecurityHelpers/SslHelper.java +++ b/src/org/kde/kdeconnect/Helpers/SecurityHelpers/SslHelper.java @@ -27,15 +27,15 @@ import android.provider.Settings; import android.util.Base64; import android.util.Log; -import org.spongycastle.asn1.x500.X500NameBuilder; -import org.spongycastle.asn1.x500.style.BCStyle; -import org.spongycastle.cert.X509CertificateHolder; -import org.spongycastle.cert.X509v3CertificateBuilder; -import org.spongycastle.cert.jcajce.JcaX509CertificateConverter; -import org.spongycastle.cert.jcajce.JcaX509v3CertificateBuilder; -import org.spongycastle.jce.provider.BouncyCastleProvider; -import org.spongycastle.operator.ContentSigner; -import org.spongycastle.operator.jcajce.JcaContentSignerBuilder; +import org.bouncycastle.asn1.x500.X500NameBuilder; +import org.bouncycastle.asn1.x500.style.BCStyle; +import org.bouncycastle.cert.X509CertificateHolder; +import org.bouncycastle.cert.X509v3CertificateBuilder; +import org.bouncycastle.cert.jcajce.JcaX509CertificateConverter; +import org.bouncycastle.cert.jcajce.JcaX509v3CertificateBuilder; +import org.bouncycastle.jce.provider.BouncyCastleProvider; +import org.bouncycastle.operator.ContentSigner; +import org.bouncycastle.operator.jcajce.JcaContentSignerBuilder; import java.math.BigInteger; import java.security.KeyStore;