diff options
author | Arne Schwabe <arne@rfc2549.org> | 2016-03-23 16:39:00 +0100 |
---|---|---|
committer | Arne Schwabe <arne@rfc2549.org> | 2016-03-23 16:39:00 +0100 |
commit | 237836932b2f3a66a08a7020332496c96916e662 (patch) | |
tree | c79457937b6a399556f0baa8736e6c24f2ee1077 /main/src | |
parent | a6b5b603a65e653dcd1aa02e7d0ceffa502f77bb (diff) |
More fixes in LogFileHandler
Diffstat (limited to 'main/src')
-rw-r--r-- | main/src/main/java/de/blinkt/openvpn/core/LogFileHandler.java | 17 | ||||
-rw-r--r-- | main/src/main/java/de/blinkt/openvpn/fragments/Utils.java | 11 |
2 files changed, 15 insertions, 13 deletions
diff --git a/main/src/main/java/de/blinkt/openvpn/core/LogFileHandler.java b/main/src/main/java/de/blinkt/openvpn/core/LogFileHandler.java index 77bb26dc..a30cde5b 100644 --- a/main/src/main/java/de/blinkt/openvpn/core/LogFileHandler.java +++ b/main/src/main/java/de/blinkt/openvpn/core/LogFileHandler.java @@ -136,12 +136,12 @@ class LogFileHandler extends Handler { } else { VpnStatus.logError(String.format(Locale.getDefault(), "Could not read log item from file: %d/%d: %s", - read, len, Utils.bytesToHex(buf, read))); + read, len, bytesToHex(buf, Math.max(read,80)))); } p.recycle(); //Next item - read = logFile.read(buf, 0, 2); + read = logFile.read(buf, 0, 4); itemsRead++; if (itemsRead > 2*VpnStatus.MAXLOGENTRIES) { VpnStatus.logError("Too many logentries read from cache, aborting."); @@ -161,4 +161,17 @@ class LogFileHandler extends Handler { } } + final protected static char[] hexArray = "0123456789ABCDEF".toCharArray(); + public static String bytesToHex(byte[] bytes, int len) { + len = Math.min(bytes.length, len); + char[] hexChars = new char[len * 2]; + for ( int j = 0; j < len; j++ ) { + int v = bytes[j] & 0xFF; + hexChars[j * 2] = hexArray[v >>> 4]; + hexChars[j * 2 + 1] = hexArray[v & 0x0F]; + } + return new String(hexChars); + } + + } diff --git a/main/src/main/java/de/blinkt/openvpn/fragments/Utils.java b/main/src/main/java/de/blinkt/openvpn/fragments/Utils.java index 382a97f6..243eae98 100644 --- a/main/src/main/java/de/blinkt/openvpn/fragments/Utils.java +++ b/main/src/main/java/de/blinkt/openvpn/fragments/Utils.java @@ -263,15 +263,4 @@ public class Utils { return prefix + VpnProfile.INLINE_TAG + newData; } - final protected static char[] hexArray = "0123456789ABCDEF".toCharArray(); - public static String bytesToHex(byte[] bytes, int len) { - len = Math.min(bytes.length, len); - char[] hexChars = new char[len * 2]; - for ( int j = 0; j < len; j++ ) { - int v = bytes[j] & 0xFF; - hexChars[j * 2] = hexArray[v >>> 4]; - hexChars[j * 2 + 1] = hexArray[v & 0x0F]; - } - return new String(hexChars); - } } |