summaryrefslogtreecommitdiff
path: root/src/de/blinkt/openvpn/core
diff options
context:
space:
mode:
authorArne Schwabe <arne@rfc2549.org>2013-08-20 13:27:49 +0200
committerArne Schwabe <arne@rfc2549.org>2013-08-20 13:27:49 +0200
commit8dbfc2cf65c808827058d426cf57932eb9eaefc4 (patch)
tree34e7b9fc9a220b28af2642c2b16139ccff944da3 /src/de/blinkt/openvpn/core
parent20b5cac307978d787333f4050ce28011f42bcfd0 (diff)
Rename OpenVPN class to a VPNStatus
--HG-- rename : src/de/blinkt/openvpn/core/OpenVPN.java => src/de/blinkt/openvpn/core/VpnStatus.java
Diffstat (limited to 'src/de/blinkt/openvpn/core')
-rw-r--r--src/de/blinkt/openvpn/core/DeviceStateReceiver.java8
-rw-r--r--src/de/blinkt/openvpn/core/OpenVPNThread.java22
-rw-r--r--src/de/blinkt/openvpn/core/OpenVpnManagementThread.java34
-rw-r--r--src/de/blinkt/openvpn/core/OpenVpnService.java60
-rw-r--r--src/de/blinkt/openvpn/core/ProxyDetection.java4
-rw-r--r--src/de/blinkt/openvpn/core/VPNLaunchHelper.java12
-rw-r--r--src/de/blinkt/openvpn/core/VpnStatus.java (renamed from src/de/blinkt/openvpn/core/OpenVPN.java)22
-rw-r--r--src/de/blinkt/openvpn/core/X509Utils.java2
8 files changed, 86 insertions, 78 deletions
diff --git a/src/de/blinkt/openvpn/core/DeviceStateReceiver.java b/src/de/blinkt/openvpn/core/DeviceStateReceiver.java
index 2c1db63c..8a148e10 100644
--- a/src/de/blinkt/openvpn/core/DeviceStateReceiver.java
+++ b/src/de/blinkt/openvpn/core/DeviceStateReceiver.java
@@ -9,7 +9,7 @@ import android.net.NetworkInfo;
import android.net.NetworkInfo.State;
import android.preference.PreferenceManager;
import de.blinkt.openvpn.R;
-import de.blinkt.openvpn.core.OpenVPN.ByteCountListener;
+import de.blinkt.openvpn.core.VpnStatus.ByteCountListener;
import java.util.LinkedList;
@@ -67,7 +67,7 @@ public class DeviceStateReceiver extends BroadcastReceiver implements ByteCountL
if (windowtraffic < TRAFFIC_LIMIT) {
screen = connectState.DISCONNECTED;
- OpenVPN.logInfo(R.string.screenoff_pause,
+ VpnStatus.logInfo(R.string.screenoff_pause,
OpenVpnService.humanReadableByteCount(TRAFFIC_LIMIT, false), TRAFFIC_WINDOW);
mManagement.pause(getPauseReason());
@@ -109,7 +109,7 @@ public class DeviceStateReceiver extends BroadcastReceiver implements ByteCountL
if (screenOffPause) {
if (!ProfileManager.getLastConnectedVpn().mPersistTun)
- OpenVPN.logError(R.string.screen_nopersistenttun);
+ VpnStatus.logError(R.string.screen_nopersistenttun);
screen = connectState.PENDINGDISCONNECT;
fillTrafficData();
@@ -203,7 +203,7 @@ public class DeviceStateReceiver extends BroadcastReceiver implements ByteCountL
if (!netstatestring.equals(lastStateMsg))
- OpenVPN.logInfo(R.string.netstatus, netstatestring);
+ VpnStatus.logInfo(R.string.netstatus, netstatestring);
lastStateMsg = netstatestring;
}
diff --git a/src/de/blinkt/openvpn/core/OpenVPNThread.java b/src/de/blinkt/openvpn/core/OpenVPNThread.java
index 100990bb..da6a394a 100644
--- a/src/de/blinkt/openvpn/core/OpenVPNThread.java
+++ b/src/de/blinkt/openvpn/core/OpenVPNThread.java
@@ -3,8 +3,8 @@ package de.blinkt.openvpn.core;
import android.util.Log;
import de.blinkt.openvpn.R;
import de.blinkt.openvpn.VpnProfile;
-import de.blinkt.openvpn.core.OpenVPN.ConnectionStatus;
-import de.blinkt.openvpn.core.OpenVPN.LogItem;
+import de.blinkt.openvpn.core.VpnStatus.ConnectionStatus;
+import de.blinkt.openvpn.core.VpnStatus.LogItem;
import java.io.*;
import java.text.SimpleDateFormat;
@@ -50,26 +50,26 @@ public class OpenVPNThread implements Runnable {
if (mProcess!=null)
exitvalue = mProcess.waitFor();
} catch ( IllegalThreadStateException ite) {
- OpenVPN.logError("Illegal Thread state: " + ite.getLocalizedMessage());
+ VpnStatus.logError("Illegal Thread state: " + ite.getLocalizedMessage());
} catch (InterruptedException ie) {
- OpenVPN.logError("InterruptedException: " + ie.getLocalizedMessage());
+ VpnStatus.logError("InterruptedException: " + ie.getLocalizedMessage());
}
if( exitvalue != 0)
- OpenVPN.logError("Process exited with exit value " + exitvalue);
+ VpnStatus.logError("Process exited with exit value " + exitvalue);
- OpenVPN.updateStateString("NOPROCESS","No process running.", R.string.state_noprocess,ConnectionStatus.LEVEL_NOTCONNECTED);
+ VpnStatus.updateStateString("NOPROCESS", "No process running.", R.string.state_noprocess, ConnectionStatus.LEVEL_NOTCONNECTED);
if(mDumpPath!=null) {
try {
BufferedWriter logout = new BufferedWriter(new FileWriter(mDumpPath + ".log"));
SimpleDateFormat timeformat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss",Locale.GERMAN);
- for(LogItem li :OpenVPN.getlogbuffer()){
+ for(LogItem li : VpnStatus.getlogbuffer()){
String time = timeformat.format(new Date(li.getLogtime()));
logout.write(time +" " + li.getString(mService) + "\n");
}
logout.close();
- OpenVPN.logError(R.string.minidump_generated);
+ VpnStatus.logError(R.string.minidump_generated);
} catch (IOException e) {
- OpenVPN.logError("Writing minidump log: " +e.getLocalizedMessage());
+ VpnStatus.logError("Writing minidump log: " + e.getLocalizedMessage());
}
}
@@ -111,12 +111,12 @@ public class OpenVPNThread implements Runnable {
mDumpPath = logline.substring(DUMP_PATH_STRING.length());
- OpenVPN.logMessage(0, "P:", logline);
+ VpnStatus.logMessage(0, "P:", logline);
}
} catch (IOException e) {
- OpenVPN.logMessage(0, "", "Error reading from output of OpenVPN process"+ e.getLocalizedMessage());
+ VpnStatus.logMessage(0, "", "Error reading from output of OpenVPN process" + e.getLocalizedMessage());
e.printStackTrace();
stopProcess();
}
diff --git a/src/de/blinkt/openvpn/core/OpenVpnManagementThread.java b/src/de/blinkt/openvpn/core/OpenVpnManagementThread.java
index e2ac1526..7e436f79 100644
--- a/src/de/blinkt/openvpn/core/OpenVpnManagementThread.java
+++ b/src/de/blinkt/openvpn/core/OpenVpnManagementThread.java
@@ -13,7 +13,7 @@ import org.jetbrains.annotations.NotNull;
import de.blinkt.openvpn.R;
import de.blinkt.openvpn.VpnProfile;
-import de.blinkt.openvpn.core.OpenVPN.ConnectionStatus;
+import de.blinkt.openvpn.core.VpnStatus.ConnectionStatus;
import java.io.FileDescriptor;
import java.io.IOException;
@@ -131,7 +131,7 @@ public class OpenVpnManagementThread implements Runnable, OpenVPNManagement {
try {
fds = mSocket.getAncillaryFileDescriptors();
} catch (IOException e) {
- OpenVPN.logMessage(0, "", "Error reading fds from socket" + e.getLocalizedMessage());
+ VpnStatus.logMessage(0, "", "Error reading fds from socket" + e.getLocalizedMessage());
e.printStackTrace();
}
if(fds!=null){
@@ -182,7 +182,7 @@ public class OpenVpnManagementThread implements Runnable, OpenVPNManagement {
exp.printStackTrace();
Log.d("Openvpn", "Failed to retrieve fd from socket: " + fd);
- OpenVPN.logMessage(0, "", "Failed to retrieve fd from socket: " + exp.getLocalizedMessage());
+ VpnStatus.logMessage(0, "", "Failed to retrieve fd from socket: " + exp.getLocalizedMessage());
}
private String processInput(String pendingInput) {
@@ -228,11 +228,11 @@ public class OpenVpnManagementThread implements Runnable, OpenVPNManagement {
// 0 unix time stamp
// 1 log level N,I,E etc.
// 2 log message
- OpenVPN.logMessage(0, "", args[2]);
+ VpnStatus.logMessage(0, "", args[2]);
} else if (cmd.equals("RSA_SIGN")) {
processSignCommand(argument);
} else {
- OpenVPN.logMessage(0, "MGMT:", "Got unrecognized command" + command);
+ VpnStatus.logMessage(0, "MGMT:", "Got unrecognized command" + command);
Log.i(TAG, "Got unrecognized command" + command);
}
} else if (command.startsWith("SUCCESS:")) {
@@ -240,7 +240,7 @@ public class OpenVpnManagementThread implements Runnable, OpenVPNManagement {
return;
} else {
Log.i(TAG, "Got unrecognized line from managment" + command);
- OpenVPN.logMessage(0, "MGMT:", "Got unrecognized line from management:" + command);
+ VpnStatus.logMessage(0, "MGMT:", "Got unrecognized line from management:" + command);
}
}
private void handleHold() {
@@ -249,7 +249,7 @@ public class OpenVpnManagementThread implements Runnable, OpenVPNManagement {
} else {
mWaitingForRelease=true;
- OpenVPN.updateStatePause(lastPauseReason);
+ VpnStatus.updateStatePause(lastPauseReason);
}
@@ -292,7 +292,7 @@ public class OpenVpnManagementThread implements Runnable, OpenVPNManagement {
if(proxyaddr instanceof InetSocketAddress ){
InetSocketAddress isa = (InetSocketAddress) proxyaddr;
- OpenVPN.logInfo(R.string.using_proxy, isa.getHostName(),isa.getPort());
+ 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);
@@ -305,9 +305,9 @@ public class OpenVpnManagementThread implements Runnable, OpenVPNManagement {
String[] args = argument.split(",",3);
String currentstate = args[1];
if(args[2].equals(",,"))
- OpenVPN.updateStateString(currentstate,"");
+ VpnStatus.updateStateString(currentstate, "");
else
- OpenVPN.updateStateString(currentstate,args[2]);
+ VpnStatus.updateStateString(currentstate, args[2]);
}
@@ -317,7 +317,7 @@ public class OpenVpnManagementThread implements Runnable, OpenVPNManagement {
long in = Long.parseLong(argument.substring(0, comma));
long out = Long.parseLong(argument.substring(comma+1));
- OpenVPN.updateByteCount(in,out);
+ VpnStatus.updateByteCount(in, out);
}
@@ -373,7 +373,7 @@ public class OpenVpnManagementThread implements Runnable, OpenVPNManagement {
if(!extra.equals("tun")) {
// We only support tun
String errmsg = String.format("Devicetype %s requested, but only tun is possible with the Android API, sorry!",extra);
- OpenVPN.logMessage(0, "", errmsg );
+ VpnStatus.logMessage(0, "", errmsg);
return false;
}
@@ -416,7 +416,7 @@ public class OpenVpnManagementThread implements Runnable, OpenVPNManagement {
} catch (IOException e) {
exp =e;
}
- OpenVPN.logMessage(0, "", "Could not send fd over socket:" + exp.getLocalizedMessage());
+ VpnStatus.logMessage(0, "", "Could not send fd over socket:" + exp.getLocalizedMessage());
exp.printStackTrace();
return false;
@@ -439,7 +439,7 @@ public class OpenVpnManagementThread implements Runnable, OpenVPNManagement {
return;
}
} catch (StringIndexOutOfBoundsException sioob) {
- OpenVPN.logMessage(0, "", "Could not parse management Password command: " + argument);
+ VpnStatus.logMessage(0, "", "Could not parse management Password command: " + argument);
return;
}
@@ -457,7 +457,7 @@ public class OpenVpnManagementThread implements Runnable, OpenVPNManagement {
String cmd = String.format("password '%s' %s\n", needed, VpnProfile.openVpnEscape(pw));
managmentCommand(cmd);
} else {
- OpenVPN.logMessage(0, OpenVPN.MANAGMENT_PREFIX, String.format("Openvpn requires Authentication type '%s' but no password/key information available", needed));
+ VpnStatus.logMessage(0, VpnStatus.MANAGMENT_PREFIX, String.format("Openvpn requires Authentication type '%s' but no password/key information available", needed));
}
}
@@ -466,7 +466,7 @@ public class OpenVpnManagementThread implements Runnable, OpenVPNManagement {
private void proccessPWFailed(String needed, String args) {
- OpenVPN.updateStateString("AUTH_FAILED", needed + args,R.string.state_auth_failed,ConnectionStatus.LEVEL_AUTH_FAILED);
+ VpnStatus.updateStateString("AUTH_FAILED", needed + args, R.string.state_auth_failed, ConnectionStatus.LEVEL_AUTH_FAILED);
}
@@ -493,7 +493,7 @@ public class OpenVpnManagementThread implements Runnable, OpenVPNManagement {
else
// If signalusr1 is called update the state string
// if there is another for stopping
- OpenVPN.updateStatePause(lastPauseReason);
+ VpnStatus.updateStatePause(lastPauseReason);
}
public void reconnect() {
diff --git a/src/de/blinkt/openvpn/core/OpenVpnService.java b/src/de/blinkt/openvpn/core/OpenVpnService.java
index e703e579..37c0d94f 100644
--- a/src/de/blinkt/openvpn/core/OpenVpnService.java
+++ b/src/de/blinkt/openvpn/core/OpenVpnService.java
@@ -17,9 +17,9 @@ import android.preference.PreferenceManager;
import de.blinkt.openvpn.LogWindow;
import de.blinkt.openvpn.R;
import de.blinkt.openvpn.VpnProfile;
-import de.blinkt.openvpn.core.OpenVPN.ByteCountListener;
-import de.blinkt.openvpn.core.OpenVPN.ConnectionStatus;
-import de.blinkt.openvpn.core.OpenVPN.StateListener;
+import de.blinkt.openvpn.core.VpnStatus.ByteCountListener;
+import de.blinkt.openvpn.core.VpnStatus.ConnectionStatus;
+import de.blinkt.openvpn.core.VpnStatus.StateListener;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
@@ -27,7 +27,7 @@ import java.util.HashMap;
import java.util.Locale;
import java.util.Vector;
-import static de.blinkt.openvpn.core.OpenVPN.ConnectionStatus.*;
+import static de.blinkt.openvpn.core.VpnStatus.ConnectionStatus.*;
public class OpenVpnService extends VpnService implements StateListener, Callback, ByteCountListener {
public static final String START_SERVICE = "de.blinkt.openvpn.START_SERVICE";
@@ -93,7 +93,7 @@ public class OpenVpnService extends VpnService implements StateListener, Callbac
private void endVpnService() {
mProcessThread = null;
- OpenVPN.removeByteCountListener(this);
+ VpnStatus.removeByteCountListener(this);
unregisterDeviceStateReceiver();
ProfileManager.setConntectedVpnProfileDisconnected(this);
if (!mStarting) {
@@ -101,7 +101,7 @@ public class OpenVpnService extends VpnService implements StateListener, Callbac
if (!mNotificationAlwaysVisible) {
stopSelf();
- OpenVPN.removeStateListener(this);
+ VpnStatus.removeStateListener(this);
}
}
}
@@ -235,13 +235,13 @@ public class OpenVpnService extends VpnService implements StateListener, Callbac
filter.addAction(Intent.ACTION_SCREEN_ON);
mDeviceStateReceiver = new DeviceStateReceiver(magnagement);
registerReceiver(mDeviceStateReceiver, filter);
- OpenVPN.addByteCountListener(mDeviceStateReceiver);
+ VpnStatus.addByteCountListener(mDeviceStateReceiver);
}
synchronized void unregisterDeviceStateReceiver() {
if (mDeviceStateReceiver != null)
try {
- OpenVPN.removeByteCountListener(mDeviceStateReceiver);
+ VpnStatus.removeByteCountListener(mDeviceStateReceiver);
this.unregisterReceiver(mDeviceStateReceiver);
} catch (IllegalArgumentException iae) {
// I don't know why this happens:
@@ -258,8 +258,8 @@ public class OpenVpnService extends VpnService implements StateListener, Callbac
if (intent != null && intent.getBooleanExtra(ALWAYS_SHOW_NOTIFICATION, false))
mNotificationAlwaysVisible = true;
- OpenVPN.addStateListener(this);
- OpenVPN.addByteCountListener(this);
+ VpnStatus.addStateListener(this);
+ VpnStatus.addByteCountListener(this);
if (intent != null && PAUSE_VPN.equals(intent.getAction())) {
if (mDeviceStateReceiver != null)
@@ -329,7 +329,7 @@ public class OpenVpnService extends VpnService implements StateListener, Callbac
Thread mSocketManagerThread = new Thread(ovpnManagementThread, "OpenVPNManagementThread");
mSocketManagerThread.start();
mManagement = ovpnManagementThread;
- OpenVPN.logInfo("started Socket Thread");
+ VpnStatus.logInfo("started Socket Thread");
}
}
@@ -381,7 +381,7 @@ public class OpenVpnService extends VpnService implements StateListener, Callbac
this.unregisterReceiver(mDeviceStateReceiver);
}
// Just in case unregister for state
- OpenVPN.removeStateListener(this);
+ VpnStatus.removeStateListener(this);
}
@@ -389,7 +389,7 @@ public class OpenVpnService extends VpnService implements StateListener, Callbac
Builder builder = new Builder();
if (mLocalIP == null && mLocalIPv6 == null) {
- OpenVPN.logMessage(0, "", getString(R.string.opentun_no_ipaddr));
+ VpnStatus.logMessage(0, "", getString(R.string.opentun_no_ipaddr));
return null;
}
@@ -397,7 +397,7 @@ public class OpenVpnService extends VpnService implements StateListener, Callbac
try {
builder.addAddress(mLocalIP.mIp, mLocalIP.len);
} catch (IllegalArgumentException iae) {
- OpenVPN.logError(R.string.dns_add_error, mLocalIP, iae.getLocalizedMessage());
+ VpnStatus.logError(R.string.dns_add_error, mLocalIP, iae.getLocalizedMessage());
return null;
}
}
@@ -407,7 +407,7 @@ public class OpenVpnService extends VpnService implements StateListener, Callbac
try {
builder.addAddress(ipv6parts[0], Integer.parseInt(ipv6parts[1]));
} catch (IllegalArgumentException iae) {
- OpenVPN.logError(R.string.dns_add_error, mLocalIPv6, iae.getLocalizedMessage());
+ VpnStatus.logError(R.string.ip_add_error, mLocalIPv6, iae.getLocalizedMessage());
return null;
}
@@ -418,7 +418,7 @@ public class OpenVpnService extends VpnService implements StateListener, Callbac
try {
builder.addDnsServer(dns);
} catch (IllegalArgumentException iae) {
- OpenVPN.logError(R.string.dns_add_error, dns, iae.getLocalizedMessage());
+ VpnStatus.logError(R.string.dns_add_error, dns, iae.getLocalizedMessage());
}
}
@@ -430,7 +430,7 @@ public class OpenVpnService extends VpnService implements StateListener, Callbac
try {
builder.addRoute(route.mIp, route.len);
} catch (IllegalArgumentException ia) {
- OpenVPN.logMessage(0, "", getString(R.string.route_rejected) + route + " " + ia.getLocalizedMessage());
+ VpnStatus.logMessage(0, "", getString(R.string.route_rejected) + route + " " + ia.getLocalizedMessage());
}
}
@@ -439,18 +439,18 @@ public class OpenVpnService extends VpnService implements StateListener, Callbac
String[] v6parts = v6route.split("/");
builder.addRoute(v6parts[0], Integer.parseInt(v6parts[1]));
} catch (IllegalArgumentException ia) {
- OpenVPN.logMessage(0, "", getString(R.string.route_rejected) + v6route + " " + ia.getLocalizedMessage());
+ VpnStatus.logMessage(0, "", getString(R.string.route_rejected) + v6route + " " + ia.getLocalizedMessage());
}
}
if (mDomain != null)
builder.addSearchDomain(mDomain);
- OpenVPN.logInfo(R.string.last_openvpn_tun_config);
- OpenVPN.logInfo(R.string.local_ip_info, mLocalIP.mIp, mLocalIP.len, mLocalIPv6, mMtu);
- OpenVPN.logInfo(R.string.dns_server_info, joinString(mDnslist), mDomain);
- OpenVPN.logInfo(R.string.routes_info, joinString(mRoutes));
- OpenVPN.logInfo(R.string.routes_info6, joinString(mRoutesv6));
+ VpnStatus.logInfo(R.string.last_openvpn_tun_config);
+ VpnStatus.logInfo(R.string.local_ip_info, mLocalIP.mIp, mLocalIP.len, mLocalIPv6, mMtu);
+ VpnStatus.logInfo(R.string.dns_server_info, joinString(mDnslist), mDomain);
+ VpnStatus.logInfo(R.string.routes_info, joinString(mRoutes));
+ VpnStatus.logInfo(R.string.routes_info6, joinString(mRoutesv6));
String session = mProfile.mName;
if (mLocalIP != null && mLocalIPv6 != null)
@@ -462,7 +462,7 @@ public class OpenVpnService extends VpnService implements StateListener, Callbac
// No DNS Server, log a warning
if (mDnslist.size() == 0)
- OpenVPN.logInfo(R.string.warn_no_dns);
+ VpnStatus.logInfo(R.string.warn_no_dns);
// Reset information
mDnslist.clear();
@@ -477,9 +477,9 @@ public class OpenVpnService extends VpnService implements StateListener, Callbac
try {
return builder.establish();
} catch (Exception e) {
- OpenVPN.logMessage(0, "", getString(R.string.tun_open_error));
- OpenVPN.logMessage(0, "", getString(R.string.error) + e.getLocalizedMessage());
- OpenVPN.logMessage(0, "", getString(R.string.tun_error_helpful));
+ VpnStatus.logMessage(0, "", getString(R.string.tun_open_error));
+ VpnStatus.logMessage(0, "", getString(R.string.error) + e.getLocalizedMessage());
+ VpnStatus.logMessage(0, "", getString(R.string.tun_error_helpful));
return null;
}
@@ -510,11 +510,11 @@ public class OpenVpnService extends VpnService implements StateListener, Callbac
public void addRoute(String dest, String mask) {
CIDRIP route = new CIDRIP(dest, mask);
if (route.len == 32 && !mask.equals("255.255.255.255")) {
- OpenVPN.logMessage(0, "", getString(R.string.route_not_cidr, dest, mask));
+ VpnStatus.logMessage(0, "", getString(R.string.route_not_cidr, dest, mask));
}
if (route.normalise())
- OpenVPN.logMessage(0, "", getString(R.string.route_not_netip, dest, route.len, route.mIp));
+ VpnStatus.logMessage(0, "", getString(R.string.route_not_netip, dest, route.len, route.mIp));
mRoutes.add(route);
}
@@ -544,7 +544,7 @@ public class OpenVpnService extends VpnService implements StateListener, Callbac
else
mLocalIP.len = 31;
} else {
- OpenVPN.logMessage(0, "", getString(R.string.ip_not_cidr, local, netmask, mode));
+ VpnStatus.logMessage(0, "", getString(R.string.ip_not_cidr, local, netmask, mode));
}
}
}
diff --git a/src/de/blinkt/openvpn/core/ProxyDetection.java b/src/de/blinkt/openvpn/core/ProxyDetection.java
index bc8bf293..4f66c503 100644
--- a/src/de/blinkt/openvpn/core/ProxyDetection.java
+++ b/src/de/blinkt/openvpn/core/ProxyDetection.java
@@ -27,9 +27,9 @@ public class ProxyDetection {
}
} catch (MalformedURLException e) {
- OpenVPN.logError(R.string.getproxy_error,e.getLocalizedMessage());
+ VpnStatus.logError(R.string.getproxy_error, e.getLocalizedMessage());
} catch (URISyntaxException e) {
- OpenVPN.logError(R.string.getproxy_error,e.getLocalizedMessage());
+ VpnStatus.logError(R.string.getproxy_error, e.getLocalizedMessage());
}
return null;
}
diff --git a/src/de/blinkt/openvpn/core/VPNLaunchHelper.java b/src/de/blinkt/openvpn/core/VPNLaunchHelper.java
index 7d14ee6b..f6e8e0e3 100644
--- a/src/de/blinkt/openvpn/core/VPNLaunchHelper.java
+++ b/src/de/blinkt/openvpn/core/VPNLaunchHelper.java
@@ -26,7 +26,7 @@ public class VPNLaunchHelper {
mvpn = context.getAssets().open("minivpn." + Build.CPU_ABI);
}
catch (IOException errabi) {
- OpenVPN.logInfo("Failed getting assets for archicture " + Build.CPU_ABI);
+ VpnStatus.logInfo("Failed getting assets for archicture " + Build.CPU_ABI);
e2=errabi;
mvpn = context.getAssets().open("minivpn." + Build.CPU_ABI2);
@@ -45,7 +45,7 @@ public class VPNLaunchHelper {
fout.close();
if(!mvpnout.setExecutable(true)) {
- OpenVPN.logMessage(0, "","Failed to set minivpn executable");
+ VpnStatus.logMessage(0, "", "Failed to set minivpn executable");
return false;
}
@@ -53,8 +53,8 @@ public class VPNLaunchHelper {
return true;
} catch (IOException e) {
if(e2!=null)
- OpenVPN.logMessage(0, "",e2.getLocalizedMessage());
- OpenVPN.logMessage(0, "",e.getLocalizedMessage());
+ VpnStatus.logMessage(0, "", e2.getLocalizedMessage());
+ VpnStatus.logMessage(0, "", e.getLocalizedMessage());
e.printStackTrace();
return false;
}
@@ -63,10 +63,10 @@ public class VPNLaunchHelper {
public static void startOpenVpn(VpnProfile startprofile, Context context) {
if(!writeMiniVPN(context)) {
- OpenVPN.logMessage(0, "", "Error writing minivpn binary");
+ VpnStatus.logMessage(0, "", "Error writing minivpn binary");
return;
}
- OpenVPN.logMessage(0, "", context.getString(R.string.building_configration));
+ VpnStatus.logMessage(0, "", context.getString(R.string.building_configration));
Intent startVPN = startprofile.prepareIntent(context);
if(startVPN!=null)
diff --git a/src/de/blinkt/openvpn/core/OpenVPN.java b/src/de/blinkt/openvpn/core/VpnStatus.java
index af090204..86f0f727 100644
--- a/src/de/blinkt/openvpn/core/OpenVPN.java
+++ b/src/de/blinkt/openvpn/core/VpnStatus.java
@@ -20,9 +20,10 @@ import java.security.cert.X509Certificate;
import java.util.Arrays;
import java.util.LinkedList;
import java.util.Locale;
+import java.util.UnknownFormatConversionException;
import java.util.Vector;
-public class OpenVPN {
+public class VpnStatus {
public static LinkedList<LogItem> logbuffer;
@@ -61,9 +62,9 @@ public class OpenVPN {
static {
logbuffer = new LinkedList<LogItem>();
- logListener = new Vector<OpenVPN.LogListener>();
- stateListener = new Vector<OpenVPN.StateListener>();
- byteCountListener = new Vector<OpenVPN.ByteCountListener>();
+ logListener = new Vector<VpnStatus.LogListener>();
+ stateListener = new Vector<VpnStatus.StateListener>();
+ byteCountListener = new Vector<VpnStatus.ByteCountListener>();
logInformation();
}
@@ -142,6 +143,7 @@ public class OpenVPN {
}
public String getString(Context c) {
+ try {
if(mMessage !=null) {
return mMessage;
} else {
@@ -161,6 +163,12 @@ public class OpenVPN {
return str;
}
}
+ } catch (UnknownFormatConversionException e) {
+ if (c != null)
+ throw new UnknownFormatConversionException(e.getLocalizedMessage() + getString(null));
+ else
+ throw e;
+ }
}
// The lint is wrong here
@@ -304,13 +312,13 @@ public class OpenVPN {
public static void updateStatePause(OpenVPNManagement.pauseReason pauseReason) {
switch (pauseReason) {
case noNetwork:
- OpenVPN.updateStateString("NONETWORK", "", R.string.state_nonetwork, ConnectionStatus.LEVEL_NONETWORK);
+ VpnStatus.updateStateString("NONETWORK", "", R.string.state_nonetwork, ConnectionStatus.LEVEL_NONETWORK);
break;
case screenOff:
- OpenVPN.updateStateString("SCREENOFF", "", R.string.state_screenoff, ConnectionStatus.LEVEL_VPNPAUSED);
+ VpnStatus.updateStateString("SCREENOFF", "", R.string.state_screenoff, ConnectionStatus.LEVEL_VPNPAUSED);
break;
case userPause:
- OpenVPN.updateStateString("USERPAUSE", "", R.string.state_userpause, ConnectionStatus.LEVEL_VPNPAUSED);
+ VpnStatus.updateStateString("USERPAUSE", "", R.string.state_userpause, ConnectionStatus.LEVEL_VPNPAUSED);
break;
}
diff --git a/src/de/blinkt/openvpn/core/X509Utils.java b/src/de/blinkt/openvpn/core/X509Utils.java
index efdda3ca..f6bd7774 100644
--- a/src/de/blinkt/openvpn/core/X509Utils.java
+++ b/src/de/blinkt/openvpn/core/X509Utils.java
@@ -67,7 +67,7 @@ public class X509Utils {
return getCertificateFriendlyName(cert);
} catch (Exception e) {
- OpenVPN.logError("Could not read certificate" + e.getLocalizedMessage());
+ VpnStatus.logError("Could not read certificate" + e.getLocalizedMessage());
}
}
return c.getString(R.string.cannotparsecert);