summaryrefslogtreecommitdiff
path: root/main/src
diff options
context:
space:
mode:
authorArne Schwabe <arne@rfc2549.org>2014-03-13 13:37:57 +0100
committerArne Schwabe <arne@rfc2549.org>2014-03-13 13:37:57 +0100
commitd2692a74e86d44cc70e276184f1c67a84bfe17ae (patch)
treea446a705d60a7097f93b3a3e3e06e11ca53d4796 /main/src
parent9c3b8cae419af4888580fe89b4c5d3789d4369ad (diff)
Allow interface roaming. Currently only tested with static/udp configuration
Diffstat (limited to 'main/src')
-rw-r--r--main/src/main/java/de/blinkt/openvpn/core/DeviceStateReceiver.java12
-rw-r--r--main/src/main/java/de/blinkt/openvpn/core/OpenVPNManagement.java4
-rw-r--r--main/src/main/java/de/blinkt/openvpn/core/OpenVpnManagementThread.java15
3 files changed, 26 insertions, 5 deletions
diff --git a/main/src/main/java/de/blinkt/openvpn/core/DeviceStateReceiver.java b/main/src/main/java/de/blinkt/openvpn/core/DeviceStateReceiver.java
index 68b30bce..41e8ff0a 100644
--- a/main/src/main/java/de/blinkt/openvpn/core/DeviceStateReceiver.java
+++ b/main/src/main/java/de/blinkt/openvpn/core/DeviceStateReceiver.java
@@ -172,15 +172,19 @@ public class DeviceStateReceiver extends BroadcastReceiver implements ByteCountL
int newnet = networkInfo.getType();
network = connectState.SHOULDBECONNECTED;
- if (sendusr1 && lastNetwork != newnet) {
+ if (lastNetwork != newnet) {
if (screen == connectState.PENDINGDISCONNECT)
screen = connectState.DISCONNECTED;
if (shouldBeConnected()) {
- if (lastNetwork == -1) {
- mManagement.resume();
+ if (sendusr1) {
+ if (lastNetwork == -1) {
+ mManagement.resume();
+ } else {
+ mManagement.reconnect();
+ }
} else {
- mManagement.reconnect();
+ mManagement.networkChange();
}
}
diff --git a/main/src/main/java/de/blinkt/openvpn/core/OpenVPNManagement.java b/main/src/main/java/de/blinkt/openvpn/core/OpenVPNManagement.java
index ce8d38c2..a5a3e9f4 100644
--- a/main/src/main/java/de/blinkt/openvpn/core/OpenVPNManagement.java
+++ b/main/src/main/java/de/blinkt/openvpn/core/OpenVPNManagement.java
@@ -17,4 +17,8 @@ public interface OpenVPNManagement {
boolean stopVPN();
+ /*
+ * Rebind the interface
+ */
+ void networkChange();
}
diff --git a/main/src/main/java/de/blinkt/openvpn/core/OpenVpnManagementThread.java b/main/src/main/java/de/blinkt/openvpn/core/OpenVpnManagementThread.java
index 1937ffc0..6ef41e1b 100644
--- a/main/src/main/java/de/blinkt/openvpn/core/OpenVpnManagementThread.java
+++ b/main/src/main/java/de/blinkt/openvpn/core/OpenVpnManagementThread.java
@@ -158,7 +158,10 @@ public class OpenVpnManagementThread implements Runnable, OpenVPNManagement {
// You can even get more evil by parsing toString() and extract the int from that :)
- mOpenVPNService.protect(fdint);
+ boolean result = mOpenVPNService.protect(fdint);
+ if (!result)
+ VpnStatus.logWarning("Could not protect VPN socket");
+
//ParcelFileDescriptor pfd = ParcelFileDescriptor.fromFd(fdint);
//pfd.close();
@@ -232,6 +235,10 @@ public class OpenVpnManagementThread implements Runnable, OpenVPNManagement {
} else if (command.startsWith("SUCCESS:")) {
/* Ignore this kind of message too */
return;
+ } else if (command.startsWith("PROTECTFD: ")) {
+ FileDescriptor fdtoprotect = mFDList.pollFirst();
+ if (fdtoprotect!=null)
+ protectFileDescriptor(fdtoprotect);
} else {
Log.i(TAG, "Got unrecognized line from managment" + command);
VpnStatus.logWarning("MGMT: Got unrecognized line from management:" + command);
@@ -535,6 +542,12 @@ public class OpenVpnManagementThread implements Runnable, OpenVPNManagement {
return sendCMD;
}
+ @Override
+ public void networkChange() {
+ if(!mWaitingForRelease)
+ managmentCommand("network-change\n");
+ }
+
public void signalusr1() {
mReleaseHold=false;