diff options
Diffstat (limited to 'main/src')
6 files changed, 69 insertions, 328 deletions
diff --git a/main/src/main/aidl/de/blinkt/openvpn/core/IOpenVPNServiceInternal.aidl b/main/src/main/aidl/de/blinkt/openvpn/core/IOpenVPNServiceInternal.aidl index 1c1df7dc..293c2b6d 100644 --- a/main/src/main/aidl/de/blinkt/openvpn/core/IOpenVPNServiceInternal.aidl +++ b/main/src/main/aidl/de/blinkt/openvpn/core/IOpenVPNServiceInternal.aidl @@ -21,9 +21,6 @@ interface IOpenVPNServiceInternal { */ boolean stopVPN(boolean replaceConnection); - void addAllowedExternalApp(String packagename); + boolean isVpnRunning(); - boolean isAllowedExternalApp(String packagename); - - void challengeResponse(String repsonse); } diff --git a/main/src/main/cpp/CMakeLists.txt b/main/src/main/cpp/CMakeLists.txt index f40eaa4d..fae64f33 100644 --- a/main/src/main/cpp/CMakeLists.txt +++ b/main/src/main/cpp/CMakeLists.txt @@ -31,25 +31,25 @@ include(lzo.cmake) include(lz4.cmake) include(openssl/openssl.cmake) -if(NOT ${OPENVPN3OSSL} OR ${OPENVPN2MBED}) - add_subdirectory(mbedtls) -endif() +#if(NOT ${OPENVPN3OSSL} OR ${OPENVPN2MBED}) +# add_subdirectory(mbedtls) +#endif() # Super hacky way to determine flavour #-DCMAKE_LIBRARY_OUTPUT_DIRECTORY=/Users/arne/software/icsopenvpn/main/build/intermediates/cmake/normal/debug/obj/arm64-v8a -if (NOT ${CMAKE_LIBRARY_OUTPUT_DIRECTORY} MATCHES "build/intermediates/cmake/.*skeleton.*/") - FIND_PACKAGE(SWIG 3.0 REQUIRED) +#if (NOT ${CMAKE_LIBRARY_OUTPUT_DIRECTORY} MATCHES "build/intermediates/cmake/.*skeleton.*/") +# FIND_PACKAGE(SWIG 3.0 REQUIRED) - add_custom_command(OUTPUT "ovpncli_wrap.cxx" - COMMAND ${CMAKE_COMMAND} -E make_directory ovpn3 - COMMAND ${SWIG_EXECUTABLE} -outdir ovpn3 - -c++ - -java -package net.openvpn.ovpn3 - -outcurrentdir - -DOPENVPN_PLATFORM_ANDROID - -I${CMAKE_SOURCE_DIR}/openvpn3/client - -I${CMAKE_SOURCE_DIR}/openvpn3 - ${CMAKE_SOURCE_DIR}/openvpn3/client/ovpncli.i) +# add_custom_command(OUTPUT "ovpncli_wrap.cxx" +# COMMAND ${CMAKE_COMMAND} -E make_directory ovpn3 +# COMMAND ${SWIG_EXECUTABLE} -outdir ovpn3 +# -c++ +# -java -package net.openvpn.ovpn3 +# -outcurrentdir +# -DOPENVPN_PLATFORM_ANDROID +# -I${CMAKE_SOURCE_DIR}/openvpn3/client +# -I${CMAKE_SOURCE_DIR}/openvpn3 +# ${CMAKE_SOURCE_DIR}/openvpn3/client/ovpncli.i) # proper way bunt unfinished @@ -59,49 +59,49 @@ if (NOT ${CMAKE_LIBRARY_OUTPUT_DIRECTORY} MATCHES "build/intermediates/cmake/.*s #SWIG_ADD_MODULE(ovpen3cli java openvpn3/javacli/ovpncli.i) - set(ovpn3_SRCS - openvpn3/client/ovpncli.cpp - openvpn3/openvpn/openssl/xkey/xkey_provider.c - openvpn3/openvpn/openssl/xkey/xkey_helper.c - ovpncli_wrap.cxx) - - add_library(ovpn3 SHARED ${ovpn3_SRCS}) - - target_include_directories(ovpn3 PUBLIC - ${CMAKE_CURRENT_SOURCE_DIR}/lzo/include - ${CMAKE_CURRENT_SOURCE_DIR}/openvpn3 - ${CMAKE_CURRENT_SOURCE_DIR}/asio/asio/include - ${CMAKE_CURRENT_SOURCE_DIR}/openvpn3/client - ${CMAKE_CURRENT_SOURCE_DIR}/mbedtls/include - ) - - if (${OPENVPN3OSSL}) - target_compile_definitions(ovpn3 PRIVATE - -DUSE_OPENSSL - ) - target_link_libraries(ovpn3 crypto ssl lzo lz4) - else () - target_compile_definitions(ovpn3 PRIVATE - -DUSE_MBEDTLS - ) - target_link_libraries(ovpn3 mbedtls mbedx509 mbedcrypto lzo lz4) - endif () - - target_compile_definitions(ovpn3 PRIVATE - -DHAVE_CONFIG_H - -DHAVE_LZO - -DHAVE_LZ4 - -DASIO_STANDALONE - -DUSE_ASIO - -DOPENVPN_CORE_GIT_VERSION=\"${OPENVPN3_GIT}\" - -DOPENVPN_SHOW_SESSION_TOKEN - -DOPENSSL_API_COMPAT=0x10200000L - -DOPENVPN_ALLOW_INSECURE_CERTPROFILE - -DENABLE_EXTERNAL_PKI - ) -else () - message("Not budiling OpenVPN for output dir ${CMAKE_LIBRARY_OUTPUT_DIRECTORY}") -endif () + # set(ovpn3_SRCS + # openvpn3/client/ovpncli.cpp + # openvpn3/openvpn/openssl/xkey/xkey_provider.c + # openvpn3/openvpn/openssl/xkey/xkey_helper.c + # ovpncli_wrap.cxx) + + # add_library(ovpn3 SHARED ${ovpn3_SRCS}) + + # target_include_directories(ovpn3 PUBLIC + # ${CMAKE_CURRENT_SOURCE_DIR}/lzo/include + # ${CMAKE_CURRENT_SOURCE_DIR}/openvpn3 + # ${CMAKE_CURRENT_SOURCE_DIR}/asio/asio/include + # ${CMAKE_CURRENT_SOURCE_DIR}/openvpn3/client + # ${CMAKE_CURRENT_SOURCE_DIR}/mbedtls/include + # ) + + # if (${OPENVPN3OSSL}) +# target_compile_definitions(ovpn3 PRIVATE +# -DUSE_OPENSSL +# ) +# target_link_libraries(ovpn3 crypto ssl lzo lz4) +# else () +# target_compile_definitions(ovpn3 PRIVATE +# -DUSE_MBEDTLS +# ) +# target_link_libraries(ovpn3 mbedtls mbedx509 mbedcrypto lzo lz4) +# endif () + + # target_compile_definitions(ovpn3 PRIVATE + # -DHAVE_CONFIG_H + # -DHAVE_LZO + # -DHAVE_LZ4 + # -DASIO_STANDALONE + # -DUSE_ASIO + # -DOPENVPN_CORE_GIT_VERSION=\"${OPENVPN3_GIT}\" + # -DOPENVPN_SHOW_SESSION_TOKEN + # -DOPENSSL_API_COMPAT=0x10200000L + # -DOPENVPN_ALLOW_INSECURE_CERTPROFILE + # -DENABLE_EXTERNAL_PKI + # ) +#else () +# message("Not building OpenVPN for output dir ${CMAKE_LIBRARY_OUTPUT_DIRECTORY}") +#endif () add_library(ovpnutil SHARED ovpnutil/jniglue.c) target_compile_definitions(ovpnutil PRIVATE -DTARGET_ARCH_ABI=\"${ANDROID_ABI}\" @@ -110,15 +110,16 @@ target_compile_definitions(ovpnutil PRIVATE -DTARGET_ARCH_ABI=\"${ANDROID_ABI}\" ) target_link_libraries(ovpnutil log) -add_library(osslutil SHARED ovpnutil/osslutil.cpp) -target_link_libraries(osslutil log crypto ssl) +#add_library(osslutil SHARED ovpnutil/osslutil.cpp) +#target_link_libraries(osslutil log crypto ssl) -if (NOT ${CMAKE_LIBRARY_OUTPUT_DIRECTORY} MATCHES "build/intermediates/cmake/.*skeleton.*/") - add_library(osslspeedtest SHARED ovpnutil/sslspeed.c) - target_link_libraries(osslspeedtest log crypto ssl) -else () - message("Not budiling SSLSpeedTest for output dir ${CMAKE_LIBRARY_OUTPUT_DIRECTORY}") -endif () +#if (NOT ${CMAKE_LIBRARY_OUTPUT_DIRECTORY} MATCHES "build/intermediates/cmake/.*skeleton.*/") +# message("Building SSLSpeedTest for output dir ${CMAKE_LIBRARY_OUTPUT_DIRECTORY}") +# add_library(osslspeedtest SHARED ovpnutil/sslspeed.c) +# target_link_libraries(osslspeedtest log crypto ssl) +#else () +# message("Not budiling SSLSpeedTest for output dir ${CMAKE_LIBRARY_OUTPUT_DIRECTORY}") +#endif () set(openvpn_srcs src/compat/compat-basename.c diff --git a/main/src/main/java/de/blinkt/openvpn/core/ConnectionStatus.java b/main/src/main/java/de/blinkt/openvpn/core/ConnectionStatus.java index 03d842e3..3e6d23f7 100644 --- a/main/src/main/java/de/blinkt/openvpn/core/ConnectionStatus.java +++ b/main/src/main/java/de/blinkt/openvpn/core/ConnectionStatus.java @@ -21,6 +21,7 @@ public enum ConnectionStatus implements Parcelable { LEVEL_START, LEVEL_AUTH_FAILED, LEVEL_WAITING_FOR_USER_INPUT, + LEVEL_BLOCKING, // used for Bitmask's VoidVPN UNKNOWN_LEVEL; @Override diff --git a/main/src/test/java/de/blinkt/openvpn/core/TestConfigGenerator.java b/main/src/test/java/de/blinkt/openvpn/core/TestConfigGenerator.java deleted file mode 100644 index e2be04b4..00000000 --- a/main/src/test/java/de/blinkt/openvpn/core/TestConfigGenerator.java +++ /dev/null @@ -1,77 +0,0 @@ -/* - * Copyright (c) 2012-2018 Arne Schwabe - * Distributed under the GNU GPL v2 with additional terms. For full terms see the file doc/LICENSE.txt - */ - -package de.blinkt.openvpn.core; - -import android.content.Context; -import android.content.pm.PackageManager; -import android.os.Build; - -import junit.framework.Assert; - -import org.junit.Test; -import org.junit.runner.RunWith; -import org.robolectric.RobolectricTestRunner; -import org.robolectric.RuntimeEnvironment; -import org.robolectric.annotation.Config; - -import de.blinkt.openvpn.VpnProfile; - -import static de.blinkt.openvpn.VpnProfile.AUTH_RETRY_NOINTERACT; -import static de.blinkt.openvpn.VpnProfile.TYPE_USERPASS; - -/** - * Created by arne on 14.03.18. - */ - - -@Config(sdk = Build.VERSION_CODES.O_MR1) -@RunWith(RobolectricTestRunner.class) -public class TestConfigGenerator { - @Test - public void testAuthRetryGen() throws PackageManager.NameNotFoundException { - /*Context mc = mock(Context.class); - PackageManager mpm = mock(PackageManager.class); - - PackageInfo mpi = new PackageInfo(); - mpi.versionCode = 177; - mpi.versionName = "foo"; - - when(mc.getCacheDir()).thenReturn(new File("/j/unit/test/")); - when(mc.getPackageName()).thenReturn("de.blinkt.openvpn"); - when(mc.getPackageManager()).thenReturn(mpm); - when(mpm.getPackageInfo(eq("de.blinkt.openvpn"),eq(0))).thenReturn(mpi);*/ - - - - VpnProfile vp = new VpnProfile ("test") { - @Override - public String getPlatformVersionEnvString() { - return "test"; - } - }; - - vp.mAuthenticationType = TYPE_USERPASS; - vp.mAuthRetry = AUTH_RETRY_NOINTERACT; - String config = vp.getConfigFile(RuntimeEnvironment.application, false); - Assert.assertTrue(config.contains("\nauth-retry nointeract\n")); - for (Connection connection: vp.mConnections) - Assert.assertTrue(connection.mProxyType == Connection.ProxyType.NONE); - - } - - @Test - public void testEscape() - { - String uglyPassword = "^OrFg1{G^SS8b4J@B$Y1Dr\\GwG-dw3aBJ/R@WI*doCVP',+:>zjqC[&b6[8=KL:`{l&:i!_4*npE?4k2c^(n>9Tjp~u2Z]l8(y&Gg<-cwR2k=yKK:-%f-ezQ\"^g)[d,kbsu$cqih\\wA~on$~)QSODtip2cd,+->qv,roF*9>6q:lTepm=r?Y-+(K]ERGn\"+AiLj<(R_'BOg:vsh0wh]BQ-PVo534;l%R*FF!+,$?Q00%839(k?E!x0R[Lx6qK\\&"; - String escapedUglyPassword = VpnProfile.openVpnEscape(uglyPassword); - - String testWithQuote = "'meinpw"; - String escapedQuote = VpnProfile.openVpnEscape(testWithQuote); - org.junit.Assert.assertEquals("\"'meinpw\"", escapedQuote); - } - - -} diff --git a/main/src/test/java/de/blinkt/openvpn/core/TestIpParser.java b/main/src/test/java/de/blinkt/openvpn/core/TestIpParser.java deleted file mode 100644 index b57749e3..00000000 --- a/main/src/test/java/de/blinkt/openvpn/core/TestIpParser.java +++ /dev/null @@ -1,37 +0,0 @@ -/* - * Copyright (c) 2012-2016 Arne Schwabe - * Distributed under the GNU GPL v2 with additional terms. For full terms see the file doc/LICENSE.txt - */ - -package de.blinkt.openvpn.core; - -import org.junit.Assert; -import org.junit.Test; - -import java.net.Inet6Address; -import java.net.InetAddress; -import java.net.UnknownHostException; - -/** - * Created by arne on 23.07.16. - */ - -public class TestIpParser { - - @Test - public void parseIPv6Zeros() throws UnknownHostException { - - testAddress("2020:0:1234::", 45, "2020:0:1234::/45"); - testAddress("::", 0, "::/0"); - testAddress("2a02:2e0:3fe:1001:302::", 128, "2a02:2e0:3fe:1001:302::/128"); - testAddress("2a02:2e0:3fe:1001:302::70", 128, "2a02:2e0:3fe:1001:302:0:0:70/128"); - } - - void testAddress(String input, int mask, String output) throws UnknownHostException { - Inet6Address ip = (Inet6Address) InetAddress.getByName(input); - - NetworkSpace.IpAddress netIp = new NetworkSpace.IpAddress(ip, mask, true); - - Assert.assertEquals(output, netIp.toString()); - } -} diff --git a/main/src/test/java/de/blinkt/openvpn/core/TestLogFileHandler.java b/main/src/test/java/de/blinkt/openvpn/core/TestLogFileHandler.java index e024bf90..e69de29b 100644 --- a/main/src/test/java/de/blinkt/openvpn/core/TestLogFileHandler.java +++ b/main/src/test/java/de/blinkt/openvpn/core/TestLogFileHandler.java @@ -1,144 +0,0 @@ -/* - * Copyright (c) 2012-2017 Arne Schwabe - * Distributed under the GNU GPL v2 with additional terms. For full terms see the file doc/LICENSE.txt - */ - -package de.blinkt.openvpn.core; - -import android.annotation.SuppressLint; - -import junit.framework.Assert; - -import org.junit.Before; -import org.junit.Test; - -import java.io.ByteArrayInputStream; -import java.io.ByteArrayOutputStream; -import java.io.IOException; -import java.io.InputStream; -import java.io.OutputStream; -import java.io.UnsupportedEncodingException; -import java.util.Arrays; - -public class TestLogFileHandler { - - byte[] testUnescaped = new byte[]{0x00, 0x55, -27, 0x00, 0x56, 0x10, -128, 0x55, 0x54}; - byte[] expectedEscaped = new byte[]{0x55, 0x00, 0x00, 0x00, 0x09, 0x00, 0x56, 0x00, -27, 0x00, 0x56, 0x01, 0x10, -128, 0x56, 0x00, 0x54}; - private TestingLogFileHandler lfh; - - - @Before - public void setup() { - lfh = new TestingLogFileHandler(); - } - - @Test - public void testWriteByteArray() throws IOException { - - ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream(); - - lfh.setLogFile(byteArrayOutputStream); - - lfh.writeEscapedBytes(testUnescaped); - - byte[] result = byteArrayOutputStream.toByteArray(); - Assert.assertTrue(Arrays.equals(expectedEscaped, result)); - } - - @Test - public void readByteArray() throws IOException { - - ByteArrayInputStream in = new ByteArrayInputStream(expectedEscaped); - - lfh.readCacheContents(in); - - Assert.assertTrue(Arrays.equals(testUnescaped, lfh.mRestoredByteArray)); - - } - - @Test - public void testMarschal() throws UnsupportedEncodingException { - LogItem li = new LogItem(VpnStatus.LogLevel.DEBUG, 72, "foobar"); - LogItem li2 = marschalAndBack(li); - testEquals(li, li2); - Assert.assertEquals(li, li2); - } - - @Test - public void testMarschalArgs() throws UnsupportedEncodingException { - LogItem li = new LogItem(VpnStatus.LogLevel.DEBUG, 72, 772, "sinnloser Text", 7723, 723.2f, 7.2); - LogItem li2 = marschalAndBack(li); - testEquals(li, li2); - Assert.assertEquals(li, li2); - } - - @Test - public void testMarschalString() throws UnsupportedEncodingException { - LogItem li = new LogItem(VpnStatus.LogLevel.DEBUG, "Nutzlose Nachricht"); - LogItem li2 = marschalAndBack(li); - testEquals(li, li2); - Assert.assertEquals(li, li2); - } - - @Test - public void testLogInsertByTime() - { - VpnStatus vpnStatus = new VpnStatus(); - /* Add the generic information message */ - VpnStatus.clearLog(); - - long[] testTimes = {1000, 20000, 1500, 500, 6000, 70000, System.currentTimeMillis()+5000}; - for (long time: testTimes) { - LogItem li = new LogItem(VpnStatus.LogLevel.INFO, "unit test", time); - VpnStatus.newLogItemIfUnique(li); - } - - long lastlogTime = 0; - for(LogItem li:VpnStatus.getlogbuffer()) - { - org.junit.Assert.assertTrue(li.getLogtime() >= lastlogTime); - lastlogTime = li.getLogtime(); - } - } - - - private void testEquals(LogItem li, LogItem li2) { - Assert.assertEquals(li.getLogLevel(), li2.getLogLevel()); - Assert.assertEquals(li.getLogtime(), li2.getLogtime()); - Assert.assertEquals(li.getVerbosityLevel(), li2.getVerbosityLevel()); - Assert.assertEquals(li.toString(), li2.toString()); - - } - - private LogItem marschalAndBack(LogItem li) throws UnsupportedEncodingException { - byte[] bytes = li.getMarschaledBytes(); - - return new LogItem(bytes, bytes.length); - } - - - @SuppressLint("HandlerLeak") - static class TestingLogFileHandler extends LogFileHandler { - - public byte[] mRestoredByteArray; - - public TestingLogFileHandler() { - super(null); - } - - public void setLogFile(OutputStream out) { - mLogFile = out; - } - - @Override - public void readCacheContents(InputStream in) throws IOException { - super.readCacheContents(in); - } - - @Override - protected void restoreLogItem(byte[] buf, int len) { - mRestoredByteArray = Arrays.copyOf(buf, len); - } - } - -}
\ No newline at end of file |