diff --git a/.gitignore b/.gitignore
index b5067c6039560d87fa0bfef02c8a967980113531..804337f0b9edc12836e0515125976e349261160f 100644
--- a/.gitignore
+++ b/.gitignore
@@ -52,7 +52,6 @@ bitmask_android/assets/minivpn.armeabi-v7a
 bitmask_android/assets/minivpn.mips
 bitmask_android/assets/minivpn.x86
 openvpn/a.out.dSYM
-openvpn/config-version.h
 openvpn/config.status
 Makefile
 openvpn/libtool
@@ -76,9 +75,9 @@ gradle.properties*
 build
 .gradle
 jniLibs
-bitmask_android/ovpnlibs/
 G*
 *.dot
 /ics-openvpn/
 /TAGS
 /ics-openvpn
+app/ovpnlibs
diff --git a/CHANGELOG b/CHANGELOG
index caf1fe5da7213c82a64de4a34a707df03f4385ce..9ba29e66593e06e9602eb6ae482a50d93becbc52 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -1,3 +1,11 @@
+0.7.0 September 26 2014 - the "quick" release
+Features
+- Restart quickly if killed
+- F-Droid ready
+Bugs Fixed
+- Vpn can be turned off with the Off switch
+- "Blocked" notification not shown if Vpn is ff
+
 0.6.0 August 18 2014 - the "persistent" release
 Features
 - Improved security:
diff --git a/app/build.gradle b/app/build.gradle
index f2ddd9cd967b3606ebfc98b93d0beb0f251041e3..1057da447e1c6c26b22117ff03bf0d6f39150d22 100644
--- a/app/build.gradle
+++ b/app/build.gradle
@@ -1,4 +1,5 @@
 apply plugin: 'android'
+import org.ajoberstar.grgit.*
 
 android {
   compileSdkVersion 19
@@ -23,14 +24,15 @@ android {
   buildTypes {
     release {
       //runProguard true
-      signingConfig signingConfigs.release.isSigningReady() ? signingConfigs.release : signingConfigs.debug
+      if(signingConfigs.contains(release))
+	signingConfig signingConfigs.release.isSigningReady() ? signingConfigs.release : signingConfigs.debug
     }
   }
 
   lintOptions {
     abortOnError false
   }
-    
+
   sourceSets {
     main {
       assets.srcDirs = ['assets', 'ovpnlibs/assets']
@@ -41,13 +43,9 @@ android {
       assets.srcDirs = ['src/debug/assets']
     }
   }
-
-  //check.dependsOn connectedCheck
 }
 
 dependencies {
-  // androidTestCompile 'com.android.support:support-v4:20+'
-  // androidTestCompile 'com.android.support:appcompat-v7:20.+'
   androidTestCompile 'com.jayway.android.robotium:robotium-solo:5.2.1'
   compile 'com.intellij:annotations:12.0'
 }
@@ -60,7 +58,9 @@ def processFileInplace(file, Closure processText) {
 
 task checkoutStrippedIcsOpenVPN ( type: Copy ) {
   //FIXME Checkout ics-openvpn-stripped from branch "ics-openvpn-upstream"
-  from '/tmp/bitmask_android_tmp/ics-openvpn-stripped'
+  grgit = Grgit.open(project.file('../'))
+  
+  from '../../bitmask_android_tmp/ics-openvpn-stripped'
   into '../ics-openvpn-stripped'
 }
 
@@ -96,10 +96,10 @@ task copyIcsOpenVPNClasses( type: Copy, dependsOn: 'checkoutStrippedIcsOpenVPN'
 
 // thanks to http://pleac.sourceforge.net/pleac_groovy/fileaccess.html
 task removeDuplicatedStrings( dependsOn: 'copyIcsOpenVPNClasses' ) << {
-  new File('.').eachFileRecurse {
+  new File('app').eachFileRecurse {
     if(it.name.equals('strings.xml')) {
-      def ics_openvpn_file = file(it.path.replace('strings.xml', 'strings-icsopenvpn.xml'))
-      if(ics_openvpn_file.exists()) { 
+      def ics_openvpn_file = file(it.absolutePath.replace('strings.xml', 'strings-icsopenvpn.xml'))
+      if(ics_openvpn_file.exists()) {
 	def ics_openvpn_strings_names = (new XmlParser()).parse(ics_openvpn_file)
 	def current_file = it
       
@@ -155,4 +155,8 @@ task updateIcsOpenVpn( type: Copy, dependsOn: 'mergeUntranslatable') {
     include 'snappy/**'
   } into '.'
 }
-//build.dependsOn ':app:mergeUntranslatable'
\ No newline at end of file
+
+//assembleRelease.dependsOn connectedCheck
+afterEvaluate {
+  //installRelease.dependsOn connectedCheck
+}
diff --git a/app/jni/Android.mk b/app/jni/Android.mk
index 33d0bc764a384a8c766901b15f18037a352e2629..0c906f9753846e272817ac0324384ef7ce40f267 100644
--- a/app/jni/Android.mk
+++ b/app/jni/Android.mk
@@ -5,7 +5,7 @@ JNI_DIR := $(call my-dir)
 #WITH_POLAR=1
 #WITH_OPENVPN3=1
 # Build openvpn with polar (OpenVPN3 core is always build with polar)
-#WITH_BREAKPAD=0
+WITH_BREAKPAD=0
 
 
 include lzo/Android.mk
@@ -13,7 +13,7 @@ include snappy/Android.mk
 
 include openssl/Android.mk
 
-ifneq ($(USE_BREAKPAD),0)
+ifneq ($(WITH_BREAKPAD),0)
 	ifneq ($(TARGET_ARCH),mips)
 	WITH_BREAKPAD=1
 	include google-breakpad/android/google_breakpad/Android.mk
diff --git a/app/openvpn/.gitignore b/app/openvpn/.gitignore
index 538c0208ff1d2457e45f362fbe7875f62bd4f6d8..94b3b9a1ec8645d24ce8ea8b3033e96fadefceb9 100644
--- a/app/openvpn/.gitignore
+++ b/app/openvpn/.gitignore
@@ -53,7 +53,6 @@ distro/rpm/openvpn.spec
 tests/t_client.sh
 tests/t_client-*-20??????-??????/
 src/openvpn/openvpn
-config-version.h
 nbproject
 test-driver
 compile
diff --git a/app/openvpn/config-version.h b/app/openvpn/config-version.h
new file mode 100644
index 0000000000000000000000000000000000000000..762b9dc69528cd2d6bf3b13ee0724526a6c55662
--- /dev/null
+++ b/app/openvpn/config-version.h
@@ -0,0 +1,2 @@
+#define CONFIGURE_GIT_REVISION "icsopenvpn_618-e63b88d330782d14"
+#define CONFIGURE_GIT_FLAGS ""
diff --git a/app/ovpnlibs/assets/nopievpn.armeabi b/app/ovpnlibs/assets/nopievpn.armeabi
deleted file mode 100755
index 908dceabfe2b5d93db18a4c09b24d7ee3f6317f7..0000000000000000000000000000000000000000
Binary files a/app/ovpnlibs/assets/nopievpn.armeabi and /dev/null differ
diff --git a/app/ovpnlibs/assets/nopievpn.armeabi-v7a b/app/ovpnlibs/assets/nopievpn.armeabi-v7a
deleted file mode 100755
index bba1ea2286185dddebb691cc5cc1bd7a85bdf49f..0000000000000000000000000000000000000000
Binary files a/app/ovpnlibs/assets/nopievpn.armeabi-v7a and /dev/null differ
diff --git a/app/ovpnlibs/assets/nopievpn.mips b/app/ovpnlibs/assets/nopievpn.mips
deleted file mode 100755
index c2ec658917a632e04947e1b81c356c6b7af7c643..0000000000000000000000000000000000000000
Binary files a/app/ovpnlibs/assets/nopievpn.mips and /dev/null differ
diff --git a/app/ovpnlibs/assets/nopievpn.x86 b/app/ovpnlibs/assets/nopievpn.x86
deleted file mode 100755
index 8a4b7d134eda597472ac835bdfdc6d143763afd8..0000000000000000000000000000000000000000
Binary files a/app/ovpnlibs/assets/nopievpn.x86 and /dev/null differ
diff --git a/app/ovpnlibs/assets/pievpn.armeabi b/app/ovpnlibs/assets/pievpn.armeabi
deleted file mode 100755
index 8849f8627e29fab77f791feed22ad7920a818f1c..0000000000000000000000000000000000000000
Binary files a/app/ovpnlibs/assets/pievpn.armeabi and /dev/null differ
diff --git a/app/ovpnlibs/assets/pievpn.armeabi-v7a b/app/ovpnlibs/assets/pievpn.armeabi-v7a
deleted file mode 100755
index fce4d07713410b0ce3c9bf0662b0c9e1de0eae97..0000000000000000000000000000000000000000
Binary files a/app/ovpnlibs/assets/pievpn.armeabi-v7a and /dev/null differ
diff --git a/app/ovpnlibs/assets/pievpn.mips b/app/ovpnlibs/assets/pievpn.mips
deleted file mode 100755
index fcc9c8ef6921cd4769991984e88905aa98262bc1..0000000000000000000000000000000000000000
Binary files a/app/ovpnlibs/assets/pievpn.mips and /dev/null differ
diff --git a/app/ovpnlibs/assets/pievpn.x86 b/app/ovpnlibs/assets/pievpn.x86
deleted file mode 100755
index df9b45eb556c4496fde6f5286bff86e13e74c4a5..0000000000000000000000000000000000000000
Binary files a/app/ovpnlibs/assets/pievpn.x86 and /dev/null differ
diff --git a/app/src/debug/java/se/leap/bitmaskclient/ConfigurationWizard.java b/app/src/debug/java/se/leap/bitmaskclient/ConfigurationWizard.java
index 153cb73129b5d79c8aba150f02c939f1ffd66de2..c405d06f1c0bf9a1d8417bb44d40117718989f6c 100644
--- a/app/src/debug/java/se/leap/bitmaskclient/ConfigurationWizard.java
+++ b/app/src/debug/java/se/leap/bitmaskclient/ConfigurationWizard.java
@@ -96,7 +96,7 @@ implements ProviderListFragment.Callbacks, NewProviderDialogInterface, ProviderD
     @Override
     protected void onCreate(Bundle savedInstanceState) {
         super.onCreate(savedInstanceState);
-	    preferences = preferences;
+	preferences = getSharedPreferences(Dashboard.SHARED_PREFERENCES, MODE_PRIVATE);
         
         setContentView(R.layout.configuration_wizard_activity);
 	    mProgressBar = (ProgressBar) findViewById(R.id.progressbar_configuration_wizard);
diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml
index 0c55bf7877eb3876f7aeb633237804853bfd0f96..423293b677389d5c4b133fcc14d917af0dc265f3 100644
--- a/app/src/main/AndroidManifest.xml
+++ b/app/src/main/AndroidManifest.xml
@@ -17,8 +17,8 @@
 
 <manifest xmlns:android="http://schemas.android.com/apk/res/android"
     package="se.leap.bitmaskclient"
-    android:versionCode="91"
-    android:versionName="0.6.0" >
+    android:versionCode="93"
+    android:versionName="0.7.0" >
 
     <uses-permission android:name="android.permission.INTERNET" />
     <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
@@ -36,8 +36,8 @@
         android:label="@string/app" >
 
         <service
-            android:name="de.blinkt.openvpn.core.OpenVpnService"
-            android:permission="android.permission.BIND_VPN_SERVICE" >
+            android:name="de.blinkt.openvpn.core.OpenVPNService"
+            android:permission="android.permission.BIND_VPN_SERVICE">
             <intent-filter>
                 <action android:name="android.net.VpnService" />
             </intent-filter>
diff --git a/app/src/main/assets/minivpn.armeabi b/app/src/main/assets/minivpn.armeabi
deleted file mode 100644
index 7018dbc9ff2cc5aa9857c17ae4bc106d8b9e741d..0000000000000000000000000000000000000000
Binary files a/app/src/main/assets/minivpn.armeabi and /dev/null differ
diff --git a/app/src/main/assets/minivpn.armeabi-v7a b/app/src/main/assets/minivpn.armeabi-v7a
deleted file mode 100644
index a8e0101783e2152993c40057fd93efb9e0d0774c..0000000000000000000000000000000000000000
Binary files a/app/src/main/assets/minivpn.armeabi-v7a and /dev/null differ
diff --git a/app/src/main/assets/minivpn.mips b/app/src/main/assets/minivpn.mips
deleted file mode 100644
index c44e56c5ee1ba1ba6ead69592b232690d65dcfb2..0000000000000000000000000000000000000000
Binary files a/app/src/main/assets/minivpn.mips and /dev/null differ
diff --git a/app/src/main/assets/minivpn.x86 b/app/src/main/assets/minivpn.x86
deleted file mode 100644
index 1a6bf4647e0121d33fec484f2d1f6cb1541af743..0000000000000000000000000000000000000000
Binary files a/app/src/main/assets/minivpn.x86 and /dev/null differ
diff --git a/app/src/main/java/de/blinkt/openvpn/LaunchVPN.java b/app/src/main/java/de/blinkt/openvpn/LaunchVPN.java
index 3f80eef0fc14d6bc4f62731ed476569467eaf5b0..a424a489ad923017892caba9cc1122e2783c9b32 100644
--- a/app/src/main/java/de/blinkt/openvpn/LaunchVPN.java
+++ b/app/src/main/java/de/blinkt/openvpn/LaunchVPN.java
@@ -113,6 +113,7 @@ public class LaunchVPN extends Activity {
 		}
 	}
 
+
 	@Override
 	protected void onActivityResult (int requestCode, int resultCode, Intent data) {
 		super.onActivityResult(requestCode, resultCode, data);
diff --git a/app/src/main/java/de/blinkt/openvpn/VpnProfile.java b/app/src/main/java/de/blinkt/openvpn/VpnProfile.java
index d44d0f5a29fa0a96427b16a78407e54c5b27ddc0..6fec5f46b36e2149eb2b4d198a83f24517bf5a4b 100644
--- a/app/src/main/java/de/blinkt/openvpn/VpnProfile.java
+++ b/app/src/main/java/de/blinkt/openvpn/VpnProfile.java
@@ -47,7 +47,7 @@ import javax.crypto.IllegalBlockSizeException;
 import javax.crypto.NoSuchPaddingException;
 
 import de.blinkt.openvpn.core.NativeUtils;
-import de.blinkt.openvpn.core.OpenVpnService;
+import de.blinkt.openvpn.core.OpenVPNService;
 import de.blinkt.openvpn.core.VpnStatus;
 import de.blinkt.openvpn.core.X509Utils;
 
@@ -69,6 +69,7 @@ public class VpnProfile implements Serializable {
     private static final String OVPNCONFIGFILE = "android.conf";
     public static final int MAXLOGLEVEL = 4;
     public static final int CURRENT_PROFILE_VERSION = 2;
+    public static final int DEFAULT_MSSFIX_SIZE = 1450;
     public static String DEFAULT_DNS1 = "8.8.8.8";
     public static String DEFAULT_DNS2 = "8.8.4.4";
 
@@ -147,6 +148,9 @@ public class VpnProfile implements Serializable {
     private int mProfileVersion;
     public String mExcludedRoutes;
     public String mExcludedRoutesv6;
+    public int mMssFix =0; // -1 is default,
+
+
 
     public VpnProfile(String name) {
         mUuid = UUID.randomUUID();
@@ -186,6 +190,7 @@ public class VpnProfile implements Serializable {
         mCheckRemoteCN = false;
         mPersistTun = false;
         mAllowLocalLAN = true;
+        mMssFix = 0;
     }
 
     public UUID getUUID() {
@@ -389,6 +394,13 @@ public class VpnProfile implements Serializable {
 
         }
 
+        if (mMssFix !=0){
+            if (mMssFix!=1450)
+                cfg+=String.format("mssfix %d\n", mMssFix, Locale.US);
+            else
+                cfg+="mssfix\n";
+        }
+
         if (mNobind)
             cfg += "nobind\n";
 
@@ -570,7 +582,7 @@ public class VpnProfile implements Serializable {
     public Intent prepareIntent(Context context) {
         String prefix = context.getPackageName();
 
-        Intent intent = new Intent(context, OpenVpnService.class);
+        Intent intent = new Intent(context, OpenVPNService.class);
 
         if (mAuthenticationType == VpnProfile.TYPE_KEYSTORE || mAuthenticationType == VpnProfile.TYPE_USERPASS_KEYSTORE) {
             if (getKeyStoreCertificates(context) == null)
diff --git a/app/src/main/java/de/blinkt/openvpn/activities/DisconnectVPN.java b/app/src/main/java/de/blinkt/openvpn/activities/DisconnectVPN.java
index 8e418053e0d51d5a54b1ca32e8bcb79acd4488e8..5910173a2e20d42d43789f881dfc71c85cfecdc2 100644
--- a/app/src/main/java/de/blinkt/openvpn/activities/DisconnectVPN.java
+++ b/app/src/main/java/de/blinkt/openvpn/activities/DisconnectVPN.java
@@ -6,14 +6,14 @@ import android.content.*;
 import android.os.IBinder;
 
 import se.leap.bitmaskclient.R;
-import de.blinkt.openvpn.core.OpenVpnService;
+import de.blinkt.openvpn.core.OpenVPNService;
 import de.blinkt.openvpn.core.ProfileManager;
 
 /**
  * Created by arne on 13.10.13.
  */
 public class DisconnectVPN extends Activity implements DialogInterface.OnClickListener{
-    protected OpenVpnService mService;
+    protected OpenVPNService mService;
 
     private ServiceConnection mConnection = new ServiceConnection() {
 
@@ -22,7 +22,7 @@ public class DisconnectVPN extends Activity implements DialogInterface.OnClickLi
         public void onServiceConnected(ComponentName className,
                                        IBinder service) {
             // We've bound to LocalService, cast the IBinder and get LocalService instance
-            OpenVpnService.LocalBinder binder = (OpenVpnService.LocalBinder) service;
+            OpenVPNService.LocalBinder binder = (OpenVPNService.LocalBinder) service;
             mService = binder.getService();
         }
 
@@ -36,8 +36,8 @@ public class DisconnectVPN extends Activity implements DialogInterface.OnClickLi
     @Override
     protected void onResume() {
         super.onResume();
-        Intent intent = new Intent(this, OpenVpnService.class);
-        intent.setAction(OpenVpnService.START_SERVICE);
+        Intent intent = new Intent(this, OpenVPNService.class);
+        intent.setAction(OpenVPNService.START_SERVICE);
         bindService(intent, mConnection, Context.BIND_AUTO_CREATE);
         showDisconnectDialog();
     }
diff --git a/app/src/main/java/de/blinkt/openvpn/core/ConfigParser.java b/app/src/main/java/de/blinkt/openvpn/core/ConfigParser.java
index d23b521fe3c1628437ac9cee2a405e28d738f509..9c3621e017af962427104083ae8a15a5f01d8a20 100644
--- a/app/src/main/java/de/blinkt/openvpn/core/ConfigParser.java
+++ b/app/src/main/java/de/blinkt/openvpn/core/ConfigParser.java
@@ -432,6 +432,19 @@ public class ConfigParser {
             throw new ConfigParseError("Sorry. Only tun mode is supported. See the FAQ for more detail");
 		}
 
+        Vector<String> mssfix = getOption("mssfix",0,1);
+
+        if (mssfix!=null) {
+            if (mssfix.size()>=2) {
+                try {
+                    np.mMssFix=Integer.parseInt(mssfix.get(1));
+                } catch(NumberFormatException e) {
+                    throw new ConfigParseError("Argument to --mssfix has to be an integer");
+                }
+            } else {
+                np.mMssFix = VpnProfile.DEFAULT_MSSFIX_SIZE;
+            }
+        }
 
 
 		Vector<String> mode =getOption("mode",1,1);
diff --git a/app/src/main/java/de/blinkt/openvpn/core/DeviceStateReceiver.java b/app/src/main/java/de/blinkt/openvpn/core/DeviceStateReceiver.java
index 18c5f1d9414234ffd9882f5e812f3c6b0c4697f7..0126d08eec54ef004c32c585e8fbdfad36b640e7 100644
--- a/app/src/main/java/de/blinkt/openvpn/core/DeviceStateReceiver.java
+++ b/app/src/main/java/de/blinkt/openvpn/core/DeviceStateReceiver.java
@@ -68,7 +68,7 @@ public class DeviceStateReceiver extends BroadcastReceiver implements ByteCountL
         if (windowtraffic < TRAFFIC_LIMIT) {
             screen = connectState.DISCONNECTED;
             VpnStatus.logInfo(R.string.screenoff_pause,
-                    OpenVpnService.humanReadableByteCount(TRAFFIC_LIMIT, false), TRAFFIC_WINDOW);
+                    OpenVPNService.humanReadableByteCount(TRAFFIC_LIMIT, false), TRAFFIC_WINDOW);
 
             mManagement.pause(getPauseReason());
         }
diff --git a/app/src/main/java/de/blinkt/openvpn/core/ICSOpenVPNApplication.java b/app/src/main/java/de/blinkt/openvpn/core/ICSOpenVPNApplication.java
index 1daa34332317102bae0a2f02ff03e090b0b60b48..485e536945af5032b43c5d95ef9d9ef88a4e61a9 100644
--- a/app/src/main/java/de/blinkt/openvpn/core/ICSOpenVPNApplication.java
+++ b/app/src/main/java/de/blinkt/openvpn/core/ICSOpenVPNApplication.java
@@ -1,14 +1,37 @@
 package de.blinkt.openvpn.core;
-
 import android.app.Application;
 
-/**
- * Created by arne on 28.12.13.
- */
+/*
+import org.acra.ACRA;
+import org.acra.ReportingInteractionMode;
+import org.acra.annotation.ReportsCrashes;
+*/
+
+import se.leap.bitmaskclient.BuildConfig;
+import se.leap.bitmaskclient.R;
+import de.blinkt.openvpn.core.PRNGFixes;
+
+/*
+@ReportsCrashes(
+        formKey = "",
+        formUri = "http://reports.blinkt.de/report-icsopenvpn",
+        reportType = org.acra.sender.HttpSender.Type.JSON,
+        httpMethod = org.acra.sender.HttpSender.Method.PUT,
+        formUriBasicAuthLogin="report-icsopenvpn",
+        formUriBasicAuthPassword="Tohd4neiF9Ai!!!!111eleven",
+        mode = ReportingInteractionMode.TOAST,
+        resToastText = R.string.crash_toast_text
+)
+*/
 public class ICSOpenVPNApplication extends Application {
     @Override
     public void onCreate() {
         super.onCreate();
         PRNGFixes.apply();
+
+        if (BuildConfig.DEBUG) {
+            //ACRA.init(this);
+        }
     }
+
 }
diff --git a/app/src/main/java/de/blinkt/openvpn/core/NetworkSpace.java b/app/src/main/java/de/blinkt/openvpn/core/NetworkSpace.java
index 81a17ef960f8d5a0c93cb88b717f2a8a2a05dbe9..8c6cb1f53d8771ddbc4faf3f05fa8a9790c1f501 100644
--- a/app/src/main/java/de/blinkt/openvpn/core/NetworkSpace.java
+++ b/app/src/main/java/de/blinkt/openvpn/core/NetworkSpace.java
@@ -76,8 +76,8 @@ public class NetworkSpace {
 
             netAddress = BigInteger.ZERO;
             for (byte b : address.getAddress()) {
-                s -= 16;
-                netAddress = netAddress.add(BigInteger.valueOf(b).shiftLeft(s));
+                s -= 8;
+                netAddress = netAddress.add(BigInteger.valueOf((b & 0xFF)).shiftLeft(s));
             }
         }
 
@@ -152,12 +152,12 @@ public class NetworkSpace {
         String getIPv6Address() {
             if (BuildConfig.DEBUG) Assert.assertTrue (!isV4);
             BigInteger r = netAddress;
-            if (r.longValue() == 0)
+            if (r.compareTo(BigInteger.ZERO)==0 && networkMask==0)
                 return "::";
 
             Vector<String> parts = new Vector<String>();
             while (r.compareTo(BigInteger.ZERO) == 1) {
-                parts.add(0, String.format(Locale.US, "%x", r.mod(BigInteger.valueOf(256)).longValue()));
+                parts.add(0, String.format(Locale.US, "%x", r.mod(BigInteger.valueOf(0x10000)).longValue()));
                 r = r.shiftRight(16);
             }
 
diff --git a/app/src/main/java/de/blinkt/openvpn/core/OpenVpnService.java b/app/src/main/java/de/blinkt/openvpn/core/OpenVPNService.java
similarity index 91%
rename from app/src/main/java/de/blinkt/openvpn/core/OpenVpnService.java
rename to app/src/main/java/de/blinkt/openvpn/core/OpenVPNService.java
index 0cf93de35bb3e96d014b0fe1652beb702663f023..743e7cc535aae708b4831a7842c20ad4a564e77e 100644
--- a/app/src/main/java/de/blinkt/openvpn/core/OpenVpnService.java
+++ b/app/src/main/java/de/blinkt/openvpn/core/OpenVPNService.java
@@ -40,14 +40,14 @@ import de.blinkt.openvpn.core.VpnStatus.StateListener;
 
 import static de.blinkt.openvpn.core.NetworkSpace.ipAddress;
 import static de.blinkt.openvpn.core.VpnStatus.ConnectionStatus.LEVEL_CONNECTED;
-import static de.blinkt.openvpn.core.VpnStatus.ConnectionStatus.LEVEL_CONNECTING_SERVER_REPLIED;
 import static de.blinkt.openvpn.core.VpnStatus.ConnectionStatus.LEVEL_NONETWORK;
+import static de.blinkt.openvpn.core.VpnStatus.ConnectionStatus.LEVEL_NOTCONNECTED;
 import static de.blinkt.openvpn.core.VpnStatus.ConnectionStatus.LEVEL_CONNECTING_NO_SERVER_REPLY_YET;
 import static de.blinkt.openvpn.core.VpnStatus.ConnectionStatus.LEVEL_WAITING_FOR_USER_INPUT;
-
 import se.leap.bitmaskclient.Dashboard;
 
-public class OpenVpnService extends VpnService implements StateListener, Callback, ByteCountListener {
+public class OpenVPNService extends VpnService implements StateListener, Callback, ByteCountListener {
+
     public static final String START_SERVICE = "de.blinkt.openvpn.START_SERVICE";
     public static final String START_SERVICE_STICKY = "de.blinkt.openvpn.START_SERVICE_STICKY";
     public static final String ALWAYS_SHOW_NOTIFICATION = "de.blinkt.openvpn.NOTIFICATION_ALWAYS_VISIBLE";
@@ -74,7 +74,7 @@ public class OpenVpnService extends VpnService implements StateListener, Callbac
     private OpenVPNManagement mManagement;
     private String mLastTunCfg;
     private String mRemoteGW;
-    private Object mProcessLock = new Object();
+    private final Object mProcessLock = new Object();
 
     // From: http://stackoverflow.com/questions/3758606/how-to-convert-byte-size-into-human-readable-format-in-java
     public static String humanReadableByteCount(long bytes, boolean mbit) {
@@ -116,6 +116,7 @@ public class OpenVpnService extends VpnService implements StateListener, Callbac
         synchronized (mProcessLock) {
             mProcessThread = null;
         }
+	mConnecttime = 0;
         VpnStatus.removeByteCountListener(this);
         unregisterDeviceStateReceiver();
         ProfileManager.setConntectedVpnProfileDisconnected(this);
@@ -166,7 +167,7 @@ public class OpenVpnService extends VpnService implements StateListener, Callbac
 
 
         mNotificationManager.notify(OPENVPN_STATUS, notification);
-        // startForeground(OPENVPN_STATUS, notification);
+        //startForeground(OPENVPN_STATUS, notification);
     }
 
     private int getIconByConnectionStatus(ConnectionStatus level) {
@@ -212,7 +213,7 @@ public class OpenVpnService extends VpnService implements StateListener, Callbac
             nbuilder.addAction(android.R.drawable.ic_menu_close_clear_cancel,
                     getString(R.string.cancel_connection), disconnectPendingIntent);
 
-            Intent pauseVPN = new Intent(this, OpenVpnService.class);
+            Intent pauseVPN = new Intent(this, OpenVPNService.class);
             if (mDeviceStateReceiver == null || !mDeviceStateReceiver.isUserPaused()) {
                 pauseVPN.setAction(PAUSE_VPN);
                 PendingIntent pauseVPNPending = PendingIntent.getService(this, 0, pauseVPN, 0);
@@ -308,23 +309,32 @@ public class OpenVpnService extends VpnService implements StateListener, Callbac
             return START_REDELIVER_INTENT;
         }
 
-        if (intent == null)
-            return START_NOT_STICKY;
-
+	String UUID = "UUID";
+        if (intent == null) {
+	    SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this);
+	    android.util.Log.d("bitmaskclient", "UUID is " + prefs.getString(UUID, ""));
+	    mProfile = ProfileManager.get(this, prefs.getString(UUID, ""));
+	    android.util.Log.d("bitmaskclient", "mProfile is null? " + (mProfile == null));
+	    if(mProfile != null)
+		intent = mProfile.prepareIntent(getBaseContext());
+	    else
+                return START_NOT_STICKY;
+	}
+	if(mProfile != null)
+	    android.util.Log.d("bitmaskclient", "mProfile != null");
         // Extract information from the intent.
         String prefix = getPackageName();
         String[] argv = intent.getStringArrayExtra(prefix + ".ARGV");
         String nativelibdir = intent.getStringExtra(prefix + ".nativelib");
-        String profileUUID = intent.getStringExtra(prefix + ".profileUUID");
+        String profileUUID = intent.getStringExtra(prefix + ".profileUUID");	
 
         mProfile = ProfileManager.get(this, profileUUID);
 
-
         String startTitle = getString(R.string.start_vpn_title, mProfile.mName);
         String startTicker = getString(R.string.start_vpn_ticker, mProfile.mName);
         showNotification(startTitle, startTicker,
                 false, 0, LEVEL_CONNECTING_NO_SERVER_REPLY_YET);
-	
+
         // Set a flag that we are starting a new VPN
         mStarting = true;
         // Stop the previous session by interrupting the thread.
@@ -351,12 +361,13 @@ public class OpenVpnService extends VpnService implements StateListener, Callbac
 
         // Start a new session by creating a new thread.
         SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this);
-
+	
         mOvpn3 = prefs.getBoolean("ovpn3", false);
         if (!"ovpn3".equals(BuildConfig.FLAVOR))
             mOvpn3 = false;
 
 
+	prefs.edit().putString(UUID, profileUUID).commit();
         // Open the Management Interface
         if (!mOvpn3) {
 
@@ -399,13 +410,16 @@ public class OpenVpnService extends VpnService implements StateListener, Callbac
 
         ProfileManager.setConnectedVpnProfile(this, mProfile);
 
-        return START_NOT_STICKY;
+        if (mProfile.mPersistTun)
+            return START_STICKY;
+	else
+	    return START_NOT_STICKY;
     }
 
     private OpenVPNManagement instantiateOpenVPN3Core() {
         try {
             Class cl = Class.forName("de.blinkt.openvpn.core.OpenVPNThreadv3");
-            return (OpenVPNManagement) cl.getConstructor(OpenVpnService.class,VpnProfile.class).newInstance(this,mProfile);
+            return (OpenVPNManagement) cl.getConstructor(OpenVPNService.class,VpnProfile.class).newInstance(this,mProfile);
         } catch (IllegalArgumentException e) {
             e.printStackTrace();
         } catch (InstantiationException e) {
@@ -499,8 +513,15 @@ public class OpenVpnService extends VpnService implements StateListener, Callbac
             }
         }
 
-
-        builder.setMtu(mMtu);
+        String release = Build.VERSION.RELEASE;
+        if ((Build.VERSION.SDK_INT == Build.VERSION_CODES.KITKAT && !release.startsWith("4.4.3")
+                &&  !release.startsWith("4.4.4") &&  !release.startsWith("4.4.5") && !release.startsWith("4.4.6"))
+                && mMtu < 1280) {
+            VpnStatus.logInfo(String.format("Forcing MTU to 1280 instead of %d to workaround Android Bug #70916", mMtu));
+            builder.setMtu(1280);
+        } else {
+            builder.setMtu(mMtu);
+        }
 
         Collection<ipAddress> positiveIPv4Routes = mRoutes.getPositiveIPList();
         Collection<ipAddress> positiveIPv6Routes = mRoutesv6.getPositiveIPList();
@@ -702,23 +723,32 @@ public class OpenVpnService extends VpnService implements StateListener, Callbac
                 mDisplayBytecount = true;
                 mConnecttime = System.currentTimeMillis();
                 lowpriority = true;
-		NotificationManager mNotificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
-		mNotificationManager.cancel(OPENVPN_STATUS);
-            } else if(!mProfile.mPersistTun || mConnecttime == 0){
-                mDisplayBytecount = false;
-		String msg = getString(resid);
-		String ticker = msg;
-		showNotification(msg + " " + logmessage, ticker, lowpriority , 0, level);
-            } else if(mProfile.mPersistTun && level == LEVEL_NONETWORK) {
-		NotificationManager mNotificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
-		mNotificationManager.cancel(OPENVPN_STATUS);
-	    } else if(mProfile.mPersistTun && mConnecttime > 0) {
+		if(mProfile.mPersistTun) {
+		    NotificationManager ns = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
+		    ns.cancel(OPENVPN_STATUS);
+		    return;
+		}
+	    } else if (level == LEVEL_NONETWORK || level == LEVEL_NOTCONNECTED) {
+		NotificationManager ns = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
+		ns.cancel(OPENVPN_STATUS);
+		return;
+	    } else if (level != LEVEL_NOTCONNECTED && mConnecttime > 0) {
                 mDisplayBytecount = false;
 		String msg = "Traffic is blocked until the VPN becomes active.";
-		String ticker = msg;		
+		String ticker = msg;
 		showNotification(msg, ticker, lowpriority , 0, level);
-	    }
+		return;
+	    } else {
+                mDisplayBytecount = false;
+            }
 
+            // Other notifications are shown,
+            // This also mean we are no longer connected, ignore bytecount messages until next
+            // CONNECTED
+            // Does not work :(
+            String msg = getString(resid);
+            String ticker = msg;
+            showNotification(msg + " " + logmessage, ticker, lowpriority , 0, level);
         }
     }
 
@@ -738,6 +768,9 @@ public class OpenVpnService extends VpnService implements StateListener, Callbac
                     humanReadableByteCount(diffIn / OpenVPNManagement.mBytecountInterval, true),
                     humanReadableByteCount(out, false),
                     humanReadableByteCount(diffOut / OpenVPNManagement.mBytecountInterval, true));
+
+            boolean lowpriority = !mNotificationAlwaysVisible;
+            //showNotification(netstat, null, lowpriority, mConnecttime, LEVEL_CONNECTED);
         }
 
     }
@@ -773,9 +806,9 @@ public class OpenVpnService extends VpnService implements StateListener, Callbac
     }
 
     public class LocalBinder extends Binder {
-        public OpenVpnService getService() {
+        public OpenVPNService getService() {
             // Return this instance of LocalService so clients can call public methods
-            return OpenVpnService.this;
+            return OpenVPNService.this;
         }
     }
 }
diff --git a/app/src/main/java/de/blinkt/openvpn/core/OpenVPNThread.java b/app/src/main/java/de/blinkt/openvpn/core/OpenVPNThread.java
index 67c05e7d7309ce486038c060af61fed31f1218ec..5fa2ab9ef1c6a307f0f8886e27e392a2a1f92846 100644
--- a/app/src/main/java/de/blinkt/openvpn/core/OpenVPNThread.java
+++ b/app/src/main/java/de/blinkt/openvpn/core/OpenVPNThread.java
@@ -33,11 +33,11 @@ public class OpenVPNThread implements Runnable {
     private String[] mArgv;
 	private Process mProcess;
 	private String mNativeDir;
-	private OpenVpnService mService;
+	private OpenVPNService mService;
 	private String mDumpPath;
 	private Map<String, String> mProcessEnv;
 
-	public OpenVPNThread(OpenVpnService service,String[] argv, Map<String,String> processEnv, String nativelibdir)
+	public OpenVPNThread(OpenVPNService service,String[] argv, Map<String,String> processEnv, String nativelibdir)
 	{
 		mArgv = argv;
 		mNativeDir = nativelibdir;
diff --git a/app/src/main/java/de/blinkt/openvpn/core/OpenVpnManagementThread.java b/app/src/main/java/de/blinkt/openvpn/core/OpenVpnManagementThread.java
index e6e5be25bf293e1aa1bf712d07998bd6cde53285..e200f210c9bf3bd04362400da87d87d558cf0e6d 100644
--- a/app/src/main/java/de/blinkt/openvpn/core/OpenVpnManagementThread.java
+++ b/app/src/main/java/de/blinkt/openvpn/core/OpenVpnManagementThread.java
@@ -33,49 +33,50 @@ import de.blinkt.openvpn.core.VpnStatus.ConnectionStatus;
 
 public class OpenVpnManagementThread implements Runnable, OpenVPNManagement {
 
-	private static final String TAG = "openvpn";
-	private LocalSocket mSocket;
-	private VpnProfile mProfile;
-	private OpenVpnService mOpenVPNService;
-	private LinkedList<FileDescriptor> mFDList=new LinkedList<FileDescriptor>();
+    private static final String TAG = "openvpn";
+    private LocalSocket mSocket;
+    private VpnProfile mProfile;
+    private OpenVPNService mOpenVPNService;
+    private LinkedList<FileDescriptor> mFDList = new LinkedList<FileDescriptor>();
     private LocalServerSocket mServerSocket;
-	private boolean mReleaseHold=true;
-	private boolean mWaitingForRelease=false;
-	private long mLastHoldRelease=0;
+    private boolean mReleaseHold = true;
+    private boolean mWaitingForRelease = false;
+    private long mLastHoldRelease = 0;
 
-	private static Vector<OpenVpnManagementThread> active=new Vector<OpenVpnManagementThread>();
+    private static final Vector<OpenVpnManagementThread> active = new Vector<OpenVpnManagementThread>();
     private LocalSocket mServerSocketLocal;
 
     private pauseReason lastPauseReason = pauseReason.noNetwork;
 
-    public OpenVpnManagementThread(VpnProfile profile, OpenVpnService openVpnService) {
-		mProfile = profile;
-		mOpenVPNService = openVpnService;
-		
+    public OpenVpnManagementThread(VpnProfile profile, OpenVPNService openVpnService) {
+        mProfile = profile;
+        mOpenVPNService = openVpnService;
 
-		SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(openVpnService);
-		boolean managemeNetworkState = prefs.getBoolean("netchangereconnect", true);
-		if(managemeNetworkState)
-			mReleaseHold=false;
 
-	}
+        SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(openVpnService);
+        boolean managemeNetworkState = prefs.getBoolean("netchangereconnect", true);
+        if (managemeNetworkState)
+            mReleaseHold = false;
+
+    }
 
     public boolean openManagementInterface(@NotNull Context c) {
         // Could take a while to open connection
-        int tries=8;
+        int tries = 8;
 
-        String socketName = (c.getCacheDir().getAbsolutePath() + "/" +  "mgmtsocket");
+        String socketName = (c.getCacheDir().getAbsolutePath() + "/" + "mgmtsocket");
         // The mServerSocketLocal is transferred to the LocalServerSocket, ignore warning
 
         mServerSocketLocal = new LocalSocket();
 
-        while(tries > 0 && !mServerSocketLocal.isConnected()) {
+        while (tries > 0 && !mServerSocketLocal.isConnected()) {
             try {
                 mServerSocketLocal.bind(new LocalSocketAddress(socketName,
                         LocalSocketAddress.Namespace.FILESYSTEM));
             } catch (IOException e) {
                 // wait 300 ms before retrying
-                try { Thread.sleep(300);
+                try {
+                    Thread.sleep(300);
                 } catch (InterruptedException e1) {
                 }
 
@@ -95,165 +96,168 @@ public class OpenVpnManagementThread implements Runnable, OpenVPNManagement {
 
     }
 
-	public void managmentCommand(String cmd) {
+    public void managmentCommand(String cmd) {
         try {
-		    if(mSocket!=null && mSocket.getOutputStream() !=null) {
-				mSocket.getOutputStream().write(cmd.getBytes());
-				mSocket.getOutputStream().flush();
-			}
-        }catch (IOException e) {
-				// Ignore socket stack traces
+            if (mSocket != null && mSocket.getOutputStream() != null) {
+                mSocket.getOutputStream().write(cmd.getBytes());
+                mSocket.getOutputStream().flush();
+            }
+        } catch (IOException e) {
+            // Ignore socket stack traces
         }
-	}
+    }
 
 
-	@Override
-	public void run() {
-		byte [] buffer  =new byte[2048];
-		//	mSocket.setSoTimeout(5); // Setting a timeout cannot be that bad
+    @Override
+    public void run() {
+        byte[] buffer = new byte[2048];
+        //	mSocket.setSoTimeout(5); // Setting a timeout cannot be that bad
 
-		String pendingInput="";
-		active.add(this);
+        String pendingInput = "";
+        synchronized (active) {
+            active.add(this);
+        }
 
-		try {
-			// Wait for a client to connect
-			mSocket= mServerSocket.accept();
-			InputStream instream = mSocket.getInputStream();
+        try {
+            // Wait for a client to connect
+            mSocket = mServerSocket.accept();
+            InputStream instream = mSocket.getInputStream();
             // Close the management socket after client connected
 
             mServerSocket.close();
             // Closing one of the two sockets also closes the other
             //mServerSocketLocal.close();
 
-			while(true) {
-				int numbytesread = instream.read(buffer);
-				if(numbytesread==-1)
-					return;
-
-				FileDescriptor[] fds = null;
-				try {
-					fds = mSocket.getAncillaryFileDescriptors();
-				} catch (IOException e) {
-					VpnStatus.logException("Error reading fds from socket", e);
-				}
-				if(fds!=null){
-                    Collections.addAll(mFDList, fds);
-				}
+            while (true) {
+                int numbytesread = instream.read(buffer);
+                if (numbytesread == -1)
+                    return;
 
-				String input = new String(buffer,0,numbytesread,"UTF-8");
+                FileDescriptor[] fds = null;
+                try {
+                    fds = mSocket.getAncillaryFileDescriptors();
+                } catch (IOException e) {
+                    VpnStatus.logException("Error reading fds from socket", e);
+                }
+                if (fds != null) {
+                    Collections.addAll(mFDList, fds);
+                }
 
-				pendingInput += input;
+                String input = new String(buffer, 0, numbytesread, "UTF-8");
 
-				pendingInput=processInput(pendingInput);
+                pendingInput += input;
 
+                pendingInput = processInput(pendingInput);
 
 
-			}
-		} catch (IOException e) {
+            }
+        } catch (IOException e) {
             if (!e.getMessage().equals("socket closed"))
                 VpnStatus.logException(e);
-		}
-		active.remove(this);
-	}
+        }
+        synchronized (active) {
+            active.remove(this);
+        }
+    }
 
-	//! Hack O Rama 2000!
-	private void protectFileDescriptor(FileDescriptor fd) {
-		Exception exp;
-		try {
-			Method getInt =  FileDescriptor.class.getDeclaredMethod("getInt$");
-			int fdint = (Integer) getInt.invoke(fd);
+    //! Hack O Rama 2000!
+    private void protectFileDescriptor(FileDescriptor fd) {
+        Exception exp;
+        try {
+            Method getInt = FileDescriptor.class.getDeclaredMethod("getInt$");
+            int fdint = (Integer) getInt.invoke(fd);
 
-			// You can even get more evil by parsing toString() and extract the int from that :)
+            // You can even get more evil by parsing toString() and extract the int from that :)
 
-			boolean result = mOpenVPNService.protect(fdint);
+            boolean result = mOpenVPNService.protect(fdint);
             if (!result)
                 VpnStatus.logWarning("Could not protect VPN socket");
 
 
-			//ParcelFileDescriptor pfd = ParcelFileDescriptor.fromFd(fdint);
-			//pfd.close();
-			NativeUtils.jniclose(fdint);
-			return;
-		} catch (NoSuchMethodException e) {
-			exp =e;
-		} catch (IllegalArgumentException e) {
-			exp =e;
-		} catch (IllegalAccessException e) {
-			exp =e;
-		} catch (InvocationTargetException e) {
-			exp =e;
-		} catch (NullPointerException e) {
-			exp =e;
-		}
+            //ParcelFileDescriptor pfd = ParcelFileDescriptor.fromFd(fdint);
+            //pfd.close();
+            NativeUtils.jniclose(fdint);
+            return;
+        } catch (NoSuchMethodException e) {
+            exp = e;
+        } catch (IllegalArgumentException e) {
+            exp = e;
+        } catch (IllegalAccessException e) {
+            exp = e;
+        } catch (InvocationTargetException e) {
+            exp = e;
+        } catch (NullPointerException e) {
+            exp = e;
+        }
 
         Log.d("Openvpn", "Failed to retrieve fd from socket: " + fd);
-        VpnStatus.logException("Failed to retrieve fd from socket (" + fd + ")" , exp);
-	}
+        VpnStatus.logException("Failed to retrieve fd from socket (" + fd + ")", exp);
+    }
 
-	private String processInput(String pendingInput) {
+    private String processInput(String pendingInput) {
 
 
-		while(pendingInput.contains("\n")) {
-			String[] tokens = pendingInput.split("\\r?\\n", 2);
-			processCommand(tokens[0]);
-			if(tokens.length == 1)
-				// No second part, newline was at the end
-				pendingInput="";
-			else
-				pendingInput=tokens[1];
-		}
-		return pendingInput;
-	}
+        while (pendingInput.contains("\n")) {
+            String[] tokens = pendingInput.split("\\r?\\n", 2);
+            processCommand(tokens[0]);
+            if (tokens.length == 1)
+                // No second part, newline was at the end
+                pendingInput = "";
+            else
+                pendingInput = tokens[1];
+        }
+        return pendingInput;
+    }
 
 
-	private void processCommand(String command) {
+    private void processCommand(String command) {
         //Log.i(TAG, "Line from managment" + command);
 
 
         if (command.startsWith(">") && command.contains(":")) {
-			String[] parts = command.split(":",2);
-			String cmd = parts[0].substring(1);
-			String argument = parts[1];
+            String[] parts = command.split(":", 2);
+            String cmd = parts[0].substring(1);
+            String argument = parts[1];
 
 
-			if(cmd.equals("INFO")) {
-				/* Ignore greeting from management */
+            if (cmd.equals("INFO")) {
+                /* Ignore greeting from management */
                 return;
-			}else if (cmd.equals("PASSWORD")) {
-				processPWCommand(argument);
-			} else if (cmd.equals("HOLD")) {
-				handleHold();
-			} else if (cmd.equals("NEED-OK")) {
-				processNeedCommand(argument);
-			} else if (cmd.equals("BYTECOUNT")){
-				processByteCount(argument);
-			} else if (cmd.equals("STATE")) {
-				processState(argument);
-			} else if (cmd.equals("PROXY")) {
-				processProxyCMD(argument);
-			} else if (cmd.equals("LOG")) {
-                 processLogMessage(argument);
-			} else if (cmd.equals("RSA_SIGN")) {
-				processSignCommand(argument);
-			} else {
-				VpnStatus.logWarning("MGMT: Got unrecognized command" + command);
-				Log.i(TAG, "Got unrecognized command" + command);
-			}
-		} else if (command.startsWith("SUCCESS:")) {
+            } else if (cmd.equals("PASSWORD")) {
+                processPWCommand(argument);
+            } else if (cmd.equals("HOLD")) {
+                handleHold();
+            } else if (cmd.equals("NEED-OK")) {
+                processNeedCommand(argument);
+            } else if (cmd.equals("BYTECOUNT")) {
+                processByteCount(argument);
+            } else if (cmd.equals("STATE")) {
+                processState(argument);
+            } else if (cmd.equals("PROXY")) {
+                processProxyCMD(argument);
+            } else if (cmd.equals("LOG")) {
+                processLogMessage(argument);
+            } else if (cmd.equals("RSA_SIGN")) {
+                processSignCommand(argument);
+            } else {
+                VpnStatus.logWarning("MGMT: Got unrecognized command" + command);
+                Log.i(TAG, "Got unrecognized command" + command);
+            }
+        } else if (command.startsWith("SUCCESS:")) {
 			/* Ignore this kind of message too */
             return;
         } else if (command.startsWith("PROTECTFD: ")) {
             FileDescriptor fdtoprotect = mFDList.pollFirst();
-            if (fdtoprotect!=null)
+            if (fdtoprotect != null)
                 protectFileDescriptor(fdtoprotect);
-		} else {
-			Log.i(TAG, "Got unrecognized line from managment" + command);
-			VpnStatus.logWarning("MGMT: Got unrecognized line from management:" + command);
-		}
-	}
+        } else {
+            Log.i(TAG, "Got unrecognized line from managment" + command);
+            VpnStatus.logWarning("MGMT: Got unrecognized line from management:" + command);
+        }
+    }
 
     private void processLogMessage(String argument) {
-        String[] args = argument.split(",",4);
+        String[] args = argument.split(",", 4);
         // 0 unix time stamp
         // 1 log level N,I,E etc.
                 /*
@@ -287,109 +291,110 @@ public class OpenVpnManagementThread implements Runnable, OpenVPNManagement {
         if (msg.startsWith("MANAGEMENT: CMD"))
             ovpnlevel = Math.max(4, ovpnlevel);
 
-        VpnStatus.logMessageOpenVPN(level,ovpnlevel, msg);
+        VpnStatus.logMessageOpenVPN(level, ovpnlevel, msg);
     }
 
     private void handleHold() {
-		if(mReleaseHold) {
-			releaseHoldCmd();
-		} else { 
-			mWaitingForRelease=true;
+        if (mReleaseHold) {
+            releaseHoldCmd();
+        } else {
+            mWaitingForRelease = true;
 
             VpnStatus.updateStatePause(lastPauseReason);
 
 
-		}
-	}
-	private void releaseHoldCmd() {
-		if ((System.currentTimeMillis()- mLastHoldRelease) < 5000) {
-			try {
-				Thread.sleep(3000);
-			} catch (InterruptedException e) {
+        }
+    }
+
+    private void releaseHoldCmd() {
+        if ((System.currentTimeMillis() - mLastHoldRelease) < 5000) {
+            try {
+                Thread.sleep(3000);
+            } catch (InterruptedException ignored) {
             }
-			
-		}
-		mWaitingForRelease=false;
-		mLastHoldRelease  = System.currentTimeMillis();
-		managmentCommand("hold release\n");
-		managmentCommand("bytecount " + mBytecountInterval + "\n");
+
+        }
+        mWaitingForRelease = false;
+        mLastHoldRelease = System.currentTimeMillis();
+        managmentCommand("hold release\n");
+        managmentCommand("bytecount " + mBytecountInterval + "\n");
         managmentCommand("state on\n");
         //managmentCommand("log on all\n");
-	}
-	
-	public void releaseHold() {
-		mReleaseHold=true;
-		if(mWaitingForRelease)
-			releaseHoldCmd();
-			
-	}
-
-	private void processProxyCMD(String argument) {
-		String[] args = argument.split(",",3);
-		SocketAddress proxyaddr = ProxyDetection.detectProxy(mProfile);
-
-		
-		if(args.length >= 2) {
-			String proto = args[1];
-			if(proto.equals("UDP")) {
-				proxyaddr=null;
-			}
-		}
-
-		if(proxyaddr instanceof InetSocketAddress ){
-			InetSocketAddress isa = (InetSocketAddress) proxyaddr;
-			
-			VpnStatus.logInfo(R.string.using_proxy, isa.getHostName(), isa.getPort());
-			
-			String proxycmd = String.format(Locale.ENGLISH,"proxy HTTP %s %d\n", isa.getHostName(),isa.getPort());
-			managmentCommand(proxycmd);
-		} else {
-			managmentCommand("proxy NONE\n");
-		}
-
-	}
-	private void processState(String argument) {
-		String[] args = argument.split(",",3);
-		String currentstate = args[1];
-
-		if(args[2].equals(",,"))
-			VpnStatus.updateStateString(currentstate, "");
-		else
-			VpnStatus.updateStateString(currentstate, args[2]);
-	}
-
-
-	private void processByteCount(String argument) {
-		//   >BYTECOUNT:{BYTES_IN},{BYTES_OUT}
-		int comma = argument.indexOf(',');
-		long in = Long.parseLong(argument.substring(0, comma));
-		long out = Long.parseLong(argument.substring(comma+1));
-
-		VpnStatus.updateByteCount(in, out);
-		
-	}
-
-
-
-	private void processNeedCommand(String argument) {
-		int p1 =argument.indexOf('\'');
-		int p2 = argument.indexOf('\'',p1+1);
-
-		String needed = argument.substring(p1+1, p2);
-		String extra = argument.split(":",2)[1];
-
-		String status = "ok";
-
-
-		if (needed.equals("PROTECTFD")) {
-			FileDescriptor fdtoprotect = mFDList.pollFirst();
-			protectFileDescriptor(fdtoprotect);
-		} else if (needed.equals("DNSSERVER")) {
-			mOpenVPNService.addDNS(extra);
-		}else if (needed.equals("DNSDOMAIN")){
-			mOpenVPNService.setDomain(extra);
-		} else if (needed.equals("ROUTE")) {
-			String[] routeparts = extra.split(" ");
+    }
+
+    public void releaseHold() {
+        mReleaseHold = true;
+        if (mWaitingForRelease)
+            releaseHoldCmd();
+
+    }
+
+    private void processProxyCMD(String argument) {
+        String[] args = argument.split(",", 3);
+        SocketAddress proxyaddr = ProxyDetection.detectProxy(mProfile);
+
+
+        if (args.length >= 2) {
+            String proto = args[1];
+            if (proto.equals("UDP")) {
+                proxyaddr = null;
+            }
+        }
+
+        if (proxyaddr instanceof InetSocketAddress) {
+            InetSocketAddress isa = (InetSocketAddress) proxyaddr;
+
+            VpnStatus.logInfo(R.string.using_proxy, isa.getHostName(), isa.getPort());
+
+            String proxycmd = String.format(Locale.ENGLISH, "proxy HTTP %s %d\n", isa.getHostName(), isa.getPort());
+            managmentCommand(proxycmd);
+        } else {
+            managmentCommand("proxy NONE\n");
+        }
+
+    }
+
+    private void processState(String argument) {
+        String[] args = argument.split(",", 3);
+        String currentstate = args[1];
+
+        if (args[2].equals(",,"))
+            VpnStatus.updateStateString(currentstate, "");
+        else
+            VpnStatus.updateStateString(currentstate, args[2]);
+    }
+
+
+    private void processByteCount(String argument) {
+        //   >BYTECOUNT:{BYTES_IN},{BYTES_OUT}
+        int comma = argument.indexOf(',');
+        long in = Long.parseLong(argument.substring(0, comma));
+        long out = Long.parseLong(argument.substring(comma + 1));
+
+        VpnStatus.updateByteCount(in, out);
+
+    }
+
+
+    private void processNeedCommand(String argument) {
+        int p1 = argument.indexOf('\'');
+        int p2 = argument.indexOf('\'', p1 + 1);
+
+        String needed = argument.substring(p1 + 1, p2);
+        String extra = argument.split(":", 2)[1];
+
+        String status = "ok";
+
+
+        if (needed.equals("PROTECTFD")) {
+            FileDescriptor fdtoprotect = mFDList.pollFirst();
+            protectFileDescriptor(fdtoprotect);
+        } else if (needed.equals("DNSSERVER")) {
+            mOpenVPNService.addDNS(extra);
+        } else if (needed.equals("DNSDOMAIN")) {
+            mOpenVPNService.setDomain(extra);
+        } else if (needed.equals("ROUTE")) {
+            String[] routeparts = extra.split(" ");
 
             /*
             buf_printf (&out, "%s %s %s dev %s", network, netmask, gateway, rgi->iface);
@@ -397,209 +402,208 @@ public class OpenVpnManagementThread implements Runnable, OpenVPNManagement {
             buf_printf (&out, "%s %s %s", network, netmask, gateway);
             */
 
-            if(routeparts.length==5) {
+            if (routeparts.length == 5) {
                 if (BuildConfig.DEBUG) Assert.assertEquals("dev", routeparts[3]);
                 mOpenVPNService.addRoute(routeparts[0], routeparts[1], routeparts[2], routeparts[4]);
-            }  else if (routeparts.length >= 3) {
+            } else if (routeparts.length >= 3) {
                 mOpenVPNService.addRoute(routeparts[0], routeparts[1], routeparts[2], null);
             } else {
                 VpnStatus.logError("Unrecognized ROUTE cmd:" + Arrays.toString(routeparts) + " | " + argument);
             }
 
-		} else if (needed.equals("ROUTE6")) {
+        } else if (needed.equals("ROUTE6")) {
             String[] routeparts = extra.split(" ");
-			mOpenVPNService.addRoutev6(routeparts[0],routeparts[1]);
-		} else if (needed.equals("IFCONFIG")) {
-			String[] ifconfigparts = extra.split(" ");
-			int mtu = Integer.parseInt(ifconfigparts[2]);
-			mOpenVPNService.setLocalIP(ifconfigparts[0], ifconfigparts[1],mtu,ifconfigparts[3]);
-		} else if (needed.equals("IFCONFIG6")) {
-			mOpenVPNService.setLocalIPv6(extra);
-
-		} else if (needed.equals("PERSIST_TUN_ACTION")) {
+            mOpenVPNService.addRoutev6(routeparts[0], routeparts[1]);
+        } else if (needed.equals("IFCONFIG")) {
+            String[] ifconfigparts = extra.split(" ");
+            int mtu = Integer.parseInt(ifconfigparts[2]);
+            mOpenVPNService.setLocalIP(ifconfigparts[0], ifconfigparts[1], mtu, ifconfigparts[3]);
+        } else if (needed.equals("IFCONFIG6")) {
+            mOpenVPNService.setLocalIPv6(extra);
+
+        } else if (needed.equals("PERSIST_TUN_ACTION")) {
             // check if tun cfg stayed the same
             status = mOpenVPNService.getTunReopenStatus();
         } else if (needed.equals("OPENTUN")) {
-			if(sendTunFD(needed,extra))
-				return;
-			else
-				status="cancel";
-			// This not nice or anything but setFileDescriptors accepts only FilDescriptor class :(
-
-		} else {
-			Log.e(TAG,"Unkown needok command " + argument);
-			return;
-		}
-
-		String cmd = String.format("needok '%s' %s\n", needed, status);
-		managmentCommand(cmd);
-	}
-
-	private boolean sendTunFD (String needed, String extra) {
-		Exception exp;
-		if(!extra.equals("tun")) {
-			// We only support tun
-			VpnStatus.logError(String.format("Device type %s requested, but only tun is possible with the Android API, sorry!",extra));
-
-			return false;
-		}
-		ParcelFileDescriptor pfd = mOpenVPNService.openTun();
-		if(pfd==null)
-			return false;
-
-		Method setInt;
-		int fdint = pfd.getFd();
-		try {
-			setInt = FileDescriptor.class.getDeclaredMethod("setInt$",int.class);
-			FileDescriptor fdtosend = new FileDescriptor();
-
-			setInt.invoke(fdtosend,fdint);
-
-			FileDescriptor[] fds = {fdtosend};
-			mSocket.setFileDescriptorsForSend(fds);
-
-			// Trigger a send so we can close the fd on our side of the channel
-			// The API documentation fails to mention that it will not reset the file descriptor to
-			// be send and will happily send the file descriptor on every write ...
-			String cmd = String.format("needok '%s' %s\n", needed, "ok");
-			managmentCommand(cmd);
-
-			// Set the FileDescriptor to null to stop this mad behavior 
-			mSocket.setFileDescriptorsForSend(null);
-
-			pfd.close();			
-
-			return true;
-		} catch (NoSuchMethodException e) {
-			exp =e;
-		} catch (IllegalArgumentException e) {
-			exp =e;
-		} catch (IllegalAccessException e) {
-			exp =e;
-		} catch (InvocationTargetException e) {
-			exp =e;
-		} catch (IOException e) {
-			exp =e;
-		}
-        VpnStatus.logException("Could not send fd over socket" , exp);
+            if (sendTunFD(needed, extra))
+                return;
+            else
+                status = "cancel";
+            // This not nice or anything but setFileDescriptors accepts only FilDescriptor class :(
+
+        } else {
+            Log.e(TAG, "Unkown needok command " + argument);
+            return;
+        }
+
+        String cmd = String.format("needok '%s' %s\n", needed, status);
+        managmentCommand(cmd);
+    }
+
+    private boolean sendTunFD(String needed, String extra) {
+        Exception exp;
+        if (!extra.equals("tun")) {
+            // We only support tun
+            VpnStatus.logError(String.format("Device type %s requested, but only tun is possible with the Android API, sorry!", extra));
+
+            return false;
+        }
+        ParcelFileDescriptor pfd = mOpenVPNService.openTun();
+        if (pfd == null)
+            return false;
+
+        Method setInt;
+        int fdint = pfd.getFd();
+        try {
+            setInt = FileDescriptor.class.getDeclaredMethod("setInt$", int.class);
+            FileDescriptor fdtosend = new FileDescriptor();
+
+            setInt.invoke(fdtosend, fdint);
+
+            FileDescriptor[] fds = {fdtosend};
+            mSocket.setFileDescriptorsForSend(fds);
+
+            // Trigger a send so we can close the fd on our side of the channel
+            // The API documentation fails to mention that it will not reset the file descriptor to
+            // be send and will happily send the file descriptor on every write ...
+            String cmd = String.format("needok '%s' %s\n", needed, "ok");
+            managmentCommand(cmd);
+
+            // Set the FileDescriptor to null to stop this mad behavior
+            mSocket.setFileDescriptorsForSend(null);
+
+            pfd.close();
+
+            return true;
+        } catch (NoSuchMethodException e) {
+            exp = e;
+        } catch (IllegalArgumentException e) {
+            exp = e;
+        } catch (IllegalAccessException e) {
+            exp = e;
+        } catch (InvocationTargetException e) {
+            exp = e;
+        } catch (IOException e) {
+            exp = e;
+        }
+        VpnStatus.logException("Could not send fd over socket", exp);
 
         return false;
-	}
-
-	private void processPWCommand(String argument) {
-		//argument has the form 	Need 'Private Key' password
-		// or  ">PASSWORD:Verification Failed: '%s' ['%s']"
-		String needed;
-		
-		
-		
-		try{
-
-			int p1 = argument.indexOf('\'');
-			int p2 = argument.indexOf('\'',p1+1);
-			needed = argument.substring(p1+1, p2);
-			if (argument.startsWith("Verification Failed")) {
-				proccessPWFailed(needed, argument.substring(p2+1));
-				return;
-			}
-		} catch (StringIndexOutOfBoundsException sioob) {
-			VpnStatus.logError("Could not parse management Password command: " + argument);
-			return;
-		}
-
-		String pw=null;
-
-		if(needed.equals("Private Key")) {
-			pw = mProfile.getPasswordPrivateKey();
-		} else if (needed.equals("Auth")) {
-			String usercmd = String.format("username '%s' %s\n", 
-					needed, VpnProfile.openVpnEscape(mProfile.mUsername));
-			managmentCommand(usercmd);
-			pw = mProfile.getPasswordAuth();
-		} 
-		if(pw!=null) {
-			String cmd = String.format("password '%s' %s\n", needed, VpnProfile.openVpnEscape(pw));
-			managmentCommand(cmd);
-		} else {
-			VpnStatus.logError(String.format("Openvpn requires Authentication type '%s' but no password/key information available", needed));
-		}
-
-	}
-
-
-
-
-	private void proccessPWFailed(String needed, String args) {
-		VpnStatus.updateStateString("AUTH_FAILED", needed + args, R.string.state_auth_failed, ConnectionStatus.LEVEL_AUTH_FAILED);
-	}
-
-
-	private static boolean stopOpenVPN() {
-		boolean sendCMD=false;
-		for (OpenVpnManagementThread mt: active){
-			mt.managmentCommand("signal SIGINT\n");
-			sendCMD=true;
-			try {
-				if(mt.mSocket !=null)
-					mt.mSocket.close();
-			} catch (IOException e) {
-				// Ignore close error on already closed socket
-			}
-		}
-		return sendCMD;		
-	}
+    }
+
+    private void processPWCommand(String argument) {
+        //argument has the form 	Need 'Private Key' password
+        // or  ">PASSWORD:Verification Failed: '%s' ['%s']"
+        String needed;
+
+
+        try {
+
+            int p1 = argument.indexOf('\'');
+            int p2 = argument.indexOf('\'', p1 + 1);
+            needed = argument.substring(p1 + 1, p2);
+            if (argument.startsWith("Verification Failed")) {
+                proccessPWFailed(needed, argument.substring(p2 + 1));
+                return;
+            }
+        } catch (StringIndexOutOfBoundsException sioob) {
+            VpnStatus.logError("Could not parse management Password command: " + argument);
+            return;
+        }
+
+        String pw = null;
+
+        if (needed.equals("Private Key")) {
+            pw = mProfile.getPasswordPrivateKey();
+        } else if (needed.equals("Auth")) {
+            String usercmd = String.format("username '%s' %s\n",
+                    needed, VpnProfile.openVpnEscape(mProfile.mUsername));
+            managmentCommand(usercmd);
+            pw = mProfile.getPasswordAuth();
+        }
+        if (pw != null) {
+            String cmd = String.format("password '%s' %s\n", needed, VpnProfile.openVpnEscape(pw));
+            managmentCommand(cmd);
+        } else {
+            VpnStatus.logError(String.format("Openvpn requires Authentication type '%s' but no password/key information available", needed));
+        }
+
+    }
+
+
+    private void proccessPWFailed(String needed, String args) {
+        VpnStatus.updateStateString("AUTH_FAILED", needed + args, R.string.state_auth_failed, ConnectionStatus.LEVEL_AUTH_FAILED);
+    }
+
+
+    private static boolean stopOpenVPN() {
+        synchronized (active) {
+            boolean sendCMD = false;
+            for (OpenVpnManagementThread mt : active) {
+                mt.managmentCommand("signal SIGINT\n");
+                sendCMD = true;
+                try {
+                    if (mt.mSocket != null)
+                        mt.mSocket.close();
+                } catch (IOException e) {
+                    // Ignore close error on already closed socket
+                }
+            }
+            return sendCMD;
+        }
+    }
 
     @Override
     public void networkChange() {
-        if(!mWaitingForRelease)
+        if (!mWaitingForRelease)
             managmentCommand("network-change\n");
     }
 
-	public void signalusr1() {
-		mReleaseHold=false;
+    public void signalusr1() {
+        mReleaseHold = false;
 
-		if(!mWaitingForRelease)
-			managmentCommand("signal SIGUSR1\n");
+        if (!mWaitingForRelease)
+            managmentCommand("signal SIGUSR1\n");
         else
             // If signalusr1 is called update the state string
             // if there is another for stopping
             VpnStatus.updateStatePause(lastPauseReason);
-	}
+    }
 
-	public void reconnect() {
-		signalusr1();
-		releaseHold();
-	}
+    public void reconnect() {
+        signalusr1();
+        releaseHold();
+    }
 
-	private void processSignCommand(String b64data) {
+    private void processSignCommand(String b64data) {
 
-		String signed_string = mProfile.getSignedData(b64data);
-        if(signed_string==null) {
+        String signed_string = mProfile.getSignedData(b64data);
+        if (signed_string == null) {
             managmentCommand("rsa-sig\n");
             managmentCommand("\nEND\n");
             stopOpenVPN();
             return;
         }
         managmentCommand("rsa-sig\n");
-		managmentCommand(signed_string);
+        managmentCommand(signed_string);
         managmentCommand("\nEND\n");
-	}
+    }
 
-	@Override
-	public void pause (pauseReason reason) {
+    @Override
+    public void pause(pauseReason reason) {
         lastPauseReason = reason;
-		signalusr1();
-	}
+        signalusr1();
+    }
 
-	@Override
-	public void resume() {
-		releaseHold();
+    @Override
+    public void resume() {
+        releaseHold();
         /* Reset the reason why we are disconnected */
         lastPauseReason = pauseReason.noNetwork;
-	}
+    }
 
-	@Override
-	public boolean stopVPN() {
-		return stopOpenVPN();
-	}
+    @Override
+    public boolean stopVPN() {
+        return stopOpenVPN();
+    }
 }
diff --git a/app/src/main/java/de/blinkt/openvpn/fragments/LogFragment.java b/app/src/main/java/de/blinkt/openvpn/fragments/LogFragment.java
index 6e592121ed9c1e0cd3b1ec6b438a937cd3f269f7..ca85053340e1b94e41f8c13c97264cec0bded47d 100644
--- a/app/src/main/java/de/blinkt/openvpn/fragments/LogFragment.java
+++ b/app/src/main/java/de/blinkt/openvpn/fragments/LogFragment.java
@@ -53,7 +53,7 @@ import se.leap.bitmaskclient.R;
 import de.blinkt.openvpn.VpnProfile;
 import de.blinkt.openvpn.activities.DisconnectVPN;
 import de.blinkt.openvpn.core.OpenVPNManagement;
-import de.blinkt.openvpn.core.OpenVpnService;
+import de.blinkt.openvpn.core.OpenVPNService;
 import de.blinkt.openvpn.core.ProfileManager;
 import de.blinkt.openvpn.core.VpnStatus;
 import de.blinkt.openvpn.core.VpnStatus.ConnectionStatus;
@@ -61,7 +61,7 @@ import de.blinkt.openvpn.core.VpnStatus.LogItem;
 import de.blinkt.openvpn.core.VpnStatus.LogListener;
 import de.blinkt.openvpn.core.VpnStatus.StateListener;
 
-import static de.blinkt.openvpn.core.OpenVpnService.humanReadableByteCount;
+import static de.blinkt.openvpn.core.OpenVPNService.humanReadableByteCount;
 
 import se.leap.bitmaskclient.Dashboard;
 
@@ -503,8 +503,8 @@ public class LogFragment extends ListFragment implements StateListener, SeekBar.
 		super.onResume();
 		VpnStatus.addStateListener(this);
         VpnStatus.addByteCountListener(this);
-        Intent intent = new Intent(getActivity(), OpenVpnService.class);
-        intent.setAction(OpenVpnService.START_SERVICE);
+        Intent intent = new Intent(getActivity(), OpenVPNService.class);
+        intent.setAction(OpenVPNService.START_SERVICE);
 
     }
 
diff --git a/app/src/main/java/se/leap/bitmaskclient/EIP.java b/app/src/main/java/se/leap/bitmaskclient/EIP.java
index 43ad3c1f1561ca6070c49afa0f3dd39ca018b159..43fe0b7ce16b2d282895b6215847f8bf28ea394a 100644
--- a/app/src/main/java/se/leap/bitmaskclient/EIP.java
+++ b/app/src/main/java/se/leap/bitmaskclient/EIP.java
@@ -38,8 +38,8 @@ import de.blinkt.openvpn.activities.DisconnectVPN;
 import de.blinkt.openvpn.core.ConfigParser.ConfigParseError;
 import de.blinkt.openvpn.core.ConfigParser;
 import de.blinkt.openvpn.core.OpenVpnManagementThread;
-import de.blinkt.openvpn.core.OpenVpnService.LocalBinder;
-import de.blinkt.openvpn.core.OpenVpnService;
+import de.blinkt.openvpn.core.OpenVPNService.LocalBinder;
+import de.blinkt.openvpn.core.OpenVPNService;
 import de.blinkt.openvpn.core.ProfileManager;
 import de.blinkt.openvpn.core.VpnStatus.ConnectionStatus;
 import java.io.IOException;
@@ -73,7 +73,7 @@ import se.leap.bitmaskclient.R;
  * Internet Proxy connection.  Connections are started, stopped, and queried through
  * this IntentService.
  * Contains logic for parsing eip-service.json from the provider, configuring and selecting
- * gateways, and controlling {@link de.blinkt.openvpn.core.OpenVpnService} connections.
+ * gateways, and controlling {@link de.blinkt.openvpn.core.OpenVPNService} connections.
  * 
  * @author Sean Leonard <meanderingcode@aetherislands.net>
  * @author Parménides GV <parmegv@sdf.org>
@@ -105,7 +105,6 @@ public final class EIP extends IntentService {
     
 	private static Context context;
 	private static ResultReceiver mReceiver;
-	private static OpenVpnService mVpnService;
 	private static boolean mBound = false;
 	// Used to store actions to "resume" onServiceConnection
 	private static String mPending = null;
@@ -467,7 +466,6 @@ public final class EIP extends IntentService {
 				cp.parseConfig(new StringReader(certSecretFromSharedPreferences()));
 				cp.parseConfig(new StringReader("remote-cert-tls server"));
 				cp.parseConfig(new StringReader("persist-tun"));
-				Log.d(TAG, "persist-tun");
 				VpnProfile vp = cp.convertProfile();
 				//vp.mAuthenticationType=VpnProfile.TYPE_STATICKEYS;
 				mVpnProfile = vp;
diff --git a/app/src/main/java/se/leap/bitmaskclient/EipServiceFragment.java b/app/src/main/java/se/leap/bitmaskclient/EipServiceFragment.java
index c8a28c0aab7508b745fe80aebc49e29ccfdc8dc7..18ee0262fefef8fccf3c106ce7813ae97416bc50 100644
--- a/app/src/main/java/se/leap/bitmaskclient/EipServiceFragment.java
+++ b/app/src/main/java/se/leap/bitmaskclient/EipServiceFragment.java
@@ -251,7 +251,7 @@ public class EipServiceFragment extends Fragment implements StateListener, OnChe
     }
 
     private boolean isDisconnectedLevel(final ConnectionStatus level) {
-	return level == ConnectionStatus.LEVEL_NONETWORK || level == ConnectionStatus.LEVEL_NOTCONNECTED || level == ConnectionStatus.LEVEL_AUTH_FAILED;
+	return level == ConnectionStatus.LEVEL_NOTCONNECTED || level == ConnectionStatus.LEVEL_AUTH_FAILED;
     }
 
     private void setConnectedUI() {
diff --git a/app/src/main/res/values-ca/strings-icsopenvpn.xml b/app/src/main/res/values-ca/strings-icsopenvpn.xml
index 67db802274977f2b610c6343cd73b25a9eaaacce..7e74c198e98e51505980d4bef7ce54c23e8640a1 100755
--- a/app/src/main/res/values-ca/strings-icsopenvpn.xml
+++ b/app/src/main/res/values-ca/strings-icsopenvpn.xml
@@ -1,5 +1,5 @@
 <?xml version="1.0" encoding="utf-8"?>
-<!--Generated by crowdin.net-->
+<!--Generated by crowdin.com-->
 <!-- Generated by crowdin.net -->
 <resources>
 
diff --git a/app/src/main/res/values-de/strings-icsopenvpn.xml b/app/src/main/res/values-de/strings-icsopenvpn.xml
index bf115be50859ef85f19851c4c6302e3a2b566c43..5ece9326066e8ab7f1e097b6311d97ca721e4083 100755
--- a/app/src/main/res/values-de/strings-icsopenvpn.xml
+++ b/app/src/main/res/values-de/strings-icsopenvpn.xml
@@ -1,5 +1,5 @@
 <?xml version="1.0" encoding="utf-8"?>
-<!--Generated by crowdin.net-->
+<!--Generated by crowdin.com-->
 <!-- Generated by crowdin.net -->
 <resources>
 
@@ -156,7 +156,7 @@
   <string name="converted_profile">Importiertes Profil</string>
   <string name="converted_profile_i">Importiertes Profil %d</string>
   <string name="broken_images">Fehlerhafte Images</string>
-  <string name="broken_images_faq">&lt;p&gt;Von offiziellen HTC Firmwares ist bekannt, dass diese teilweise merkwürdige Routing Probleme haben, die dafür sorgen, dass der Verkehr nicht durch den Tunnel fließt. (Siehe auch &lt;a href=\"http://code.google.com/p/ics-openvpn/issues/detail?id=18\"&gt;Issue 18&lt;/a&gt; im Bug Tracker.)&lt;/p&gt;&lt;p&gt;Bei älteren Version der offiziellen SONY Firmwares für das Xperia arc S and Xperia Ray scheint der VPNService Support  komplett zu fehlen. (Siehe auch &lt;a href=\"http://code.google.com/p/ics-openvpn/issues/detail?id=29\"&gt;Issue 29&lt;/a&gt; im Bug Tracker.)&lt;/p&gt;&lt;p&gt;Auf anderen (insbesondere Custom ROMS) fehlt teilweise das tun Kernel Modul oder die Rechte von /dev/tun sind falsch gesetzt. Auf einigen CM9 Firmware wird die \"/dev/tun Eigentümer setzen\" Option in den Allgemeinen Einstellungen benötigt.&lt;/p&gt;&lt;p&gt;Am wichtigsten ist aber, falls Sie eine fehlerhafte Firmware haben, melden Sie dies Ihrem Hersteller. Desto mehr Leute den Fehler dem Hersteller melden desto wahrscheinlicher werden Sie eine Fehlerkorrektur bekommen.&lt;/p&gt;</string>
+  <string name="broken_images_faq">&lt;p&gt;Von offiziellen HTC Firmwares ist bekannt, dass diese teilweise merkwürdige Routing Probleme haben, die dafür sorgen, dass der Verkehr nicht durch den Tunnel fließt. (Siehe auch &lt;a href=\"http://code.google.com/p/ics-openvpn/issues/detail?id=18\"&gt;Issue 18&lt;/a&gt; im Bug Tracker.)&lt;/p&gt;&lt;p&gt;Bei älteren Version der offiziellen SONY Firmwares für das Xperia arc S and Xperia Ray scheint der VPNService Support  komplett zu fehlen. (Siehe auch &lt;a href=\"http://code.google.com/p/ics-openvpn/issues/detail?id=29\"&gt;Issue 29&lt;/a&gt; im Bug Tracker.)&lt;/p&gt;&lt;p&gt;Auf anderen (insbesondere Custom ROMS) fehlt teilweise das tun Kernel Modul oder die Rechte von /dev/tun sind falsch gesetzt. Auf einigen CM9 Firmware wird die \"/dev/tun Eigentümer setzen\" Option in den Allgemeinen Einstellungen benötigt.&lt;/p&gt;&lt;p&gt;Am wichtigsten ist aber, falls Sie eine fehlerhafte Firmware haben, melden Sie dies Ihrem Hersteller. Je mehr Leute den Fehler dem Hersteller melden, desto wahrscheinlicher werden Sie eine Fehlerkorrektur bekommen.&lt;/p&gt;</string>
   <string name="pkcs12_file_encryption_key">PKCS12 Veschlüsslungspassword</string>
   <string name="private_key_password">Passphrase privater Schlüssel</string>
   <string name="password">Passwort</string>
diff --git a/app/src/main/res/values-es/strings-icsopenvpn.xml b/app/src/main/res/values-es/strings-icsopenvpn.xml
index e9b6ed8114277c88d041edb9131796b58cf784f4..399392bfa661dd56185ce86bbecc39db579172b4 100755
--- a/app/src/main/res/values-es/strings-icsopenvpn.xml
+++ b/app/src/main/res/values-es/strings-icsopenvpn.xml
@@ -1,5 +1,5 @@
 <?xml version="1.0" encoding="utf-8"?>
-<!--Generated by crowdin.net-->
+<!--Generated by crowdin.com-->
 <!-- Generated by crowdin.net -->
 <resources>
 
@@ -215,6 +215,7 @@
   <string name="vpn_import_hint">Use el icono &lt;img src=\"ic_menu_archive\"/&gt; para importar un perfil existente (.ovpn or .conf) de tu tarjeta.</string>
   <string name="faq_hint">Asegúrese de checar también las preguntas frecuentes. Hay una guía de inicio rápido.</string>
   <string name="faq_routing_title">Configuración de enrutamiento o interfaz</string>
+  <string name="faq_routing">El enrutamiento y la configuración de la interfaz no se realiza a través de comandos tradicionales ifconfig / ruta, pero mediante el uso de la API VPNService. Esto resulta en una configuración de enrutamiento diferente que en otros sistemas operativos. La configuración del túnel VPN consta de la dirección IP y las redes que deben ser colocados de través de esta interfaz. Se necesita Especialmente hay dirección compañero de estudios o de gateway. Rutas especiales para llegar a la VPN Server (por ejemplo agregan al usar redirect-gateway) no son necesarios, ya sea. La aplicación, en consecuencia ignorará esta configuración al importar una configuración. La aplicación asegura con la API VPNService que la conexión con el servidor no se encamina a través del túnel VPN. Sólo redes especificando ser enrutados a través del túnel es compatible. La aplicación intenta detectar las redes que no deben ser enrutados a través de túnel (por ejemplo, la ruta xxxx aaaa net_gateway) y calcula un conjunto de rutas que excluye este rutas para emular el comportamiento de otras plataformas. Las ventanas de registro muestra la configuración de la VPNService al establecer una conexión.</string>
   <string name="persisttun_summary">No regresar a modo sin conexión VPN cuando OpenVPN esta volviendose a conectar.</string>
   <string name="persistent_tun_title">Tun persistente</string>
   <string name="openvpn_log">Registro de OpenVPN</string>
@@ -314,4 +315,8 @@
   <string name="blocklocal_summary">Las redes conectadas directamente a los interfaces locales no serán enrutadas a través de la VPN. Al desmarcar esta opción, todo el tráfico previsto para las redes locales será redirigido a la VPN.</string>
   <string name="blocklocal_title">Evitar la VPN para las redes locales</string>
   <string name="userpw_file">Archivo de Usuario/Contraseña</string>
+  <string name="imported_from_file">[Importado de:%s]</string>
+  <string name="files_missing_hint">Algunos archivos no se pudo encontrar. Por favor, seleccione los archivos que desea importar el perfil:</string>
+  <string name="openvpn_is_no_free_vpn">Para utilizar esta aplicación usted necesita un proveedor de servicio VPN /  es un apoyo OpenVPN (a menudo proporcionados por su empleador). Echa un vistazo a http://community.openvpn.net/ para más información sobre OpenVPN y cómo configurar su propio servidor OpenVPN.</string>
+  <string name="import_log">Importar registros:</string>
 </resources>
diff --git a/app/src/main/res/values-fr/strings-icsopenvpn.xml b/app/src/main/res/values-fr/strings-icsopenvpn.xml
index 34512801fa58fb27dc347e8864f74ddb22bf0307..a26ce4454e169b6a4784867f8f03aaab4bcb8e3b 100755
--- a/app/src/main/res/values-fr/strings-icsopenvpn.xml
+++ b/app/src/main/res/values-fr/strings-icsopenvpn.xml
@@ -1,5 +1,5 @@
 <?xml version="1.0" encoding="utf-8"?>
-<!--Generated by crowdin.net-->
+<!--Generated by crowdin.com-->
 <!-- Generated by crowdin.net -->
 <resources>
 
@@ -216,6 +216,7 @@ Sur certaines images, cette notification joue un son.\nAndroid à introduit ces
   <string name="vpn_import_hint">"Utilisez l\'icône &lt;img src=\"ic_menu_archive\"/&gt; pour importer un fichier profil (.opvpn ou  .conf) de votre carte SD."</string>
   <string name="faq_hint">"Veillez également à consulter la FAQ. Il s\'y trouve un guide de démarrage rapide."</string>
   <string name="faq_routing_title">"Redirections / Configuration de l\'interface"</string>
+  <string name="faq_routing">The Routing and interface configuration is not done via traditional ifconfig/route commands but by using the VPNService API. This results in a different routing configuration than on other OSes. The configuration for the VPN tunnel consists of the  IP address and the networks that should be routed over this interface. Especially no peer partner address or gateway address is needed. Special routes to reach the VPN Server (for example added when using redirect-gateway) are not needed either. The application will consequently ignore these settings when importing a configuration. The app ensures with the VPNService API that the connection to the server is not routed through the VPN tunnel. Only specifying networks to be routed via tunnel is supported. The app tries to detect networks that should not be routed over tunnel (e.g. route x.x.x.x y.y.y.y net_gateway) and calculates a route set that excludes this routes to emulate the behaviour of other platforms. The log windows shows the configuration of the VPNService upon establishing a connection.</string>
   <string name="persisttun_summary">Ne pas couper la connexion VPN lors de la reconnexion d\'OpenVPN.</string>
   <string name="persistent_tun_title">Persistance de l\'interface TUN</string>
   <string name="openvpn_log">Log OpenVPN</string>
diff --git a/app/src/main/res/values-hu/strings.xml b/app/src/main/res/values-hu/strings.xml
new file mode 100755
index 0000000000000000000000000000000000000000..e362c81a3728ac478206dab4bb5779c1334a18e6
--- /dev/null
+++ b/app/src/main/res/values-hu/strings.xml
@@ -0,0 +1,6 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--Generated by crowdin.net-->
+<!-- Generated by crowdin.net -->
+<resources>
+  <string name="app">OpenVPN Androidhoz</string>
+</resources>
diff --git a/app/src/main/res/values-in/strings.xml b/app/src/main/res/values-in/strings.xml
new file mode 100755
index 0000000000000000000000000000000000000000..715057ae0766359a7a64ca990ff21e84ff749b9a
--- /dev/null
+++ b/app/src/main/res/values-in/strings.xml
@@ -0,0 +1,6 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--Generated by crowdin.net-->
+<!-- Generated by crowdin.net -->
+<resources>
+  <string name="app">OpenVPN untuk Android</string>
+</resources>
diff --git a/app/src/main/res/values-ja/strings-icsopenvpn.xml b/app/src/main/res/values-ja/strings-icsopenvpn.xml
index c96b9b8e718105f0bd5498240670bd2f126159dd..d537e3d8bcbc688b3ae8b8cb5af3e86b983e0319 100755
--- a/app/src/main/res/values-ja/strings-icsopenvpn.xml
+++ b/app/src/main/res/values-ja/strings-icsopenvpn.xml
@@ -1,5 +1,5 @@
 <?xml version="1.0" encoding="utf-8"?>
-<!--Generated by crowdin.net-->
+<!--Generated by crowdin.com-->
 <!-- Generated by crowdin.net -->
 <resources>
 
diff --git a/app/src/main/res/values-pl/strings.xml b/app/src/main/res/values-pl/strings.xml
new file mode 100755
index 0000000000000000000000000000000000000000..aa233bb7ba3c07cd11b0e94fceee07e0a156561d
--- /dev/null
+++ b/app/src/main/res/values-pl/strings.xml
@@ -0,0 +1,6 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--Generated by crowdin.net-->
+<!-- Generated by crowdin.net -->
+<resources>
+  <string name="app">OpenVPN dla Androida</string>
+</resources>
diff --git a/app/src/main/res/values-pt/strings-icsopenvpn.xml b/app/src/main/res/values-pt/strings-icsopenvpn.xml
new file mode 100755
index 0000000000000000000000000000000000000000..30bf569eedaa7e11e28c5a7cad406a603612314a
--- /dev/null
+++ b/app/src/main/res/values-pt/strings-icsopenvpn.xml
@@ -0,0 +1,139 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--Generated by crowdin.com-->
+<!-- Generated by crowdin.net -->
+<resources>
+
+  <string name="address">Endereço do Servidor:</string>
+  <string name="port">Porta:</string>
+  <string name="location">Localização</string>
+  <string name="cant_read_folder">Não foi possível ler o diretório</string>
+  <string name="select">Selecionar</string>
+  <string name="cancel">Cancelar</string>
+  <string name="no_data">Não há dados</string>
+  <string name="useLZO">Compressão LZO</string>
+  <string name="client_no_certificate">Sem Certificado</string>
+  <string name="client_certificate_title">Certificado do Cliente</string>
+  <string name="client_key_title">Chave do Certificado do Cliente</string>
+  <string name="client_pkcs12_title">Arquivo PKCS12</string>
+  <string name="ca_title">Certificado CA</string>
+  <string name="no_certificate">Você deve selecionar um certificado</string>
+  <string name="copyright_guicode">O código fonte e o rastreamento de incidentes estão disponíveis em  http://code.google.com/p/ics-openvpn/</string>
+  <string name="copyright_others">Este programa utiliza os seguintes componentes; veja o código fonte para mais detalhes das licenças</string>
+  <string name="about">Sobre</string>
+  <string name="vpn_list_title">Perfis</string>
+  <string name="vpn_type">Tipo</string>
+  <string name="pkcs12pwquery">Senha do PKCS12</string>
+  <string name="file_select">Selecionar&#8230;</string>
+  <string name="file_nothing_selected">Você deve selecionar um arquivo</string>
+  <string name="useTLSAuth">Utilizar Autenticação TLS</string>
+  <string name="tls_direction">Direção TLS</string>
+  <string name="ipv6_dialog_tile">Entre o Endereço IPv6/CIDR (ex: 2000:dd::23/64)</string>
+  <string name="ipv4_dialog_title">Entre o endereço IPv4/CIDR (ex: 1.2.3.4/24)</string>
+  <string name="ipv4_address">Endereço IPv4</string>
+  <string name="ipv6_address">Endereço IPv6</string>
+  <string name="custom_option_warning">Insira as opções personalizadas para o OpenVPN. Utilize com cuidado. Observe também que muitas das opções relacionadas ao tun do OpenVPN não podem ser suportadas pelo design do VPNSettings. Contate o autor se você acha que uma opção importante está faltando.</string>
+  <string name="auth_username">Usuário</string>
+  <string name="auth_pwquery">Senha</string>
+  <string name="static_keys_info">Para a configuração estática as chaves de autenticação de TLS serão utilizadas como chaves estáticas</string>
+  <string name="configure_the_vpn">Configurar VPN</string>
+  <string name="menu_add_profile">Adicionar Perfil</string>
+  <string name="add_profile_name_prompt">Digite um nome que identifica o novo perfil</string>
+  <string name="duplicate_profile_name">Por favor, digite um nome de perfil único</string>
+  <string name="profilename">Nome do perfil</string>
+  <string name="no_keystore_cert_selected">Você deve selecionar um certificado de usuário</string>
+  <string name="no_error_found">Nenhum erro encontrado</string>
+  <string name="config_error_found">Erro na configuração</string>
+  <string name="ipv4_format_error">Erro ao analisar o endereço IPv4</string>
+  <string name="custom_route_format_error">Erro ao analisar as rotas personalizadas</string>
+  <string name="pw_query_hint">(deixe em branco para consulta sob demanda)</string>
+  <string name="vpn_shortcut">Atalho do OpenVPN</string>
+  <string name="vpn_launch_title">Conectar a VPN</string>
+  <string name="shortcut_profile_notfound">O perfil especificado no atalho não foi encontrado</string>
+  <string name="random_host_prefix">Prefixo de Host aleatório</string>
+  <string name="random_host_summary">Adiciona 6 caracteres aleatórios na frente do hostname</string>
+  <string name="custom_config_title">Habilitar opções personalizadas</string>
+  <string name="custom_config_summary">Opções personalizadas. Use com cuidado!</string>
+  <string name="route_rejected">Rota rejeitada pelo Android</string>
+  <string name="cancel_connection">Desconectar</string>
+  <string name="cancel_connection_long">Desconectar VPN</string>
+  <string name="clear_log">limpar log</string>
+  <string name="title_cancel">Cancelar confirmação</string>
+  <string name="cancel_connection_query">Desconectar a VPN conectada/cancelar a tentativa de conexão?</string>
+  <string name="remove_vpn">Remover VPN</string>
+  <string name="check_remote_tlscert">Verifica se o servidor usa um certificado com as extensões de servidor TLS (- servidor remoto-cert-TLS)</string>
+  <string name="check_remote_tlscert_title">Esperar certificado do servidor TLS</string>
+  <string name="remote_tlscn_check_summary">Verifica o DN Subject do certificado do servidor remoto</string>
+  <string name="remote_tlscn_check_title">Verificar o Hostname do Certificado</string>
+  <string name="enter_tlscn_dialog">Especificar a conta usada para verificar o certificado remoto DN (por exemplo, C = DE, L = Paderborn, UO = aviária operadoras IP, CN=openvpn.blinkt.de)\n\Especificar o DN completo ou o RDN (openvpn.blinkt.de no exemplo) ou um prefixo RDN para verification.\n\nWhen usando o prefixo RDN \"Servidor\" corresponde a \"Server-1\" e \"Server-2\" \n\nDeixando vazio, o  campo de texto irá verificar o RDN contra o servidor hostname.\n\nPara mais detalhes consulte a página principal do 2.3.1+ OpenVPN sob — verificar-X509-nome</string>
+  <string name="enter_tlscn_title">Subject do certificado remoto</string>
+  <string name="tls_key_auth">Permite a Autenticação de Chave TLS</string>
+  <string name="tls_auth_file">Arquivo de Auth TLS</string>
+  <string name="pull_on_summary">Solicitações de endereços de IP, rotas e opções de sincronização do servidor.</string>
+  <string name="pull_off_summary">Nenhuma informação é solicitada do servidor. Configurações precisam ser especificadas abaixo.</string>
+  <string name="use_pull">Obter Configurações</string>
+  <string name="dns">DNS</string>
+  <string name="override_dns">Substituir as configurações de DNS pelo servidor</string>
+  <string name="dns_override_summary">Use seus próprios servidores de DNS</string>
+  <string name="searchdomain">Domínio de pesquisa</string>
+  <string name="dns1_summary">Servidor DNS a ser usado.</string>
+  <string name="dns_server">Servidor DNS</string>
+  <string name="secondary_dns_message">Servidor DNS secundário utilizado caso o servidor primário esteja inacessível.</string>
+  <string name="backup_dns">Servidor DNS alternativo</string>
+  <string name="ignored_pushed_routes">Ignorar rotas empurradas</string>
+  <string name="ignore_routes_summary">Ignorar rota empurrada pelo servidor.</string>
+  <string name="default_route_summary">Redireccionar todo o tráfego pela VPN</string>
+  <string name="use_default_title">Usar rota padrão</string>
+  <string name="custom_route_message">Digite rotas personalizadas. Apenas indique destino em formato CIDR. \"10.0.0.0 / 8 2002 :: / 16\" iria dirigir as redes 10.0.0.0 / 8 e 2002 :: / 16 sobre a VPN.</string>
+  <string name="custom_route_message_excluded">As rotas que não devem ser encaminhados pelo VPN. Use a mesma sintaxe para rotas incluídas.</string>
+  <string name="custom_routes_title">Rotas personalizadas</string>
+  <string name="custom_routes_title_excluded">Redes excluídas</string>
+  <string name="log_verbosity_level">Nível de complexidade do log</string>
+  <string name="float_summary">Permite pacotes autenticados a partir de qualquer IP</string>
+  <string name="float_title">Permitir servidor flutuante</string>
+  <string name="custom_options_title">Opções personalizadas</string>
+  <string name="edit_vpn">Editar configurações de VPN</string>
+  <string name="remove_vpn_query">Remover o perfil VPN \'%s\'?</string>
+  <string name="tun_error_helpful">Em algumas imagens ICS personalizado a permissão em / dev / tun pode estar errada, ou o módulo tun pode estar faltando completamente. Para imagens CM9 tente a opção correção propriedade sobre as configurações gerais</string>
+  <string name="tun_open_error">Falha ao abrir a interface de tun</string>
+  <string name="error">"Erro:"</string>
+  <string name="clear">Claro</string>
+  <string name="last_openvpn_tun_config">Abrindo a interface tun:</string>
+  <string name="local_ip_info">Local IPv4: %1$s/%2$d IPv6:%3$s MTU:%4$d</string>
+  <string name="dns_server_info">Servidor DNS: %1$s, domínio: %2$s</string>
+  <string name="routes_info_incl">Rotas: %1$s %2$s</string>
+  <string name="routes_info_excl">Rotas excluídas: %1$s %2$s</string>
+  <string name="routes_debug">Rotas VpnService  instaladas: %1$s %2$s</string>
+  <string name="ip_not_cidr">Existem múltiplas informações de interface, %1$s e %2$s, a aplicação assume que o segundo endereço é um endereço \'peer\' do endereço remoto. Será usada uma máscara de rede /32 para o IP local. O modo estabelecido pela OpenVPN é \"%3$s\".</string>
+  <string name="route_not_cidr">Não consigo entender %1$s e %2$s como uma rota IP com máscara de rede CIDR, usando /32 como máscara de rede.</string>
+  <string name="route_not_netip">A rota %1$s/%2$s foi corrigida para %3$s/%2$s</string>
+  <string name="keychain_access">Não é possível aceder aos certificados \'Keychain Android\'. Isso pode ter sido causado por uma atualização de firmware ou uma restauração das configurações da app/app. Será necessário editar o perfil VPN e selecionar novamente o certificado nas configurações básicas para recriar a permissão e possibilitar o acesso ao certificado.</string>
+  <string name="version_info">%1$s %2$s</string>
+  <string name="send_logfile">Enviar arquivo de log</string>
+  <string name="send">Enviar</string>
+  <string name="ics_openvpn_log_file">Ficheiro de registo do ICS OpenVPN</string>
+  <string name="copied_entry">Entrada de registo copiada para a área de transferência</string>
+  <string name="tap_mode">Entrada de registo copiada para a área de transferência</string>
+  <string name="faq_tap_mode">A API VPN não permite o modo Tap em dispositivos sem acesso root. Desta forma não é possível oferecer suporte Tap nesta aplicação</string>
+  <string name="tap_faq2">Novamente? Você está brincando? Não, o modo tap não é suportado de maneira nenhuma e enviar mais emails a perguntar se eventualmente será, não irá ajudar.</string>
+  <string name="faq">Perguntas frequentes</string>
+  <string name="encryption">Encriptação</string>
+  <string name="menu_import_short">Importar</string>
+  <string name="import_vpn">Importar</string>
+  <string name="ipv4">IPv4</string>
+  <string name="ipv6">IPv6</string>
+  <string name="password">Senha</string>
+  <string name="generalsettings">Configurações</string>
+  <string name="advanced">Avançado</string>
+  <string name="ignore">Ignorar</string>
+  <string name="restart">Reiniciar</string>
+  <string name="state_connecting">Conectando</string>
+  <string name="state_auth">Autenticando</string>
+  <string name="state_connected">Conectado</string>
+  <string name="add">Add</string>
+  <string name="pauseVPN">Pausa VPN</string>
+  <string name="resumevpn">Retomar VPN</string>
+  <string name="uploaded_data">Upload</string>
+  <string name="downloaded_data">Download</string>
+  <string name="vpn_status">Vpn Status</string>
+  <string name="logview_options">Ver opções</string>
+</resources>
diff --git a/app/src/main/res/values-pt/strings.xml b/app/src/main/res/values-pt/strings.xml
new file mode 100755
index 0000000000000000000000000000000000000000..29eff2ba2220eb48fe332b102332ca38169b4522
--- /dev/null
+++ b/app/src/main/res/values-pt/strings.xml
@@ -0,0 +1,6 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--Generated by crowdin.com-->
+<!-- Generated by crowdin.net -->
+<resources>
+  <string name="app">OpenVPN para Android</string>
+</resources>
diff --git a/app/src/main/res/values-ru/strings-icsopenvpn.xml b/app/src/main/res/values-ru/strings-icsopenvpn.xml
index 999df70bb31086d819514897f509d296e81b0f31..400269ec94cf76b5b8d5f94a872c09c4691e2f98 100755
--- a/app/src/main/res/values-ru/strings-icsopenvpn.xml
+++ b/app/src/main/res/values-ru/strings-icsopenvpn.xml
@@ -1,5 +1,5 @@
 <?xml version="1.0" encoding="utf-8"?>
-<!--Generated by crowdin.net-->
+<!--Generated by crowdin.com-->
 <!-- Generated by crowdin.net -->
 <resources>
 
@@ -215,6 +215,7 @@
   <string name="vpn_import_hint">Используйте &lt;img src=\"ic_menu_archive\"/&gt; кнопку для импорта существующих профилей (.ovpn or .conf) с вашей карты памяти.</string>
   <string name="faq_hint">Не забудьте заглянуть в FAQ. Также имеется краткое руководство.</string>
   <string name="faq_routing_title">Конфигурация маршрутизации/интерфейса</string>
+  <string name="faq_routing">Конфигурация маршрутизации и интерфейса производится не через традиционные ifconfig/route команды, а с помощью VPNService API. Это приводит к созданию другой конфигурации маршрутизации, отличной от конфигураций, используемых на других ОС. Конфигурация VPN-туннеля состоит из IP-адресов и сетей, которые должны направляться через этот интерфейс. Никаких особых партнерских адресов или адресов шлюза не требуется. Также не требуются и специальные маршруты для соединения с VPN-сервером (например, добавленные при использовании redirect-gateway). Следовательно, приложение будет игнорировать эти параметры при импорте конфигурации. Приложение с помощью VPNService API гарантирует, что подключение к серверу не направляется через VPN-туннель. Поддерживается направление через туннель только определенных сетей. Приложение пытается определить сети, которые не должны быть направлены через туннель (например, маршрут x.x.x.x y.y.y.y net_gateway) и вычисляет список маршрутов, в который не включаются эти маршруты, чтобы эмулировать поведение других платформ. Окна журналов и логов показывают конфигурацию сервиса VPN после установления соединения.</string>
   <string name="persisttun_summary">Не открывать диалог, когда происходит переподключение VPN.</string>
   <string name="persistent_tun_title">Постоянный tun</string>
   <string name="openvpn_log">OpenVPN Журнал</string>
@@ -291,6 +292,8 @@
   <string name="vpnbehaviour">Поведение VPN</string>
   <string name="allow_vpn_changes">Разрешить изменение VPN-профилей</string>
   <string name="hwkeychain">Аппаратное хранилище ключей:</string>
+  <string name="permission_icon_app">Иконка приложения пытается использовать OpenVPN для Android</string>
+  <string name="faq_vpndialog43">«Начиная с Android 4.3, диалог подтверждения VPN-соединения защищен от приложений, \"накладывающихся поверх экрана». Это приводит к тому, что диалоговое окно подтверждения не реагирует на сенсорные нажатия. Если у вас имеется приложение, использующее наложения, то это может вызвать такое поведение. Если вы обнаружите где-либо такое приложение, свяжитесь с автором приложения. Эта проблема затрагивает все VPN приложения на Android 4.3 и более поздних версиях. Смотрите также &lt; a href = \"http://code.google.com/p/ics-openvpn/issues/detail?id=185\" &gt; Проблему 185 &lt; &gt; для получения дополнительных сведений»</string>
   <string name="faq_vpndialog43_title">Окно подтверждения VPN для Android 4.3 и позже</string>
   <string name="donatePlayStore">Также Вы можете выразить благодарность в виде пожертвования на Play Store:</string>
   <string name="thanks_for_donation">Спасибо за пожертвование %s!</string>
@@ -308,8 +311,10 @@
   <string name="unhandled_exception">Неопознання ошибка: %1$s\n\n%2$s</string>
   <string name="unhandled_exception_context">%3$s: %1$s\n\n%2$s</string>
   <string name="faq_system_dialog_xposed">Если на Вашем устройстве установлены Рут права, Вы можете установить &lt;a href=\"http://xposed.info/\"&gt;Xposed framework&lt;/a&gt; и &lt;a href=\"http://repo.xposed.info/module/de.blinkt.vpndialogxposed\"&gt;модуль автоматического подтверждения диалога подключения VPN&lt;/a&gt; на свой страх и риск</string>
+  <string name="full_licenses">Полные тексты лицензий</string>
   <string name="blocklocal_summary">Сети напрямую доступные через локальный интерфейс не будут маршрутизированы через VPN. Отключите эту опцию чтобы направить трафик через VPN.</string>
   <string name="blocklocal_title">Не использовать VPN для локальных адресов</string>
+  <string name="userpw_file">Файл логина и пароля</string>
   <string name="imported_from_file">[Импортировано из: %s]</string>
   <string name="files_missing_hint">Некоторые файлы не найдены. Выберите файлы для импорта в профиль:</string>
   <string name="openvpn_is_no_free_vpn">Для использования данного приложения Вам необходим VPN провайдер/шлюз поддерживающий OpenVPN. Для получения информации по настройке собственного OpenVPN сервера: http://community.openvpn.net/</string>
diff --git a/app/src/main/res/values-sv/strings.xml b/app/src/main/res/values-sv/strings.xml
new file mode 100755
index 0000000000000000000000000000000000000000..9e2326bfc06ab5ef9cb0c9d505f6421736df6393
--- /dev/null
+++ b/app/src/main/res/values-sv/strings.xml
@@ -0,0 +1,6 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--Generated by crowdin.net-->
+<!-- Generated by crowdin.net -->
+<resources>
+  <string name="app">OpenVPN för Android</string>
+</resources>
diff --git a/app/src/main/res/values-tr/strings.xml b/app/src/main/res/values-tr/strings.xml
new file mode 100755
index 0000000000000000000000000000000000000000..1ab863d12396ae1595201e7145f06edbffb8f820
--- /dev/null
+++ b/app/src/main/res/values-tr/strings.xml
@@ -0,0 +1,6 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--Generated by crowdin.net-->
+<!-- Generated by crowdin.net -->
+<resources>
+  <string name="app">Android için OpenVPN</string>
+</resources>
diff --git a/app/src/main/res/values/strings-icsopenvpn.xml b/app/src/main/res/values/strings-icsopenvpn.xml
index 40698afa2b9a8c53161412780f63ef7b4bd51538..aadbff3243b5dde53b9621281fdfa18594a60bfe 100755
--- a/app/src/main/res/values/strings-icsopenvpn.xml
+++ b/app/src/main/res/values/strings-icsopenvpn.xml
@@ -254,7 +254,7 @@
     <string name="start_vpn_ticker">Connecting to VPN %s</string>
     <string name="jelly_keystore_alphanumeric_bug">Some versions of Android 4.1 have problems if the name of the keystore certificate contains non alphanumeric characters (like spaces, underscores or dashes). Try to reimport the certificate without special characters</string>
     <string name="encryption_cipher">Encryption cipher</string>
-    <string name="packet_auth">Packets authentication</string>
+    <string name="packet_auth">Packet authentication</string>
     <string name="auth_dialog_title">Enter packet authentication method</string>
     <string name="mobile_info_extended">Running on %1$s (%2$s) %3$s, Android API %4$d, version %5$s, %6$s</string>
     <string name="built_by">built by %s</string>
@@ -319,4 +319,9 @@
     <string name="openvpn_is_no_free_vpn">To use this app you need a VPN provider/VPN gateway supporting OpenVPN (often provided by your employer). Check out http://community.openvpn.net/ for more information on OpenVPN and how to setup your own OpenVPN server.</string>
     <string name="import_log">Import log:</string>
     <string name="ip_looks_like_subnet">Vpn topology \"%3$s\" specified but ifconfig %1$s %2$s looks more like an IP address with a network mask. Assuming \"subnet\" topology.</string>
+    <string name="mssfix_invalid_value">mssfix value has to be a integer between 0 and 9000</string>
+    <string name="mssfix_value_dialog">Announce to TCP sessions running over the tunnel that they should limit their send packet sizes such that after OpenVPN has encapsulated them, the resulting UDP packet size that OpenVPN sends to its peer will not exceed this number of bytes. (default is 1450)</string>
+    <string name="mssfix_checkbox">Override MSS value of TCP payload</string>
+    <string name="mssfix_dialogtitle">Set MSS of TCP payload</string>
+
 </resources>
diff --git a/app/src/main/res/values/untranslatable.xml b/app/src/main/res/values/untranslatable.xml
index 90090c527c5462bffb577d8517ed2a093350b5a9..b45d5ae7d1fe450f922fbac86d4f4885ff61aac3 100644
--- a/app/src/main/res/values/untranslatable.xml
+++ b/app/src/main/res/values/untranslatable.xml
@@ -1290,6 +1290,1145 @@
 
 
 
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+    <string name="crash_toast_text">OpenVPN for Android crashed, crash reported</string>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
 
 
 
diff --git a/app/src/ovpn3/java/de/blinkt/openvpn/core/OpenVPNThreadv3.java b/app/src/ovpn3/java/de/blinkt/openvpn/core/OpenVPNThreadv3.java
index 6d3dce691d32ff8c515d8a952b51fb56afb4276e..e595106c089031037f828dba3a600067331cfff2 100644
--- a/app/src/ovpn3/java/de/blinkt/openvpn/core/OpenVPNThreadv3.java
+++ b/app/src/ovpn3/java/de/blinkt/openvpn/core/OpenVPNThreadv3.java
@@ -14,9 +14,7 @@ import net.openvpn.ovpn3.ClientAPI_TransportStats;
 import java.lang.Override;
 
 import de.blinkt.openvpn.VpnProfile;
-import de.blinkt.openvpn.core.OpenVPNManagement;
-import de.blinkt.openvpn.core.OpenVpnService;
-import de.blinkt.openvpn.core.VpnStatus;
+
 import android.content.Context;
 
 public class OpenVPNThreadv3 extends ClientAPI_OpenVPNClient implements Runnable, OpenVPNManagement {
@@ -29,7 +27,7 @@ public class OpenVPNThreadv3 extends ClientAPI_OpenVPNClient implements Runnable
 	}
 
 	private VpnProfile mVp;
-	private OpenVpnService mService;
+	private OpenVPNService mService;
 
 	class StatusPoller implements  Runnable 
 	{
@@ -224,7 +222,7 @@ public class OpenVPNThreadv3 extends ClientAPI_OpenVPNClient implements Runnable
 
 	}
 
-	public OpenVPNThreadv3(OpenVpnService openVpnService, VpnProfile vp) {
+	public OpenVPNThreadv3(OpenVPNService openVpnService, VpnProfile vp) {
 		init_process();
 		mVp =vp;
 		mService =openVpnService;
diff --git a/build.gradle b/build.gradle
index 1a4f693224dd9b3587fe64712583bb8e5d9caaf3..6888c76449479226fb2f8e51d5c06a18c00c6a41 100644
--- a/build.gradle
+++ b/build.gradle
@@ -1,4 +1,3 @@
-import au.com.coherentsoftware.gradle.mercurial.task.*
 import org.apache.tools.ant.filters.ReplaceTokens
 
 buildscript {
@@ -8,7 +7,7 @@ buildscript {
   }
   dependencies {
     classpath 'com.android.tools.build:gradle:0.11.+'
-    classpath 'au.com.coherentsoftware.gradle:Gradle-MercurialMqPlugin:1.1.0+'
+    classpath 'org.ajoberstar:gradle-git:0.10+'
   }
 }
 
@@ -16,29 +15,4 @@ allprojects {
   repositories {
     mavenCentral()
   }
-}
-
-apply plugin: 'mercurial-mq'
-
-// task checkoutIcsOpenvpn( type: GitCheckout ) {
-//   branch = 'ics-openvpn-upstream'
-// }
-
-// task cloneIcsOpenVPN( type: HgClone ) {
-//   ext.srcFile = file('build.gradle')
-//   ext.destDir = new File('.', 'ics-openvpn')
-//   inputs.file srcFile
-//   outputs.dir destDir
-     
-//   sourceUrl = 'https://code.google.com/p/ics-openvpn/'
-// }
-
-// task updateIcsOpenVPN( type: HgUpdate, dependsOn: 'pullIcsOpenVPN' ) {
-//   workingDir = 'ics-openvpn'
-//   branch = 'default'
-// }
-
-// task pullIcsOpenVPN( type: HgPull ) {
-//   sourceUrl = 'https://code.google.com/p/ics-openvpn/'
-//   workingDir = 'ics-openvpn'
-// }
\ No newline at end of file
+}
\ No newline at end of file
diff --git a/ics-openvpn-stripped/main/src/main/java/de/blinkt/openvpn/LaunchVPN.java b/ics-openvpn-stripped/main/src/main/java/de/blinkt/openvpn/LaunchVPN.java
index 218dd0008350eceb991daf531e5e5c6519261204..8c899efc1750dff59cf17c694f338a3f7b715e9e 100644
--- a/ics-openvpn-stripped/main/src/main/java/de/blinkt/openvpn/LaunchVPN.java
+++ b/ics-openvpn-stripped/main/src/main/java/de/blinkt/openvpn/LaunchVPN.java
@@ -111,6 +111,7 @@ public class LaunchVPN extends Activity {
 		}
 	}
 
+
 	@Override
 	protected void onActivityResult (int requestCode, int resultCode, Intent data) {
 		super.onActivityResult(requestCode, resultCode, data);
diff --git a/ics-openvpn-stripped/main/src/main/java/de/blinkt/openvpn/VpnProfile.java b/ics-openvpn-stripped/main/src/main/java/de/blinkt/openvpn/VpnProfile.java
index e2ebfd42c32218821f64370f4d0158a3d9e359e5..25823442152fdaf8f637057708b141580eaf12ea 100644
--- a/ics-openvpn-stripped/main/src/main/java/de/blinkt/openvpn/VpnProfile.java
+++ b/ics-openvpn-stripped/main/src/main/java/de/blinkt/openvpn/VpnProfile.java
@@ -45,7 +45,7 @@ import javax.crypto.IllegalBlockSizeException;
 import javax.crypto.NoSuchPaddingException;
 
 import de.blinkt.openvpn.core.NativeUtils;
-import de.blinkt.openvpn.core.OpenVpnService;
+import de.blinkt.openvpn.core.OpenVPNService;
 import de.blinkt.openvpn.core.VpnStatus;
 import de.blinkt.openvpn.core.X509Utils;
 
@@ -67,6 +67,7 @@ public class VpnProfile implements Serializable {
     private static final String OVPNCONFIGFILE = "android.conf";
     public static final int MAXLOGLEVEL = 4;
     public static final int CURRENT_PROFILE_VERSION = 2;
+    public static final int DEFAULT_MSSFIX_SIZE = 1450;
     public static String DEFAULT_DNS1 = "8.8.8.8";
     public static String DEFAULT_DNS2 = "8.8.4.4";
 
@@ -145,6 +146,9 @@ public class VpnProfile implements Serializable {
     private int mProfileVersion;
     public String mExcludedRoutes;
     public String mExcludedRoutesv6;
+    public int mMssFix =0; // -1 is default,
+
+
 
     public VpnProfile(String name) {
         mUuid = UUID.randomUUID();
@@ -184,6 +188,7 @@ public class VpnProfile implements Serializable {
         mCheckRemoteCN = false;
         mPersistTun = false;
         mAllowLocalLAN = true;
+        mMssFix = 0;
     }
 
     public UUID getUUID() {
@@ -387,6 +392,13 @@ public class VpnProfile implements Serializable {
 
         }
 
+        if (mMssFix !=0){
+            if (mMssFix!=1450)
+                cfg+=String.format("mssfix %d\n", mMssFix, Locale.US);
+            else
+                cfg+="mssfix\n";
+        }
+
         if (mNobind)
             cfg += "nobind\n";
 
@@ -568,7 +580,7 @@ public class VpnProfile implements Serializable {
     public Intent prepareIntent(Context context) {
         String prefix = context.getPackageName();
 
-        Intent intent = new Intent(context, OpenVpnService.class);
+        Intent intent = new Intent(context, OpenVPNService.class);
 
         if (mAuthenticationType == VpnProfile.TYPE_KEYSTORE || mAuthenticationType == VpnProfile.TYPE_USERPASS_KEYSTORE) {
             if (getKeyStoreCertificates(context) == null)
diff --git a/ics-openvpn-stripped/main/src/main/java/de/blinkt/openvpn/activities/DisconnectVPN.java b/ics-openvpn-stripped/main/src/main/java/de/blinkt/openvpn/activities/DisconnectVPN.java
index 8e418053e0d51d5a54b1ca32e8bcb79acd4488e8..5910173a2e20d42d43789f881dfc71c85cfecdc2 100644
--- a/ics-openvpn-stripped/main/src/main/java/de/blinkt/openvpn/activities/DisconnectVPN.java
+++ b/ics-openvpn-stripped/main/src/main/java/de/blinkt/openvpn/activities/DisconnectVPN.java
@@ -6,14 +6,14 @@ import android.content.*;
 import android.os.IBinder;
 
 import se.leap.bitmaskclient.R;
-import de.blinkt.openvpn.core.OpenVpnService;
+import de.blinkt.openvpn.core.OpenVPNService;
 import de.blinkt.openvpn.core.ProfileManager;
 
 /**
  * Created by arne on 13.10.13.
  */
 public class DisconnectVPN extends Activity implements DialogInterface.OnClickListener{
-    protected OpenVpnService mService;
+    protected OpenVPNService mService;
 
     private ServiceConnection mConnection = new ServiceConnection() {
 
@@ -22,7 +22,7 @@ public class DisconnectVPN extends Activity implements DialogInterface.OnClickLi
         public void onServiceConnected(ComponentName className,
                                        IBinder service) {
             // We've bound to LocalService, cast the IBinder and get LocalService instance
-            OpenVpnService.LocalBinder binder = (OpenVpnService.LocalBinder) service;
+            OpenVPNService.LocalBinder binder = (OpenVPNService.LocalBinder) service;
             mService = binder.getService();
         }
 
@@ -36,8 +36,8 @@ public class DisconnectVPN extends Activity implements DialogInterface.OnClickLi
     @Override
     protected void onResume() {
         super.onResume();
-        Intent intent = new Intent(this, OpenVpnService.class);
-        intent.setAction(OpenVpnService.START_SERVICE);
+        Intent intent = new Intent(this, OpenVPNService.class);
+        intent.setAction(OpenVPNService.START_SERVICE);
         bindService(intent, mConnection, Context.BIND_AUTO_CREATE);
         showDisconnectDialog();
     }
diff --git a/ics-openvpn-stripped/main/src/main/java/de/blinkt/openvpn/core/ConfigParser.java b/ics-openvpn-stripped/main/src/main/java/de/blinkt/openvpn/core/ConfigParser.java
index d23b521fe3c1628437ac9cee2a405e28d738f509..9c3621e017af962427104083ae8a15a5f01d8a20 100644
--- a/ics-openvpn-stripped/main/src/main/java/de/blinkt/openvpn/core/ConfigParser.java
+++ b/ics-openvpn-stripped/main/src/main/java/de/blinkt/openvpn/core/ConfigParser.java
@@ -432,6 +432,19 @@ public class ConfigParser {
             throw new ConfigParseError("Sorry. Only tun mode is supported. See the FAQ for more detail");
 		}
 
+        Vector<String> mssfix = getOption("mssfix",0,1);
+
+        if (mssfix!=null) {
+            if (mssfix.size()>=2) {
+                try {
+                    np.mMssFix=Integer.parseInt(mssfix.get(1));
+                } catch(NumberFormatException e) {
+                    throw new ConfigParseError("Argument to --mssfix has to be an integer");
+                }
+            } else {
+                np.mMssFix = VpnProfile.DEFAULT_MSSFIX_SIZE;
+            }
+        }
 
 
 		Vector<String> mode =getOption("mode",1,1);
diff --git a/ics-openvpn-stripped/main/src/main/java/de/blinkt/openvpn/core/DeviceStateReceiver.java b/ics-openvpn-stripped/main/src/main/java/de/blinkt/openvpn/core/DeviceStateReceiver.java
index 18c5f1d9414234ffd9882f5e812f3c6b0c4697f7..0126d08eec54ef004c32c585e8fbdfad36b640e7 100644
--- a/ics-openvpn-stripped/main/src/main/java/de/blinkt/openvpn/core/DeviceStateReceiver.java
+++ b/ics-openvpn-stripped/main/src/main/java/de/blinkt/openvpn/core/DeviceStateReceiver.java
@@ -68,7 +68,7 @@ public class DeviceStateReceiver extends BroadcastReceiver implements ByteCountL
         if (windowtraffic < TRAFFIC_LIMIT) {
             screen = connectState.DISCONNECTED;
             VpnStatus.logInfo(R.string.screenoff_pause,
-                    OpenVpnService.humanReadableByteCount(TRAFFIC_LIMIT, false), TRAFFIC_WINDOW);
+                    OpenVPNService.humanReadableByteCount(TRAFFIC_LIMIT, false), TRAFFIC_WINDOW);
 
             mManagement.pause(getPauseReason());
         }
diff --git a/ics-openvpn-stripped/main/src/main/java/de/blinkt/openvpn/core/ICSOpenVPNApplication.java b/ics-openvpn-stripped/main/src/main/java/de/blinkt/openvpn/core/ICSOpenVPNApplication.java
index 1daa34332317102bae0a2f02ff03e090b0b60b48..485e536945af5032b43c5d95ef9d9ef88a4e61a9 100644
--- a/ics-openvpn-stripped/main/src/main/java/de/blinkt/openvpn/core/ICSOpenVPNApplication.java
+++ b/ics-openvpn-stripped/main/src/main/java/de/blinkt/openvpn/core/ICSOpenVPNApplication.java
@@ -1,14 +1,37 @@
 package de.blinkt.openvpn.core;
-
 import android.app.Application;
 
-/**
- * Created by arne on 28.12.13.
- */
+/*
+import org.acra.ACRA;
+import org.acra.ReportingInteractionMode;
+import org.acra.annotation.ReportsCrashes;
+*/
+
+import se.leap.bitmaskclient.BuildConfig;
+import se.leap.bitmaskclient.R;
+import de.blinkt.openvpn.core.PRNGFixes;
+
+/*
+@ReportsCrashes(
+        formKey = "",
+        formUri = "http://reports.blinkt.de/report-icsopenvpn",
+        reportType = org.acra.sender.HttpSender.Type.JSON,
+        httpMethod = org.acra.sender.HttpSender.Method.PUT,
+        formUriBasicAuthLogin="report-icsopenvpn",
+        formUriBasicAuthPassword="Tohd4neiF9Ai!!!!111eleven",
+        mode = ReportingInteractionMode.TOAST,
+        resToastText = R.string.crash_toast_text
+)
+*/
 public class ICSOpenVPNApplication extends Application {
     @Override
     public void onCreate() {
         super.onCreate();
         PRNGFixes.apply();
+
+        if (BuildConfig.DEBUG) {
+            //ACRA.init(this);
+        }
     }
+
 }
diff --git a/ics-openvpn-stripped/main/src/main/java/de/blinkt/openvpn/core/NetworkSpace.java b/ics-openvpn-stripped/main/src/main/java/de/blinkt/openvpn/core/NetworkSpace.java
index 81a17ef960f8d5a0c93cb88b717f2a8a2a05dbe9..8c6cb1f53d8771ddbc4faf3f05fa8a9790c1f501 100644
--- a/ics-openvpn-stripped/main/src/main/java/de/blinkt/openvpn/core/NetworkSpace.java
+++ b/ics-openvpn-stripped/main/src/main/java/de/blinkt/openvpn/core/NetworkSpace.java
@@ -76,8 +76,8 @@ public class NetworkSpace {
 
             netAddress = BigInteger.ZERO;
             for (byte b : address.getAddress()) {
-                s -= 16;
-                netAddress = netAddress.add(BigInteger.valueOf(b).shiftLeft(s));
+                s -= 8;
+                netAddress = netAddress.add(BigInteger.valueOf((b & 0xFF)).shiftLeft(s));
             }
         }
 
@@ -152,12 +152,12 @@ public class NetworkSpace {
         String getIPv6Address() {
             if (BuildConfig.DEBUG) Assert.assertTrue (!isV4);
             BigInteger r = netAddress;
-            if (r.longValue() == 0)
+            if (r.compareTo(BigInteger.ZERO)==0 && networkMask==0)
                 return "::";
 
             Vector<String> parts = new Vector<String>();
             while (r.compareTo(BigInteger.ZERO) == 1) {
-                parts.add(0, String.format(Locale.US, "%x", r.mod(BigInteger.valueOf(256)).longValue()));
+                parts.add(0, String.format(Locale.US, "%x", r.mod(BigInteger.valueOf(0x10000)).longValue()));
                 r = r.shiftRight(16);
             }
 
diff --git a/ics-openvpn-stripped/main/src/main/java/de/blinkt/openvpn/core/OpenVpnService.java b/ics-openvpn-stripped/main/src/main/java/de/blinkt/openvpn/core/OpenVPNService.java
similarity index 91%
rename from ics-openvpn-stripped/main/src/main/java/de/blinkt/openvpn/core/OpenVpnService.java
rename to ics-openvpn-stripped/main/src/main/java/de/blinkt/openvpn/core/OpenVPNService.java
index 0cf93de35bb3e96d014b0fe1652beb702663f023..743e7cc535aae708b4831a7842c20ad4a564e77e 100644
--- a/ics-openvpn-stripped/main/src/main/java/de/blinkt/openvpn/core/OpenVpnService.java
+++ b/ics-openvpn-stripped/main/src/main/java/de/blinkt/openvpn/core/OpenVPNService.java
@@ -40,14 +40,14 @@ import de.blinkt.openvpn.core.VpnStatus.StateListener;
 
 import static de.blinkt.openvpn.core.NetworkSpace.ipAddress;
 import static de.blinkt.openvpn.core.VpnStatus.ConnectionStatus.LEVEL_CONNECTED;
-import static de.blinkt.openvpn.core.VpnStatus.ConnectionStatus.LEVEL_CONNECTING_SERVER_REPLIED;
 import static de.blinkt.openvpn.core.VpnStatus.ConnectionStatus.LEVEL_NONETWORK;
+import static de.blinkt.openvpn.core.VpnStatus.ConnectionStatus.LEVEL_NOTCONNECTED;
 import static de.blinkt.openvpn.core.VpnStatus.ConnectionStatus.LEVEL_CONNECTING_NO_SERVER_REPLY_YET;
 import static de.blinkt.openvpn.core.VpnStatus.ConnectionStatus.LEVEL_WAITING_FOR_USER_INPUT;
-
 import se.leap.bitmaskclient.Dashboard;
 
-public class OpenVpnService extends VpnService implements StateListener, Callback, ByteCountListener {
+public class OpenVPNService extends VpnService implements StateListener, Callback, ByteCountListener {
+
     public static final String START_SERVICE = "de.blinkt.openvpn.START_SERVICE";
     public static final String START_SERVICE_STICKY = "de.blinkt.openvpn.START_SERVICE_STICKY";
     public static final String ALWAYS_SHOW_NOTIFICATION = "de.blinkt.openvpn.NOTIFICATION_ALWAYS_VISIBLE";
@@ -74,7 +74,7 @@ public class OpenVpnService extends VpnService implements StateListener, Callbac
     private OpenVPNManagement mManagement;
     private String mLastTunCfg;
     private String mRemoteGW;
-    private Object mProcessLock = new Object();
+    private final Object mProcessLock = new Object();
 
     // From: http://stackoverflow.com/questions/3758606/how-to-convert-byte-size-into-human-readable-format-in-java
     public static String humanReadableByteCount(long bytes, boolean mbit) {
@@ -116,6 +116,7 @@ public class OpenVpnService extends VpnService implements StateListener, Callbac
         synchronized (mProcessLock) {
             mProcessThread = null;
         }
+	mConnecttime = 0;
         VpnStatus.removeByteCountListener(this);
         unregisterDeviceStateReceiver();
         ProfileManager.setConntectedVpnProfileDisconnected(this);
@@ -166,7 +167,7 @@ public class OpenVpnService extends VpnService implements StateListener, Callbac
 
 
         mNotificationManager.notify(OPENVPN_STATUS, notification);
-        // startForeground(OPENVPN_STATUS, notification);
+        //startForeground(OPENVPN_STATUS, notification);
     }
 
     private int getIconByConnectionStatus(ConnectionStatus level) {
@@ -212,7 +213,7 @@ public class OpenVpnService extends VpnService implements StateListener, Callbac
             nbuilder.addAction(android.R.drawable.ic_menu_close_clear_cancel,
                     getString(R.string.cancel_connection), disconnectPendingIntent);
 
-            Intent pauseVPN = new Intent(this, OpenVpnService.class);
+            Intent pauseVPN = new Intent(this, OpenVPNService.class);
             if (mDeviceStateReceiver == null || !mDeviceStateReceiver.isUserPaused()) {
                 pauseVPN.setAction(PAUSE_VPN);
                 PendingIntent pauseVPNPending = PendingIntent.getService(this, 0, pauseVPN, 0);
@@ -308,23 +309,32 @@ public class OpenVpnService extends VpnService implements StateListener, Callbac
             return START_REDELIVER_INTENT;
         }
 
-        if (intent == null)
-            return START_NOT_STICKY;
-
+	String UUID = "UUID";
+        if (intent == null) {
+	    SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this);
+	    android.util.Log.d("bitmaskclient", "UUID is " + prefs.getString(UUID, ""));
+	    mProfile = ProfileManager.get(this, prefs.getString(UUID, ""));
+	    android.util.Log.d("bitmaskclient", "mProfile is null? " + (mProfile == null));
+	    if(mProfile != null)
+		intent = mProfile.prepareIntent(getBaseContext());
+	    else
+                return START_NOT_STICKY;
+	}
+	if(mProfile != null)
+	    android.util.Log.d("bitmaskclient", "mProfile != null");
         // Extract information from the intent.
         String prefix = getPackageName();
         String[] argv = intent.getStringArrayExtra(prefix + ".ARGV");
         String nativelibdir = intent.getStringExtra(prefix + ".nativelib");
-        String profileUUID = intent.getStringExtra(prefix + ".profileUUID");
+        String profileUUID = intent.getStringExtra(prefix + ".profileUUID");	
 
         mProfile = ProfileManager.get(this, profileUUID);
 
-
         String startTitle = getString(R.string.start_vpn_title, mProfile.mName);
         String startTicker = getString(R.string.start_vpn_ticker, mProfile.mName);
         showNotification(startTitle, startTicker,
                 false, 0, LEVEL_CONNECTING_NO_SERVER_REPLY_YET);
-	
+
         // Set a flag that we are starting a new VPN
         mStarting = true;
         // Stop the previous session by interrupting the thread.
@@ -351,12 +361,13 @@ public class OpenVpnService extends VpnService implements StateListener, Callbac
 
         // Start a new session by creating a new thread.
         SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this);
-
+	
         mOvpn3 = prefs.getBoolean("ovpn3", false);
         if (!"ovpn3".equals(BuildConfig.FLAVOR))
             mOvpn3 = false;
 
 
+	prefs.edit().putString(UUID, profileUUID).commit();
         // Open the Management Interface
         if (!mOvpn3) {
 
@@ -399,13 +410,16 @@ public class OpenVpnService extends VpnService implements StateListener, Callbac
 
         ProfileManager.setConnectedVpnProfile(this, mProfile);
 
-        return START_NOT_STICKY;
+        if (mProfile.mPersistTun)
+            return START_STICKY;
+	else
+	    return START_NOT_STICKY;
     }
 
     private OpenVPNManagement instantiateOpenVPN3Core() {
         try {
             Class cl = Class.forName("de.blinkt.openvpn.core.OpenVPNThreadv3");
-            return (OpenVPNManagement) cl.getConstructor(OpenVpnService.class,VpnProfile.class).newInstance(this,mProfile);
+            return (OpenVPNManagement) cl.getConstructor(OpenVPNService.class,VpnProfile.class).newInstance(this,mProfile);
         } catch (IllegalArgumentException e) {
             e.printStackTrace();
         } catch (InstantiationException e) {
@@ -499,8 +513,15 @@ public class OpenVpnService extends VpnService implements StateListener, Callbac
             }
         }
 
-
-        builder.setMtu(mMtu);
+        String release = Build.VERSION.RELEASE;
+        if ((Build.VERSION.SDK_INT == Build.VERSION_CODES.KITKAT && !release.startsWith("4.4.3")
+                &&  !release.startsWith("4.4.4") &&  !release.startsWith("4.4.5") && !release.startsWith("4.4.6"))
+                && mMtu < 1280) {
+            VpnStatus.logInfo(String.format("Forcing MTU to 1280 instead of %d to workaround Android Bug #70916", mMtu));
+            builder.setMtu(1280);
+        } else {
+            builder.setMtu(mMtu);
+        }
 
         Collection<ipAddress> positiveIPv4Routes = mRoutes.getPositiveIPList();
         Collection<ipAddress> positiveIPv6Routes = mRoutesv6.getPositiveIPList();
@@ -702,23 +723,32 @@ public class OpenVpnService extends VpnService implements StateListener, Callbac
                 mDisplayBytecount = true;
                 mConnecttime = System.currentTimeMillis();
                 lowpriority = true;
-		NotificationManager mNotificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
-		mNotificationManager.cancel(OPENVPN_STATUS);
-            } else if(!mProfile.mPersistTun || mConnecttime == 0){
-                mDisplayBytecount = false;
-		String msg = getString(resid);
-		String ticker = msg;
-		showNotification(msg + " " + logmessage, ticker, lowpriority , 0, level);
-            } else if(mProfile.mPersistTun && level == LEVEL_NONETWORK) {
-		NotificationManager mNotificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
-		mNotificationManager.cancel(OPENVPN_STATUS);
-	    } else if(mProfile.mPersistTun && mConnecttime > 0) {
+		if(mProfile.mPersistTun) {
+		    NotificationManager ns = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
+		    ns.cancel(OPENVPN_STATUS);
+		    return;
+		}
+	    } else if (level == LEVEL_NONETWORK || level == LEVEL_NOTCONNECTED) {
+		NotificationManager ns = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
+		ns.cancel(OPENVPN_STATUS);
+		return;
+	    } else if (level != LEVEL_NOTCONNECTED && mConnecttime > 0) {
                 mDisplayBytecount = false;
 		String msg = "Traffic is blocked until the VPN becomes active.";
-		String ticker = msg;		
+		String ticker = msg;
 		showNotification(msg, ticker, lowpriority , 0, level);
-	    }
+		return;
+	    } else {
+                mDisplayBytecount = false;
+            }
 
+            // Other notifications are shown,
+            // This also mean we are no longer connected, ignore bytecount messages until next
+            // CONNECTED
+            // Does not work :(
+            String msg = getString(resid);
+            String ticker = msg;
+            showNotification(msg + " " + logmessage, ticker, lowpriority , 0, level);
         }
     }
 
@@ -738,6 +768,9 @@ public class OpenVpnService extends VpnService implements StateListener, Callbac
                     humanReadableByteCount(diffIn / OpenVPNManagement.mBytecountInterval, true),
                     humanReadableByteCount(out, false),
                     humanReadableByteCount(diffOut / OpenVPNManagement.mBytecountInterval, true));
+
+            boolean lowpriority = !mNotificationAlwaysVisible;
+            //showNotification(netstat, null, lowpriority, mConnecttime, LEVEL_CONNECTED);
         }
 
     }
@@ -773,9 +806,9 @@ public class OpenVpnService extends VpnService implements StateListener, Callbac
     }
 
     public class LocalBinder extends Binder {
-        public OpenVpnService getService() {
+        public OpenVPNService getService() {
             // Return this instance of LocalService so clients can call public methods
-            return OpenVpnService.this;
+            return OpenVPNService.this;
         }
     }
 }
diff --git a/ics-openvpn-stripped/main/src/main/java/de/blinkt/openvpn/core/OpenVPNThread.java b/ics-openvpn-stripped/main/src/main/java/de/blinkt/openvpn/core/OpenVPNThread.java
index 67c05e7d7309ce486038c060af61fed31f1218ec..5fa2ab9ef1c6a307f0f8886e27e392a2a1f92846 100644
--- a/ics-openvpn-stripped/main/src/main/java/de/blinkt/openvpn/core/OpenVPNThread.java
+++ b/ics-openvpn-stripped/main/src/main/java/de/blinkt/openvpn/core/OpenVPNThread.java
@@ -33,11 +33,11 @@ public class OpenVPNThread implements Runnable {
     private String[] mArgv;
 	private Process mProcess;
 	private String mNativeDir;
-	private OpenVpnService mService;
+	private OpenVPNService mService;
 	private String mDumpPath;
 	private Map<String, String> mProcessEnv;
 
-	public OpenVPNThread(OpenVpnService service,String[] argv, Map<String,String> processEnv, String nativelibdir)
+	public OpenVPNThread(OpenVPNService service,String[] argv, Map<String,String> processEnv, String nativelibdir)
 	{
 		mArgv = argv;
 		mNativeDir = nativelibdir;
diff --git a/ics-openvpn-stripped/main/src/main/java/de/blinkt/openvpn/core/OpenVpnManagementThread.java b/ics-openvpn-stripped/main/src/main/java/de/blinkt/openvpn/core/OpenVpnManagementThread.java
index e6e5be25bf293e1aa1bf712d07998bd6cde53285..e200f210c9bf3bd04362400da87d87d558cf0e6d 100644
--- a/ics-openvpn-stripped/main/src/main/java/de/blinkt/openvpn/core/OpenVpnManagementThread.java
+++ b/ics-openvpn-stripped/main/src/main/java/de/blinkt/openvpn/core/OpenVpnManagementThread.java
@@ -33,49 +33,50 @@ import de.blinkt.openvpn.core.VpnStatus.ConnectionStatus;
 
 public class OpenVpnManagementThread implements Runnable, OpenVPNManagement {
 
-	private static final String TAG = "openvpn";
-	private LocalSocket mSocket;
-	private VpnProfile mProfile;
-	private OpenVpnService mOpenVPNService;
-	private LinkedList<FileDescriptor> mFDList=new LinkedList<FileDescriptor>();
+    private static final String TAG = "openvpn";
+    private LocalSocket mSocket;
+    private VpnProfile mProfile;
+    private OpenVPNService mOpenVPNService;
+    private LinkedList<FileDescriptor> mFDList = new LinkedList<FileDescriptor>();
     private LocalServerSocket mServerSocket;
-	private boolean mReleaseHold=true;
-	private boolean mWaitingForRelease=false;
-	private long mLastHoldRelease=0;
+    private boolean mReleaseHold = true;
+    private boolean mWaitingForRelease = false;
+    private long mLastHoldRelease = 0;
 
-	private static Vector<OpenVpnManagementThread> active=new Vector<OpenVpnManagementThread>();
+    private static final Vector<OpenVpnManagementThread> active = new Vector<OpenVpnManagementThread>();
     private LocalSocket mServerSocketLocal;
 
     private pauseReason lastPauseReason = pauseReason.noNetwork;
 
-    public OpenVpnManagementThread(VpnProfile profile, OpenVpnService openVpnService) {
-		mProfile = profile;
-		mOpenVPNService = openVpnService;
-		
+    public OpenVpnManagementThread(VpnProfile profile, OpenVPNService openVpnService) {
+        mProfile = profile;
+        mOpenVPNService = openVpnService;
 
-		SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(openVpnService);
-		boolean managemeNetworkState = prefs.getBoolean("netchangereconnect", true);
-		if(managemeNetworkState)
-			mReleaseHold=false;
 
-	}
+        SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(openVpnService);
+        boolean managemeNetworkState = prefs.getBoolean("netchangereconnect", true);
+        if (managemeNetworkState)
+            mReleaseHold = false;
+
+    }
 
     public boolean openManagementInterface(@NotNull Context c) {
         // Could take a while to open connection
-        int tries=8;
+        int tries = 8;
 
-        String socketName = (c.getCacheDir().getAbsolutePath() + "/" +  "mgmtsocket");
+        String socketName = (c.getCacheDir().getAbsolutePath() + "/" + "mgmtsocket");
         // The mServerSocketLocal is transferred to the LocalServerSocket, ignore warning
 
         mServerSocketLocal = new LocalSocket();
 
-        while(tries > 0 && !mServerSocketLocal.isConnected()) {
+        while (tries > 0 && !mServerSocketLocal.isConnected()) {
             try {
                 mServerSocketLocal.bind(new LocalSocketAddress(socketName,
                         LocalSocketAddress.Namespace.FILESYSTEM));
             } catch (IOException e) {
                 // wait 300 ms before retrying
-                try { Thread.sleep(300);
+                try {
+                    Thread.sleep(300);
                 } catch (InterruptedException e1) {
                 }
 
@@ -95,165 +96,168 @@ public class OpenVpnManagementThread implements Runnable, OpenVPNManagement {
 
     }
 
-	public void managmentCommand(String cmd) {
+    public void managmentCommand(String cmd) {
         try {
-		    if(mSocket!=null && mSocket.getOutputStream() !=null) {
-				mSocket.getOutputStream().write(cmd.getBytes());
-				mSocket.getOutputStream().flush();
-			}
-        }catch (IOException e) {
-				// Ignore socket stack traces
+            if (mSocket != null && mSocket.getOutputStream() != null) {
+                mSocket.getOutputStream().write(cmd.getBytes());
+                mSocket.getOutputStream().flush();
+            }
+        } catch (IOException e) {
+            // Ignore socket stack traces
         }
-	}
+    }
 
 
-	@Override
-	public void run() {
-		byte [] buffer  =new byte[2048];
-		//	mSocket.setSoTimeout(5); // Setting a timeout cannot be that bad
+    @Override
+    public void run() {
+        byte[] buffer = new byte[2048];
+        //	mSocket.setSoTimeout(5); // Setting a timeout cannot be that bad
 
-		String pendingInput="";
-		active.add(this);
+        String pendingInput = "";
+        synchronized (active) {
+            active.add(this);
+        }
 
-		try {
-			// Wait for a client to connect
-			mSocket= mServerSocket.accept();
-			InputStream instream = mSocket.getInputStream();
+        try {
+            // Wait for a client to connect
+            mSocket = mServerSocket.accept();
+            InputStream instream = mSocket.getInputStream();
             // Close the management socket after client connected
 
             mServerSocket.close();
             // Closing one of the two sockets also closes the other
             //mServerSocketLocal.close();
 
-			while(true) {
-				int numbytesread = instream.read(buffer);
-				if(numbytesread==-1)
-					return;
-
-				FileDescriptor[] fds = null;
-				try {
-					fds = mSocket.getAncillaryFileDescriptors();
-				} catch (IOException e) {
-					VpnStatus.logException("Error reading fds from socket", e);
-				}
-				if(fds!=null){
-                    Collections.addAll(mFDList, fds);
-				}
+            while (true) {
+                int numbytesread = instream.read(buffer);
+                if (numbytesread == -1)
+                    return;
 
-				String input = new String(buffer,0,numbytesread,"UTF-8");
+                FileDescriptor[] fds = null;
+                try {
+                    fds = mSocket.getAncillaryFileDescriptors();
+                } catch (IOException e) {
+                    VpnStatus.logException("Error reading fds from socket", e);
+                }
+                if (fds != null) {
+                    Collections.addAll(mFDList, fds);
+                }
 
-				pendingInput += input;
+                String input = new String(buffer, 0, numbytesread, "UTF-8");
 
-				pendingInput=processInput(pendingInput);
+                pendingInput += input;
 
+                pendingInput = processInput(pendingInput);
 
 
-			}
-		} catch (IOException e) {
+            }
+        } catch (IOException e) {
             if (!e.getMessage().equals("socket closed"))
                 VpnStatus.logException(e);
-		}
-		active.remove(this);
-	}
+        }
+        synchronized (active) {
+            active.remove(this);
+        }
+    }
 
-	//! Hack O Rama 2000!
-	private void protectFileDescriptor(FileDescriptor fd) {
-		Exception exp;
-		try {
-			Method getInt =  FileDescriptor.class.getDeclaredMethod("getInt$");
-			int fdint = (Integer) getInt.invoke(fd);
+    //! Hack O Rama 2000!
+    private void protectFileDescriptor(FileDescriptor fd) {
+        Exception exp;
+        try {
+            Method getInt = FileDescriptor.class.getDeclaredMethod("getInt$");
+            int fdint = (Integer) getInt.invoke(fd);
 
-			// You can even get more evil by parsing toString() and extract the int from that :)
+            // You can even get more evil by parsing toString() and extract the int from that :)
 
-			boolean result = mOpenVPNService.protect(fdint);
+            boolean result = mOpenVPNService.protect(fdint);
             if (!result)
                 VpnStatus.logWarning("Could not protect VPN socket");
 
 
-			//ParcelFileDescriptor pfd = ParcelFileDescriptor.fromFd(fdint);
-			//pfd.close();
-			NativeUtils.jniclose(fdint);
-			return;
-		} catch (NoSuchMethodException e) {
-			exp =e;
-		} catch (IllegalArgumentException e) {
-			exp =e;
-		} catch (IllegalAccessException e) {
-			exp =e;
-		} catch (InvocationTargetException e) {
-			exp =e;
-		} catch (NullPointerException e) {
-			exp =e;
-		}
+            //ParcelFileDescriptor pfd = ParcelFileDescriptor.fromFd(fdint);
+            //pfd.close();
+            NativeUtils.jniclose(fdint);
+            return;
+        } catch (NoSuchMethodException e) {
+            exp = e;
+        } catch (IllegalArgumentException e) {
+            exp = e;
+        } catch (IllegalAccessException e) {
+            exp = e;
+        } catch (InvocationTargetException e) {
+            exp = e;
+        } catch (NullPointerException e) {
+            exp = e;
+        }
 
         Log.d("Openvpn", "Failed to retrieve fd from socket: " + fd);
-        VpnStatus.logException("Failed to retrieve fd from socket (" + fd + ")" , exp);
-	}
+        VpnStatus.logException("Failed to retrieve fd from socket (" + fd + ")", exp);
+    }
 
-	private String processInput(String pendingInput) {
+    private String processInput(String pendingInput) {
 
 
-		while(pendingInput.contains("\n")) {
-			String[] tokens = pendingInput.split("\\r?\\n", 2);
-			processCommand(tokens[0]);
-			if(tokens.length == 1)
-				// No second part, newline was at the end
-				pendingInput="";
-			else
-				pendingInput=tokens[1];
-		}
-		return pendingInput;
-	}
+        while (pendingInput.contains("\n")) {
+            String[] tokens = pendingInput.split("\\r?\\n", 2);
+            processCommand(tokens[0]);
+            if (tokens.length == 1)
+                // No second part, newline was at the end
+                pendingInput = "";
+            else
+                pendingInput = tokens[1];
+        }
+        return pendingInput;
+    }
 
 
-	private void processCommand(String command) {
+    private void processCommand(String command) {
         //Log.i(TAG, "Line from managment" + command);
 
 
         if (command.startsWith(">") && command.contains(":")) {
-			String[] parts = command.split(":",2);
-			String cmd = parts[0].substring(1);
-			String argument = parts[1];
+            String[] parts = command.split(":", 2);
+            String cmd = parts[0].substring(1);
+            String argument = parts[1];
 
 
-			if(cmd.equals("INFO")) {
-				/* Ignore greeting from management */
+            if (cmd.equals("INFO")) {
+                /* Ignore greeting from management */
                 return;
-			}else if (cmd.equals("PASSWORD")) {
-				processPWCommand(argument);
-			} else if (cmd.equals("HOLD")) {
-				handleHold();
-			} else if (cmd.equals("NEED-OK")) {
-				processNeedCommand(argument);
-			} else if (cmd.equals("BYTECOUNT")){
-				processByteCount(argument);
-			} else if (cmd.equals("STATE")) {
-				processState(argument);
-			} else if (cmd.equals("PROXY")) {
-				processProxyCMD(argument);
-			} else if (cmd.equals("LOG")) {
-                 processLogMessage(argument);
-			} else if (cmd.equals("RSA_SIGN")) {
-				processSignCommand(argument);
-			} else {
-				VpnStatus.logWarning("MGMT: Got unrecognized command" + command);
-				Log.i(TAG, "Got unrecognized command" + command);
-			}
-		} else if (command.startsWith("SUCCESS:")) {
+            } else if (cmd.equals("PASSWORD")) {
+                processPWCommand(argument);
+            } else if (cmd.equals("HOLD")) {
+                handleHold();
+            } else if (cmd.equals("NEED-OK")) {
+                processNeedCommand(argument);
+            } else if (cmd.equals("BYTECOUNT")) {
+                processByteCount(argument);
+            } else if (cmd.equals("STATE")) {
+                processState(argument);
+            } else if (cmd.equals("PROXY")) {
+                processProxyCMD(argument);
+            } else if (cmd.equals("LOG")) {
+                processLogMessage(argument);
+            } else if (cmd.equals("RSA_SIGN")) {
+                processSignCommand(argument);
+            } else {
+                VpnStatus.logWarning("MGMT: Got unrecognized command" + command);
+                Log.i(TAG, "Got unrecognized command" + command);
+            }
+        } else if (command.startsWith("SUCCESS:")) {
 			/* Ignore this kind of message too */
             return;
         } else if (command.startsWith("PROTECTFD: ")) {
             FileDescriptor fdtoprotect = mFDList.pollFirst();
-            if (fdtoprotect!=null)
+            if (fdtoprotect != null)
                 protectFileDescriptor(fdtoprotect);
-		} else {
-			Log.i(TAG, "Got unrecognized line from managment" + command);
-			VpnStatus.logWarning("MGMT: Got unrecognized line from management:" + command);
-		}
-	}
+        } else {
+            Log.i(TAG, "Got unrecognized line from managment" + command);
+            VpnStatus.logWarning("MGMT: Got unrecognized line from management:" + command);
+        }
+    }
 
     private void processLogMessage(String argument) {
-        String[] args = argument.split(",",4);
+        String[] args = argument.split(",", 4);
         // 0 unix time stamp
         // 1 log level N,I,E etc.
                 /*
@@ -287,109 +291,110 @@ public class OpenVpnManagementThread implements Runnable, OpenVPNManagement {
         if (msg.startsWith("MANAGEMENT: CMD"))
             ovpnlevel = Math.max(4, ovpnlevel);
 
-        VpnStatus.logMessageOpenVPN(level,ovpnlevel, msg);
+        VpnStatus.logMessageOpenVPN(level, ovpnlevel, msg);
     }
 
     private void handleHold() {
-		if(mReleaseHold) {
-			releaseHoldCmd();
-		} else { 
-			mWaitingForRelease=true;
+        if (mReleaseHold) {
+            releaseHoldCmd();
+        } else {
+            mWaitingForRelease = true;
 
             VpnStatus.updateStatePause(lastPauseReason);
 
 
-		}
-	}
-	private void releaseHoldCmd() {
-		if ((System.currentTimeMillis()- mLastHoldRelease) < 5000) {
-			try {
-				Thread.sleep(3000);
-			} catch (InterruptedException e) {
+        }
+    }
+
+    private void releaseHoldCmd() {
+        if ((System.currentTimeMillis() - mLastHoldRelease) < 5000) {
+            try {
+                Thread.sleep(3000);
+            } catch (InterruptedException ignored) {
             }
-			
-		}
-		mWaitingForRelease=false;
-		mLastHoldRelease  = System.currentTimeMillis();
-		managmentCommand("hold release\n");
-		managmentCommand("bytecount " + mBytecountInterval + "\n");
+
+        }
+        mWaitingForRelease = false;
+        mLastHoldRelease = System.currentTimeMillis();
+        managmentCommand("hold release\n");
+        managmentCommand("bytecount " + mBytecountInterval + "\n");
         managmentCommand("state on\n");
         //managmentCommand("log on all\n");
-	}
-	
-	public void releaseHold() {
-		mReleaseHold=true;
-		if(mWaitingForRelease)
-			releaseHoldCmd();
-			
-	}
-
-	private void processProxyCMD(String argument) {
-		String[] args = argument.split(",",3);
-		SocketAddress proxyaddr = ProxyDetection.detectProxy(mProfile);
-
-		
-		if(args.length >= 2) {
-			String proto = args[1];
-			if(proto.equals("UDP")) {
-				proxyaddr=null;
-			}
-		}
-
-		if(proxyaddr instanceof InetSocketAddress ){
-			InetSocketAddress isa = (InetSocketAddress) proxyaddr;
-			
-			VpnStatus.logInfo(R.string.using_proxy, isa.getHostName(), isa.getPort());
-			
-			String proxycmd = String.format(Locale.ENGLISH,"proxy HTTP %s %d\n", isa.getHostName(),isa.getPort());
-			managmentCommand(proxycmd);
-		} else {
-			managmentCommand("proxy NONE\n");
-		}
-
-	}
-	private void processState(String argument) {
-		String[] args = argument.split(",",3);
-		String currentstate = args[1];
-
-		if(args[2].equals(",,"))
-			VpnStatus.updateStateString(currentstate, "");
-		else
-			VpnStatus.updateStateString(currentstate, args[2]);
-	}
-
-
-	private void processByteCount(String argument) {
-		//   >BYTECOUNT:{BYTES_IN},{BYTES_OUT}
-		int comma = argument.indexOf(',');
-		long in = Long.parseLong(argument.substring(0, comma));
-		long out = Long.parseLong(argument.substring(comma+1));
-
-		VpnStatus.updateByteCount(in, out);
-		
-	}
-
-
-
-	private void processNeedCommand(String argument) {
-		int p1 =argument.indexOf('\'');
-		int p2 = argument.indexOf('\'',p1+1);
-
-		String needed = argument.substring(p1+1, p2);
-		String extra = argument.split(":",2)[1];
-
-		String status = "ok";
-
-
-		if (needed.equals("PROTECTFD")) {
-			FileDescriptor fdtoprotect = mFDList.pollFirst();
-			protectFileDescriptor(fdtoprotect);
-		} else if (needed.equals("DNSSERVER")) {
-			mOpenVPNService.addDNS(extra);
-		}else if (needed.equals("DNSDOMAIN")){
-			mOpenVPNService.setDomain(extra);
-		} else if (needed.equals("ROUTE")) {
-			String[] routeparts = extra.split(" ");
+    }
+
+    public void releaseHold() {
+        mReleaseHold = true;
+        if (mWaitingForRelease)
+            releaseHoldCmd();
+
+    }
+
+    private void processProxyCMD(String argument) {
+        String[] args = argument.split(",", 3);
+        SocketAddress proxyaddr = ProxyDetection.detectProxy(mProfile);
+
+
+        if (args.length >= 2) {
+            String proto = args[1];
+            if (proto.equals("UDP")) {
+                proxyaddr = null;
+            }
+        }
+
+        if (proxyaddr instanceof InetSocketAddress) {
+            InetSocketAddress isa = (InetSocketAddress) proxyaddr;
+
+            VpnStatus.logInfo(R.string.using_proxy, isa.getHostName(), isa.getPort());
+
+            String proxycmd = String.format(Locale.ENGLISH, "proxy HTTP %s %d\n", isa.getHostName(), isa.getPort());
+            managmentCommand(proxycmd);
+        } else {
+            managmentCommand("proxy NONE\n");
+        }
+
+    }
+
+    private void processState(String argument) {
+        String[] args = argument.split(",", 3);
+        String currentstate = args[1];
+
+        if (args[2].equals(",,"))
+            VpnStatus.updateStateString(currentstate, "");
+        else
+            VpnStatus.updateStateString(currentstate, args[2]);
+    }
+
+
+    private void processByteCount(String argument) {
+        //   >BYTECOUNT:{BYTES_IN},{BYTES_OUT}
+        int comma = argument.indexOf(',');
+        long in = Long.parseLong(argument.substring(0, comma));
+        long out = Long.parseLong(argument.substring(comma + 1));
+
+        VpnStatus.updateByteCount(in, out);
+
+    }
+
+
+    private void processNeedCommand(String argument) {
+        int p1 = argument.indexOf('\'');
+        int p2 = argument.indexOf('\'', p1 + 1);
+
+        String needed = argument.substring(p1 + 1, p2);
+        String extra = argument.split(":", 2)[1];
+
+        String status = "ok";
+
+
+        if (needed.equals("PROTECTFD")) {
+            FileDescriptor fdtoprotect = mFDList.pollFirst();
+            protectFileDescriptor(fdtoprotect);
+        } else if (needed.equals("DNSSERVER")) {
+            mOpenVPNService.addDNS(extra);
+        } else if (needed.equals("DNSDOMAIN")) {
+            mOpenVPNService.setDomain(extra);
+        } else if (needed.equals("ROUTE")) {
+            String[] routeparts = extra.split(" ");
 
             /*
             buf_printf (&out, "%s %s %s dev %s", network, netmask, gateway, rgi->iface);
@@ -397,209 +402,208 @@ public class OpenVpnManagementThread implements Runnable, OpenVPNManagement {
             buf_printf (&out, "%s %s %s", network, netmask, gateway);
             */
 
-            if(routeparts.length==5) {
+            if (routeparts.length == 5) {
                 if (BuildConfig.DEBUG) Assert.assertEquals("dev", routeparts[3]);
                 mOpenVPNService.addRoute(routeparts[0], routeparts[1], routeparts[2], routeparts[4]);
-            }  else if (routeparts.length >= 3) {
+            } else if (routeparts.length >= 3) {
                 mOpenVPNService.addRoute(routeparts[0], routeparts[1], routeparts[2], null);
             } else {
                 VpnStatus.logError("Unrecognized ROUTE cmd:" + Arrays.toString(routeparts) + " | " + argument);
             }
 
-		} else if (needed.equals("ROUTE6")) {
+        } else if (needed.equals("ROUTE6")) {
             String[] routeparts = extra.split(" ");
-			mOpenVPNService.addRoutev6(routeparts[0],routeparts[1]);
-		} else if (needed.equals("IFCONFIG")) {
-			String[] ifconfigparts = extra.split(" ");
-			int mtu = Integer.parseInt(ifconfigparts[2]);
-			mOpenVPNService.setLocalIP(ifconfigparts[0], ifconfigparts[1],mtu,ifconfigparts[3]);
-		} else if (needed.equals("IFCONFIG6")) {
-			mOpenVPNService.setLocalIPv6(extra);
-
-		} else if (needed.equals("PERSIST_TUN_ACTION")) {
+            mOpenVPNService.addRoutev6(routeparts[0], routeparts[1]);
+        } else if (needed.equals("IFCONFIG")) {
+            String[] ifconfigparts = extra.split(" ");
+            int mtu = Integer.parseInt(ifconfigparts[2]);
+            mOpenVPNService.setLocalIP(ifconfigparts[0], ifconfigparts[1], mtu, ifconfigparts[3]);
+        } else if (needed.equals("IFCONFIG6")) {
+            mOpenVPNService.setLocalIPv6(extra);
+
+        } else if (needed.equals("PERSIST_TUN_ACTION")) {
             // check if tun cfg stayed the same
             status = mOpenVPNService.getTunReopenStatus();
         } else if (needed.equals("OPENTUN")) {
-			if(sendTunFD(needed,extra))
-				return;
-			else
-				status="cancel";
-			// This not nice or anything but setFileDescriptors accepts only FilDescriptor class :(
-
-		} else {
-			Log.e(TAG,"Unkown needok command " + argument);
-			return;
-		}
-
-		String cmd = String.format("needok '%s' %s\n", needed, status);
-		managmentCommand(cmd);
-	}
-
-	private boolean sendTunFD (String needed, String extra) {
-		Exception exp;
-		if(!extra.equals("tun")) {
-			// We only support tun
-			VpnStatus.logError(String.format("Device type %s requested, but only tun is possible with the Android API, sorry!",extra));
-
-			return false;
-		}
-		ParcelFileDescriptor pfd = mOpenVPNService.openTun();
-		if(pfd==null)
-			return false;
-
-		Method setInt;
-		int fdint = pfd.getFd();
-		try {
-			setInt = FileDescriptor.class.getDeclaredMethod("setInt$",int.class);
-			FileDescriptor fdtosend = new FileDescriptor();
-
-			setInt.invoke(fdtosend,fdint);
-
-			FileDescriptor[] fds = {fdtosend};
-			mSocket.setFileDescriptorsForSend(fds);
-
-			// Trigger a send so we can close the fd on our side of the channel
-			// The API documentation fails to mention that it will not reset the file descriptor to
-			// be send and will happily send the file descriptor on every write ...
-			String cmd = String.format("needok '%s' %s\n", needed, "ok");
-			managmentCommand(cmd);
-
-			// Set the FileDescriptor to null to stop this mad behavior 
-			mSocket.setFileDescriptorsForSend(null);
-
-			pfd.close();			
-
-			return true;
-		} catch (NoSuchMethodException e) {
-			exp =e;
-		} catch (IllegalArgumentException e) {
-			exp =e;
-		} catch (IllegalAccessException e) {
-			exp =e;
-		} catch (InvocationTargetException e) {
-			exp =e;
-		} catch (IOException e) {
-			exp =e;
-		}
-        VpnStatus.logException("Could not send fd over socket" , exp);
+            if (sendTunFD(needed, extra))
+                return;
+            else
+                status = "cancel";
+            // This not nice or anything but setFileDescriptors accepts only FilDescriptor class :(
+
+        } else {
+            Log.e(TAG, "Unkown needok command " + argument);
+            return;
+        }
+
+        String cmd = String.format("needok '%s' %s\n", needed, status);
+        managmentCommand(cmd);
+    }
+
+    private boolean sendTunFD(String needed, String extra) {
+        Exception exp;
+        if (!extra.equals("tun")) {
+            // We only support tun
+            VpnStatus.logError(String.format("Device type %s requested, but only tun is possible with the Android API, sorry!", extra));
+
+            return false;
+        }
+        ParcelFileDescriptor pfd = mOpenVPNService.openTun();
+        if (pfd == null)
+            return false;
+
+        Method setInt;
+        int fdint = pfd.getFd();
+        try {
+            setInt = FileDescriptor.class.getDeclaredMethod("setInt$", int.class);
+            FileDescriptor fdtosend = new FileDescriptor();
+
+            setInt.invoke(fdtosend, fdint);
+
+            FileDescriptor[] fds = {fdtosend};
+            mSocket.setFileDescriptorsForSend(fds);
+
+            // Trigger a send so we can close the fd on our side of the channel
+            // The API documentation fails to mention that it will not reset the file descriptor to
+            // be send and will happily send the file descriptor on every write ...
+            String cmd = String.format("needok '%s' %s\n", needed, "ok");
+            managmentCommand(cmd);
+
+            // Set the FileDescriptor to null to stop this mad behavior
+            mSocket.setFileDescriptorsForSend(null);
+
+            pfd.close();
+
+            return true;
+        } catch (NoSuchMethodException e) {
+            exp = e;
+        } catch (IllegalArgumentException e) {
+            exp = e;
+        } catch (IllegalAccessException e) {
+            exp = e;
+        } catch (InvocationTargetException e) {
+            exp = e;
+        } catch (IOException e) {
+            exp = e;
+        }
+        VpnStatus.logException("Could not send fd over socket", exp);
 
         return false;
-	}
-
-	private void processPWCommand(String argument) {
-		//argument has the form 	Need 'Private Key' password
-		// or  ">PASSWORD:Verification Failed: '%s' ['%s']"
-		String needed;
-		
-		
-		
-		try{
-
-			int p1 = argument.indexOf('\'');
-			int p2 = argument.indexOf('\'',p1+1);
-			needed = argument.substring(p1+1, p2);
-			if (argument.startsWith("Verification Failed")) {
-				proccessPWFailed(needed, argument.substring(p2+1));
-				return;
-			}
-		} catch (StringIndexOutOfBoundsException sioob) {
-			VpnStatus.logError("Could not parse management Password command: " + argument);
-			return;
-		}
-
-		String pw=null;
-
-		if(needed.equals("Private Key")) {
-			pw = mProfile.getPasswordPrivateKey();
-		} else if (needed.equals("Auth")) {
-			String usercmd = String.format("username '%s' %s\n", 
-					needed, VpnProfile.openVpnEscape(mProfile.mUsername));
-			managmentCommand(usercmd);
-			pw = mProfile.getPasswordAuth();
-		} 
-		if(pw!=null) {
-			String cmd = String.format("password '%s' %s\n", needed, VpnProfile.openVpnEscape(pw));
-			managmentCommand(cmd);
-		} else {
-			VpnStatus.logError(String.format("Openvpn requires Authentication type '%s' but no password/key information available", needed));
-		}
-
-	}
-
-
-
-
-	private void proccessPWFailed(String needed, String args) {
-		VpnStatus.updateStateString("AUTH_FAILED", needed + args, R.string.state_auth_failed, ConnectionStatus.LEVEL_AUTH_FAILED);
-	}
-
-
-	private static boolean stopOpenVPN() {
-		boolean sendCMD=false;
-		for (OpenVpnManagementThread mt: active){
-			mt.managmentCommand("signal SIGINT\n");
-			sendCMD=true;
-			try {
-				if(mt.mSocket !=null)
-					mt.mSocket.close();
-			} catch (IOException e) {
-				// Ignore close error on already closed socket
-			}
-		}
-		return sendCMD;		
-	}
+    }
+
+    private void processPWCommand(String argument) {
+        //argument has the form 	Need 'Private Key' password
+        // or  ">PASSWORD:Verification Failed: '%s' ['%s']"
+        String needed;
+
+
+        try {
+
+            int p1 = argument.indexOf('\'');
+            int p2 = argument.indexOf('\'', p1 + 1);
+            needed = argument.substring(p1 + 1, p2);
+            if (argument.startsWith("Verification Failed")) {
+                proccessPWFailed(needed, argument.substring(p2 + 1));
+                return;
+            }
+        } catch (StringIndexOutOfBoundsException sioob) {
+            VpnStatus.logError("Could not parse management Password command: " + argument);
+            return;
+        }
+
+        String pw = null;
+
+        if (needed.equals("Private Key")) {
+            pw = mProfile.getPasswordPrivateKey();
+        } else if (needed.equals("Auth")) {
+            String usercmd = String.format("username '%s' %s\n",
+                    needed, VpnProfile.openVpnEscape(mProfile.mUsername));
+            managmentCommand(usercmd);
+            pw = mProfile.getPasswordAuth();
+        }
+        if (pw != null) {
+            String cmd = String.format("password '%s' %s\n", needed, VpnProfile.openVpnEscape(pw));
+            managmentCommand(cmd);
+        } else {
+            VpnStatus.logError(String.format("Openvpn requires Authentication type '%s' but no password/key information available", needed));
+        }
+
+    }
+
+
+    private void proccessPWFailed(String needed, String args) {
+        VpnStatus.updateStateString("AUTH_FAILED", needed + args, R.string.state_auth_failed, ConnectionStatus.LEVEL_AUTH_FAILED);
+    }
+
+
+    private static boolean stopOpenVPN() {
+        synchronized (active) {
+            boolean sendCMD = false;
+            for (OpenVpnManagementThread mt : active) {
+                mt.managmentCommand("signal SIGINT\n");
+                sendCMD = true;
+                try {
+                    if (mt.mSocket != null)
+                        mt.mSocket.close();
+                } catch (IOException e) {
+                    // Ignore close error on already closed socket
+                }
+            }
+            return sendCMD;
+        }
+    }
 
     @Override
     public void networkChange() {
-        if(!mWaitingForRelease)
+        if (!mWaitingForRelease)
             managmentCommand("network-change\n");
     }
 
-	public void signalusr1() {
-		mReleaseHold=false;
+    public void signalusr1() {
+        mReleaseHold = false;
 
-		if(!mWaitingForRelease)
-			managmentCommand("signal SIGUSR1\n");
+        if (!mWaitingForRelease)
+            managmentCommand("signal SIGUSR1\n");
         else
             // If signalusr1 is called update the state string
             // if there is another for stopping
             VpnStatus.updateStatePause(lastPauseReason);
-	}
+    }
 
-	public void reconnect() {
-		signalusr1();
-		releaseHold();
-	}
+    public void reconnect() {
+        signalusr1();
+        releaseHold();
+    }
 
-	private void processSignCommand(String b64data) {
+    private void processSignCommand(String b64data) {
 
-		String signed_string = mProfile.getSignedData(b64data);
-        if(signed_string==null) {
+        String signed_string = mProfile.getSignedData(b64data);
+        if (signed_string == null) {
             managmentCommand("rsa-sig\n");
             managmentCommand("\nEND\n");
             stopOpenVPN();
             return;
         }
         managmentCommand("rsa-sig\n");
-		managmentCommand(signed_string);
+        managmentCommand(signed_string);
         managmentCommand("\nEND\n");
-	}
+    }
 
-	@Override
-	public void pause (pauseReason reason) {
+    @Override
+    public void pause(pauseReason reason) {
         lastPauseReason = reason;
-		signalusr1();
-	}
+        signalusr1();
+    }
 
-	@Override
-	public void resume() {
-		releaseHold();
+    @Override
+    public void resume() {
+        releaseHold();
         /* Reset the reason why we are disconnected */
         lastPauseReason = pauseReason.noNetwork;
-	}
+    }
 
-	@Override
-	public boolean stopVPN() {
-		return stopOpenVPN();
-	}
+    @Override
+    public boolean stopVPN() {
+        return stopOpenVPN();
+    }
 }
diff --git a/ics-openvpn-stripped/main/src/main/java/de/blinkt/openvpn/fragments/LogFragment.java b/ics-openvpn-stripped/main/src/main/java/de/blinkt/openvpn/fragments/LogFragment.java
index d96a66a0951cb671c1bff1c0ad9fc903f8475847..4187910399bea5dd27c39bb89b7bdab7b0a073bb 100644
--- a/ics-openvpn-stripped/main/src/main/java/de/blinkt/openvpn/fragments/LogFragment.java
+++ b/ics-openvpn-stripped/main/src/main/java/de/blinkt/openvpn/fragments/LogFragment.java
@@ -51,7 +51,7 @@ import se.leap.bitmaskclient.R;
 import de.blinkt.openvpn.VpnProfile;
 import de.blinkt.openvpn.activities.DisconnectVPN;
 import de.blinkt.openvpn.core.OpenVPNManagement;
-import de.blinkt.openvpn.core.OpenVpnService;
+import de.blinkt.openvpn.core.OpenVPNService;
 import de.blinkt.openvpn.core.ProfileManager;
 import de.blinkt.openvpn.core.VpnStatus;
 import de.blinkt.openvpn.core.VpnStatus.ConnectionStatus;
@@ -59,7 +59,7 @@ import de.blinkt.openvpn.core.VpnStatus.LogItem;
 import de.blinkt.openvpn.core.VpnStatus.LogListener;
 import de.blinkt.openvpn.core.VpnStatus.StateListener;
 
-import static de.blinkt.openvpn.core.OpenVpnService.humanReadableByteCount;
+import static de.blinkt.openvpn.core.OpenVPNService.humanReadableByteCount;
 
 import se.leap.bitmaskclient.Dashboard;
 
@@ -501,8 +501,8 @@ public class LogFragment extends ListFragment implements StateListener, SeekBar.
 		super.onResume();
 		VpnStatus.addStateListener(this);
         VpnStatus.addByteCountListener(this);
-        Intent intent = new Intent(getActivity(), OpenVpnService.class);
-        intent.setAction(OpenVpnService.START_SERVICE);
+        Intent intent = new Intent(getActivity(), OpenVPNService.class);
+        intent.setAction(OpenVPNService.START_SERVICE);
 
     }
 
diff --git a/ics-openvpn-stripped/main/src/main/res/values-ca/strings.xml b/ics-openvpn-stripped/main/src/main/res/values-ca/strings.xml
index 554b48162edcb1de553c275fa0a6f4831ee1e489..c90277d782f078376169616820f58efc587a4a0b 100755
--- a/ics-openvpn-stripped/main/src/main/res/values-ca/strings.xml
+++ b/ics-openvpn-stripped/main/src/main/res/values-ca/strings.xml
@@ -1,5 +1,5 @@
 <?xml version="1.0" encoding="utf-8"?>
-<!--Generated by crowdin.net-->
+<!--Generated by crowdin.com-->
 <!-- Generated by crowdin.net -->
 <resources>
   <string name="app">OpenVPN per Android</string>
diff --git a/ics-openvpn-stripped/main/src/main/res/values-de/strings.xml b/ics-openvpn-stripped/main/src/main/res/values-de/strings.xml
index eb6ef36eca47983f441b48e2c381f3fff88cd5c7..bdda9bb2ef6e1aa576e873c7f9828b150c5c91a2 100755
--- a/ics-openvpn-stripped/main/src/main/res/values-de/strings.xml
+++ b/ics-openvpn-stripped/main/src/main/res/values-de/strings.xml
@@ -1,5 +1,5 @@
 <?xml version="1.0" encoding="utf-8"?>
-<!--Generated by crowdin.net-->
+<!--Generated by crowdin.com-->
 <!-- Generated by crowdin.net -->
 <resources>
   <string name="app">OpenVPN für Android</string>
@@ -156,7 +156,7 @@
   <string name="converted_profile">Importiertes Profil</string>
   <string name="converted_profile_i">Importiertes Profil %d</string>
   <string name="broken_images">Fehlerhafte Images</string>
-  <string name="broken_images_faq">&lt;p&gt;Von offiziellen HTC Firmwares ist bekannt, dass diese teilweise merkwürdige Routing Probleme haben, die dafür sorgen, dass der Verkehr nicht durch den Tunnel fließt. (Siehe auch &lt;a href=\"http://code.google.com/p/ics-openvpn/issues/detail?id=18\"&gt;Issue 18&lt;/a&gt; im Bug Tracker.)&lt;/p&gt;&lt;p&gt;Bei älteren Version der offiziellen SONY Firmwares für das Xperia arc S and Xperia Ray scheint der VPNService Support  komplett zu fehlen. (Siehe auch &lt;a href=\"http://code.google.com/p/ics-openvpn/issues/detail?id=29\"&gt;Issue 29&lt;/a&gt; im Bug Tracker.)&lt;/p&gt;&lt;p&gt;Auf anderen (insbesondere Custom ROMS) fehlt teilweise das tun Kernel Modul oder die Rechte von /dev/tun sind falsch gesetzt. Auf einigen CM9 Firmware wird die \"/dev/tun Eigentümer setzen\" Option in den Allgemeinen Einstellungen benötigt.&lt;/p&gt;&lt;p&gt;Am wichtigsten ist aber, falls Sie eine fehlerhafte Firmware haben, melden Sie dies Ihrem Hersteller. Desto mehr Leute den Fehler dem Hersteller melden desto wahrscheinlicher werden Sie eine Fehlerkorrektur bekommen.&lt;/p&gt;</string>
+  <string name="broken_images_faq">&lt;p&gt;Von offiziellen HTC Firmwares ist bekannt, dass diese teilweise merkwürdige Routing Probleme haben, die dafür sorgen, dass der Verkehr nicht durch den Tunnel fließt. (Siehe auch &lt;a href=\"http://code.google.com/p/ics-openvpn/issues/detail?id=18\"&gt;Issue 18&lt;/a&gt; im Bug Tracker.)&lt;/p&gt;&lt;p&gt;Bei älteren Version der offiziellen SONY Firmwares für das Xperia arc S and Xperia Ray scheint der VPNService Support  komplett zu fehlen. (Siehe auch &lt;a href=\"http://code.google.com/p/ics-openvpn/issues/detail?id=29\"&gt;Issue 29&lt;/a&gt; im Bug Tracker.)&lt;/p&gt;&lt;p&gt;Auf anderen (insbesondere Custom ROMS) fehlt teilweise das tun Kernel Modul oder die Rechte von /dev/tun sind falsch gesetzt. Auf einigen CM9 Firmware wird die \"/dev/tun Eigentümer setzen\" Option in den Allgemeinen Einstellungen benötigt.&lt;/p&gt;&lt;p&gt;Am wichtigsten ist aber, falls Sie eine fehlerhafte Firmware haben, melden Sie dies Ihrem Hersteller. Je mehr Leute den Fehler dem Hersteller melden, desto wahrscheinlicher werden Sie eine Fehlerkorrektur bekommen.&lt;/p&gt;</string>
   <string name="pkcs12_file_encryption_key">PKCS12 Veschlüsslungspassword</string>
   <string name="private_key_password">Passphrase privater Schlüssel</string>
   <string name="password">Passwort</string>
diff --git a/ics-openvpn-stripped/main/src/main/res/values-es/strings.xml b/ics-openvpn-stripped/main/src/main/res/values-es/strings.xml
index 5ad33bbd5a0c009ca2c4fd96969e90f977665261..ffd37c5f576434004565681e5a54c185e30327ba 100755
--- a/ics-openvpn-stripped/main/src/main/res/values-es/strings.xml
+++ b/ics-openvpn-stripped/main/src/main/res/values-es/strings.xml
@@ -1,5 +1,5 @@
 <?xml version="1.0" encoding="utf-8"?>
-<!--Generated by crowdin.net-->
+<!--Generated by crowdin.com-->
 <!-- Generated by crowdin.net -->
 <resources>
   <string name="app">OpenVPN para Android</string>
@@ -215,6 +215,7 @@
   <string name="vpn_import_hint">Use el icono &lt;img src=\"ic_menu_archive\"/&gt; para importar un perfil existente (.ovpn or .conf) de tu tarjeta.</string>
   <string name="faq_hint">Asegúrese de checar también las preguntas frecuentes. Hay una guía de inicio rápido.</string>
   <string name="faq_routing_title">Configuración de enrutamiento o interfaz</string>
+  <string name="faq_routing">El enrutamiento y la configuración de la interfaz no se realiza a través de comandos tradicionales ifconfig / ruta, pero mediante el uso de la API VPNService. Esto resulta en una configuración de enrutamiento diferente que en otros sistemas operativos. La configuración del túnel VPN consta de la dirección IP y las redes que deben ser colocados de través de esta interfaz. Se necesita Especialmente hay dirección compañero de estudios o de gateway. Rutas especiales para llegar a la VPN Server (por ejemplo agregan al usar redirect-gateway) no son necesarios, ya sea. La aplicación, en consecuencia ignorará esta configuración al importar una configuración. La aplicación asegura con la API VPNService que la conexión con el servidor no se encamina a través del túnel VPN. Sólo redes especificando ser enrutados a través del túnel es compatible. La aplicación intenta detectar las redes que no deben ser enrutados a través de túnel (por ejemplo, la ruta xxxx aaaa net_gateway) y calcula un conjunto de rutas que excluye este rutas para emular el comportamiento de otras plataformas. Las ventanas de registro muestra la configuración de la VPNService al establecer una conexión.</string>
   <string name="persisttun_summary">No regresar a modo sin conexión VPN cuando OpenVPN esta volviendose a conectar.</string>
   <string name="persistent_tun_title">Tun persistente</string>
   <string name="openvpn_log">Registro de OpenVPN</string>
@@ -314,4 +315,8 @@
   <string name="blocklocal_summary">Las redes conectadas directamente a los interfaces locales no serán enrutadas a través de la VPN. Al desmarcar esta opción, todo el tráfico previsto para las redes locales será redirigido a la VPN.</string>
   <string name="blocklocal_title">Evitar la VPN para las redes locales</string>
   <string name="userpw_file">Archivo de Usuario/Contraseña</string>
+  <string name="imported_from_file">[Importado de:%s]</string>
+  <string name="files_missing_hint">Algunos archivos no se pudo encontrar. Por favor, seleccione los archivos que desea importar el perfil:</string>
+  <string name="openvpn_is_no_free_vpn">Para utilizar esta aplicación usted necesita un proveedor de servicio VPN /  es un apoyo OpenVPN (a menudo proporcionados por su empleador). Echa un vistazo a http://community.openvpn.net/ para más información sobre OpenVPN y cómo configurar su propio servidor OpenVPN.</string>
+  <string name="import_log">Importar registros:</string>
 </resources>
diff --git a/ics-openvpn-stripped/main/src/main/res/values-fr/strings.xml b/ics-openvpn-stripped/main/src/main/res/values-fr/strings.xml
index 8479d591dcc4adb3a2b6f5e37de11dd04e7baa7a..626ea89cec3827bde1fc92f392d92cd795ff35e9 100755
--- a/ics-openvpn-stripped/main/src/main/res/values-fr/strings.xml
+++ b/ics-openvpn-stripped/main/src/main/res/values-fr/strings.xml
@@ -1,5 +1,5 @@
 <?xml version="1.0" encoding="utf-8"?>
-<!--Generated by crowdin.net-->
+<!--Generated by crowdin.com-->
 <!-- Generated by crowdin.net -->
 <resources>
   <string name="app">"OpenVPN pour Android"</string>
@@ -216,6 +216,7 @@ Sur certaines images, cette notification joue un son.\nAndroid à introduit ces
   <string name="vpn_import_hint">"Utilisez l\'icône &lt;img src=\"ic_menu_archive\"/&gt; pour importer un fichier profil (.opvpn ou  .conf) de votre carte SD."</string>
   <string name="faq_hint">"Veillez également à consulter la FAQ. Il s\'y trouve un guide de démarrage rapide."</string>
   <string name="faq_routing_title">"Redirections / Configuration de l\'interface"</string>
+  <string name="faq_routing">The Routing and interface configuration is not done via traditional ifconfig/route commands but by using the VPNService API. This results in a different routing configuration than on other OSes. The configuration for the VPN tunnel consists of the  IP address and the networks that should be routed over this interface. Especially no peer partner address or gateway address is needed. Special routes to reach the VPN Server (for example added when using redirect-gateway) are not needed either. The application will consequently ignore these settings when importing a configuration. The app ensures with the VPNService API that the connection to the server is not routed through the VPN tunnel. Only specifying networks to be routed via tunnel is supported. The app tries to detect networks that should not be routed over tunnel (e.g. route x.x.x.x y.y.y.y net_gateway) and calculates a route set that excludes this routes to emulate the behaviour of other platforms. The log windows shows the configuration of the VPNService upon establishing a connection.</string>
   <string name="persisttun_summary">Ne pas couper la connexion VPN lors de la reconnexion d\'OpenVPN.</string>
   <string name="persistent_tun_title">Persistance de l\'interface TUN</string>
   <string name="openvpn_log">Log OpenVPN</string>
diff --git a/ics-openvpn-stripped/main/src/main/res/values-ja/strings.xml b/ics-openvpn-stripped/main/src/main/res/values-ja/strings.xml
index fddc6deaa2ec525aa05aad2d6d3793048b649354..05525a4b214b52ae509e3ff407ac381b83044ee6 100755
--- a/ics-openvpn-stripped/main/src/main/res/values-ja/strings.xml
+++ b/ics-openvpn-stripped/main/src/main/res/values-ja/strings.xml
@@ -1,5 +1,5 @@
 <?xml version="1.0" encoding="utf-8"?>
-<!--Generated by crowdin.net-->
+<!--Generated by crowdin.com-->
 <!-- Generated by crowdin.net -->
 <resources>
   <string name="app">OpenVPN for Android</string>
diff --git a/ics-openvpn-stripped/main/src/main/res/values-pt/strings.xml b/ics-openvpn-stripped/main/src/main/res/values-pt/strings.xml
new file mode 100755
index 0000000000000000000000000000000000000000..9a9138f3d0710ae0c0d46102ad16e7667144fb65
--- /dev/null
+++ b/ics-openvpn-stripped/main/src/main/res/values-pt/strings.xml
@@ -0,0 +1,139 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--Generated by crowdin.com-->
+<!-- Generated by crowdin.net -->
+<resources>
+  <string name="app">OpenVPN para Android</string>
+  <string name="address">Endereço do Servidor:</string>
+  <string name="port">Porta:</string>
+  <string name="location">Localização</string>
+  <string name="cant_read_folder">Não foi possível ler o diretório</string>
+  <string name="select">Selecionar</string>
+  <string name="cancel">Cancelar</string>
+  <string name="no_data">Não há dados</string>
+  <string name="useLZO">Compressão LZO</string>
+  <string name="client_no_certificate">Sem Certificado</string>
+  <string name="client_certificate_title">Certificado do Cliente</string>
+  <string name="client_key_title">Chave do Certificado do Cliente</string>
+  <string name="client_pkcs12_title">Arquivo PKCS12</string>
+  <string name="ca_title">Certificado CA</string>
+  <string name="no_certificate">Você deve selecionar um certificado</string>
+  <string name="copyright_guicode">O código fonte e o rastreamento de incidentes estão disponíveis em  http://code.google.com/p/ics-openvpn/</string>
+  <string name="copyright_others">Este programa utiliza os seguintes componentes; veja o código fonte para mais detalhes das licenças</string>
+  <string name="about">Sobre</string>
+  <string name="vpn_list_title">Perfis</string>
+  <string name="vpn_type">Tipo</string>
+  <string name="pkcs12pwquery">Senha do PKCS12</string>
+  <string name="file_select">Selecionar&#8230;</string>
+  <string name="file_nothing_selected">Você deve selecionar um arquivo</string>
+  <string name="useTLSAuth">Utilizar Autenticação TLS</string>
+  <string name="tls_direction">Direção TLS</string>
+  <string name="ipv6_dialog_tile">Entre o Endereço IPv6/CIDR (ex: 2000:dd::23/64)</string>
+  <string name="ipv4_dialog_title">Entre o endereço IPv4/CIDR (ex: 1.2.3.4/24)</string>
+  <string name="ipv4_address">Endereço IPv4</string>
+  <string name="ipv6_address">Endereço IPv6</string>
+  <string name="custom_option_warning">Insira as opções personalizadas para o OpenVPN. Utilize com cuidado. Observe também que muitas das opções relacionadas ao tun do OpenVPN não podem ser suportadas pelo design do VPNSettings. Contate o autor se você acha que uma opção importante está faltando.</string>
+  <string name="auth_username">Usuário</string>
+  <string name="auth_pwquery">Senha</string>
+  <string name="static_keys_info">Para a configuração estática as chaves de autenticação de TLS serão utilizadas como chaves estáticas</string>
+  <string name="configure_the_vpn">Configurar VPN</string>
+  <string name="menu_add_profile">Adicionar Perfil</string>
+  <string name="add_profile_name_prompt">Digite um nome que identifica o novo perfil</string>
+  <string name="duplicate_profile_name">Por favor, digite um nome de perfil único</string>
+  <string name="profilename">Nome do perfil</string>
+  <string name="no_keystore_cert_selected">Você deve selecionar um certificado de usuário</string>
+  <string name="no_error_found">Nenhum erro encontrado</string>
+  <string name="config_error_found">Erro na configuração</string>
+  <string name="ipv4_format_error">Erro ao analisar o endereço IPv4</string>
+  <string name="custom_route_format_error">Erro ao analisar as rotas personalizadas</string>
+  <string name="pw_query_hint">(deixe em branco para consulta sob demanda)</string>
+  <string name="vpn_shortcut">Atalho do OpenVPN</string>
+  <string name="vpn_launch_title">Conectar a VPN</string>
+  <string name="shortcut_profile_notfound">O perfil especificado no atalho não foi encontrado</string>
+  <string name="random_host_prefix">Prefixo de Host aleatório</string>
+  <string name="random_host_summary">Adiciona 6 caracteres aleatórios na frente do hostname</string>
+  <string name="custom_config_title">Habilitar opções personalizadas</string>
+  <string name="custom_config_summary">Opções personalizadas. Use com cuidado!</string>
+  <string name="route_rejected">Rota rejeitada pelo Android</string>
+  <string name="cancel_connection">Desconectar</string>
+  <string name="cancel_connection_long">Desconectar VPN</string>
+  <string name="clear_log">limpar log</string>
+  <string name="title_cancel">Cancelar confirmação</string>
+  <string name="cancel_connection_query">Desconectar a VPN conectada/cancelar a tentativa de conexão?</string>
+  <string name="remove_vpn">Remover VPN</string>
+  <string name="check_remote_tlscert">Verifica se o servidor usa um certificado com as extensões de servidor TLS (- servidor remoto-cert-TLS)</string>
+  <string name="check_remote_tlscert_title">Esperar certificado do servidor TLS</string>
+  <string name="remote_tlscn_check_summary">Verifica o DN Subject do certificado do servidor remoto</string>
+  <string name="remote_tlscn_check_title">Verificar o Hostname do Certificado</string>
+  <string name="enter_tlscn_dialog">Especificar a conta usada para verificar o certificado remoto DN (por exemplo, C = DE, L = Paderborn, UO = aviária operadoras IP, CN=openvpn.blinkt.de)\n\Especificar o DN completo ou o RDN (openvpn.blinkt.de no exemplo) ou um prefixo RDN para verification.\n\nWhen usando o prefixo RDN \"Servidor\" corresponde a \"Server-1\" e \"Server-2\" \n\nDeixando vazio, o  campo de texto irá verificar o RDN contra o servidor hostname.\n\nPara mais detalhes consulte a página principal do 2.3.1+ OpenVPN sob — verificar-X509-nome</string>
+  <string name="enter_tlscn_title">Subject do certificado remoto</string>
+  <string name="tls_key_auth">Permite a Autenticação de Chave TLS</string>
+  <string name="tls_auth_file">Arquivo de Auth TLS</string>
+  <string name="pull_on_summary">Solicitações de endereços de IP, rotas e opções de sincronização do servidor.</string>
+  <string name="pull_off_summary">Nenhuma informação é solicitada do servidor. Configurações precisam ser especificadas abaixo.</string>
+  <string name="use_pull">Obter Configurações</string>
+  <string name="dns">DNS</string>
+  <string name="override_dns">Substituir as configurações de DNS pelo servidor</string>
+  <string name="dns_override_summary">Use seus próprios servidores de DNS</string>
+  <string name="searchdomain">Domínio de pesquisa</string>
+  <string name="dns1_summary">Servidor DNS a ser usado.</string>
+  <string name="dns_server">Servidor DNS</string>
+  <string name="secondary_dns_message">Servidor DNS secundário utilizado caso o servidor primário esteja inacessível.</string>
+  <string name="backup_dns">Servidor DNS alternativo</string>
+  <string name="ignored_pushed_routes">Ignorar rotas empurradas</string>
+  <string name="ignore_routes_summary">Ignorar rota empurrada pelo servidor.</string>
+  <string name="default_route_summary">Redireccionar todo o tráfego pela VPN</string>
+  <string name="use_default_title">Usar rota padrão</string>
+  <string name="custom_route_message">Digite rotas personalizadas. Apenas indique destino em formato CIDR. \"10.0.0.0 / 8 2002 :: / 16\" iria dirigir as redes 10.0.0.0 / 8 e 2002 :: / 16 sobre a VPN.</string>
+  <string name="custom_route_message_excluded">As rotas que não devem ser encaminhados pelo VPN. Use a mesma sintaxe para rotas incluídas.</string>
+  <string name="custom_routes_title">Rotas personalizadas</string>
+  <string name="custom_routes_title_excluded">Redes excluídas</string>
+  <string name="log_verbosity_level">Nível de complexidade do log</string>
+  <string name="float_summary">Permite pacotes autenticados a partir de qualquer IP</string>
+  <string name="float_title">Permitir servidor flutuante</string>
+  <string name="custom_options_title">Opções personalizadas</string>
+  <string name="edit_vpn">Editar configurações de VPN</string>
+  <string name="remove_vpn_query">Remover o perfil VPN \'%s\'?</string>
+  <string name="tun_error_helpful">Em algumas imagens ICS personalizado a permissão em / dev / tun pode estar errada, ou o módulo tun pode estar faltando completamente. Para imagens CM9 tente a opção correção propriedade sobre as configurações gerais</string>
+  <string name="tun_open_error">Falha ao abrir a interface de tun</string>
+  <string name="error">"Erro:"</string>
+  <string name="clear">Claro</string>
+  <string name="last_openvpn_tun_config">Abrindo a interface tun:</string>
+  <string name="local_ip_info">Local IPv4: %1$s/%2$d IPv6:%3$s MTU:%4$d</string>
+  <string name="dns_server_info">Servidor DNS: %1$s, domínio: %2$s</string>
+  <string name="routes_info_incl">Rotas: %1$s %2$s</string>
+  <string name="routes_info_excl">Rotas excluídas: %1$s %2$s</string>
+  <string name="routes_debug">Rotas VpnService  instaladas: %1$s %2$s</string>
+  <string name="ip_not_cidr">Existem múltiplas informações de interface, %1$s e %2$s, a aplicação assume que o segundo endereço é um endereço \'peer\' do endereço remoto. Será usada uma máscara de rede /32 para o IP local. O modo estabelecido pela OpenVPN é \"%3$s\".</string>
+  <string name="route_not_cidr">Não consigo entender %1$s e %2$s como uma rota IP com máscara de rede CIDR, usando /32 como máscara de rede.</string>
+  <string name="route_not_netip">A rota %1$s/%2$s foi corrigida para %3$s/%2$s</string>
+  <string name="keychain_access">Não é possível aceder aos certificados \'Keychain Android\'. Isso pode ter sido causado por uma atualização de firmware ou uma restauração das configurações da app/app. Será necessário editar o perfil VPN e selecionar novamente o certificado nas configurações básicas para recriar a permissão e possibilitar o acesso ao certificado.</string>
+  <string name="version_info">%1$s %2$s</string>
+  <string name="send_logfile">Enviar arquivo de log</string>
+  <string name="send">Enviar</string>
+  <string name="ics_openvpn_log_file">Ficheiro de registo do ICS OpenVPN</string>
+  <string name="copied_entry">Entrada de registo copiada para a área de transferência</string>
+  <string name="tap_mode">Entrada de registo copiada para a área de transferência</string>
+  <string name="faq_tap_mode">A API VPN não permite o modo Tap em dispositivos sem acesso root. Desta forma não é possível oferecer suporte Tap nesta aplicação</string>
+  <string name="tap_faq2">Novamente? Você está brincando? Não, o modo tap não é suportado de maneira nenhuma e enviar mais emails a perguntar se eventualmente será, não irá ajudar.</string>
+  <string name="faq">Perguntas frequentes</string>
+  <string name="encryption">Encriptação</string>
+  <string name="menu_import_short">Importar</string>
+  <string name="import_vpn">Importar</string>
+  <string name="ipv4">IPv4</string>
+  <string name="ipv6">IPv6</string>
+  <string name="password">Senha</string>
+  <string name="generalsettings">Configurações</string>
+  <string name="advanced">Avançado</string>
+  <string name="ignore">Ignorar</string>
+  <string name="restart">Reiniciar</string>
+  <string name="state_connecting">Conectando</string>
+  <string name="state_auth">Autenticando</string>
+  <string name="state_connected">Conectado</string>
+  <string name="add">Add</string>
+  <string name="pauseVPN">Pausa VPN</string>
+  <string name="resumevpn">Retomar VPN</string>
+  <string name="uploaded_data">Upload</string>
+  <string name="downloaded_data">Download</string>
+  <string name="vpn_status">Vpn Status</string>
+  <string name="logview_options">Ver opções</string>
+</resources>
diff --git a/ics-openvpn-stripped/main/src/main/res/values-ru/strings.xml b/ics-openvpn-stripped/main/src/main/res/values-ru/strings.xml
index 6747bcab79ab6ccd758c4ea8bacf8725c576a8b3..13390642a532d58a154e96d87ac61229c64f7ff4 100755
--- a/ics-openvpn-stripped/main/src/main/res/values-ru/strings.xml
+++ b/ics-openvpn-stripped/main/src/main/res/values-ru/strings.xml
@@ -1,5 +1,5 @@
 <?xml version="1.0" encoding="utf-8"?>
-<!--Generated by crowdin.net-->
+<!--Generated by crowdin.com-->
 <!-- Generated by crowdin.net -->
 <resources>
   <string name="app">OpenVPN для Android</string>
@@ -215,6 +215,7 @@
   <string name="vpn_import_hint">Используйте &lt;img src=\"ic_menu_archive\"/&gt; кнопку для импорта существующих профилей (.ovpn or .conf) с вашей карты памяти.</string>
   <string name="faq_hint">Не забудьте заглянуть в FAQ. Также имеется краткое руководство.</string>
   <string name="faq_routing_title">Конфигурация маршрутизации/интерфейса</string>
+  <string name="faq_routing">Конфигурация маршрутизации и интерфейса производится не через традиционные ifconfig/route команды, а с помощью VPNService API. Это приводит к созданию другой конфигурации маршрутизации, отличной от конфигураций, используемых на других ОС. Конфигурация VPN-туннеля состоит из IP-адресов и сетей, которые должны направляться через этот интерфейс. Никаких особых партнерских адресов или адресов шлюза не требуется. Также не требуются и специальные маршруты для соединения с VPN-сервером (например, добавленные при использовании redirect-gateway). Следовательно, приложение будет игнорировать эти параметры при импорте конфигурации. Приложение с помощью VPNService API гарантирует, что подключение к серверу не направляется через VPN-туннель. Поддерживается направление через туннель только определенных сетей. Приложение пытается определить сети, которые не должны быть направлены через туннель (например, маршрут x.x.x.x y.y.y.y net_gateway) и вычисляет список маршрутов, в который не включаются эти маршруты, чтобы эмулировать поведение других платформ. Окна журналов и логов показывают конфигурацию сервиса VPN после установления соединения.</string>
   <string name="persisttun_summary">Не открывать диалог, когда происходит переподключение VPN.</string>
   <string name="persistent_tun_title">Постоянный tun</string>
   <string name="openvpn_log">OpenVPN Журнал</string>
@@ -291,6 +292,8 @@
   <string name="vpnbehaviour">Поведение VPN</string>
   <string name="allow_vpn_changes">Разрешить изменение VPN-профилей</string>
   <string name="hwkeychain">Аппаратное хранилище ключей:</string>
+  <string name="permission_icon_app">Иконка приложения пытается использовать OpenVPN для Android</string>
+  <string name="faq_vpndialog43">«Начиная с Android 4.3, диалог подтверждения VPN-соединения защищен от приложений, \"накладывающихся поверх экрана». Это приводит к тому, что диалоговое окно подтверждения не реагирует на сенсорные нажатия. Если у вас имеется приложение, использующее наложения, то это может вызвать такое поведение. Если вы обнаружите где-либо такое приложение, свяжитесь с автором приложения. Эта проблема затрагивает все VPN приложения на Android 4.3 и более поздних версиях. Смотрите также &lt; a href = \"http://code.google.com/p/ics-openvpn/issues/detail?id=185\" &gt; Проблему 185 &lt; &gt; для получения дополнительных сведений»</string>
   <string name="faq_vpndialog43_title">Окно подтверждения VPN для Android 4.3 и позже</string>
   <string name="donatePlayStore">Также Вы можете выразить благодарность в виде пожертвования на Play Store:</string>
   <string name="thanks_for_donation">Спасибо за пожертвование %s!</string>
@@ -308,8 +311,10 @@
   <string name="unhandled_exception">Неопознання ошибка: %1$s\n\n%2$s</string>
   <string name="unhandled_exception_context">%3$s: %1$s\n\n%2$s</string>
   <string name="faq_system_dialog_xposed">Если на Вашем устройстве установлены Рут права, Вы можете установить &lt;a href=\"http://xposed.info/\"&gt;Xposed framework&lt;/a&gt; и &lt;a href=\"http://repo.xposed.info/module/de.blinkt.vpndialogxposed\"&gt;модуль автоматического подтверждения диалога подключения VPN&lt;/a&gt; на свой страх и риск</string>
+  <string name="full_licenses">Полные тексты лицензий</string>
   <string name="blocklocal_summary">Сети напрямую доступные через локальный интерфейс не будут маршрутизированы через VPN. Отключите эту опцию чтобы направить трафик через VPN.</string>
   <string name="blocklocal_title">Не использовать VPN для локальных адресов</string>
+  <string name="userpw_file">Файл логина и пароля</string>
   <string name="imported_from_file">[Импортировано из: %s]</string>
   <string name="files_missing_hint">Некоторые файлы не найдены. Выберите файлы для импорта в профиль:</string>
   <string name="openvpn_is_no_free_vpn">Для использования данного приложения Вам необходим VPN провайдер/шлюз поддерживающий OpenVPN. Для получения информации по настройке собственного OpenVPN сервера: http://community.openvpn.net/</string>
diff --git a/ics-openvpn-stripped/main/src/main/res/values/strings.xml b/ics-openvpn-stripped/main/src/main/res/values/strings.xml
index a054d16b772893d222d7405fea51c35ca5275e13..8b302ad7f546e1d1ba509f709f45f9beada862d4 100755
--- a/ics-openvpn-stripped/main/src/main/res/values/strings.xml
+++ b/ics-openvpn-stripped/main/src/main/res/values/strings.xml
@@ -254,7 +254,7 @@
     <string name="start_vpn_ticker">Connecting to VPN %s</string>
     <string name="jelly_keystore_alphanumeric_bug">Some versions of Android 4.1 have problems if the name of the keystore certificate contains non alphanumeric characters (like spaces, underscores or dashes). Try to reimport the certificate without special characters</string>
     <string name="encryption_cipher">Encryption cipher</string>
-    <string name="packet_auth">Packets authentication</string>
+    <string name="packet_auth">Packet authentication</string>
     <string name="auth_dialog_title">Enter packet authentication method</string>
     <string name="mobile_info_extended">Running on %1$s (%2$s) %3$s, Android API %4$d, version %5$s, %6$s</string>
     <string name="built_by">built by %s</string>
@@ -319,4 +319,9 @@
     <string name="openvpn_is_no_free_vpn">To use this app you need a VPN provider/VPN gateway supporting OpenVPN (often provided by your employer). Check out http://community.openvpn.net/ for more information on OpenVPN and how to setup your own OpenVPN server.</string>
     <string name="import_log">Import log:</string>
     <string name="ip_looks_like_subnet">Vpn topology \"%3$s\" specified but ifconfig %1$s %2$s looks more like an IP address with a network mask. Assuming \"subnet\" topology.</string>
+    <string name="mssfix_invalid_value">mssfix value has to be a integer between 0 and 9000</string>
+    <string name="mssfix_value_dialog">Announce to TCP sessions running over the tunnel that they should limit their send packet sizes such that after OpenVPN has encapsulated them, the resulting UDP packet size that OpenVPN sends to its peer will not exceed this number of bytes. (default is 1450)</string>
+    <string name="mssfix_checkbox">Override MSS value of TCP payload</string>
+    <string name="mssfix_dialogtitle">Set MSS of TCP payload</string>
+
 </resources>
diff --git a/ics-openvpn-stripped/main/src/main/res/values/untranslatable.xml b/ics-openvpn-stripped/main/src/main/res/values/untranslatable.xml
index 4d2bc4d9a59f71b2fb46cbe8fe71f6fa3e5cf700..6845f984389bb8b83d256f34c675e1467070cd47 100644
--- a/ics-openvpn-stripped/main/src/main/res/values/untranslatable.xml
+++ b/ics-openvpn-stripped/main/src/main/res/values/untranslatable.xml
@@ -34,11 +34,12 @@
         <item>50</item>
         <item>-1</item>
     </string-array>
-
+    <string name="crash_toast_text">OpenVPN for Android crashed, crash reported</string>
+    
     <!-- These strings should not be visible to the user -->
     <string name="state_user_vpn_permission" translatable="false">Waiting for user permission to use VPN API</string>
     <string name="state_user_vpn_password" translatable="false">Waiting for user VPN password</string>
     <string name="state_user_vpn_password_cancelled" translatable="false">VPN password input dialog cancelled</string>
     <string name="state_user_vpn_permission_cancelled" translatable="false">VPN API permission dialog cancelled</string>
-    
-</resources>
\ No newline at end of file
+
+</resources>
diff --git a/ics-openvpn-stripped/main/src/ovpn3/java/de/blinkt/openvpn/core/OpenVPNThreadv3.java b/ics-openvpn-stripped/main/src/ovpn3/java/de/blinkt/openvpn/core/OpenVPNThreadv3.java
index 6d3dce691d32ff8c515d8a952b51fb56afb4276e..e595106c089031037f828dba3a600067331cfff2 100644
--- a/ics-openvpn-stripped/main/src/ovpn3/java/de/blinkt/openvpn/core/OpenVPNThreadv3.java
+++ b/ics-openvpn-stripped/main/src/ovpn3/java/de/blinkt/openvpn/core/OpenVPNThreadv3.java
@@ -14,9 +14,7 @@ import net.openvpn.ovpn3.ClientAPI_TransportStats;
 import java.lang.Override;
 
 import de.blinkt.openvpn.VpnProfile;
-import de.blinkt.openvpn.core.OpenVPNManagement;
-import de.blinkt.openvpn.core.OpenVpnService;
-import de.blinkt.openvpn.core.VpnStatus;
+
 import android.content.Context;
 
 public class OpenVPNThreadv3 extends ClientAPI_OpenVPNClient implements Runnable, OpenVPNManagement {
@@ -29,7 +27,7 @@ public class OpenVPNThreadv3 extends ClientAPI_OpenVPNClient implements Runnable
 	}
 
 	private VpnProfile mVp;
-	private OpenVpnService mService;
+	private OpenVPNService mService;
 
 	class StatusPoller implements  Runnable 
 	{
@@ -224,7 +222,7 @@ public class OpenVPNThreadv3 extends ClientAPI_OpenVPNClient implements Runnable
 
 	}
 
-	public OpenVPNThreadv3(OpenVpnService openVpnService, VpnProfile vp) {
+	public OpenVPNThreadv3(OpenVPNService openVpnService, VpnProfile vp) {
 		init_process();
 		mVp =vp;
 		mService =openVpnService;