summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorArne Schwabe <arne@rfc2549.org>2012-05-18 14:11:37 +0200
committerArne Schwabe <arne@rfc2549.org>2012-05-18 14:11:37 +0200
commit40eb17c3c472bf088568abe7082427f1ab891399 (patch)
treef1433083ca238930bf3b8167d6c38a7a3cacb2ec
parentf743921f5812cd7f6c6b681382d60508ed02a4a9 (diff)
Allow only one log window at a time (closes issue #26)
Make OpenvpnService honour net30 routes (closes issue #24)
-rw-r--r--AndroidManifest.xml4
-rw-r--r--openvpn/src/openvpn/tun.c17
-rw-r--r--res/values/strings.xml5
-rw-r--r--res/xml/vpn_headers.xml8
-rw-r--r--src/de/blinkt/openvpn/CIDRIP.java32
-rw-r--r--src/de/blinkt/openvpn/LaunchVPN.java1
-rw-r--r--src/de/blinkt/openvpn/OpenVpnManagementThread.java2
-rw-r--r--src/de/blinkt/openvpn/OpenVpnService.java21
8 files changed, 61 insertions, 29 deletions
diff --git a/AndroidManifest.xml b/AndroidManifest.xml
index 4655509..9f11995 100644
--- a/AndroidManifest.xml
+++ b/AndroidManifest.xml
@@ -17,8 +17,8 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="de.blinkt.openvpn"
- android:versionCode="25"
- android:versionName="0.5.4" >
+ android:versionCode="26"
+ android:versionName="0.5.5" >
<uses-permission android:name="android.permission.INTERNET" />
diff --git a/openvpn/src/openvpn/tun.c b/openvpn/src/openvpn/tun.c
index ab83d7b..92ad001 100644
--- a/openvpn/src/openvpn/tun.c
+++ b/openvpn/src/openvpn/tun.c
@@ -782,7 +782,22 @@ do_ifconfig (struct tuntap *tt,
struct user_pass up;
struct buffer out = alloc_buf_gc (64, &gc);
- buf_printf (&out, "%s %s %d", ifconfig_local, ifconfig_remote_netmask, tun_mtu);
+ char* top;
+ switch(tt->topology) {
+ case TOP_NET30:
+ top = "net30";
+ break;
+ case TOP_P2P:
+ top="p2p";
+ break;
+ case TOP_SUBNET:
+ top="subnet";
+ break;
+ default:
+ top="undef";
+ }
+
+ buf_printf (&out, "%s %s %d %s", ifconfig_local, ifconfig_remote_netmask, tun_mtu,top);
strcpy(up.username, buf_bptr(&out));
management_query_user_pass(management, &up , "IFCONFIG", GET_USER_PASS_NEED_OK,(void*) 0);
diff --git a/res/values/strings.xml b/res/values/strings.xml
index f055754..c74362e 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -165,7 +165,7 @@
<string name="dns_domain_info">DNS Domain: %s</string>
<string name="routes_info">Routes: %s</string>
<string name="routes_info6">Routes Ipv6: %s</string>
- <string name="ip_not_cidr">Got interface information %1$s and %2$s, assuming second address is peer address of remote. Using /32 netmask for local IP.</string>
+ <string name="ip_not_cidr">Got interface information %1$s and %2$s, assuming second address is peer address of remote. Using /32 netmask for local IP. Mode given by openvpn is \"%3$s\".</string>
<string name="route_not_cidr">Cannot make sense of %1$s and %2$s as IP route with CIDR netmask, using /32 as netmask.</string>
<string name="route_not_netip">Corrected route %1$s/%2$s to %3$s/%2$s</string>
<string name="keychain_access">Cannot accces the Android Keychain Certificates. If you restored a backup of the app/app settings reselect the certificate to recreate the permission to access the certificate.</string>
@@ -219,6 +219,5 @@
<string name="broken_image_cert">Got an excption trying to show the Android 4.0+ certificate selction dialog. This should never happens as this a standard feature of Android 4.0+. Maybe your Android ROM support for certificate storage is broken</string>
<string name="ipv4">IPv4</string>
<string name="ipv6">IPv6</string>
- <string name="use_default_titlev6">TODO</string>
- <string name="speed_waiting">Waiting byte count message</string>
+ <string name="speed_waiting">Waiting for byte count messageā€¦</string>
</resources>
diff --git a/res/xml/vpn_headers.xml b/res/xml/vpn_headers.xml
index 3762d44..c840e6a 100644
--- a/res/xml/vpn_headers.xml
+++ b/res/xml/vpn_headers.xml
@@ -4,14 +4,12 @@
<header
android:id="@+id/basicsettingsid"
android:fragment="de.blinkt.openvpn.Settings_Basic"
- android:tag="BasicSettings"
- android:title="Basic Settings" />
+ android:title="Basic" />
<!-- android:icon="@drawable/ic_settings_applications" -->
<header
android:fragment="de.blinkt.openvpn.Settings_IP"
- android:summary="IP Address"
- android:title="IP Settings" />
+ android:title="IP and DNS" />
<header
android:fragment="de.blinkt.openvpn.Settings_Routing"
android:title="Routing" />
@@ -23,7 +21,7 @@
<header
android:fragment="de.blinkt.openvpn.Settings_Obscure"
android:summary="Obscure OpenVPN Settings. Normally not needed."
- android:title="Obscure" >
+ android:title="Advanced" >
</header>
<header
android:fragment="de.blinkt.openvpn.ShowConfigFragment"
diff --git a/src/de/blinkt/openvpn/CIDRIP.java b/src/de/blinkt/openvpn/CIDRIP.java
index c2f0d82..ccb3836 100644
--- a/src/de/blinkt/openvpn/CIDRIP.java
+++ b/src/de/blinkt/openvpn/CIDRIP.java
@@ -5,13 +5,7 @@ class CIDRIP{
int len;
public CIDRIP(String ip, String mask){
mIp=ip;
- String[] ipt = mask.split("\\.");
- long netmask=0;
-
- netmask += Long.parseLong(ipt[0])<< 24;
- netmask += Integer.parseInt(ipt[1])<< 16;
- netmask += Integer.parseInt(ipt[2])<< 8;
- netmask += Integer.parseInt(ipt[3]);
+ long netmask=getInt(mask);
// Add 33. bit to ensure the loop terminates
netmask += 1l << 32;
@@ -36,14 +30,7 @@ class CIDRIP{
}
public boolean normalise(){
- long ip=0;
-
- String[] ipt = mIp.split("\\.");
-
- ip += Long.parseLong(ipt[0])<< 24;
- ip += Integer.parseInt(ipt[1])<< 16;
- ip += Integer.parseInt(ipt[2])<< 8;
- ip += Integer.parseInt(ipt[3]);
+ long ip=getInt(mIp);
long newip = ip & (0xffffffffl << (32 -len));
if (newip != ip){
@@ -53,4 +40,19 @@ class CIDRIP{
return false;
}
}
+ static long getInt(String ipaddr) {
+ String[] ipt = ipaddr.split("\\.");
+ long ip=0;
+
+ ip += Long.parseLong(ipt[0])<< 24;
+ ip += Integer.parseInt(ipt[1])<< 16;
+ ip += Integer.parseInt(ipt[2])<< 8;
+ ip += Integer.parseInt(ipt[3]);
+
+ return ip;
+ }
+ public long getInt() {
+ return getInt(mIp);
+ }
+
} \ No newline at end of file
diff --git a/src/de/blinkt/openvpn/LaunchVPN.java b/src/de/blinkt/openvpn/LaunchVPN.java
index b084b19..73b1f34 100644
--- a/src/de/blinkt/openvpn/LaunchVPN.java
+++ b/src/de/blinkt/openvpn/LaunchVPN.java
@@ -349,6 +349,7 @@ public class LaunchVPN extends ListActivity implements OnItemClickListener {
void startOpenVpn() {
Intent startLW = new Intent(getBaseContext(),LogWindow.class);
+ startLW.addFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
startActivity(startLW);
if(!writeMiniVPN()) {
diff --git a/src/de/blinkt/openvpn/OpenVpnManagementThread.java b/src/de/blinkt/openvpn/OpenVpnManagementThread.java
index b568bd6..82d6f00 100644
--- a/src/de/blinkt/openvpn/OpenVpnManagementThread.java
+++ b/src/de/blinkt/openvpn/OpenVpnManagementThread.java
@@ -239,7 +239,7 @@ public class OpenVpnManagementThread implements Runnable {
} else if (needed.equals("IFCONFIG")) {
String[] ifconfigparts = extra.split(" ");
int mtu = Integer.parseInt(ifconfigparts[2]);
- mOpenVPNService.setLocalIP(ifconfigparts[0], ifconfigparts[1],mtu);
+ mOpenVPNService.setLocalIP(ifconfigparts[0], ifconfigparts[1],mtu,ifconfigparts[3]);
} else if (needed.equals("IFCONFIG6")) {
mOpenVPNService.setLocalIPv6(extra);
diff --git a/src/de/blinkt/openvpn/OpenVpnService.java b/src/de/blinkt/openvpn/OpenVpnService.java
index 8f846e3..e2f7ba1 100644
--- a/src/de/blinkt/openvpn/OpenVpnService.java
+++ b/src/de/blinkt/openvpn/OpenVpnService.java
@@ -248,7 +248,9 @@ public class OpenVpnService extends VpnService implements Handler.Callback {
// Let the configure Button show the Log
Intent intent = new Intent(getBaseContext(),LogWindow.class);
+ intent.addFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
PendingIntent startLW = PendingIntent.getActivity(getApplicationContext(), 0, intent, 0);
+ intent.addFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
builder.setConfigureIntent(startLW);
try {
ParcelFileDescriptor pfd = builder.establish();
@@ -309,16 +311,31 @@ public class OpenVpnService extends VpnService implements Handler.Callback {
}
- public void setLocalIP(String local, String netmask,int mtu) {
+ public void setLocalIP(String local, String netmask,int mtu, String mode) {
mLocalIP = new CIDRIP(local, netmask);
mMtu = mtu;
if(mLocalIP.len == 32 && !netmask.equals("255.255.255.255")) {
- OpenVPN.logMessage(0, "", String.format(getString(R.string.ip_not_cidr, local,netmask)));
+ // get the netmask as IP
+ long netint = CIDRIP.getInt(netmask);
+ if(Math.abs(netint - mLocalIP.getInt()) ==1) {
+ if(mode.equals("net30"))
+ mLocalIP.len=30;
+ else
+ mLocalIP.len=31;
+ } else {
+ OpenVPN.logMessage(0, "", String.format(getString(R.string.ip_not_cidr, local,netmask,mode)));
+ }
}
}
+
+
+
+
+
+
public void setLocalIPv6(String ipv6addr) {
mLocalIPv6 = ipv6addr;
}