summaryrefslogtreecommitdiff
path: root/src/de/blinkt/openvpn
diff options
context:
space:
mode:
authorArne Schwabe <arne@rfc2549.org>2012-05-13 22:51:52 +0200
committerArne Schwabe <arne@rfc2549.org>2012-05-13 22:51:52 +0200
commit048094fa587dbb0bef8ce1443936528e3912eb2e (patch)
tree02c95b4e3af883593ccd3dad38683d97a89d409d /src/de/blinkt/openvpn
parenta3baaf3a8bc5705a6a20b6c09477ffa878804f32 (diff)
Implement the required ipv6 changes.
GUI part is still incomplete
Diffstat (limited to 'src/de/blinkt/openvpn')
-rw-r--r--src/de/blinkt/openvpn/ConfigParser.java8
-rw-r--r--src/de/blinkt/openvpn/OpenVpnManagementThread.java5
-rw-r--r--src/de/blinkt/openvpn/OpenVpnService.java40
3 files changed, 48 insertions, 5 deletions
diff --git a/src/de/blinkt/openvpn/ConfigParser.java b/src/de/blinkt/openvpn/ConfigParser.java
index 1b37c0a..5e054c6 100644
--- a/src/de/blinkt/openvpn/ConfigParser.java
+++ b/src/de/blinkt/openvpn/ConfigParser.java
@@ -337,7 +337,7 @@ public class ConfigParser {
}
- Vector<Vector<String>> dhcpoptions = getAllOption("dhcp-options", 2, 2);
+ Vector<Vector<String>> dhcpoptions = getAllOption("dhcp-option", 2, 2);
if(dhcpoptions!=null) {
for(Vector<String> dhcpoption:dhcpoptions) {
String type=dhcpoption.get(1);
@@ -354,6 +354,12 @@ public class ConfigParser {
}
}
+ Vector<String> ifconfig = getOption("ifconfig", 2, 2);
+ if(ifconfig!=null) {
+ CIDRIP cidr = new CIDRIP(ifconfig.get(1), ifconfig.get(2));
+ np.mIPv4Address=cidr.toString();
+ }
+
if(getOption("remote-random-hostname", 0, 0)!=null)
np.mUseRandomHostname=true;
diff --git a/src/de/blinkt/openvpn/OpenVpnManagementThread.java b/src/de/blinkt/openvpn/OpenVpnManagementThread.java
index bc2b0e1..ce6f718 100644
--- a/src/de/blinkt/openvpn/OpenVpnManagementThread.java
+++ b/src/de/blinkt/openvpn/OpenVpnManagementThread.java
@@ -192,10 +192,15 @@ public class OpenVpnManagementThread implements Runnable {
} else if (needed.equals("ROUTE")) {
String[] routeparts = extra.split(" ");
mOpenVPNService.addRoute(routeparts[0], routeparts[1]);
+ } else if (needed.equals("ROUTE6")) {
+ mOpenVPNService.addRoutev6(extra);
} else if (needed.equals("IFCONFIG")) {
String[] ifconfigparts = extra.split(" ");
int mtu = Integer.parseInt(ifconfigparts[2]);
mOpenVPNService.setLocalIP(ifconfigparts[0], ifconfigparts[1],mtu);
+ } else if (needed.equals("IFCONFIG6")) {
+ mOpenVPNService.setLocalIPv6(extra);
+
} else if (needed.equals("OPENTUN")) {
if(sendTunFD(needed,extra))
return;
diff --git a/src/de/blinkt/openvpn/OpenVpnService.java b/src/de/blinkt/openvpn/OpenVpnService.java
index 8a884fc..48ab03b 100644
--- a/src/de/blinkt/openvpn/OpenVpnService.java
+++ b/src/de/blinkt/openvpn/OpenVpnService.java
@@ -45,6 +45,7 @@ public class OpenVpnService extends VpnService implements Handler.Callback {
private String mDomain=null;
private Vector<CIDRIP> mRoutes=new Vector<CIDRIP>();
+ private Vector<String> mRoutesv6=new Vector<String>();
private CIDRIP mLocalIP=null;
@@ -52,6 +53,7 @@ public class OpenVpnService extends VpnService implements Handler.Callback {
private Thread mSocketManagerThread;
private int mMtu;
+ private String mLocalIPv6=null;
@@ -201,12 +203,20 @@ public class OpenVpnService extends VpnService implements Handler.Callback {
public ParcelFileDescriptor openTun() {
Builder builder = new Builder();
- if(mLocalIP==null) {
+ if(mLocalIP==null && mLocalIPv6==null) {
OpenVPN.logMessage(0, "", getString(R.string.opentun_no_ipaddr));
return null;
}
- builder.addAddress(mLocalIP.mIp, mLocalIP.len);
+ if(mLocalIP!=null) {
+ builder.addAddress(mLocalIP.mIp, mLocalIP.len);
+ }
+
+ if(mLocalIPv6!=null) {
+ String[] ipv6parts = mLocalIPv6.split("/");
+ builder.addAddress(ipv6parts[0],Integer.parseInt(ipv6parts[1]));
+ }
+
for (String dns : mDnslist ) {
builder.addDnsServer(dns);
@@ -223,16 +233,26 @@ public class OpenVpnService extends VpnService implements Handler.Callback {
}
}
+ for(String v6route:mRoutesv6) {
+ try {
+ String[] v6parts = v6route.split("/");
+ builder.addRoute(v6parts[0],Integer.parseInt(v6parts[1]));
+ } catch (IllegalArgumentException ia) {
+ OpenVPN.logMessage(0, "", getString(R.string.route_rejected) + v6route + " " + ia.getLocalizedMessage());
+ }
+ }
+
if(mDomain!=null)
builder.addSearchDomain(mDomain);
- String bconfig[] = new String[5];
+ String bconfig[] = new String[6];
bconfig[0]= getString(R.string.last_openvpn_tun_config);
- bconfig[1] = String.format(getString(R.string.local_ip_info,mLocalIP.mIp,mLocalIP.len,mMtu));
+ bconfig[1] = String.format(getString(R.string.local_ip_info,mLocalIP.mIp,mLocalIP.len,mLocalIPv6, mMtu));
bconfig[2] = String.format(getString(R.string.dns_server_info, joinString(mDnslist)));
bconfig[3] = String.format(getString(R.string.dns_domain_info, mDomain));
bconfig[4] = String.format(getString(R.string.routes_info, joinString(mRoutes)));
+ bconfig[5] = String.format(getString(R.string.routes_info6, joinString(mRoutesv6)));
builder.setSession(mProfile.mName + " - " + mLocalIP);
@@ -242,7 +262,9 @@ public class OpenVpnService extends VpnService implements Handler.Callback {
// Reset information
mDnslist.clear();
mRoutes.clear();
+ mRoutesv6.clear();
mLocalIP=null;
+ mLocalIPv6=null;
// Let the configure Button show the Log
Intent intent = new Intent(getBaseContext(),LogWindow.class);
@@ -301,6 +323,10 @@ public class OpenVpnService extends VpnService implements Handler.Callback {
mRoutes.add(route);
}
+
+ public void addRoutev6(String extra) {
+ mRoutesv6.add(extra);
+ }
public void setLocalIP(String local, String netmask,int mtu) {
@@ -313,7 +339,13 @@ public class OpenVpnService extends VpnService implements Handler.Callback {
}
+ public void setLocalIPv6(String ipv6addr) {
+ mLocalIPv6 = ipv6addr;
+ }
+
+
public Handler getHandler() {
return mHandler;
}
+
}