├── .eslintignore ├── .eslintrc.js ├── .gitignore ├── .gitmodules ├── .npmignore ├── .prettierrc.js ├── LICENSE ├── README.md ├── android ├── .classpath ├── .project ├── .settings │ └── org.eclipse.buildship.core.prefs ├── README.md ├── build.gradle ├── gradle.properties ├── gradle │ └── wrapper │ │ ├── gradle-wrapper.jar │ │ └── gradle-wrapper.properties ├── gradlew ├── gradlew.bat └── src │ └── main │ ├── AndroidManifest.xml │ ├── java │ ├── com │ │ └── sijav │ │ │ └── reactnativeipsecvpn │ │ │ ├── BaseActivityEventListener.java │ │ │ ├── RNIpSecVpn.java │ │ │ ├── RNIpSecVpnPackage.java │ │ │ └── RNIpSecVpnStateHandler.java │ └── org │ │ └── strongswan │ │ └── android │ │ ├── data │ │ ├── LogContentProvider.java │ │ ├── VpnProfile.java │ │ ├── VpnProfileDataSource.java │ │ └── VpnType.java │ │ ├── logic │ │ ├── CharonVpnService.java │ │ ├── NetworkManager.java │ │ ├── Scheduler.java │ │ ├── SimpleFetcher.java │ │ ├── StrongSwanApplication.java │ │ ├── TrustedCertificateManager.java │ │ ├── UserCredentialManager.java │ │ ├── VpnStateService.java │ │ └── imc │ │ │ ├── AndroidImc.java │ │ │ ├── ImcState.java │ │ │ ├── RemediationInstruction.java │ │ │ ├── attributes │ │ │ ├── Attribute.java │ │ │ ├── AttributeType.java │ │ │ ├── DeviceIdAttribute.java │ │ │ ├── InstalledPackagesAttribute.java │ │ │ ├── PortFilterAttribute.java │ │ │ ├── PrivateEnterpriseNumber.java │ │ │ ├── ProductInformationAttribute.java │ │ │ ├── SettingsAttribute.java │ │ │ └── StringVersionAttribute.java │ │ │ └── collectors │ │ │ ├── Collector.java │ │ │ ├── DeviceIdCollector.java │ │ │ ├── InstalledPackagesCollector.java │ │ │ ├── PortFilterCollector.java │ │ │ ├── ProductInformationCollector.java │ │ │ ├── Protocol.java │ │ │ ├── SettingsCollector.java │ │ │ └── StringVersionCollector.java │ │ ├── security │ │ ├── LocalCertificateKeyStoreProvider.java │ │ ├── LocalCertificateKeyStoreSpi.java │ │ ├── LocalCertificateStore.java │ │ └── TrustedCertificateEntry.java │ │ ├── ui │ │ └── VpnProfileListFragment.java │ │ └── utils │ │ ├── BufferedByteWriter.java │ │ ├── Constants.java │ │ ├── IPRange.java │ │ ├── IPRangeSet.java │ │ ├── SettingsWriter.java │ │ └── Utils.java │ ├── jni │ ├── Android.mk │ ├── Application.mk │ └── libandroidbridge │ │ ├── Android.mk │ │ ├── android_jni.c │ │ ├── android_jni.h │ │ ├── backend │ │ ├── android_attr.c │ │ ├── android_attr.h │ │ ├── android_creds.c │ │ ├── android_creds.h │ │ ├── android_dns_proxy.c │ │ ├── android_dns_proxy.h │ │ ├── android_fetcher.c │ │ ├── android_fetcher.h │ │ ├── android_private_key.c │ │ ├── android_private_key.h │ │ ├── android_scheduler.c │ │ ├── android_scheduler.h │ │ ├── android_service.c │ │ └── android_service.h │ │ ├── byod │ │ ├── imc_android.c │ │ ├── imc_android.h │ │ ├── imc_android_state.c │ │ └── imc_android_state.h │ │ ├── charonservice.c │ │ ├── charonservice.h │ │ ├── kernel │ │ ├── android_ipsec.c │ │ ├── android_ipsec.h │ │ ├── android_net.c │ │ ├── android_net.h │ │ ├── network_manager.c │ │ └── network_manager.h │ │ ├── vpnservice_builder.c │ │ └── vpnservice_builder.h │ └── libs │ ├── arm64-v8a │ ├── libandroidbridge.so │ ├── libcharon.so │ ├── libimcv.so │ ├── libipsec.so │ ├── libstrongswan.so │ ├── libtnccs.so │ ├── libtncif.so │ └── libtpmtss.so │ ├── armeabi-v7a │ ├── libandroidbridge.so │ ├── libcharon.so │ ├── libimcv.so │ ├── libipsec.so │ ├── libstrongswan.so │ ├── libtnccs.so │ ├── libtncif.so │ └── libtpmtss.so │ ├── x86 │ ├── libandroidbridge.so │ ├── libcharon.so │ ├── libimcv.so │ ├── libipsec.so │ ├── libstrongswan.so │ ├── libtnccs.so │ ├── libtncif.so │ └── libtpmtss.so │ └── x86_64 │ ├── libandroidbridge.so │ ├── libcharon.so │ ├── libimcv.so │ ├── libipsec.so │ ├── libstrongswan.so │ ├── libtnccs.so │ ├── libtncif.so │ └── libtpmtss.so ├── example ├── .buckconfig ├── .eslintrc.js ├── .flowconfig ├── .gitattributes ├── .gitignore ├── .npmignore ├── .prettierrc.js ├── .watchmanconfig ├── App.js ├── android │ ├── .project │ ├── .settings │ │ └── org.eclipse.buildship.core.prefs │ ├── app │ │ ├── BUCK │ │ ├── build.gradle │ │ ├── build_defs.bzl │ │ ├── debug.keystore │ │ ├── my-upload-key.keystore │ │ ├── proguard-rules.pro │ │ └── src │ │ │ ├── debug │ │ │ ├── AndroidManifest.xml │ │ │ └── java │ │ │ │ └── com │ │ │ │ └── example │ │ │ │ └── ReactNativeFlipper.java │ │ │ └── main │ │ │ ├── AndroidManifest.xml │ │ │ └── res │ │ │ ├── mipmap-hdpi │ │ │ ├── ic_launcher.png │ │ │ └── ic_launcher_round.png │ │ │ ├── mipmap-mdpi │ │ │ ├── ic_launcher.png │ │ │ └── ic_launcher_round.png │ │ │ ├── mipmap-xhdpi │ │ │ ├── ic_launcher.png │ │ │ └── ic_launcher_round.png │ │ │ ├── mipmap-xxhdpi │ │ │ ├── ic_launcher.png │ │ │ └── ic_launcher_round.png │ │ │ ├── mipmap-xxxhdpi │ │ │ ├── ic_launcher.png │ │ │ └── ic_launcher_round.png │ │ │ └── values │ │ │ ├── strings.xml │ │ │ └── styles.xml │ ├── build.gradle │ ├── gradle.properties │ ├── gradle │ │ └── wrapper │ │ │ ├── gradle-wrapper.jar │ │ │ └── gradle-wrapper.properties │ ├── gradlew │ ├── gradlew.bat │ └── settings.gradle ├── app.json ├── babel.config.js ├── index.js ├── ios │ ├── Podfile │ ├── example-tvOS │ │ └── Info.plist │ ├── example-tvOSTests │ │ └── Info.plist │ ├── example.xcodeproj │ │ ├── project.pbxproj │ │ └── xcshareddata │ │ │ └── xcschemes │ │ │ ├── example-tvOS.xcscheme │ │ │ └── example.xcscheme │ ├── example.xcworkspace │ │ ├── contents.xcworkspacedata │ │ └── xcshareddata │ │ │ └── IDEWorkspaceChecks.plist │ ├── example │ │ ├── AppDelegate.h │ │ ├── AppDelegate.m │ │ ├── Images.xcassets │ │ │ ├── AppIcon.appiconset │ │ │ │ └── Contents.json │ │ │ └── Contents.json │ │ ├── Info.plist │ │ ├── LaunchScreen.storyboard │ │ └── main.m │ └── exampleTests │ │ ├── Info.plist │ │ └── exampleTests.m ├── metro.config.js ├── package-lock.json └── package.json ├── index.d.ts ├── index.js ├── index.js.map ├── index.ts ├── ios ├── RNIpSecVpn.swift ├── RNIpSecVpn.xcodeproj │ └── project.pbxproj ├── RNIpSecVpn.xcworkspace │ ├── contents.xcworkspacedata │ └── xcshareddata │ │ └── IDEWorkspaceChecks.plist ├── RNIpSecVpnBridge.h └── RNIpSecVpnBridge.m ├── package-lock.json ├── package.json ├── react-native-ip-sec-vpn.podspec ├── tsconfig.json └── yarn.lock /.eslintignore: -------------------------------------------------------------------------------- 1 | **/node_modules 2 | lib/ 3 | -------------------------------------------------------------------------------- /.eslintrc.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | root: true, 3 | extends: ["@react-native-community", "./node_modules/gts"], 4 | parser: ['@typescript-eslint/parser', "simple-import-sort"], 5 | plugins: ['@typescript-eslint'], 6 | rules: { 7 | noUseBeforeDeclare: false, 8 | "@typescript-eslint/member-delimiter-style": [ 9 | "error", 10 | { 11 | "multiline": { 12 | "delimiter": "none", 13 | "requireLast": false 14 | }, 15 | "singleline": { 16 | "delimiter": "semi" 17 | } 18 | } 19 | ], 20 | "simple-import-sort/sort": [ 21 | "error", 22 | { 23 | "groups": [["^\\u0000", "^@?\\w", "^[^.]", "^\\."]] 24 | } 25 | ] 26 | } 27 | }; 28 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # OSX 2 | # 3 | .DS_Store 4 | 5 | # node.js 6 | # 7 | node_modules/ 8 | npm-debug.log 9 | yarn-error.log 10 | 11 | # Xcode 12 | # 13 | build/ 14 | *.pbxuser 15 | !default.pbxuser 16 | *.mode1v3 17 | !default.mode1v3 18 | *.mode2v3 19 | !default.mode2v3 20 | *.perspectivev3 21 | !default.perspectivev3 22 | xcuserdata 23 | *.xccheckout 24 | *.moved-aside 25 | DerivedData 26 | *.hmap 27 | *.ipa 28 | *.xcuserstate 29 | project.xcworkspace 30 | 31 | # Android/IntelliJ 32 | # 33 | build/ 34 | .idea 35 | .gradle 36 | local.properties 37 | *.iml 38 | 39 | # BUCK 40 | buck-out/ 41 | \.buckd/ 42 | *.keystore 43 | 44 | Podfile.lock 45 | -------------------------------------------------------------------------------- /.gitmodules: -------------------------------------------------------------------------------- 1 | 2 | [submodule "android/src/main/jni/openssl"] 3 | path = android/src/main/jni/openssl 4 | url = git://git.strongswan.org/android-ndk-openssl.git 5 | branch = ndk-static 6 | [submodule "android/src/main/jni/strongswan"] 7 | path = android/src/main/jni/strongswan 8 | url = https://github.com/strongswan/strongswan 9 | -------------------------------------------------------------------------------- /.npmignore: -------------------------------------------------------------------------------- 1 | # OSX 2 | # 3 | .DS_Store 4 | 5 | # node.js 6 | # 7 | node_modules/ 8 | npm-debug.log 9 | yarn-error.log 10 | 11 | # Xcode 12 | # 13 | build/ 14 | *.pbxuser 15 | !default.pbxuser 16 | *.mode1v3 17 | !default.mode1v3 18 | *.mode2v3 19 | !default.mode2v3 20 | *.perspectivev3 21 | !default.perspectivev3 22 | xcuserdata 23 | *.xccheckout 24 | *.moved-aside 25 | DerivedData 26 | *.hmap 27 | *.ipa 28 | *.xcuserstate 29 | project.xcworkspace 30 | 31 | # Android/IntelliJ 32 | # 33 | build/ 34 | libs/ 35 | .idea 36 | .gradle 37 | local.properties 38 | *.iml 39 | 40 | # BUCK 41 | buck-out/ 42 | \.buckd/ 43 | *.keystore 44 | 45 | # Example 46 | example/ -------------------------------------------------------------------------------- /.prettierrc.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | bracketSpacing: true, 3 | jsxSingleQuote: true, 4 | semi: true, 5 | printWidth: 140, 6 | } 7 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2020 Sina 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /android/.classpath: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /android/.project: -------------------------------------------------------------------------------- 1 | 2 | 3 | android 4 | Project android created by Buildship. 5 | 6 | 7 | 8 | 9 | org.eclipse.jdt.core.javabuilder 10 | 11 | 12 | 13 | 14 | org.eclipse.buildship.core.gradleprojectbuilder 15 | 16 | 17 | 18 | 19 | 20 | org.eclipse.jdt.core.javanature 21 | org.eclipse.buildship.core.gradleprojectnature 22 | 23 | 24 | 25 | 1603066483429 26 | 27 | 30 28 | 29 | org.eclipse.core.resources.regexFilterMatcher 30 | node_modules|.git|__CREATED_BY_JAVA_LANGUAGE_SERVER__ 31 | 32 | 33 | 34 | 35 | -------------------------------------------------------------------------------- /android/.settings/org.eclipse.buildship.core.prefs: -------------------------------------------------------------------------------- 1 | arguments= 2 | auto.sync=false 3 | build.scans.enabled=false 4 | connection.gradle.distribution=GRADLE_DISTRIBUTION(WRAPPER) 5 | connection.project.dir= 6 | eclipse.preferences.version=1 7 | gradle.user.home= 8 | java.home=C\:\:\:\:\:\:\:\:\:\:\:\:\:\:\:\:\:\:\:\:\:\:\:\:\:\:\:\:\:\:\:\:\:\:\:\:\:\:\:\:\:\:\:\:\:\:\:\:\:\:\:\:\:\:\:\:\:\:\:\:\:\:\:\:/Program Files/Java/jdk1.8.0_161 9 | jvm.arguments= 10 | offline.mode=false 11 | override.workspace.settings=true 12 | show.console.view=true 13 | show.executions.view=true 14 | -------------------------------------------------------------------------------- /android/README.md: -------------------------------------------------------------------------------- 1 | README 2 | ====== 3 | 4 | If you want to publish the lib as a maven dependency, follow these steps before publishing a new version to npm: 5 | 6 | 1. Be sure to have the Android [SDK](https://developer.android.com/studio/index.html) and [NDK](https://developer.android.com/ndk/guides/index.html) installed 7 | 2. Be sure to have a `local.properties` file in this folder that points to the Android SDK and NDK 8 | ``` 9 | ndk.dir=/Users/{username}/Library/Android/sdk/ndk-bundle 10 | sdk.dir=/Users/{username}/Library/Android/sdk 11 | ``` 12 | 3. Delete the `maven` folder 13 | 4. Run `./gradlew installArchives` 14 | 5. Verify that latest set of generated files is in the maven folder with the correct version number 15 | -------------------------------------------------------------------------------- /android/gradle.properties: -------------------------------------------------------------------------------- 1 | android.useAndroidX=true -------------------------------------------------------------------------------- /android/gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cristinaITdeveloper/react-native-ipsec-ikev2/c6239c2de8f00431a414290f03f22caa98929034/android/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /android/gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | #Sat May 16 18:26:59 IRDT 2020 2 | distributionBase=GRADLE_USER_HOME 3 | distributionPath=wrapper/dists 4 | zipStoreBase=GRADLE_USER_HOME 5 | zipStorePath=wrapper/dists 6 | distributionUrl=https\://services.gradle.org/distributions/gradle-5.6.4-all.zip 7 | -------------------------------------------------------------------------------- /android/gradlew.bat: -------------------------------------------------------------------------------- 1 | @if "%DEBUG%" == "" @echo off 2 | @rem ########################################################################## 3 | @rem 4 | @rem Gradle startup script for Windows 5 | @rem 6 | @rem ########################################################################## 7 | 8 | @rem Set local scope for the variables with windows NT shell 9 | if "%OS%"=="Windows_NT" setlocal 10 | 11 | set DIRNAME=%~dp0 12 | if "%DIRNAME%" == "" set DIRNAME=. 13 | set APP_BASE_NAME=%~n0 14 | set APP_HOME=%DIRNAME% 15 | 16 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 17 | set DEFAULT_JVM_OPTS= 18 | 19 | @rem Find java.exe 20 | if defined JAVA_HOME goto findJavaFromJavaHome 21 | 22 | set JAVA_EXE=java.exe 23 | %JAVA_EXE% -version >NUL 2>&1 24 | if "%ERRORLEVEL%" == "0" goto init 25 | 26 | echo. 27 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 28 | echo. 29 | echo Please set the JAVA_HOME variable in your environment to match the 30 | echo location of your Java installation. 31 | 32 | goto fail 33 | 34 | :findJavaFromJavaHome 35 | set JAVA_HOME=%JAVA_HOME:"=% 36 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe 37 | 38 | if exist "%JAVA_EXE%" goto init 39 | 40 | echo. 41 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 42 | echo. 43 | echo Please set the JAVA_HOME variable in your environment to match the 44 | echo location of your Java installation. 45 | 46 | goto fail 47 | 48 | :init 49 | @rem Get command-line arguments, handling Windows variants 50 | 51 | if not "%OS%" == "Windows_NT" goto win9xME_args 52 | 53 | :win9xME_args 54 | @rem Slurp the command line arguments. 55 | set CMD_LINE_ARGS= 56 | set _SKIP=2 57 | 58 | :win9xME_args_slurp 59 | if "x%~1" == "x" goto execute 60 | 61 | set CMD_LINE_ARGS=%* 62 | 63 | :execute 64 | @rem Setup the command line 65 | 66 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar 67 | 68 | @rem Execute Gradle 69 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% 70 | 71 | :end 72 | @rem End local scope for the variables with windows NT shell 73 | if "%ERRORLEVEL%"=="0" goto mainEnd 74 | 75 | :fail 76 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of 77 | rem the _cmd.exe /c_ return code! 78 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 79 | exit /b 1 80 | 81 | :mainEnd 82 | if "%OS%"=="Windows_NT" endlocal 83 | 84 | :omega 85 | -------------------------------------------------------------------------------- /android/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 3 | 4 | 5 | 6 | 7 | 8 | 11 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /android/src/main/java/com/sijav/reactnativeipsecvpn/BaseActivityEventListener.java: -------------------------------------------------------------------------------- 1 | package com.sijav.reactnativeipsecvpn; 2 | 3 | import android.app.Activity; 4 | import android.content.Intent; 5 | 6 | import com.facebook.react.bridge.ActivityEventListener; 7 | 8 | /** An empty implementation of {@link ActivityEventListener} */ 9 | public class BaseActivityEventListener implements ActivityEventListener { 10 | 11 | /** @deprecated use {@link #onActivityResult(Activity, int, int, Intent)} instead. */ 12 | @Deprecated 13 | public void onActivityResult(int requestCode, int resultCode, Intent data) {} 14 | 15 | @Override 16 | public void onActivityResult(Activity activity, int requestCode, int resultCode, Intent data) {} 17 | 18 | @Override 19 | public void onNewIntent(Intent intent) {} 20 | } 21 | -------------------------------------------------------------------------------- /android/src/main/java/com/sijav/reactnativeipsecvpn/RNIpSecVpnPackage.java: -------------------------------------------------------------------------------- 1 | package com.sijav.reactnativeipsecvpn; 2 | 3 | import com.facebook.react.ReactPackage; 4 | import com.facebook.react.bridge.JavaScriptModule; 5 | import com.facebook.react.bridge.NativeModule; 6 | import com.facebook.react.bridge.ReactApplicationContext; 7 | import com.facebook.react.uimanager.ViewManager; 8 | 9 | import java.util.Collections; 10 | import java.util.List; 11 | 12 | public class RNIpSecVpnPackage implements ReactPackage { 13 | 14 | @Override 15 | public List createNativeModules(ReactApplicationContext reactContext) { 16 | return Collections.singletonList(new RNIpSecVpn(reactContext)); 17 | } 18 | 19 | // Deprecated from RN 0.47 20 | public List> createJSModules() { 21 | return Collections.emptyList(); 22 | } 23 | 24 | @Override 25 | public List createViewManagers(ReactApplicationContext reactContext) { 26 | return Collections.emptyList(); 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /android/src/main/java/com/sijav/reactnativeipsecvpn/RNIpSecVpnStateHandler.java: -------------------------------------------------------------------------------- 1 | package com.sijav.reactnativeipsecvpn; 2 | 3 | import android.content.ComponentName; 4 | import android.content.ServiceConnection; 5 | import android.os.IBinder; 6 | import android.util.Log; 7 | 8 | import com.facebook.react.bridge.Arguments; 9 | import com.facebook.react.bridge.WritableMap; 10 | 11 | import org.strongswan.android.logic.VpnStateService; 12 | 13 | public class RNIpSecVpnStateHandler implements ServiceConnection, VpnStateService.VpnStateListener { 14 | 15 | final String TAG = "RNIpSecVpnStateHandler"; 16 | 17 | private RNIpSecVpn context; 18 | VpnStateService vpnStateService; 19 | 20 | RNIpSecVpnStateHandler(RNIpSecVpn context){ 21 | this.context = context; 22 | } 23 | 24 | @Override 25 | public void stateChanged() { 26 | WritableMap params = Arguments.createMap(); 27 | if(vpnStateService == null){ 28 | Log.i(TAG, "RNIpSecVpnStateHandler null"); 29 | params.putInt("state", 4); 30 | params.putInt("charonState", 8); 31 | context.sendEvent("stateChanged", params); 32 | return; 33 | } 34 | VpnStateService.ErrorState errorState = vpnStateService.getErrorState(); 35 | if(errorState == VpnStateService.ErrorState.NO_ERROR){ 36 | Log.i(TAG, "RNIpSecVpnStateHandler no error"); 37 | VpnStateService.State state = vpnStateService.getState(); 38 | params.putInt("state", state != null ? state.ordinal() : 4); 39 | params.putInt("charonState", errorState.ordinal()); 40 | context.sendEvent("stateChanged", params); 41 | } else { 42 | Log.i(TAG, "RNIpSecVpnStateHandler error"); 43 | 44 | params.putInt("state", 4); 45 | params.putInt("charonState", errorState != null ? errorState.ordinal() : 8); 46 | context.sendEvent("stateChanged", params); 47 | } 48 | } 49 | 50 | @Override 51 | public void onServiceConnected(ComponentName name, IBinder service) { 52 | vpnStateService = ((VpnStateService.LocalBinder)service).getService(); 53 | if(vpnStateService != null){ 54 | vpnStateService.registerListener(this); 55 | } 56 | } 57 | 58 | @Override 59 | public void onServiceDisconnected(ComponentName name) { 60 | vpnStateService = null; 61 | } 62 | } -------------------------------------------------------------------------------- /android/src/main/java/org/strongswan/android/data/LogContentProvider.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2012 Tobias Brunner 3 | * HSR Hochschule fuer Technik Rapperswil 4 | * 5 | * This program is free software; you can redistribute it and/or modify it 6 | * under the terms of the GNU General Public License as published by the 7 | * Free Software Foundation; either version 2 of the License, or (at your 8 | * option) any later version. See . 9 | * 10 | * This program is distributed in the hope that it will be useful, but 11 | * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 12 | * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 13 | * for more details. 14 | */ 15 | 16 | package org.strongswan.android.data; 17 | 18 | import java.io.File; 19 | import java.io.FileNotFoundException; 20 | import java.security.NoSuchAlgorithmException; 21 | import java.security.SecureRandom; 22 | import java.util.concurrent.ConcurrentHashMap; 23 | 24 | import org.strongswan.android.logic.CharonVpnService; 25 | 26 | import android.content.ContentProvider; 27 | import android.content.ContentValues; 28 | import android.database.Cursor; 29 | import android.database.MatrixCursor; 30 | import android.net.Uri; 31 | import android.os.ParcelFileDescriptor; 32 | import android.os.SystemClock; 33 | import android.provider.OpenableColumns; 34 | 35 | public class LogContentProvider extends ContentProvider 36 | { 37 | private static final String AUTHORITY = "org.strongswan.android.content.log"; 38 | /* an Uri is valid for 30 minutes */ 39 | private static final long URI_VALIDITY = 30 * 60 * 1000; 40 | private static ConcurrentHashMap mUris = new ConcurrentHashMap(); 41 | private File mLogFile; 42 | 43 | public LogContentProvider() 44 | { 45 | } 46 | 47 | @Override 48 | public boolean onCreate() 49 | { 50 | mLogFile = new File(getContext().getFilesDir(), CharonVpnService.LOG_FILE); 51 | return true; 52 | } 53 | 54 | /** 55 | * The log file can only be accessed by Uris created with this method 56 | * @return null if failed to create the Uri 57 | */ 58 | public static Uri createContentUri() 59 | { 60 | SecureRandom random; 61 | try 62 | { 63 | random = SecureRandom.getInstance("SHA1PRNG"); 64 | } 65 | catch (NoSuchAlgorithmException e) 66 | { 67 | return null; 68 | } 69 | Uri uri = Uri.parse("content://" + AUTHORITY + "/" + random.nextLong()); 70 | mUris.put(uri, SystemClock.uptimeMillis()); 71 | return uri; 72 | } 73 | 74 | @Override 75 | public String getType(Uri uri) 76 | { 77 | /* MIME type for our log file */ 78 | return "text/plain"; 79 | } 80 | 81 | @Override 82 | public Cursor query(Uri uri, String[] projection, String selection, 83 | String[] selectionArgs, String sortOrder) 84 | { 85 | /* this is called by apps to find out the name and size of the file. 86 | * since we only provide a single file this is simple to implement */ 87 | if (projection == null || projection.length < 1) 88 | { 89 | return null; 90 | } 91 | Long timestamp = mUris.get(uri); 92 | if (timestamp == null) 93 | { /* don't check the validity as this information is not really private */ 94 | return null; 95 | } 96 | MatrixCursor cursor = new MatrixCursor(projection, 1); 97 | if (OpenableColumns.DISPLAY_NAME.equals(cursor.getColumnName(0))) 98 | { 99 | cursor.newRow().add(CharonVpnService.LOG_FILE); 100 | } 101 | else if (OpenableColumns.SIZE.equals(cursor.getColumnName(0))) 102 | { 103 | cursor.newRow().add(mLogFile.length()); 104 | } 105 | else 106 | { 107 | return null; 108 | } 109 | return cursor; 110 | } 111 | 112 | @Override 113 | public ParcelFileDescriptor openFile(Uri uri, String mode) throws FileNotFoundException 114 | { 115 | Long timestamp = mUris.get(uri); 116 | if (timestamp != null) 117 | { 118 | long elapsed = SystemClock.uptimeMillis() - timestamp; 119 | if (elapsed > 0 && elapsed < URI_VALIDITY) 120 | { /* we fail if clock wrapped, should happen rarely though */ 121 | return ParcelFileDescriptor.open(mLogFile, ParcelFileDescriptor.MODE_CREATE | ParcelFileDescriptor.MODE_READ_ONLY); 122 | } 123 | mUris.remove(uri); 124 | } 125 | return super.openFile(uri, mode); 126 | } 127 | 128 | @Override 129 | public Uri insert(Uri uri, ContentValues values) 130 | { 131 | /* not supported */ 132 | return null; 133 | } 134 | 135 | @Override 136 | public int delete(Uri uri, String selection, String[] selectionArgs) 137 | { 138 | /* not supported */ 139 | return 0; 140 | } 141 | 142 | @Override 143 | public int update(Uri uri, ContentValues values, String selection, 144 | String[] selectionArgs) 145 | { 146 | /* not supported */ 147 | return 0; 148 | } 149 | } 150 | -------------------------------------------------------------------------------- /android/src/main/java/org/strongswan/android/data/VpnType.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2012-2014 Tobias Brunner 3 | * HSR Hochschule fuer Technik Rapperswil 4 | * 5 | * This program is free software; you can redistribute it and/or modify it 6 | * under the terms of the GNU General Public License as published by the 7 | * Free Software Foundation; either version 2 of the License, or (at your 8 | * option) any later version. See . 9 | * 10 | * This program is distributed in the hope that it will be useful, but 11 | * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 12 | * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 13 | * for more details. 14 | */ 15 | 16 | package org.strongswan.android.data; 17 | 18 | import java.util.EnumSet; 19 | 20 | public enum VpnType 21 | { 22 | /* the order here must match the items in R.array.vpn_types */ 23 | IKEV2_EAP("ikev2-eap", EnumSet.of(VpnTypeFeature.USER_PASS)), 24 | IKEV2_CERT("ikev2-cert", EnumSet.of(VpnTypeFeature.CERTIFICATE)), 25 | IKEV2_CERT_EAP("ikev2-cert-eap", EnumSet.of(VpnTypeFeature.USER_PASS, VpnTypeFeature.CERTIFICATE)), 26 | IKEV2_EAP_TLS("ikev2-eap-tls", EnumSet.of(VpnTypeFeature.CERTIFICATE)), 27 | IKEV2_BYOD_EAP("ikev2-byod-eap", EnumSet.of(VpnTypeFeature.USER_PASS, VpnTypeFeature.BYOD)); 28 | 29 | /** 30 | * Features of a VPN type. 31 | */ 32 | public enum VpnTypeFeature 33 | { 34 | /** client certificate is required */ 35 | CERTIFICATE, 36 | /** username and password are required */ 37 | USER_PASS, 38 | /** enable BYOD features */ 39 | BYOD; 40 | } 41 | 42 | private String mIdentifier; 43 | private EnumSet mFeatures; 44 | 45 | /** 46 | * Enum which provides additional information about the supported VPN types. 47 | * 48 | * @param id identifier used to store and transmit this specific type 49 | * @param features of the given VPN type 50 | * @param certificate true if a client certificate is required 51 | */ 52 | VpnType(String id, EnumSet features) 53 | { 54 | mIdentifier = id; 55 | mFeatures = features; 56 | } 57 | 58 | /** 59 | * The identifier used to store this value in the database 60 | * @return identifier 61 | */ 62 | public String getIdentifier() 63 | { 64 | return mIdentifier; 65 | } 66 | 67 | /** 68 | * Checks whether a feature is supported/required by this type of VPN. 69 | * 70 | * @return true if the feature is supported/required 71 | */ 72 | public boolean has(VpnTypeFeature feature) 73 | { 74 | return mFeatures.contains(feature); 75 | } 76 | 77 | /** 78 | * Get the enum entry with the given identifier. 79 | * 80 | * @param identifier get the enum entry with this identifier 81 | * @return the enum entry, or the default if not found 82 | */ 83 | public static VpnType fromIdentifier(String identifier) 84 | { 85 | for (VpnType type : VpnType.values()) 86 | { 87 | if (identifier.equals(type.mIdentifier)) 88 | { 89 | return type; 90 | } 91 | } 92 | return VpnType.IKEV2_EAP; 93 | } 94 | } 95 | -------------------------------------------------------------------------------- /android/src/main/java/org/strongswan/android/logic/NetworkManager.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2012-2015 Tobias Brunner 3 | * HSR Hochschule fuer Technik Rapperswil 4 | * 5 | * This program is free software; you can redistribute it and/or modify it 6 | * under the terms of the GNU General Public License as published by the 7 | * Free Software Foundation; either version 2 of the License, or (at your 8 | * option) any later version. See . 9 | * 10 | * This program is distributed in the hope that it will be useful, but 11 | * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 12 | * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 13 | * for more details. 14 | */ 15 | 16 | package org.strongswan.android.logic; 17 | 18 | import android.content.BroadcastReceiver; 19 | import android.content.Context; 20 | import android.content.Intent; 21 | import android.content.IntentFilter; 22 | import android.net.ConnectivityManager; 23 | import android.net.NetworkInfo; 24 | 25 | import java.util.LinkedList; 26 | 27 | public class NetworkManager extends BroadcastReceiver implements Runnable 28 | { 29 | private final Context mContext; 30 | private volatile boolean mRegistered; 31 | private Thread mEventNotifier; 32 | private LinkedList mEvents = new LinkedList<>(); 33 | 34 | public NetworkManager(Context context) 35 | { 36 | mContext = context; 37 | } 38 | 39 | public void Register() 40 | { 41 | mEvents.clear(); 42 | mRegistered = true; 43 | mEventNotifier = new Thread(this); 44 | mEventNotifier.start(); 45 | mContext.registerReceiver(this, new IntentFilter(ConnectivityManager.CONNECTIVITY_ACTION)); 46 | } 47 | 48 | public void Unregister() 49 | { 50 | mContext.unregisterReceiver(this); 51 | mRegistered = false; 52 | synchronized (this) 53 | { 54 | notifyAll(); 55 | } 56 | try 57 | { 58 | mEventNotifier.join(); 59 | mEventNotifier = null; 60 | } 61 | catch (InterruptedException e) 62 | { 63 | e.printStackTrace(); 64 | } 65 | } 66 | 67 | public boolean isConnected() 68 | { 69 | ConnectivityManager cm = (ConnectivityManager)mContext.getSystemService(Context.CONNECTIVITY_SERVICE); 70 | NetworkInfo info = null; 71 | if (cm != null) 72 | { 73 | info = cm.getActiveNetworkInfo(); 74 | } 75 | return info != null && info.isConnected(); 76 | } 77 | 78 | @Override 79 | public void onReceive(Context context, Intent intent) 80 | { 81 | synchronized (this) 82 | { 83 | mEvents.addLast(isConnected()); 84 | notifyAll(); 85 | } 86 | } 87 | 88 | @Override 89 | public void run() 90 | { 91 | while (mRegistered) 92 | { 93 | boolean connected; 94 | 95 | synchronized (this) 96 | { 97 | try 98 | { 99 | while (mRegistered && mEvents.isEmpty()) 100 | { 101 | wait(); 102 | } 103 | } 104 | catch (InterruptedException ex) 105 | { 106 | break; 107 | } 108 | if (!mRegistered) 109 | { 110 | break; 111 | } 112 | connected = mEvents.removeFirst(); 113 | } 114 | /* call the native parts without holding the lock */ 115 | networkChanged(!connected); 116 | } 117 | } 118 | 119 | /** 120 | * Notify the native parts about a network change 121 | * 122 | * @param disconnected true if no connection is available at the moment 123 | */ 124 | public native void networkChanged(boolean disconnected); 125 | } -------------------------------------------------------------------------------- /android/src/main/java/org/strongswan/android/logic/Scheduler.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2020 Tobias Brunner 3 | * HSR Hochschule fuer Technik Rapperswil 4 | * 5 | * This program is free software; you can redistribute it and/or modify it 6 | * under the terms of the GNU General Public License as published by the 7 | * Free Software Foundation; either version 2 of the License, or (at your 8 | * option) any later version. See . 9 | * 10 | * This program is distributed in the hope that it will be useful, but 11 | * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 12 | * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 13 | * for more details. 14 | */ 15 | 16 | package org.strongswan.android.logic; 17 | 18 | import android.app.AlarmManager; 19 | import android.app.PendingIntent; 20 | import android.content.BroadcastReceiver; 21 | import android.content.Context; 22 | import android.content.Intent; 23 | import android.content.IntentFilter; 24 | import android.os.Build; 25 | 26 | import java.util.ArrayList; 27 | import java.util.PriorityQueue; 28 | import java.util.UUID; 29 | 30 | import androidx.annotation.RequiresApi; 31 | 32 | public class Scheduler extends BroadcastReceiver 33 | { 34 | private final String EXECUTE_JOB = "org.strongswan.android.Scheduler.EXECUTE_JOB"; 35 | private final Context mContext; 36 | private final AlarmManager mManager; 37 | private final PriorityQueue mJobs; 38 | 39 | public Scheduler(Context context) 40 | { 41 | mContext = context; 42 | mManager = (AlarmManager)context.getSystemService(Context.ALARM_SERVICE); 43 | mJobs = new PriorityQueue<>(); 44 | 45 | IntentFilter filter = new IntentFilter(); 46 | filter.addAction(EXECUTE_JOB); 47 | mContext.registerReceiver(this, filter); 48 | } 49 | 50 | /** 51 | * Remove all pending jobs and unregister the receiver. 52 | * Called via JNI. 53 | */ 54 | public void Terminate() 55 | { 56 | synchronized (this) 57 | { 58 | mJobs.clear(); 59 | } 60 | mManager.cancel(createIntent()); 61 | mContext.unregisterReceiver(this); 62 | } 63 | 64 | /** 65 | * Allocate a job ID. Called via JNI. 66 | * 67 | * @return random ID for a new job 68 | */ 69 | public String allocateId() 70 | { 71 | return UUID.randomUUID().toString(); 72 | } 73 | 74 | /** 75 | * Create a pending intent to execute a job. 76 | * 77 | * @return pending intent 78 | */ 79 | private PendingIntent createIntent() 80 | { 81 | /* using component/class doesn't work with dynamic broadcast receivers */ 82 | Intent intent = new Intent(EXECUTE_JOB); 83 | intent.setPackage(mContext.getPackageName()); 84 | return PendingIntent.getBroadcast(mContext, 0, intent, 0); 85 | } 86 | 87 | /** 88 | * Schedule executing a job in the future. 89 | * Called via JNI from different threads. 90 | * 91 | * @param id job ID 92 | * @param ms delta in milliseconds when the job should be executed 93 | */ 94 | @RequiresApi(api = Build.VERSION_CODES.M) 95 | public void scheduleJob(String id, long ms) 96 | { 97 | synchronized (this) 98 | { 99 | ScheduledJob job = new ScheduledJob(id, System.currentTimeMillis() + ms); 100 | mJobs.add(job); 101 | 102 | if (job == mJobs.peek()) 103 | { /* update the alarm if the job has to be executed before all others */ 104 | PendingIntent pending = createIntent(); 105 | mManager.setExactAndAllowWhileIdle(AlarmManager.RTC_WAKEUP, job.Time, pending); 106 | } 107 | } 108 | } 109 | 110 | @RequiresApi(api = Build.VERSION_CODES.M) 111 | @Override 112 | public void onReceive(Context context, Intent intent) 113 | { 114 | ArrayList jobs = new ArrayList<>(); 115 | long now = System.currentTimeMillis(); 116 | 117 | synchronized (this) 118 | { 119 | ScheduledJob job = mJobs.peek(); 120 | while (job != null) 121 | { 122 | if (job.Time > now) 123 | { 124 | break; 125 | } 126 | jobs.add(mJobs.remove()); 127 | job = mJobs.peek(); 128 | } 129 | if (job != null) 130 | { 131 | PendingIntent pending = createIntent(); 132 | mManager.setExactAndAllowWhileIdle(AlarmManager.RTC_WAKEUP, job.Time, pending); 133 | } 134 | } 135 | 136 | for (ScheduledJob job : jobs) 137 | { 138 | executeJob(job.Id); 139 | } 140 | } 141 | 142 | /** 143 | * Execute the job with the given ID. 144 | * 145 | * @param id job ID 146 | */ 147 | public native void executeJob(String id); 148 | 149 | /** 150 | * Keep track of scheduled jobs. 151 | */ 152 | private static class ScheduledJob implements Comparable 153 | { 154 | String Id; 155 | long Time; 156 | 157 | ScheduledJob(String id, long time) 158 | { 159 | Id = id; 160 | Time = time; 161 | } 162 | 163 | @Override 164 | public int compareTo(ScheduledJob o) 165 | { 166 | return Long.compare(Time, o.Time); 167 | } 168 | } 169 | } 170 | -------------------------------------------------------------------------------- /android/src/main/java/org/strongswan/android/logic/SimpleFetcher.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2017-2018 Tobias Brunner 3 | * HSR Hochschule fuer Technik Rapperswil 4 | * 5 | * This program is free software; you can redistribute it and/or modify it 6 | * under the terms of the GNU General Public License as published by the 7 | * Free Software Foundation; either version 2 of the License, or (at your 8 | * option) any later version. See . 9 | * 10 | * This program is distributed in the hope that it will be useful, but 11 | * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 12 | * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 13 | * for more details. 14 | */ 15 | 16 | package org.strongswan.android.logic; 17 | 18 | import java.io.BufferedOutputStream; 19 | import java.io.ByteArrayOutputStream; 20 | import java.io.IOException; 21 | import java.io.InputStream; 22 | import java.io.OutputStream; 23 | import java.net.HttpURLConnection; 24 | import java.net.SocketTimeoutException; 25 | import java.net.URL; 26 | import java.util.ArrayList; 27 | import java.util.concurrent.CancellationException; 28 | import java.util.concurrent.ExecutionException; 29 | import java.util.concurrent.ExecutorService; 30 | import java.util.concurrent.Executors; 31 | import java.util.concurrent.Future; 32 | import java.util.concurrent.TimeUnit; 33 | import java.util.concurrent.TimeoutException; 34 | 35 | import androidx.annotation.Keep; 36 | 37 | @Keep 38 | public class SimpleFetcher 39 | { 40 | private static ExecutorService mExecutor = Executors.newCachedThreadPool(); 41 | private static Object mLock = new Object(); 42 | private static ArrayList mFutures = new ArrayList<>(); 43 | private static boolean mDisabled; 44 | 45 | public static byte[] fetch(String uri, byte[] data, String contentType) 46 | { 47 | Future future; 48 | 49 | synchronized (mLock) 50 | { 51 | if (mDisabled) 52 | { 53 | return null; 54 | } 55 | future = mExecutor.submit(() -> { 56 | URL url = new URL(uri); 57 | HttpURLConnection conn = (HttpURLConnection) url.openConnection(); 58 | conn.setConnectTimeout(10000); 59 | conn.setReadTimeout(10000); 60 | try 61 | { 62 | if (contentType != null) 63 | { 64 | conn.setRequestProperty("Content-Type", contentType); 65 | } 66 | if (data != null) 67 | { 68 | conn.setDoOutput(true); 69 | conn.setFixedLengthStreamingMode(data.length); 70 | OutputStream out = new BufferedOutputStream(conn.getOutputStream()); 71 | out.write(data); 72 | out.close(); 73 | } 74 | return streamToArray(conn.getInputStream()); 75 | } 76 | catch (SocketTimeoutException e) 77 | { 78 | return null; 79 | } 80 | finally 81 | { 82 | conn.disconnect(); 83 | } 84 | }); 85 | 86 | mFutures.add(future); 87 | } 88 | 89 | try 90 | { 91 | /* this enforces a timeout as the ones set on HttpURLConnection might not work reliably */ 92 | return future.get(10000, TimeUnit.MILLISECONDS); 93 | } 94 | catch (InterruptedException|ExecutionException|TimeoutException|CancellationException e) 95 | { 96 | return null; 97 | } 98 | finally 99 | { 100 | synchronized (mLock) 101 | { 102 | mFutures.remove(future); 103 | } 104 | } 105 | } 106 | 107 | /** 108 | * Enable fetching after it has been disabled. 109 | */ 110 | public static void enable() 111 | { 112 | synchronized (mLock) 113 | { 114 | mDisabled = false; 115 | } 116 | } 117 | 118 | /** 119 | * Disable the fetcher and abort any future requests. 120 | * 121 | * The native thread is not cancelable as it is working on an IKE_SA (cancelling the methods of 122 | * HttpURLConnection is not reliably possible anyway), so to abort while fetching we cancel the 123 | * Future (causing a return from fetch() immediately) and let the executor thread continue its 124 | * thing in the background. 125 | * 126 | * Also prevents future fetches until enabled again (e.g. if we aborted OCSP but would then 127 | * block in the subsequent fetch for a CRL). 128 | */ 129 | public static void disable() 130 | { 131 | synchronized (mLock) 132 | { 133 | mDisabled = true; 134 | for (Future future : mFutures) 135 | { 136 | future.cancel(true); 137 | } 138 | } 139 | } 140 | 141 | private static byte[] streamToArray(InputStream in) throws IOException 142 | { 143 | ByteArrayOutputStream out = new ByteArrayOutputStream(); 144 | byte[] buf = new byte[1024]; 145 | int len; 146 | 147 | try 148 | { 149 | while ((len = in.read(buf)) != -1) 150 | { 151 | out.write(buf, 0, len); 152 | } 153 | return out.toByteArray(); 154 | } 155 | catch (IOException e) 156 | { 157 | e.printStackTrace(); 158 | } 159 | finally 160 | { 161 | in.close(); 162 | } 163 | return null; 164 | } 165 | } -------------------------------------------------------------------------------- /android/src/main/java/org/strongswan/android/logic/StrongSwanApplication.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2014 Tobias Brunner 3 | * HSR Hochschule fuer Technik Rapperswil 4 | * 5 | * This program is free software; you can redistribute it and/or modify it 6 | * under the terms of the GNU General Public License as published by the 7 | * Free Software Foundation; either version 2 of the License, or (at your 8 | * option) any later version. See . 9 | * 10 | * This program is distributed in the hope that it will be useful, but 11 | * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 12 | * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 13 | * for more details. 14 | */ 15 | 16 | package org.strongswan.android.logic; 17 | 18 | import java.security.Security; 19 | 20 | import org.strongswan.android.security.LocalCertificateKeyStoreProvider; 21 | 22 | import android.app.Application; 23 | import android.content.Context; 24 | import android.os.Build; 25 | import com.sijav.reactnativeipsecvpn.RNIpSecVpn; 26 | 27 | public class StrongSwanApplication extends Application 28 | { 29 | private static Context mContext; 30 | 31 | static { 32 | Security.addProvider(new LocalCertificateKeyStoreProvider()); 33 | } 34 | 35 | @Override 36 | public void onCreate() 37 | { 38 | super.onCreate(); 39 | StrongSwanApplication.mContext = getApplicationContext(); 40 | } 41 | 42 | /** 43 | * Returns the current application context 44 | * @return context 45 | */ 46 | public static Context getContext() 47 | { 48 | return StrongSwanApplication.mContext; 49 | } 50 | 51 | /* 52 | * The libraries are extracted to /data/data/org.strongswan.android/... 53 | * during installation. On newer releases most are loaded in JNI_OnLoad. 54 | */ 55 | static 56 | { 57 | if (Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN_MR2) 58 | { 59 | System.loadLibrary("strongswan"); 60 | 61 | if (RNIpSecVpn.USE_BYOD) 62 | { 63 | System.loadLibrary("tpmtss"); 64 | System.loadLibrary("tncif"); 65 | System.loadLibrary("tnccs"); 66 | System.loadLibrary("imcv"); 67 | } 68 | 69 | System.loadLibrary("charon"); 70 | System.loadLibrary("ipsec"); 71 | } 72 | System.loadLibrary("androidbridge"); 73 | } 74 | } 75 | -------------------------------------------------------------------------------- /android/src/main/java/org/strongswan/android/logic/UserCredentialManager.java: -------------------------------------------------------------------------------- 1 | package org.strongswan.android.logic; 2 | 3 | import android.util.Log; 4 | import java.io.InputStream; 5 | import java.io.IOException; 6 | import java.security.cert.Certificate; 7 | import java.security.cert.CertificateException; 8 | import java.security.KeyStore; 9 | import java.security.KeyStoreException; 10 | import java.security.NoSuchAlgorithmException; 11 | import java.security.PrivateKey; 12 | import java.security.UnrecoverableKeyException; 13 | import java.util.ArrayList; 14 | import java.util.Arrays; 15 | import java.util.concurrent.locks.ReentrantReadWriteLock; 16 | 17 | public class UserCredentialManager { 18 | 19 | private static final String TAG = UserCredentialManager.class.getSimpleName(); 20 | private static final String PKCS12 = "PKCS12"; 21 | private final ReentrantReadWriteLock mLock = new ReentrantReadWriteLock(); 22 | private KeyStore store; 23 | 24 | private UserCredentialManager() { 25 | try { 26 | store = KeyStore.getInstance(PKCS12); 27 | store.load(null, null); 28 | } catch(Exception ex) { 29 | Log.e(TAG, "Unable to load keystore.", ex); 30 | } 31 | } 32 | 33 | private static class Singleton { 34 | public static final UserCredentialManager mInstance = new UserCredentialManager(); 35 | } 36 | 37 | public static UserCredentialManager getInstance() { 38 | return Singleton.mInstance; 39 | } 40 | 41 | public Certificate[] getUserCertificateChain(String alias) throws KeyStoreException { 42 | ArrayList certs = new ArrayList(); 43 | try { 44 | this.mLock.readLock().lock(); 45 | Certificate[] chain = store.getCertificateChain(alias); 46 | if(chain != null) 47 | certs.addAll(Arrays.asList(store.getCertificateChain(alias))); 48 | } finally { 49 | this.mLock.readLock().unlock(); 50 | } 51 | return certs.toArray(new Certificate[]{}); 52 | } 53 | 54 | public PrivateKey getUserKey(String alias, char[] password) throws KeyStoreException, NoSuchAlgorithmException, UnrecoverableKeyException { 55 | PrivateKey key; 56 | try { 57 | this.mLock.readLock().lock(); 58 | key = (PrivateKey)store.getKey(alias, password); 59 | } finally { 60 | this.mLock.readLock().unlock(); 61 | } 62 | return key; 63 | } 64 | 65 | public void storeCredentials(byte[] base64Bytes, char[] password) throws KeyStoreException, IOException, CertificateException, NoSuchAlgorithmException { 66 | byte[] decoded = android.util.Base64.decode(base64Bytes, 0); 67 | InputStream bis = new java.io.ByteArrayInputStream(decoded); 68 | try { 69 | this.mLock.writeLock().lock(); 70 | store.load(bis, password); 71 | } finally { 72 | this.mLock.writeLock().unlock(); 73 | bis.close(); 74 | } 75 | } 76 | } -------------------------------------------------------------------------------- /android/src/main/java/org/strongswan/android/logic/imc/AndroidImc.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2013 Tobias Brunner 3 | * HSR Hochschule fuer Technik Rapperswil 4 | * 5 | * This program is free software; you can redistribute it and/or modify it 6 | * under the terms of the GNU General Public License as published by the 7 | * Free Software Foundation; either version 2 of the License, or (at your 8 | * option) any later version. See . 9 | * 10 | * This program is distributed in the hope that it will be useful, but 11 | * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 12 | * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 13 | * for more details. 14 | */ 15 | 16 | package org.strongswan.android.logic.imc; 17 | 18 | import org.strongswan.android.logic.imc.attributes.Attribute; 19 | import org.strongswan.android.logic.imc.attributes.AttributeType; 20 | import org.strongswan.android.logic.imc.collectors.Collector; 21 | import org.strongswan.android.logic.imc.collectors.DeviceIdCollector; 22 | import org.strongswan.android.logic.imc.collectors.InstalledPackagesCollector; 23 | import org.strongswan.android.logic.imc.collectors.PortFilterCollector; 24 | import org.strongswan.android.logic.imc.collectors.ProductInformationCollector; 25 | import org.strongswan.android.logic.imc.collectors.SettingsCollector; 26 | import org.strongswan.android.logic.imc.collectors.StringVersionCollector; 27 | 28 | import android.content.Context; 29 | 30 | public class AndroidImc 31 | { 32 | private final Context mContext; 33 | 34 | public AndroidImc(Context context) 35 | { 36 | mContext = context; 37 | } 38 | 39 | /** 40 | * Get a measurement (the binary encoding of the requested attribute) for 41 | * the given vendor specific attribute type. 42 | * 43 | * @param vendor vendor ID 44 | * @param type vendor specific attribute type 45 | * @return encoded attribute, or null if not available or failed 46 | */ 47 | public byte[] getMeasurement(int vendor, int type) 48 | { 49 | return getMeasurement(vendor, type, null); 50 | } 51 | 52 | /** 53 | * Get a measurement (the binary encoding of the requested attribute) for 54 | * the given vendor specific attribute type. 55 | * 56 | * @param vendor vendor ID 57 | * @param type vendor specific attribute type 58 | * @param args optional arguments for a measurement 59 | * @return encoded attribute, or null if not available or failed 60 | */ 61 | public byte[] getMeasurement(int vendor, int type, String[] args) 62 | { 63 | AttributeType attributeType = AttributeType.fromValues(vendor, type); 64 | Collector collector = null; 65 | 66 | switch (attributeType) 67 | { 68 | case IETF_PRODUCT_INFORMATION: 69 | collector = new ProductInformationCollector(); 70 | break; 71 | case IETF_STRING_VERSION: 72 | collector = new StringVersionCollector(); 73 | break; 74 | case IETF_PORT_FILTER: 75 | collector = new PortFilterCollector(); 76 | break; 77 | case IETF_INSTALLED_PACKAGES: 78 | collector = new InstalledPackagesCollector(mContext); 79 | break; 80 | case ITA_SETTINGS: 81 | collector = new SettingsCollector(mContext, args); 82 | break; 83 | case ITA_DEVICE_ID: 84 | collector = new DeviceIdCollector(mContext); 85 | break; 86 | default: 87 | break; 88 | } 89 | if (collector != null) 90 | { 91 | Attribute attribute = collector.getMeasurement(); 92 | if (attribute != null) 93 | { 94 | return attribute.getEncoding(); 95 | } 96 | } 97 | return null; 98 | } 99 | } 100 | -------------------------------------------------------------------------------- /android/src/main/java/org/strongswan/android/logic/imc/ImcState.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2013 Tobias Brunner 3 | * HSR Hochschule fuer Technik Rapperswil 4 | * 5 | * This program is free software; you can redistribute it and/or modify it 6 | * under the terms of the GNU General Public License as published by the 7 | * Free Software Foundation; either version 2 of the License, or (at your 8 | * option) any later version. See . 9 | * 10 | * This program is distributed in the hope that it will be useful, but 11 | * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 12 | * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 13 | * for more details. 14 | */ 15 | 16 | package org.strongswan.android.logic.imc; 17 | 18 | public enum ImcState 19 | { 20 | UNKNOWN(0), 21 | ALLOW(1), 22 | BLOCK(2), 23 | ISOLATE(3); 24 | 25 | private final int mValue; 26 | 27 | private ImcState(int value) 28 | { 29 | mValue = value; 30 | } 31 | 32 | /** 33 | * Get the numeric value of the IMC state. 34 | * @return numeric value 35 | */ 36 | public int getValue() 37 | { 38 | return mValue; 39 | } 40 | 41 | /** 42 | * Get the enum entry from a numeric value, if defined 43 | * 44 | * @param value numeric value 45 | * @return the enum entry or null 46 | */ 47 | public static ImcState fromValue(int value) 48 | { 49 | for (ImcState state : ImcState.values()) 50 | { 51 | if (state.mValue == value) 52 | { 53 | return state; 54 | } 55 | } 56 | return null; 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /android/src/main/java/org/strongswan/android/logic/imc/attributes/Attribute.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2013 Tobias Brunner 3 | * HSR Hochschule fuer Technik Rapperswil 4 | * 5 | * This program is free software; you can redistribute it and/or modify it 6 | * under the terms of the GNU General Public License as published by the 7 | * Free Software Foundation; either version 2 of the License, or (at your 8 | * option) any later version. See . 9 | * 10 | * This program is distributed in the hope that it will be useful, but 11 | * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 12 | * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 13 | * for more details. 14 | */ 15 | 16 | package org.strongswan.android.logic.imc.attributes; 17 | 18 | /** 19 | * Interface to be implemented by attribute classes 20 | */ 21 | public interface Attribute 22 | { 23 | /** 24 | * Returns the binary encoding of the attribute 25 | * @return binary encoding 26 | */ 27 | public byte[] getEncoding(); 28 | } 29 | -------------------------------------------------------------------------------- /android/src/main/java/org/strongswan/android/logic/imc/attributes/AttributeType.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2013 Tobias Brunner 3 | * Copyright (C) 2012 Christoph Buehler 4 | * Copyright (C) 2012 Patrick Loetscher 5 | * HSR Hochschule fuer Technik Rapperswil 6 | * 7 | * This program is free software; you can redistribute it and/or modify it 8 | * under the terms of the GNU General Public License as published by the 9 | * Free Software Foundation; either version 2 of the License, or (at your 10 | * option) any later version. See . 11 | * 12 | * This program is distributed in the hope that it will be useful, but 13 | * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 14 | * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 15 | * for more details. 16 | */ 17 | 18 | package org.strongswan.android.logic.imc.attributes; 19 | 20 | public enum AttributeType 21 | { 22 | /* IETF standard PA-TNC attribute types defined by RFC 5792 */ 23 | IETF_TESTING(PrivateEnterpriseNumber.IETF, 0), 24 | IETF_ATTRIBUTE_REQUEST(PrivateEnterpriseNumber.IETF, 1), 25 | IETF_PRODUCT_INFORMATION(PrivateEnterpriseNumber.IETF, 2), 26 | IETF_NUMERIC_VERSION(PrivateEnterpriseNumber.IETF, 3), 27 | IETF_STRING_VERSION(PrivateEnterpriseNumber.IETF, 4), 28 | IETF_OPERATIONAL_STATUS(PrivateEnterpriseNumber.IETF, 5), 29 | IETF_PORT_FILTER(PrivateEnterpriseNumber.IETF, 6), 30 | IETF_INSTALLED_PACKAGES(PrivateEnterpriseNumber.IETF, 7), 31 | IETF_PA_TNC_ERROR(PrivateEnterpriseNumber.IETF, 8), 32 | IETF_ASSESSMENT_RESULT(PrivateEnterpriseNumber.IETF, 9), 33 | IETF_REMEDIATION_INSTRUCTIONS(PrivateEnterpriseNumber.IETF, 10), 34 | IETF_FORWARDING_ENABLED(PrivateEnterpriseNumber.IETF, 11), 35 | IETF_FACTORY_DEFAULT_PWD_ENABLED(PrivateEnterpriseNumber.IETF, 12), 36 | IETF_RESERVED(PrivateEnterpriseNumber.IETF, 0xffffffff), 37 | /* ITA attributes */ 38 | ITA_SETTINGS(PrivateEnterpriseNumber.ITA, 4), 39 | ITA_DEVICE_ID(PrivateEnterpriseNumber.ITA, 8); 40 | 41 | private PrivateEnterpriseNumber mVendor; 42 | private int mType; 43 | 44 | /** 45 | * Enum type for vendor specific attributes (defined in their namespace) 46 | * 47 | * @param vendor private enterprise number of vendor 48 | * @param type vendor specific attribute type 49 | */ 50 | private AttributeType(PrivateEnterpriseNumber vendor, int type) 51 | { 52 | mVendor = vendor; 53 | mType = type; 54 | } 55 | 56 | /** 57 | * Get private enterprise number of vendor 58 | * 59 | * @return PEN 60 | */ 61 | public PrivateEnterpriseNumber getVendor() 62 | { 63 | return mVendor; 64 | } 65 | 66 | /** 67 | * Get vendor specific type 68 | * 69 | * @return type 70 | */ 71 | public int getType() 72 | { 73 | return mType; 74 | } 75 | 76 | /** 77 | * Get the enum entry from the given numeric values, if defined 78 | * 79 | * @param vendor vendor id 80 | * @param type vendor specific type 81 | * @return enum entry or null 82 | */ 83 | public static AttributeType fromValues(int vendor, int type) 84 | { 85 | PrivateEnterpriseNumber pen = PrivateEnterpriseNumber.fromValue(vendor); 86 | 87 | if (pen == null) 88 | { 89 | return null; 90 | } 91 | for (AttributeType attr : AttributeType.values()) 92 | { 93 | if (attr.mVendor == pen && attr.mType == type) 94 | { 95 | return attr; 96 | } 97 | } 98 | return null; 99 | } 100 | } 101 | -------------------------------------------------------------------------------- /android/src/main/java/org/strongswan/android/logic/imc/attributes/DeviceIdAttribute.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2013 Tobias Brunner 3 | * HSR Hochschule fuer Technik Rapperswil 4 | * 5 | * This program is free software; you can redistribute it and/or modify it 6 | * under the terms of the GNU General Public License as published by the 7 | * Free Software Foundation; either version 2 of the License, or (at your 8 | * option) any later version. See . 9 | * 10 | * This program is distributed in the hope that it will be useful, but 11 | * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 12 | * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 13 | * for more details. 14 | */ 15 | 16 | package org.strongswan.android.logic.imc.attributes; 17 | 18 | /** 19 | * ITA Device ID attribute 20 | * 21 | * 1 2 3 22 | * 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 23 | * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 24 | * | Device ID (Variable Length) | 25 | * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 26 | */ 27 | public class DeviceIdAttribute implements Attribute 28 | { 29 | private String mDeviceId; 30 | 31 | /** 32 | * Set the device ID 33 | * @param version version number 34 | */ 35 | public void setDeviceId(String deviceId) 36 | { 37 | this.mDeviceId = deviceId; 38 | } 39 | 40 | @Override 41 | public byte[] getEncoding() 42 | { 43 | return mDeviceId.getBytes(); 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /android/src/main/java/org/strongswan/android/logic/imc/attributes/InstalledPackagesAttribute.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2013 Tobias Brunner 3 | * Copyright (C) 2012 Christoph Buehler 4 | * Copyright (C) 2012 Patrick Loetscher 5 | * HSR Hochschule fuer Technik Rapperswil 6 | * 7 | * This program is free software; you can redistribute it and/or modify it 8 | * under the terms of the GNU General Public License as published by the 9 | * Free Software Foundation; either version 2 of the License, or (at your 10 | * option) any later version. See . 11 | * 12 | * This program is distributed in the hope that it will be useful, but 13 | * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 14 | * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 15 | * for more details. 16 | */ 17 | 18 | package org.strongswan.android.logic.imc.attributes; 19 | 20 | import java.util.LinkedList; 21 | 22 | import org.strongswan.android.utils.BufferedByteWriter; 23 | 24 | import android.util.Pair; 25 | 26 | /** 27 | * PA-TNC Installed Packages attribute (see section 4.2.7 of RFC 5792) 28 | * 29 | * 1 2 3 30 | * 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 31 | * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 32 | * | Reserved | Package Count | 33 | * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 34 | * | Pkg Name Len | Package Name (Variable Length) | 35 | * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 36 | * | Version Len | Package Version Number (Variable Length) | 37 | * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 38 | */ 39 | public class InstalledPackagesAttribute implements Attribute 40 | { 41 | private final short RESERVED = 0; 42 | private final LinkedList> mPackages = new LinkedList>(); 43 | 44 | /** 45 | * Add an installed package to this attribute. 46 | * @param name name of the package 47 | * @param version version number of the package 48 | */ 49 | public void addPackage(String name, String version) 50 | { 51 | mPackages.add(new Pair(name, version)); 52 | } 53 | 54 | @Override 55 | public byte[] getEncoding() 56 | { 57 | BufferedByteWriter writer = new BufferedByteWriter(); 58 | writer.put16(RESERVED); 59 | writer.put16((short)mPackages.size()); 60 | for (Pair pair : mPackages) 61 | { 62 | writer.putLen8(pair.first.getBytes()); 63 | writer.putLen8(pair.second.getBytes()); 64 | } 65 | return writer.toByteArray(); 66 | } 67 | } 68 | -------------------------------------------------------------------------------- /android/src/main/java/org/strongswan/android/logic/imc/attributes/PortFilterAttribute.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2013 Tobias Brunner 3 | * Copyright (C) 2012 Christoph Buehler 4 | * Copyright (C) 2012 Patrick Loetscher 5 | * HSR Hochschule fuer Technik Rapperswil 6 | * 7 | * This program is free software; you can redistribute it and/or modify it 8 | * under the terms of the GNU General Public License as published by the 9 | * Free Software Foundation; either version 2 of the License, or (at your 10 | * option) any later version. See . 11 | * 12 | * This program is distributed in the hope that it will be useful, but 13 | * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 14 | * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 15 | * for more details. 16 | */ 17 | 18 | package org.strongswan.android.logic.imc.attributes; 19 | 20 | import java.util.LinkedList; 21 | 22 | import org.strongswan.android.logic.imc.collectors.Protocol; 23 | import org.strongswan.android.utils.BufferedByteWriter; 24 | 25 | import android.util.Pair; 26 | 27 | /** 28 | * PA-TNC Port Filter attribute (see section 4.2.6 of RFC 5792) 29 | * 30 | * 1 2 3 31 | * 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 32 | * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 33 | * | Reserved |B| Protocol | Port Number | 34 | * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 35 | * | Reserved |B| Protocol | Port Number | 36 | * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 37 | */ 38 | public class PortFilterAttribute implements Attribute 39 | { 40 | private final LinkedList> mPorts = new LinkedList>(); 41 | 42 | /** 43 | * Add an open port with the given protocol and port number 44 | * @param protocol transport protocol 45 | * @param port port number 46 | */ 47 | public void addPort(Protocol protocol, short port) 48 | { 49 | mPorts.add(new Pair(protocol, port)); 50 | } 51 | 52 | @Override 53 | public byte[] getEncoding() 54 | { 55 | BufferedByteWriter writer = new BufferedByteWriter(); 56 | for (Pair port : mPorts) 57 | { 58 | /* we report open ports, so the BLOCKED flag is not set */ 59 | writer.put((byte)0); 60 | writer.put(port.first.getValue()); 61 | writer.put16(port.second); 62 | } 63 | return writer.toByteArray(); 64 | } 65 | } 66 | -------------------------------------------------------------------------------- /android/src/main/java/org/strongswan/android/logic/imc/attributes/PrivateEnterpriseNumber.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2013 Tobias Brunner 3 | * HSR Hochschule fuer Technik Rapperswil 4 | * 5 | * This program is free software; you can redistribute it and/or modify it 6 | * under the terms of the GNU General Public License as published by the 7 | * Free Software Foundation; either version 2 of the License, or (at your 8 | * option) any later version. See . 9 | * 10 | * This program is distributed in the hope that it will be useful, but 11 | * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 12 | * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 13 | * for more details. 14 | */ 15 | 16 | package org.strongswan.android.logic.imc.attributes; 17 | 18 | public enum PrivateEnterpriseNumber 19 | { 20 | IETF(0x000000), 21 | GOOGLE(0x002B79), 22 | ITA(0x00902a), 23 | UNASSIGNED(0xfffffe), 24 | RESERVED(0xffffff); 25 | 26 | private int mValue; 27 | 28 | /** 29 | * Enum for private enterprise numbers (PEN) as allocated by IANA 30 | * 31 | * @param value numeric value 32 | */ 33 | private PrivateEnterpriseNumber(int value) 34 | { 35 | mValue = value; 36 | } 37 | 38 | /** 39 | * Get the numeric value of a PEN 40 | * 41 | * @return numeric value 42 | */ 43 | public int getValue() 44 | { 45 | return mValue; 46 | } 47 | 48 | /** 49 | * Get the enum entry from a numeric value, if defined 50 | * 51 | * @param value numeric value 52 | * @return the enum entry or null 53 | */ 54 | public static PrivateEnterpriseNumber fromValue(int value) 55 | { 56 | for (PrivateEnterpriseNumber pen : PrivateEnterpriseNumber.values()) 57 | { 58 | if (pen.mValue == value) 59 | { 60 | return pen; 61 | } 62 | } 63 | return null; 64 | } 65 | } 66 | -------------------------------------------------------------------------------- /android/src/main/java/org/strongswan/android/logic/imc/attributes/ProductInformationAttribute.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2013 Tobias Brunner 3 | * Copyright (C) 2012 Christoph Buehler 4 | * Copyright (C) 2012 Patrick Loetscher 5 | * HSR Hochschule fuer Technik Rapperswil 6 | * 7 | * This program is free software; you can redistribute it and/or modify it 8 | * under the terms of the GNU General Public License as published by the 9 | * Free Software Foundation; either version 2 of the License, or (at your 10 | * option) any later version. See . 11 | * 12 | * This program is distributed in the hope that it will be useful, but 13 | * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 14 | * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 15 | * for more details. 16 | */ 17 | 18 | package org.strongswan.android.logic.imc.attributes; 19 | 20 | import org.strongswan.android.utils.BufferedByteWriter; 21 | 22 | /** 23 | * PA-TNC Product Information attribute (see section 4.2.2 of RFC 5792) 24 | * 25 | * 1 2 3 26 | * 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 27 | * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 28 | * | Product Vendor ID | Product ID | 29 | * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 30 | * | Product ID | Product Name (Variable Length) | 31 | * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 32 | */ 33 | public class ProductInformationAttribute implements Attribute 34 | { 35 | private final String PRODUCT_NAME = "Android"; 36 | private final short PRODUCT_ID = 0; 37 | 38 | @Override 39 | public byte[] getEncoding() 40 | { 41 | BufferedByteWriter writer = new BufferedByteWriter(); 42 | writer.put24(PrivateEnterpriseNumber.GOOGLE.getValue()); 43 | writer.put16(PRODUCT_ID); 44 | writer.put(PRODUCT_NAME.getBytes()); 45 | return writer.toByteArray(); 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /android/src/main/java/org/strongswan/android/logic/imc/attributes/SettingsAttribute.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2013 Tobias Brunner 3 | * Copyright (C) 2012 Christoph Buehler 4 | * Copyright (C) 2012 Patrick Loetscher 5 | * HSR Hochschule fuer Technik Rapperswil 6 | * 7 | * This program is free software; you can redistribute it and/or modify it 8 | * under the terms of the GNU General Public License as published by the 9 | * Free Software Foundation; either version 2 of the License, or (at your 10 | * option) any later version. See . 11 | * 12 | * This program is distributed in the hope that it will be useful, but 13 | * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 14 | * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 15 | * for more details. 16 | */ 17 | 18 | package org.strongswan.android.logic.imc.attributes; 19 | 20 | import java.util.LinkedList; 21 | 22 | import org.strongswan.android.utils.BufferedByteWriter; 23 | 24 | import android.util.Pair; 25 | 26 | /** 27 | * ITA Settings attribute 28 | * 29 | * 1 2 3 30 | * 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 31 | * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 32 | * | Settings Count | 33 | * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 34 | * | Name Length | Name (Variable Length) ~ 35 | * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 36 | * ~ Name (Variable Length) ~ 37 | * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 38 | * | Value Length | Value (Variable Length) ~ 39 | * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 40 | * ~ Value (Variable Length) ~ 41 | * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 42 | * | Name Length | Name (Variable Length) ~ 43 | * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 44 | * ~ Name (Variable Length) ~ 45 | * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 46 | * | Value Length | Value (Variable Length) ~ 47 | * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 48 | * ~ Value (Variable Length) ~ 49 | * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 50 | * ........................... 51 | */ 52 | public class SettingsAttribute implements Attribute 53 | { 54 | private final LinkedList> mSettings = new LinkedList>(); 55 | 56 | /** 57 | * Add a setting to this attribute. 58 | * @param name name of the setting 59 | * @param value value of the setting 60 | */ 61 | public void addSetting(String name, String value) 62 | { 63 | mSettings.add(new Pair(name, value)); 64 | } 65 | 66 | @Override 67 | public byte[] getEncoding() 68 | { 69 | BufferedByteWriter writer = new BufferedByteWriter(); 70 | writer.put32(mSettings.size()); 71 | for (Pair pair : mSettings) 72 | { 73 | writer.putLen16(pair.first.getBytes()); 74 | writer.putLen16(pair.second.getBytes()); 75 | } 76 | return writer.toByteArray(); 77 | } 78 | } 79 | -------------------------------------------------------------------------------- /android/src/main/java/org/strongswan/android/logic/imc/attributes/StringVersionAttribute.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2013 Tobias Brunner 3 | * Copyright (C) 2012 Christoph Buehler 4 | * Copyright (C) 2012 Patrick Loetscher 5 | * HSR Hochschule fuer Technik Rapperswil 6 | * 7 | * This program is free software; you can redistribute it and/or modify it 8 | * under the terms of the GNU General Public License as published by the 9 | * Free Software Foundation; either version 2 of the License, or (at your 10 | * option) any later version. See . 11 | * 12 | * This program is distributed in the hope that it will be useful, but 13 | * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 14 | * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 15 | * for more details. 16 | */ 17 | 18 | package org.strongswan.android.logic.imc.attributes; 19 | 20 | import org.strongswan.android.utils.BufferedByteWriter; 21 | 22 | /** 23 | * PA-TNC String Version attribute (see section 4.2.4 of RFC 5792) 24 | * 25 | * 1 2 3 26 | * 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 27 | * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 28 | * | Version Len | Product Version Number (Variable Length) | 29 | * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 30 | * | Build Num Len | Internal Build Number (Variable Length) | 31 | * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 32 | * | Config. Len | Configuration Version Number (Variable Length)| 33 | * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 34 | */ 35 | public class StringVersionAttribute implements Attribute 36 | { 37 | private String mVersionNumber; 38 | private String mBuildNumber; 39 | 40 | /** 41 | * Set the product version number 42 | * @param version version number 43 | */ 44 | public void setProductVersionNumber(String version) 45 | { 46 | this.mVersionNumber = version; 47 | } 48 | 49 | /** 50 | * Set the internal build number 51 | * @param build build number 52 | */ 53 | public void setInternalBuildNumber(String build) 54 | { 55 | this.mBuildNumber = build; 56 | } 57 | 58 | @Override 59 | public byte[] getEncoding() 60 | { 61 | BufferedByteWriter writer = new BufferedByteWriter(); 62 | writer.putLen8(mVersionNumber.getBytes()); 63 | writer.putLen8(mBuildNumber.getBytes()); 64 | /* we don't provide a configuration number */ 65 | writer.put((byte)0); 66 | return writer.toByteArray(); 67 | } 68 | } 69 | -------------------------------------------------------------------------------- /android/src/main/java/org/strongswan/android/logic/imc/collectors/Collector.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2013 Tobias Brunner 3 | * HSR Hochschule fuer Technik Rapperswil 4 | * 5 | * This program is free software; you can redistribute it and/or modify it 6 | * under the terms of the GNU General Public License as published by the 7 | * Free Software Foundation; either version 2 of the License, or (at your 8 | * option) any later version. See . 9 | * 10 | * This program is distributed in the hope that it will be useful, but 11 | * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 12 | * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 13 | * for more details. 14 | */ 15 | 16 | package org.strongswan.android.logic.imc.collectors; 17 | 18 | import org.strongswan.android.logic.imc.attributes.Attribute; 19 | 20 | /** 21 | * Interface for measurement collectors 22 | */ 23 | public interface Collector 24 | { 25 | /** 26 | * This method shall return the result of a measurement, if available 27 | * @return attribute or null 28 | */ 29 | public abstract Attribute getMeasurement(); 30 | } 31 | -------------------------------------------------------------------------------- /android/src/main/java/org/strongswan/android/logic/imc/collectors/DeviceIdCollector.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2013 Tobias Brunner 3 | * HSR Hochschule fuer Technik Rapperswil 4 | * 5 | * This program is free software; you can redistribute it and/or modify it 6 | * under the terms of the GNU General Public License as published by the 7 | * Free Software Foundation; either version 2 of the License, or (at your 8 | * option) any later version. See . 9 | * 10 | * This program is distributed in the hope that it will be useful, but 11 | * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 12 | * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 13 | * for more details. 14 | */ 15 | 16 | package org.strongswan.android.logic.imc.collectors; 17 | 18 | import org.strongswan.android.logic.imc.attributes.Attribute; 19 | import org.strongswan.android.logic.imc.attributes.DeviceIdAttribute; 20 | 21 | import android.content.ContentResolver; 22 | import android.content.Context; 23 | 24 | public class DeviceIdCollector implements Collector 25 | { 26 | private final ContentResolver mContentResolver; 27 | 28 | public DeviceIdCollector(Context context) 29 | { 30 | mContentResolver = context.getContentResolver(); 31 | } 32 | 33 | @Override 34 | public Attribute getMeasurement() 35 | { 36 | String id = android.provider.Settings.Secure.getString(mContentResolver, "android_id"); 37 | if (id != null) 38 | { 39 | DeviceIdAttribute attribute = new DeviceIdAttribute(); 40 | attribute.setDeviceId(id); 41 | return attribute; 42 | } 43 | return null; 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /android/src/main/java/org/strongswan/android/logic/imc/collectors/InstalledPackagesCollector.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2013 Tobias Brunner 3 | * Copyright (C) 2012 Christoph Buehler 4 | * Copyright (C) 2012 Patrick Loetscher 5 | * HSR Hochschule fuer Technik Rapperswil 6 | * 7 | * This program is free software; you can redistribute it and/or modify it 8 | * under the terms of the GNU General Public License as published by the 9 | * Free Software Foundation; either version 2 of the License, or (at your 10 | * option) any later version. See . 11 | * 12 | * This program is distributed in the hope that it will be useful, but 13 | * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 14 | * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 15 | * for more details. 16 | */ 17 | 18 | package org.strongswan.android.logic.imc.collectors; 19 | 20 | import java.util.List; 21 | 22 | import org.strongswan.android.logic.imc.attributes.Attribute; 23 | import org.strongswan.android.logic.imc.attributes.InstalledPackagesAttribute; 24 | 25 | import android.content.Context; 26 | import android.content.pm.ApplicationInfo; 27 | import android.content.pm.PackageInfo; 28 | import android.content.pm.PackageManager; 29 | 30 | public class InstalledPackagesCollector implements Collector 31 | { 32 | private final PackageManager mPackageManager; 33 | 34 | public InstalledPackagesCollector(Context context) 35 | { 36 | mPackageManager = context.getPackageManager(); 37 | } 38 | 39 | @Override 40 | public Attribute getMeasurement() 41 | { 42 | InstalledPackagesAttribute attribute = new InstalledPackagesAttribute(); 43 | List packages = mPackageManager.getInstalledPackages(0); 44 | for (PackageInfo info : packages) 45 | { 46 | if ((info.applicationInfo.flags & ApplicationInfo.FLAG_SYSTEM) != 0 || 47 | info.packageName == null || info.versionName == null) 48 | { /* ignore packages installed in the system image */ 49 | continue; 50 | } 51 | attribute.addPackage(info.packageName, info.versionName); 52 | } 53 | return attribute; 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /android/src/main/java/org/strongswan/android/logic/imc/collectors/PortFilterCollector.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2013 Tobias Brunner 3 | * Copyright (C) 2012 Christoph Buehler 4 | * Copyright (C) 2012 Patrick Loetscher 5 | * HSR Hochschule fuer Technik Rapperswil 6 | * 7 | * This program is free software; you can redistribute it and/or modify it 8 | * under the terms of the GNU General Public License as published by the 9 | * Free Software Foundation; either version 2 of the License, or (at your 10 | * option) any later version. See . 11 | * 12 | * This program is distributed in the hope that it will be useful, but 13 | * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 14 | * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 15 | * for more details. 16 | */ 17 | 18 | package org.strongswan.android.logic.imc.collectors; 19 | 20 | import java.io.BufferedReader; 21 | import java.io.IOException; 22 | import java.io.InputStreamReader; 23 | import java.util.regex.Matcher; 24 | import java.util.regex.Pattern; 25 | 26 | import org.strongswan.android.logic.imc.attributes.Attribute; 27 | import org.strongswan.android.logic.imc.attributes.PortFilterAttribute; 28 | 29 | public class PortFilterCollector implements Collector 30 | { 31 | private static Pattern LISTEN = Pattern.compile("\\bLISTEN\\b"); 32 | private static Pattern PROTOCOL = Pattern.compile("\\b(tcp|udp)6?\\b"); 33 | private static Pattern PORT = Pattern.compile("[:]{1,3}(\\d{1,5})\\b(?!\\.)"); 34 | 35 | @Override 36 | public Attribute getMeasurement() 37 | { 38 | PortFilterAttribute attribute = null; 39 | try 40 | { 41 | Process netstat = Runtime.getRuntime().exec("netstat -n"); 42 | try 43 | { 44 | BufferedReader reader = new BufferedReader(new InputStreamReader(netstat.getInputStream())); 45 | String line; 46 | attribute = new PortFilterAttribute(); 47 | while ((line = reader.readLine()) != null) 48 | { 49 | if (!LISTEN.matcher(line).find()) 50 | { 51 | continue; 52 | } 53 | Matcher protocolMatcher = PROTOCOL.matcher(line); 54 | Matcher portMatcher = PORT.matcher(line); 55 | if (protocolMatcher.find() && portMatcher.find()) 56 | { 57 | Protocol protocol = Protocol.fromName(protocolMatcher.group()); 58 | if (protocol == null) 59 | { 60 | continue; 61 | } 62 | int port = Integer.parseInt(portMatcher.group(1)); 63 | attribute.addPort(protocol, (short)port); 64 | } 65 | } 66 | } 67 | finally 68 | { 69 | netstat.destroy(); 70 | } 71 | } 72 | catch (IOException e) 73 | { 74 | e.printStackTrace(); 75 | } 76 | return attribute; 77 | } 78 | 79 | } 80 | -------------------------------------------------------------------------------- /android/src/main/java/org/strongswan/android/logic/imc/collectors/ProductInformationCollector.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2013 Tobias Brunner 3 | * Copyright (C) 2012 Christoph Buehler 4 | * Copyright (C) 2012 Patrick Loetscher 5 | * HSR Hochschule fuer Technik Rapperswil 6 | * 7 | * This program is free software; you can redistribute it and/or modify it 8 | * under the terms of the GNU General Public License as published by the 9 | * Free Software Foundation; either version 2 of the License, or (at your 10 | * option) any later version. See . 11 | * 12 | * This program is distributed in the hope that it will be useful, but 13 | * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 14 | * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 15 | * for more details. 16 | */ 17 | 18 | package org.strongswan.android.logic.imc.collectors; 19 | 20 | import org.strongswan.android.logic.imc.attributes.Attribute; 21 | import org.strongswan.android.logic.imc.attributes.ProductInformationAttribute; 22 | 23 | public class ProductInformationCollector implements Collector 24 | { 25 | @Override 26 | public Attribute getMeasurement() 27 | { /* this is currently hardcoded in the attribute */ 28 | return new ProductInformationAttribute(); 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /android/src/main/java/org/strongswan/android/logic/imc/collectors/Protocol.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2013 Tobias Brunner 3 | * HSR Hochschule fuer Technik Rapperswil 4 | * 5 | * This program is free software; you can redistribute it and/or modify it 6 | * under the terms of the GNU General Public License as published by the 7 | * Free Software Foundation; either version 2 of the License, or (at your 8 | * option) any later version. See . 9 | * 10 | * This program is distributed in the hope that it will be useful, but 11 | * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 12 | * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 13 | * for more details. 14 | */ 15 | 16 | package org.strongswan.android.logic.imc.collectors; 17 | 18 | public enum Protocol 19 | { 20 | TCP((byte)6, "tcp", "tcp6"), 21 | UDP((byte)17, "udp", "udp6"); 22 | 23 | private final byte mValue; 24 | private String[] mNames; 25 | 26 | private Protocol(byte value, String... names) 27 | { 28 | mValue = value; 29 | mNames = names; 30 | } 31 | 32 | /** 33 | * Get the numeric value of the protocol. 34 | * @return numeric value 35 | */ 36 | public byte getValue() 37 | { 38 | return mValue; 39 | } 40 | 41 | /** 42 | * Get the protocol from the given protocol name, if found. 43 | * @param name protocol name (e.g. "udp" or "tcp") 44 | * @return enum entry or null 45 | */ 46 | public static Protocol fromName(String name) 47 | { 48 | for (Protocol protocol : Protocol.values()) 49 | { 50 | for (String keyword : protocol.mNames) 51 | { 52 | if (keyword.equalsIgnoreCase(name)) 53 | { 54 | return protocol; 55 | } 56 | } 57 | } 58 | return null; 59 | } 60 | } 61 | -------------------------------------------------------------------------------- /android/src/main/java/org/strongswan/android/logic/imc/collectors/SettingsCollector.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2013 Tobias Brunner 3 | * Copyright (C) 2012 Christoph Buehler 4 | * Copyright (C) 2012 Patrick Loetscher 5 | * HSR Hochschule fuer Technik Rapperswil 6 | * 7 | * This program is free software; you can redistribute it and/or modify it 8 | * under the terms of the GNU General Public License as published by the 9 | * Free Software Foundation; either version 2 of the License, or (at your 10 | * option) any later version. See . 11 | * 12 | * This program is distributed in the hope that it will be useful, but 13 | * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 14 | * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 15 | * for more details. 16 | */ 17 | 18 | package org.strongswan.android.logic.imc.collectors; 19 | 20 | import java.util.Locale; 21 | 22 | import org.strongswan.android.logic.imc.attributes.Attribute; 23 | import org.strongswan.android.logic.imc.attributes.SettingsAttribute; 24 | 25 | import android.content.ContentResolver; 26 | import android.content.Context; 27 | 28 | public class SettingsCollector implements Collector 29 | { 30 | private final ContentResolver mContentResolver; 31 | private final String[] mSettings; 32 | 33 | public SettingsCollector(Context context, String[] args) 34 | { 35 | mContentResolver = context.getContentResolver(); 36 | mSettings = args; 37 | } 38 | 39 | @Override 40 | public Attribute getMeasurement() 41 | { 42 | if (mSettings == null || mSettings.length == 0) 43 | { 44 | return null; 45 | } 46 | SettingsAttribute attribute = new SettingsAttribute(); 47 | for (String name : mSettings) 48 | { 49 | String value = android.provider.Settings.Secure.getString(mContentResolver, name.toLowerCase(Locale.US)); 50 | if (value == null) 51 | { 52 | value = android.provider.Settings.System.getString(mContentResolver, name.toLowerCase(Locale.US)); 53 | } 54 | if (value != null) 55 | { 56 | attribute.addSetting(name, value); 57 | } 58 | } 59 | return attribute; 60 | } 61 | } 62 | -------------------------------------------------------------------------------- /android/src/main/java/org/strongswan/android/logic/imc/collectors/StringVersionCollector.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2013 Tobias Brunner 3 | * Copyright (C) 2012 Christoph Buehler 4 | * Copyright (C) 2012 Patrick Loetscher 5 | * HSR Hochschule fuer Technik Rapperswil 6 | * 7 | * This program is free software; you can redistribute it and/or modify it 8 | * under the terms of the GNU General Public License as published by the 9 | * Free Software Foundation; either version 2 of the License, or (at your 10 | * option) any later version. See . 11 | * 12 | * This program is distributed in the hope that it will be useful, but 13 | * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 14 | * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 15 | * for more details. 16 | */ 17 | 18 | package org.strongswan.android.logic.imc.collectors; 19 | 20 | import org.strongswan.android.logic.imc.attributes.Attribute; 21 | import org.strongswan.android.logic.imc.attributes.StringVersionAttribute; 22 | 23 | public class StringVersionCollector implements Collector 24 | { 25 | @Override 26 | public Attribute getMeasurement() 27 | { 28 | StringVersionAttribute attribute = new StringVersionAttribute(); 29 | attribute.setProductVersionNumber(android.os.Build.VERSION.RELEASE); 30 | attribute.setInternalBuildNumber(android.os.Build.DISPLAY); 31 | return attribute; 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /android/src/main/java/org/strongswan/android/security/LocalCertificateKeyStoreProvider.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2014 Tobias Brunner 3 | * HSR Hochschule fuer Technik Rapperswil 4 | * 5 | * This program is free software; you can redistribute it and/or modify it 6 | * under the terms of the GNU General Public License as published by the 7 | * Free Software Foundation; either version 2 of the License, or (at your 8 | * option) any later version. See . 9 | * 10 | * This program is distributed in the hope that it will be useful, but 11 | * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 12 | * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 13 | * for more details. 14 | */ 15 | 16 | package org.strongswan.android.security; 17 | 18 | import java.security.Provider; 19 | 20 | public class LocalCertificateKeyStoreProvider extends Provider 21 | { 22 | private static final long serialVersionUID = 3515038332469843219L; 23 | 24 | public LocalCertificateKeyStoreProvider() 25 | { 26 | super("LocalCertificateKeyStoreProvider", 1.0, "KeyStore provider for local certificates"); 27 | put("KeyStore.LocalCertificateStore", LocalCertificateKeyStoreSpi.class.getName()); 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /android/src/main/java/org/strongswan/android/security/LocalCertificateKeyStoreSpi.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2014 Tobias Brunner 3 | * HSR Hochschule fuer Technik Rapperswil 4 | * 5 | * This program is free software; you can redistribute it and/or modify it 6 | * under the terms of the GNU General Public License as published by the 7 | * Free Software Foundation; either version 2 of the License, or (at your 8 | * option) any later version. See . 9 | * 10 | * This program is distributed in the hope that it will be useful, but 11 | * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 12 | * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 13 | * for more details. 14 | */ 15 | 16 | package org.strongswan.android.security; 17 | 18 | import java.io.IOException; 19 | import java.io.InputStream; 20 | import java.io.OutputStream; 21 | import java.security.Key; 22 | import java.security.KeyStoreException; 23 | import java.security.KeyStoreSpi; 24 | import java.security.NoSuchAlgorithmException; 25 | import java.security.UnrecoverableKeyException; 26 | import java.security.cert.Certificate; 27 | import java.security.cert.CertificateException; 28 | import java.util.Collections; 29 | import java.util.Date; 30 | import java.util.Enumeration; 31 | 32 | public class LocalCertificateKeyStoreSpi extends KeyStoreSpi 33 | { 34 | private final LocalCertificateStore mStore = new LocalCertificateStore(); 35 | 36 | @Override 37 | public Key engineGetKey(String alias, char[] password) throws NoSuchAlgorithmException, UnrecoverableKeyException 38 | { 39 | return null; 40 | } 41 | 42 | @Override 43 | public Certificate[] engineGetCertificateChain(String alias) 44 | { 45 | return null; 46 | } 47 | 48 | @Override 49 | public Certificate engineGetCertificate(String alias) 50 | { 51 | return mStore.getCertificate(alias); 52 | } 53 | 54 | @Override 55 | public Date engineGetCreationDate(String alias) 56 | { 57 | return mStore.getCreationDate(alias); 58 | } 59 | 60 | @Override 61 | public void engineSetKeyEntry(String alias, Key key, char[] password, Certificate[] chain) throws KeyStoreException 62 | { 63 | throw new UnsupportedOperationException(); 64 | } 65 | 66 | @Override 67 | public void engineSetKeyEntry(String alias, byte[] key, Certificate[] chain) throws KeyStoreException 68 | { 69 | throw new UnsupportedOperationException(); 70 | } 71 | 72 | @Override 73 | public void engineSetCertificateEntry(String alias, Certificate cert) throws KeyStoreException 74 | { 75 | /* we ignore the given alias as the store calculates it on its own, 76 | * duplicates are replaced */ 77 | if (!mStore.addCertificate(cert)) 78 | { 79 | throw new KeyStoreException(); 80 | } 81 | } 82 | 83 | @Override 84 | public void engineDeleteEntry(String alias) throws KeyStoreException 85 | { 86 | mStore.deleteCertificate(alias); 87 | } 88 | 89 | @Override 90 | public Enumeration engineAliases() 91 | { 92 | return Collections.enumeration(mStore.aliases()); 93 | } 94 | 95 | @Override 96 | public boolean engineContainsAlias(String alias) 97 | { 98 | return mStore.containsAlias(alias); 99 | } 100 | 101 | @Override 102 | public int engineSize() 103 | { 104 | return mStore.aliases().size(); 105 | } 106 | 107 | @Override 108 | public boolean engineIsKeyEntry(String alias) 109 | { 110 | return false; 111 | } 112 | 113 | @Override 114 | public boolean engineIsCertificateEntry(String alias) 115 | { 116 | return engineContainsAlias(alias); 117 | } 118 | 119 | @Override 120 | public String engineGetCertificateAlias(Certificate cert) 121 | { 122 | return mStore.getCertificateAlias(cert); 123 | } 124 | 125 | @Override 126 | public void engineStore(OutputStream stream, char[] password) throws IOException, NoSuchAlgorithmException, CertificateException 127 | { 128 | throw new UnsupportedOperationException(); 129 | } 130 | 131 | @Override 132 | public void engineLoad(InputStream stream, char[] password) throws IOException, NoSuchAlgorithmException, CertificateException 133 | { 134 | if (stream != null) 135 | { 136 | throw new UnsupportedOperationException(); 137 | } 138 | } 139 | } 140 | -------------------------------------------------------------------------------- /android/src/main/java/org/strongswan/android/security/TrustedCertificateEntry.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2012-2016 Tobias Brunner 3 | * HSR Hochschule fuer Technik Rapperswil 4 | * 5 | * This program is free software; you can redistribute it and/or modify it 6 | * under the terms of the GNU General Public License as published by the 7 | * Free Software Foundation; either version 2 of the License, or (at your 8 | * option) any later version. See . 9 | * 10 | * This program is distributed in the hope that it will be useful, but 11 | * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 12 | * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 13 | * for more details. 14 | */ 15 | 16 | package org.strongswan.android.security; 17 | 18 | import android.net.http.SslCertificate; 19 | 20 | import java.security.cert.CertificateParsingException; 21 | import java.security.cert.X509Certificate; 22 | import java.util.ArrayList; 23 | import java.util.Collection; 24 | import java.util.Collections; 25 | import java.util.List; 26 | 27 | public class TrustedCertificateEntry implements Comparable 28 | { 29 | private final X509Certificate mCert; 30 | private final String mAlias; 31 | private String mSubjectPrimary; 32 | private String mSubjectSecondary = ""; 33 | private String mString; 34 | 35 | /** 36 | * Create an entry for certificate lists. 37 | * 38 | * @param alias alias of the certificate (as used in the KeyStore) 39 | * @param cert certificate associated with that alias 40 | */ 41 | public TrustedCertificateEntry(String alias, X509Certificate cert) 42 | { 43 | mCert = cert; 44 | mAlias = alias; 45 | 46 | try 47 | { 48 | SslCertificate ssl = new SslCertificate(mCert); 49 | String o = ssl.getIssuedTo().getOName(); 50 | String ou = ssl.getIssuedTo().getUName(); 51 | String cn = ssl.getIssuedTo().getCName(); 52 | if (!o.isEmpty()) 53 | { 54 | mSubjectPrimary = o; 55 | if (!cn.isEmpty()) 56 | { 57 | mSubjectSecondary = cn; 58 | } 59 | else if (!ou.isEmpty()) 60 | { 61 | mSubjectSecondary = ou; 62 | } 63 | } 64 | else if (!cn.isEmpty()) 65 | { 66 | mSubjectPrimary = cn; 67 | } 68 | else 69 | { 70 | mSubjectPrimary = ssl.getIssuedTo().getDName(); 71 | } 72 | } 73 | catch (NullPointerException ex) 74 | { 75 | /* this has been seen in Play Console for certificates for which notBefore apparently 76 | * can't be parsed (which SslCertificate() does) */ 77 | mSubjectPrimary = cert.getSubjectDN().getName(); 78 | } 79 | } 80 | 81 | /** 82 | * The main subject of this certificate (O, CN or the complete DN, whatever 83 | * is found first). 84 | * 85 | * @return the main subject 86 | */ 87 | public String getSubjectPrimary() 88 | { 89 | return mSubjectPrimary; 90 | } 91 | 92 | /** 93 | * Get the secondary subject of this certificate (either CN or OU if primary 94 | * subject is O, empty otherwise) 95 | * 96 | * @return the secondary subject 97 | */ 98 | public String getSubjectSecondary() 99 | { 100 | return mSubjectSecondary; 101 | } 102 | 103 | /** 104 | * Get a sorted list of all rfc822Name, dnSName and iPAddress subjectAltNames 105 | * 106 | * @return sorted list of selected SANs 107 | */ 108 | public List getSubjectAltNames() 109 | { 110 | List list = new ArrayList<>(); 111 | try 112 | { 113 | Collection> sans = mCert.getSubjectAlternativeNames(); 114 | if (sans != null) 115 | { 116 | for (List san : sans) 117 | { 118 | switch ((Integer)san.get(0)) 119 | { 120 | case 1: /* rfc822Name */ 121 | case 2: /* dnSName */ 122 | case 7: /* iPAddress */ 123 | list.add((String)san.get(1)); 124 | break; 125 | } 126 | } 127 | } 128 | Collections.sort(list); 129 | } 130 | catch(CertificateParsingException ex) 131 | { 132 | ex.printStackTrace(); 133 | } 134 | return list; 135 | } 136 | 137 | /** 138 | * The alias associated with this certificate. 139 | * 140 | * @return KeyStore alias of this certificate 141 | */ 142 | public String getAlias() 143 | { 144 | return mAlias; 145 | } 146 | 147 | /** 148 | * The certificate. 149 | * 150 | * @return certificate 151 | */ 152 | public X509Certificate getCertificate() 153 | { 154 | return mCert; 155 | } 156 | 157 | @Override 158 | public String toString() 159 | { /* combination of both subject lines, used for filtering lists */ 160 | if (mString == null) 161 | { 162 | mString = mSubjectPrimary; 163 | if (!mSubjectSecondary.isEmpty()) 164 | { 165 | mString += ", " + mSubjectSecondary; 166 | } 167 | } 168 | return mString; 169 | } 170 | 171 | @Override 172 | public int compareTo(TrustedCertificateEntry another) 173 | { 174 | int diff = mSubjectPrimary.compareToIgnoreCase(another.mSubjectPrimary); 175 | if (diff == 0) 176 | { 177 | diff = mSubjectSecondary.compareToIgnoreCase(another.mSubjectSecondary); 178 | } 179 | return diff; 180 | } 181 | } 182 | -------------------------------------------------------------------------------- /android/src/main/java/org/strongswan/android/ui/VpnProfileListFragment.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2012-2019 Tobias Brunner 3 | * Copyright (C) 2012 Giuliano Grassi 4 | * Copyright (C) 2012 Ralf Sager 5 | * HSR Hochschule fuer Technik Rapperswil 6 | * 7 | * This program is free software; you can redistribute it and/or modify it 8 | * under the terms of the GNU General Public License as published by the 9 | * Free Software Foundation; either version 2 of the License, or (at your 10 | * option) any later version. See . 11 | * 12 | * This program is distributed in the hope that it will be useful, but 13 | * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 14 | * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 15 | * for more details. 16 | */ 17 | 18 | package org.strongswan.android.ui; 19 | 20 | import android.content.BroadcastReceiver; 21 | import android.content.Context; 22 | import android.content.Intent; 23 | import android.content.IntentFilter; 24 | import android.content.res.TypedArray; 25 | import android.os.Bundle; 26 | import android.util.AttributeSet; 27 | import android.view.ActionMode; 28 | import android.view.LayoutInflater; 29 | import android.view.Menu; 30 | import android.view.MenuInflater; 31 | import android.view.MenuItem; 32 | import android.view.View; 33 | import android.view.ViewGroup; 34 | import android.widget.AbsListView.MultiChoiceModeListener; 35 | import android.widget.AdapterView; 36 | import android.widget.AdapterView.OnItemClickListener; 37 | import android.widget.ListView; 38 | import android.widget.Toast; 39 | 40 | import org.strongswan.android.data.VpnProfile; 41 | import org.strongswan.android.data.VpnProfileDataSource; 42 | import org.strongswan.android.utils.Constants; 43 | 44 | import java.util.ArrayList; 45 | import java.util.HashSet; 46 | import java.util.Iterator; 47 | import java.util.List; 48 | import java.util.UUID; 49 | 50 | import androidx.fragment.app.Fragment; 51 | 52 | public class VpnProfileListFragment extends Fragment 53 | { 54 | 55 | /** 56 | * The activity containing this fragment should implement this interface 57 | */ 58 | public interface OnVpnProfileSelectedListener { 59 | void onVpnProfileSelected(VpnProfile profile); 60 | } 61 | 62 | } 63 | -------------------------------------------------------------------------------- /android/src/main/java/org/strongswan/android/utils/Constants.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2016-2020 Tobias Brunner 3 | * HSR Hochschule fuer Technik Rapperswil 4 | * 5 | * This program is free software; you can redistribute it and/or modify it 6 | * under the terms of the GNU General Public License as published by the 7 | * Free Software Foundation; either version 2 of the License, or (at your 8 | * option) any later version. See . 9 | * 10 | * This program is distributed in the hope that it will be useful, but 11 | * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 12 | * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 13 | * for more details. 14 | */ 15 | 16 | package org.strongswan.android.utils; 17 | 18 | public final class Constants 19 | { 20 | /** 21 | * Intent action used to notify about changes to the VPN profiles 22 | */ 23 | public static final String VPN_PROFILES_CHANGED = "org.strongswan.android.VPN_PROFILES_CHANGED"; 24 | 25 | /** 26 | * Used in the intent above to notify about edits or inserts of a VPN profile (long) 27 | */ 28 | public static final String VPN_PROFILES_SINGLE = "org.strongswan.android.VPN_PROFILES_SINGLE"; 29 | 30 | /** 31 | * Used in the intent above to notify about the deletion of multiple VPN profiles (array of longs) 32 | */ 33 | public static final String VPN_PROFILES_MULTIPLE = "org.strongswan.android.VPN_PROFILES_MULTIPLE"; 34 | 35 | /** 36 | * Limits for MTU 37 | */ 38 | public static final int MTU_MAX = 1500; 39 | public static final int MTU_MIN = 1280; 40 | 41 | /** 42 | * Limits for NAT-T keepalive 43 | */ 44 | public static final int NAT_KEEPALIVE_MAX = 120; 45 | public static final int NAT_KEEPALIVE_MIN = 10; 46 | 47 | /** 48 | * Preference key for default VPN profile 49 | */ 50 | public static final String PREF_DEFAULT_VPN_PROFILE = "pref_default_vpn_profile"; 51 | 52 | /** 53 | * Value used to signify that the most recently used profile should be used as default 54 | */ 55 | public static final String PREF_DEFAULT_VPN_PROFILE_MRU = "pref_default_vpn_profile_mru"; 56 | 57 | /** 58 | * Preference key to store the most recently used VPN profile 59 | */ 60 | public static final String PREF_MRU_VPN_PROFILE = "pref_mru_vpn_profile"; 61 | 62 | /** 63 | * Preference key to store whether the user permanently dismissed our warning to add the app to the power whitelist 64 | */ 65 | public static final String PREF_IGNORE_POWER_WHITELIST = "pref_ignore_power_whitelist"; 66 | } 67 | -------------------------------------------------------------------------------- /android/src/main/java/org/strongswan/android/utils/SettingsWriter.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2015 Tobias Brunner 3 | * HSR Hochschule fuer Technik Rapperswil 4 | * 5 | * This program is free software; you can redistribute it and/or modify it 6 | * under the terms of the GNU General Public License as published by the 7 | * Free Software Foundation; either version 2 of the License, or (at your 8 | * option) any later version. See . 9 | * 10 | * This program is distributed in the hope that it will be useful, but 11 | * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 12 | * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 13 | * for more details. 14 | */ 15 | 16 | package org.strongswan.android.utils; 17 | 18 | import java.util.Arrays; 19 | import java.util.LinkedHashMap; 20 | import java.util.Map.Entry; 21 | import java.util.regex.Pattern; 22 | 23 | 24 | /** 25 | * Simple generator for data/files that may be parsed by libstrongswan's 26 | * settings_t class. 27 | */ 28 | public class SettingsWriter 29 | { 30 | /** 31 | * Top-level section 32 | */ 33 | private final SettingsSection mTop = new SettingsSection(); 34 | 35 | /** 36 | * Set a string value 37 | * @param key 38 | * @param value 39 | * @return the writer 40 | */ 41 | public SettingsWriter setValue(String key, String value) 42 | { 43 | Pattern pattern = Pattern.compile("[^#{}=\"\\n\\t ]+"); 44 | if (key == null || !pattern.matcher(key).matches()) 45 | { 46 | return this; 47 | } 48 | String[] keys = key.split("\\."); 49 | SettingsSection section = mTop; 50 | section = findOrCreateSection(Arrays.copyOfRange(keys, 0, keys.length-1)); 51 | section.Settings.put(keys[keys.length-1], value); 52 | return this; 53 | } 54 | 55 | /** 56 | * Set an integer value 57 | * @param key 58 | * @param value 59 | * @return the writer 60 | */ 61 | public SettingsWriter setValue(String key, Integer value) 62 | { 63 | return setValue(key, value == null ? null : value.toString()); 64 | } 65 | 66 | /** 67 | * Set a boolean value 68 | * @param key 69 | * @param value 70 | * @return the writer 71 | */ 72 | public SettingsWriter setValue(String key, Boolean value) 73 | { 74 | return setValue(key, value == null ? null : value ? "1" : "0"); 75 | } 76 | 77 | /** 78 | * Serializes the settings to a string in the format understood by 79 | * libstrongswan's settings_t parser. 80 | * @return serialized settings 81 | */ 82 | public String serialize() 83 | { 84 | StringBuilder builder = new StringBuilder(); 85 | serializeSection(mTop, builder); 86 | return builder.toString(); 87 | } 88 | 89 | /** 90 | * Serialize the settings in a section and recursively serialize sub-sections 91 | * @param section 92 | * @param builder 93 | */ 94 | private void serializeSection(SettingsSection section, StringBuilder builder) 95 | { 96 | for (Entry setting : section.Settings.entrySet()) 97 | { 98 | builder.append(setting.getKey()).append('='); 99 | if (setting.getValue() != null) 100 | { 101 | builder.append("\"").append(escapeValue(setting.getValue())).append("\""); 102 | } 103 | builder.append('\n'); 104 | } 105 | 106 | for (Entry subsection : section.Sections.entrySet()) 107 | { 108 | builder.append(subsection.getKey()).append(" {\n"); 109 | serializeSection(subsection.getValue(), builder); 110 | builder.append("}\n"); 111 | } 112 | } 113 | 114 | /** 115 | * Escape value so it may be wrapped in " 116 | * @param value 117 | * @return 118 | */ 119 | private String escapeValue(String value) 120 | { 121 | return value.replace("\\", "\\\\").replace("\"", "\\\""); 122 | } 123 | 124 | /** 125 | * Find or create the nested sections with the given names 126 | * @param sections list of section names 127 | * @return final section 128 | */ 129 | private SettingsSection findOrCreateSection(String[] sections) 130 | { 131 | SettingsSection section = mTop; 132 | for (String name : sections) 133 | { 134 | SettingsSection subsection = section.Sections.get(name); 135 | if (subsection == null) 136 | { 137 | subsection = new SettingsSection(); 138 | section.Sections.put(name, subsection); 139 | } 140 | section = subsection; 141 | } 142 | return section; 143 | } 144 | 145 | /** 146 | * A section containing sub-sections and settings. 147 | */ 148 | private class SettingsSection 149 | { 150 | /** 151 | * Assigned key/value pairs 152 | */ 153 | LinkedHashMap Settings = new LinkedHashMap(); 154 | 155 | /** 156 | * Assigned sub-sections 157 | */ 158 | LinkedHashMap Sections = new LinkedHashMap(); 159 | } 160 | } 161 | -------------------------------------------------------------------------------- /android/src/main/java/org/strongswan/android/utils/Utils.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2014-2019 Tobias Brunner 3 | * HSR Hochschule fuer Technik Rapperswil 4 | * 5 | * This program is free software; you can redistribute it and/or modify it 6 | * under the terms of the GNU General Public License as published by the 7 | * Free Software Foundation; either version 2 of the License, or (at your 8 | * option) any later version. See . 9 | * 10 | * This program is distributed in the hope that it will be useful, but 11 | * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 12 | * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 13 | * for more details. 14 | */ 15 | 16 | package org.strongswan.android.utils; 17 | 18 | 19 | import java.net.InetAddress; 20 | import java.net.UnknownHostException; 21 | 22 | public class Utils 23 | { 24 | static final char[] HEXDIGITS = "0123456789abcdef".toCharArray(); 25 | 26 | /** 27 | * Converts the given byte array to a hexadecimal string encoding. 28 | * 29 | * @param bytes byte array to convert 30 | * @return hex string 31 | */ 32 | public static String bytesToHex(byte[] bytes) 33 | { 34 | char[] hex = new char[bytes.length * 2]; 35 | for (int i = 0; i < bytes.length; i++) 36 | { 37 | int value = bytes[i]; 38 | hex[i*2] = HEXDIGITS[(value & 0xf0) >> 4]; 39 | hex[i*2+1] = HEXDIGITS[ value & 0x0f]; 40 | } 41 | return new String(hex); 42 | } 43 | 44 | /** 45 | * Validate the given proposal string 46 | * 47 | * @param ike true for IKE, false for ESP 48 | * @param proposal proposal string 49 | * @return true if valid 50 | */ 51 | public native static boolean isProposalValid(boolean ike, String proposal); 52 | 53 | /** 54 | * Parse an IP address without doing a name lookup 55 | * 56 | * @param address IP address string 57 | * @return address bytes if valid 58 | */ 59 | private native static byte[] parseInetAddressBytes(String address); 60 | 61 | /** 62 | * Parse an IP address without doing a name lookup (as compared to InetAddress.fromName()) 63 | * 64 | * @param address IP address string 65 | * @return address if valid 66 | * @throws UnknownHostException if address is invalid 67 | */ 68 | public static InetAddress parseInetAddress(String address) throws UnknownHostException 69 | { 70 | byte[] bytes = parseInetAddressBytes(address); 71 | if (bytes == null) 72 | { 73 | throw new UnknownHostException(); 74 | } 75 | return InetAddress.getByAddress(bytes); 76 | } 77 | } 78 | -------------------------------------------------------------------------------- /android/src/main/jni/Android.mk: -------------------------------------------------------------------------------- 1 | LOCAL_PATH := $(call my-dir) 2 | include $(CLEAR_VARS) 3 | 4 | # use "bring your own device" (BYOD) features (also see USE_BYOD in 5 | # MainActivity.java) 6 | strongswan_USE_BYOD := true 7 | 8 | strongswan_CHARON_PLUGINS := android-log openssl fips-prf random nonce pubkey \ 9 | pkcs1 pkcs8 pem xcbc hmac socket-default kernel-netlink \ 10 | eap-identity eap-mschapv2 eap-md5 eap-gtc eap-tls 11 | 12 | ifneq ($(strongswan_USE_BYOD),) 13 | strongswan_BYOD_PLUGINS := eap-ttls eap-tnc tnc-imc tnc-tnccs tnccs-20 14 | endif 15 | 16 | strongswan_PLUGINS := $(strongswan_CHARON_PLUGINS) \ 17 | $(strongswan_BYOD_PLUGINS) 18 | 19 | include $(LOCAL_PATH)/strongswan/Android.common.mk 20 | 21 | # includes 22 | strongswan_PATH := $(LOCAL_PATH)/strongswan 23 | openssl_PATH := $(LOCAL_PATH)/openssl/include 24 | 25 | # CFLAGS (partially from a configure run using droid-gcc) 26 | strongswan_CFLAGS := \ 27 | -Wall \ 28 | -Wextra \ 29 | -Wno-format \ 30 | -Wno-pointer-sign \ 31 | -Wno-pointer-arith \ 32 | -Wno-sign-compare \ 33 | -Wno-strict-aliasing \ 34 | -Wno-unused-parameter \ 35 | -DHAVE___BOOL \ 36 | -DHAVE_STDBOOL_H \ 37 | -DHAVE_ALLOCA_H \ 38 | -DHAVE_ALLOCA \ 39 | -DHAVE_CLOCK_GETTIME \ 40 | -DHAVE_DLADDR \ 41 | -DHAVE_PTHREAD_COND_TIMEDWAIT_MONOTONIC \ 42 | -DHAVE_PRCTL \ 43 | -DHAVE_LINUX_UDP_H \ 44 | -DHAVE_STRUCT_SADB_X_POLICY_SADB_X_POLICY_PRIORITY \ 45 | -DHAVE_IPSEC_MODE_BEET \ 46 | -DHAVE_IPSEC_DIR_FWD \ 47 | -DHAVE_IN6ADDR_ANY \ 48 | -DHAVE_NETINET_IP6_H \ 49 | -DOPENSSL_NO_ENGINE \ 50 | -DCONFIG_H_INCLUDED \ 51 | -DCAPABILITIES \ 52 | -DCAPABILITIES_NATIVE \ 53 | -DMONOLITHIC \ 54 | -DUSE_IKEV1 \ 55 | -DUSE_IKEV2 \ 56 | -DUSE_BUILTIN_PRINTF \ 57 | -DDEBUG \ 58 | -DCHARON_UDP_PORT=0 \ 59 | -DCHARON_NATT_PORT=0 \ 60 | -DVERSION=\"$(strongswan_VERSION)\" \ 61 | -DDEV_RANDOM=\"/dev/random\" \ 62 | -DDEV_URANDOM=\"/dev/urandom\" 63 | 64 | ifneq ($(strongswan_USE_BYOD),) 65 | strongswan_CFLAGS += -DUSE_BYOD 66 | endif 67 | 68 | strongswan_BUILD := \ 69 | openssl \ 70 | libandroidbridge \ 71 | strongswan/src/libipsec \ 72 | strongswan/src/libcharon \ 73 | strongswan/src/libstrongswan 74 | 75 | ifneq ($(strongswan_USE_BYOD),) 76 | strongswan_BUILD += \ 77 | strongswan/src/libtnccs \ 78 | strongswan/src/libtncif \ 79 | strongswan/src/libimcv 80 | endif 81 | 82 | include $(addprefix $(LOCAL_PATH)/,$(addsuffix /Android.mk, \ 83 | $(strongswan_BUILD))) 84 | -------------------------------------------------------------------------------- /android/src/main/jni/Application.mk: -------------------------------------------------------------------------------- 1 | # select the ABI(s) to build for (see CPU-ARCH-ABIS.html in the NDK docs). 2 | APP_ABI := armeabi x86 mips 3 | APP_PLATFORM := android-14 4 | -------------------------------------------------------------------------------- /android/src/main/jni/libandroidbridge/Android.mk: -------------------------------------------------------------------------------- 1 | LOCAL_PATH := $(call my-dir) 2 | include $(CLEAR_VARS) 3 | 4 | # copy-n-paste from Makefile.am 5 | LOCAL_SRC_FILES := \ 6 | android_jni.c \ 7 | backend/android_attr.c \ 8 | backend/android_creds.c \ 9 | backend/android_fetcher.c \ 10 | backend/android_dns_proxy.c \ 11 | backend/android_private_key.c \ 12 | backend/android_scheduler.c \ 13 | backend/android_service.c \ 14 | charonservice.c \ 15 | kernel/android_ipsec.c \ 16 | kernel/android_net.c \ 17 | kernel/network_manager.c \ 18 | vpnservice_builder.c 19 | 20 | ifneq ($(strongswan_USE_BYOD),) 21 | LOCAL_SRC_FILES += \ 22 | byod/imc_android_state.c \ 23 | byod/imc_android.c 24 | endif 25 | 26 | # build libandroidbridge ------------------------------------------------------- 27 | 28 | LOCAL_C_INCLUDES += \ 29 | $(strongswan_PATH)/src/libipsec \ 30 | $(strongswan_PATH)/src/libcharon \ 31 | $(strongswan_PATH)/src/libstrongswan 32 | 33 | ifneq ($(strongswan_USE_BYOD),) 34 | LOCAL_C_INCLUDES += \ 35 | $(strongswan_PATH)/src/libimcv \ 36 | $(strongswan_PATH)/src/libtncif \ 37 | $(strongswan_PATH)/src/libtnccs \ 38 | $(strongswan_PATH)/src/libtpmtss \ 39 | $(strongswan_PATH)/src/libtls 40 | endif 41 | 42 | LOCAL_CFLAGS := $(strongswan_CFLAGS) \ 43 | -DPLUGINS='"$(strongswan_CHARON_PLUGINS)"' 44 | 45 | ifneq ($(strongswan_USE_BYOD),) 46 | LOCAL_CFLAGS += -DPLUGINS_BYOD='"$(strongswan_BYOD_PLUGINS)"' 47 | endif 48 | 49 | LOCAL_MODULE := libandroidbridge 50 | 51 | LOCAL_MODULE_TAGS := optional 52 | 53 | LOCAL_ARM_MODE := arm 54 | 55 | LOCAL_PRELINK_MODULE := false 56 | 57 | LOCAL_LDLIBS := -llog 58 | 59 | LOCAL_SHARED_LIBRARIES := libstrongswan libipsec libcharon 60 | 61 | ifneq ($(strongswan_USE_BYOD),) 62 | LOCAL_SHARED_LIBRARIES += libimcv libtncif libtnccs libtpmtss 63 | endif 64 | 65 | include $(BUILD_SHARED_LIBRARY) 66 | -------------------------------------------------------------------------------- /android/src/main/jni/libandroidbridge/backend/android_attr.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2012-2013 Tobias Brunner 3 | * Copyright (C) 2012 Giuliano Grassi 4 | * Copyright (C) 2012 Ralf Sager 5 | * HSR Hochschule fuer Technik Rapperswil 6 | * 7 | * This program is free software; you can redistribute it and/or modify it 8 | * under the terms of the GNU General Public License as published by the 9 | * Free Software Foundation; either version 2 of the License, or (at your 10 | * option) any later version. See . 11 | * 12 | * This program is distributed in the hope that it will be useful, but 13 | * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 14 | * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 15 | * for more details. 16 | */ 17 | 18 | #include "android_attr.h" 19 | #include "../charonservice.h" 20 | 21 | #include 22 | #include 23 | 24 | typedef struct private_android_attr_t private_android_attr_t; 25 | 26 | /** 27 | * Private data of an android_attr_t object. 28 | */ 29 | struct private_android_attr_t { 30 | 31 | /** 32 | * Public interface. 33 | */ 34 | android_attr_t public; 35 | }; 36 | 37 | METHOD(attribute_handler_t, handle, bool, 38 | private_android_attr_t *this, ike_sa_t *ike_sa, 39 | configuration_attribute_type_t type, chunk_t data) 40 | { 41 | vpnservice_builder_t *builder; 42 | host_t *dns; 43 | 44 | switch (type) 45 | { 46 | case INTERNAL_IP4_DNS: 47 | dns = host_create_from_chunk(AF_INET, data, 0); 48 | break; 49 | case INTERNAL_IP6_DNS: 50 | dns = host_create_from_chunk(AF_INET6, data, 0); 51 | break; 52 | default: 53 | return FALSE; 54 | } 55 | 56 | if (!dns || dns->is_anyaddr(dns)) 57 | { 58 | DESTROY_IF(dns); 59 | return FALSE; 60 | } 61 | DBG1(DBG_IKE, "installing DNS server %H", dns); 62 | builder = charonservice->get_vpnservice_builder(charonservice); 63 | builder->add_dns(builder, dns); 64 | dns->destroy(dns); 65 | return TRUE; 66 | } 67 | 68 | METHOD(attribute_handler_t, release, void, 69 | private_android_attr_t *this, ike_sa_t *ike_sa, 70 | configuration_attribute_type_t type, chunk_t data) 71 | { 72 | /* DNS servers cannot be removed from an existing TUN device */ 73 | } 74 | 75 | METHOD(enumerator_t, enumerate_dns6, bool, 76 | enumerator_t *this, va_list args) 77 | { 78 | configuration_attribute_type_t *type; 79 | chunk_t *data; 80 | 81 | VA_ARGS_VGET(args, type, data); 82 | *type = INTERNAL_IP6_DNS; 83 | *data = chunk_empty; 84 | this->venumerate = (void*)return_false; 85 | return TRUE; 86 | } 87 | 88 | METHOD(enumerator_t, enumerate_dns4, bool, 89 | enumerator_t *this, va_list args) 90 | { 91 | configuration_attribute_type_t *type; 92 | chunk_t *data; 93 | 94 | VA_ARGS_VGET(args, type, data); 95 | *type = INTERNAL_IP4_DNS; 96 | *data = chunk_empty; 97 | this->venumerate = _enumerate_dns6; 98 | return TRUE; 99 | } 100 | 101 | METHOD(attribute_handler_t, create_attribute_enumerator, enumerator_t*, 102 | private_android_attr_t *this, ike_sa_t *ike_sa, linked_list_t *vips) 103 | { 104 | enumerator_t *enumerator; 105 | 106 | INIT(enumerator, 107 | .enumerate = enumerator_enumerate_default, 108 | .venumerate = _enumerate_dns4, 109 | .destroy = (void*)free, 110 | ); 111 | return enumerator; 112 | } 113 | 114 | METHOD(android_attr_t, destroy, void, 115 | private_android_attr_t *this) 116 | { 117 | free(this); 118 | } 119 | 120 | /** 121 | * Described in header 122 | */ 123 | android_attr_t *android_attr_create() 124 | { 125 | private_android_attr_t *this; 126 | 127 | INIT(this, 128 | .public = { 129 | .handler = { 130 | .handle = _handle, 131 | .release = _release, 132 | .create_attribute_enumerator = _create_attribute_enumerator, 133 | }, 134 | .destroy = _destroy, 135 | }, 136 | ); 137 | 138 | return &this->public; 139 | } 140 | -------------------------------------------------------------------------------- /android/src/main/jni/libandroidbridge/backend/android_attr.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2012 Giuliano Grassi 3 | * Copyright (C) 2012 Ralf Sager 4 | * HSR Hochschule fuer Technik Rapperswil 5 | * 6 | * This program is free software; you can redistribute it and/or modify it 7 | * under the terms of the GNU General Public License as published by the 8 | * Free Software Foundation; either version 2 of the License, or (at your 9 | * option) any later version. See . 10 | * 11 | * This program is distributed in the hope that it will be useful, but 12 | * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 13 | * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 14 | * for more details. 15 | */ 16 | 17 | /** 18 | * @defgroup android_attr android_attr 19 | * @{ @ingroup android_backend 20 | */ 21 | 22 | #ifndef ANDROID_ATTR_H_ 23 | #define ANDROID_ATTR_H_ 24 | 25 | #include 26 | #include 27 | 28 | typedef struct android_attr_t android_attr_t; 29 | 30 | /** 31 | * Handler for DNS configuration 32 | */ 33 | struct android_attr_t { 34 | 35 | /** 36 | * implements the attribute_handler_t interface 37 | */ 38 | attribute_handler_t handler; 39 | 40 | /** 41 | * Destroy a android_attr_t 42 | */ 43 | void (*destroy)(android_attr_t *this); 44 | }; 45 | 46 | /** 47 | * Create a android_attr_t instance. 48 | */ 49 | android_attr_t *android_attr_create(void); 50 | 51 | #endif /** ANDROID_ATTR_H_ @}*/ 52 | 53 | -------------------------------------------------------------------------------- /android/src/main/jni/libandroidbridge/backend/android_creds.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2012-2017 Tobias Brunner 3 | * HSR Hochschule fuer Technik Rapperswil 4 | * 5 | * This program is free software; you can redistribute it and/or modify it 6 | * under the terms of the GNU General Public License as published by the 7 | * Free Software Foundation; either version 2 of the License, or (at your 8 | * option) any later version. See . 9 | * 10 | * This program is distributed in the hope that it will be useful, but 11 | * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 12 | * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 13 | * for more details. 14 | */ 15 | 16 | /** 17 | * @defgroup android_creds android_creds 18 | * @{ @ingroup android_backend 19 | */ 20 | 21 | #ifndef ANDROID_CREDS_H_ 22 | #define ANDROID_CREDS_H_ 23 | 24 | #include 25 | #include 26 | 27 | typedef struct android_creds_t android_creds_t; 28 | 29 | /** 30 | * Android credential set that provides CA certificates via JNI and supplied 31 | * user credentials. 32 | */ 33 | struct android_creds_t { 34 | 35 | /** 36 | * Implements credential_set_t 37 | */ 38 | credential_set_t set; 39 | 40 | /** 41 | * Add user name and password for EAP authentication 42 | * 43 | * @param username user name 44 | * @param password password 45 | */ 46 | void (*add_username_password)(android_creds_t *this, char *username, 47 | char *password); 48 | 49 | /** 50 | * Load the user certificate and private key 51 | * 52 | * @return loaded client certificate, NULL on failure 53 | */ 54 | certificate_t *(*load_user_certificate)(android_creds_t *this); 55 | 56 | /** 57 | * Clear the cached certificates and stored credentials. 58 | */ 59 | void (*clear)(android_creds_t *this); 60 | 61 | /** 62 | * Destroy a android_creds instance. 63 | */ 64 | void (*destroy)(android_creds_t *this); 65 | 66 | }; 67 | 68 | /** 69 | * Create an android_creds instance. 70 | * 71 | * @param crldir directory for cached CRLs 72 | */ 73 | android_creds_t *android_creds_create(char *crldir); 74 | 75 | #endif /** ANDROID_CREDS_H_ @}*/ 76 | 77 | -------------------------------------------------------------------------------- /android/src/main/jni/libandroidbridge/backend/android_dns_proxy.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2014 Tobias Brunner 3 | * HSR Hochschule fuer Technik Rapperswil 4 | * 5 | * This program is free software; you can redistribute it and/or modify it 6 | * under the terms of the GNU General Public License as published by the 7 | * Free Software Foundation; either version 2 of the License, or (at your 8 | * option) any later version. See . 9 | * 10 | * This program is distributed in the hope that it will be useful, but 11 | * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 12 | * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 13 | * for more details. 14 | */ 15 | 16 | /** 17 | * @defgroup android_dns_proxy android_dns_proxy 18 | * @{ @ingroup android_backend 19 | */ 20 | 21 | #ifndef ANDROID_DNS_PROXY_H_ 22 | #define ANDROID_DNS_PROXY_H_ 23 | 24 | #include 25 | 26 | typedef struct android_dns_proxy_t android_dns_proxy_t; 27 | 28 | /** 29 | * Callback called to deliver a DNS response packet. 30 | * 31 | * @param data data supplied during registration of the callback 32 | * @param packet DNS response packet (has to be destroyed) 33 | */ 34 | typedef void (*dns_proxy_response_cb_t)(void *data, ip_packet_t *packet); 35 | 36 | /** 37 | * DNS proxy class 38 | */ 39 | struct android_dns_proxy_t { 40 | 41 | /** 42 | * Handle an outbound DNS packet (if the packet is one) 43 | * 44 | * @param packet packet to handle 45 | * @return TRUE if handled, FALSE otherwise (no DNS) 46 | */ 47 | bool (*handle)(android_dns_proxy_t *this, ip_packet_t *packet); 48 | 49 | /** 50 | * Register the callback used to deliver DNS response packets. 51 | * 52 | * @param cb the callback function 53 | * @param data optional data provided to callback 54 | */ 55 | void (*register_cb)(android_dns_proxy_t *this, dns_proxy_response_cb_t cb, 56 | void *data); 57 | 58 | /** 59 | * Unregister the callback used to deliver DNS response packets. 60 | * 61 | * @param cb the callback function 62 | * @param data optional data provided to callback 63 | */ 64 | void (*unregister_cb)(android_dns_proxy_t *this, dns_proxy_response_cb_t cb); 65 | 66 | /** 67 | * Add a hostname for which queries are proxied. If at least one hostname 68 | * is configured DNS queries for others will not be handled. 69 | * 70 | * @param hostname hostname to add (gets cloned) 71 | */ 72 | void (*add_hostname)(android_dns_proxy_t *this, char *hostname); 73 | 74 | /** 75 | * Destroy an instance. 76 | */ 77 | void (*destroy)(android_dns_proxy_t *this); 78 | }; 79 | 80 | /** 81 | * Create an instance. 82 | */ 83 | android_dns_proxy_t *android_dns_proxy_create(); 84 | 85 | #endif /** ANDROID_DNS_PROXY_H_ @}*/ 86 | 87 | -------------------------------------------------------------------------------- /android/src/main/jni/libandroidbridge/backend/android_fetcher.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2017 Tobias Brunner 3 | * HSR Hochschule fuer Technik Rapperswil 4 | * 5 | * This program is free software; you can redistribute it and/or modify it 6 | * under the terms of the GNU General Public License as published by the 7 | * Free Software Foundation; either version 2 of the License, or (at your 8 | * option) any later version. See . * 9 | * This program is distributed in the hope that it will be useful, but 10 | * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 11 | * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 12 | * for more details. 13 | */ 14 | 15 | #include "android_fetcher.h" 16 | 17 | #include "../android_jni.h" 18 | #include "../charonservice.h" 19 | #include 20 | 21 | typedef struct android_fetcher_t android_fetcher_t; 22 | 23 | struct android_fetcher_t { 24 | 25 | /** 26 | * Public interface 27 | */ 28 | fetcher_t public; 29 | 30 | /** 31 | * Callback function 32 | */ 33 | fetcher_callback_t cb; 34 | 35 | /** 36 | * Data to POST 37 | */ 38 | chunk_t data; 39 | 40 | /** 41 | * Type of data to POST 42 | */ 43 | char *request_type; 44 | }; 45 | 46 | METHOD(fetcher_t, fetch, status_t, 47 | android_fetcher_t *this, char *uri, void *userdata) 48 | { 49 | JNIEnv *env; 50 | jmethodID method_id; 51 | jobjectArray jdata = NULL; 52 | jstring juri, jct = NULL; 53 | chunk_t data; 54 | status_t status = FAILED; 55 | 56 | if (this->cb == fetcher_default_callback) 57 | { 58 | *(chunk_t*)userdata = chunk_empty; 59 | } 60 | 61 | androidjni_attach_thread(&env); 62 | /* can't use FindClass here as this is not called by the main thread */ 63 | method_id = (*env)->GetStaticMethodID(env, android_simple_fetcher_class, 64 | "fetch", "(Ljava/lang/String;[BLjava/lang/String;)[B"); 65 | if (!method_id) 66 | { 67 | goto failed; 68 | } 69 | juri = (*env)->NewStringUTF(env, uri); 70 | if (!juri) 71 | { 72 | goto failed; 73 | } 74 | if (this->request_type) 75 | { 76 | jct = (*env)->NewStringUTF(env, this->request_type); 77 | if (!jct) 78 | { 79 | goto failed; 80 | } 81 | } 82 | if (this->data.ptr) 83 | { 84 | jdata = byte_array_from_chunk(env, this->data); 85 | if (!jdata) 86 | { 87 | goto failed; 88 | } 89 | } 90 | jdata = (*env)->CallStaticObjectMethod(env, android_simple_fetcher_class, 91 | method_id, juri, jdata, jct); 92 | if (!jdata || androidjni_exception_occurred(env)) 93 | { 94 | goto failed; 95 | } 96 | data = chunk_from_byte_array(env, jdata); 97 | if (this->cb(userdata, data)) 98 | { 99 | status = SUCCESS; 100 | } 101 | chunk_free(&data); 102 | androidjni_detach_thread(); 103 | return status; 104 | 105 | failed: 106 | DBG1(DBG_LIB, "failed to fetch from '%s'", uri); 107 | androidjni_exception_occurred(env); 108 | androidjni_detach_thread(); 109 | return FAILED; 110 | } 111 | 112 | METHOD(fetcher_t, set_option, bool, 113 | android_fetcher_t *this, fetcher_option_t option, ...) 114 | { 115 | bool supported = TRUE; 116 | va_list args; 117 | 118 | va_start(args, option); 119 | switch (option) 120 | { 121 | case FETCH_CALLBACK: 122 | { 123 | this->cb = va_arg(args, fetcher_callback_t); 124 | break; 125 | } 126 | case FETCH_REQUEST_DATA: 127 | { 128 | this->data = chunk_clone(va_arg(args, chunk_t)); 129 | break; 130 | } 131 | case FETCH_REQUEST_TYPE: 132 | { 133 | this->request_type = strdup(va_arg(args, char*)); 134 | break; 135 | } 136 | default: 137 | supported = FALSE; 138 | break; 139 | } 140 | va_end(args); 141 | return supported; 142 | } 143 | 144 | METHOD(fetcher_t, destroy, void, 145 | android_fetcher_t *this) 146 | { 147 | chunk_clear(&this->data); 148 | free(this->request_type); 149 | free(this); 150 | } 151 | 152 | /* 153 | * Described in header. 154 | */ 155 | fetcher_t *android_fetcher_create() 156 | { 157 | android_fetcher_t *this; 158 | 159 | INIT(this, 160 | .public = { 161 | .fetch = _fetch, 162 | .set_option = _set_option, 163 | .destroy = _destroy, 164 | }, 165 | .cb = fetcher_default_callback, 166 | ); 167 | 168 | return &this->public; 169 | } 170 | -------------------------------------------------------------------------------- /android/src/main/jni/libandroidbridge/backend/android_fetcher.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2017 Tobias Brunner 3 | * HSR Hochschule fuer Technik Rapperswil 4 | * 5 | * This program is free software; you can redistribute it and/or modify it 6 | * under the terms of the GNU General Public License as published by the 7 | * Free Software Foundation; either version 2 of the License, or (at your 8 | * option) any later version. See . 9 | * 10 | * This program is distributed in the hope that it will be useful, but 11 | * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 12 | * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 13 | * for more details. 14 | */ 15 | 16 | /** 17 | * @defgroup android_fetcher android_fetcher 18 | * @{ @ingroup android_backend 19 | */ 20 | 21 | #ifndef ANDROID_FETCHER_H_ 22 | #define ANDROID_FETCHER_H_ 23 | 24 | #include 25 | 26 | /** 27 | * Create an Android-specific fetcher instance based on SimpleFetcher 28 | * 29 | * @return fetcher_t instance 30 | */ 31 | fetcher_t *android_fetcher_create(); 32 | 33 | #endif /** ANDROID_FETCHER_H_ @}*/ 34 | -------------------------------------------------------------------------------- /android/src/main/jni/libandroidbridge/backend/android_private_key.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2012 Tobias Brunner 3 | * HSR Hochschule fuer Technik Rapperswil 4 | * 5 | * This program is free software; you can redistribute it and/or modify it 6 | * under the terms of the GNU General Public License as published by the 7 | * Free Software Foundation; either version 2 of the License, or (at your 8 | * option) any later version. See . 9 | * 10 | * This program is distributed in the hope that it will be useful, but 11 | * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 12 | * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 13 | * for more details. 14 | */ 15 | 16 | /** 17 | * @defgroup android_private_key android_private_key 18 | * @{ @ingroup android_backend 19 | */ 20 | 21 | #ifndef ANDROID_PRIVATE_KEY_H_ 22 | #define ANDROID_PRIVATE_KEY_H_ 23 | 24 | #include 25 | 26 | #include 27 | 28 | /** 29 | * Create a JNI backed key, stored in the Android KeyChain 30 | * 31 | * @param key PrivateKey instance 32 | * @param pubkey public key as extracted from the certificate (gets adopted) 33 | * @return private_key_t instance 34 | */ 35 | private_key_t *android_private_key_create(jobject key, public_key_t *pubkey); 36 | 37 | #endif /** ANDROID_PRIVATE_KEY_H_ @}*/ 38 | 39 | -------------------------------------------------------------------------------- /android/src/main/jni/libandroidbridge/backend/android_scheduler.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2020 Tobias Brunner 3 | * HSR Hochschule fuer Technik Rapperswil 4 | * 5 | * This program is free software; you can redistribute it and/or modify it 6 | * under the terms of the GNU General Public License as published by the 7 | * Free Software Foundation; either version 2 of the License, or (at your 8 | * option) any later version. See . 9 | * 10 | * This program is distributed in the hope that it will be useful, but 11 | * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 12 | * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 13 | * for more details. 14 | */ 15 | 16 | /** 17 | * @defgroup android_scheduler android_scheduler 18 | * @{ @ingroup android_backend 19 | */ 20 | 21 | #ifndef ANDROID_SCHEDULER_H_ 22 | #define ANDROID_SCHEDULER_H_ 23 | 24 | #include 25 | 26 | #include 27 | 28 | /** 29 | * Create an Android-specific scheduler_t implementation. 30 | * 31 | * The given scheduler is used for short-term events. We can't destroy it anyway 32 | * because of the scheduler job operating on it, and this way we can use it to 33 | * avoid the overhead of broadcasts for some events. 34 | * 35 | * @param context Context object 36 | * @param scheduler the default scheduler used as fallback 37 | * @return scheduler_t instance 38 | */ 39 | scheduler_t *android_scheduler_create(jobject context, scheduler_t *scheduler); 40 | 41 | #endif /** ANDROID_SCHEDULER_H_ @}*/ 42 | -------------------------------------------------------------------------------- /android/src/main/jni/libandroidbridge/backend/android_service.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2010-2015 Tobias Brunner 3 | * Copyright (C) 2012 Giuliano Grassi 4 | * Copyright (C) 2012 Ralf Sager 5 | * HSR Hochschule fuer Technik Rapperswil 6 | * 7 | * This program is free software; you can redistribute it and/or modify it 8 | * under the terms of the GNU General Public License as published by the 9 | * Free Software Foundation; either version 2 of the License, or (at your 10 | * option) any later version. See . 11 | * 12 | * This program is distributed in the hope that it will be useful, but 13 | * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 14 | * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 15 | * for more details. 16 | */ 17 | 18 | /** 19 | * @defgroup android_service android_service 20 | * @{ @ingroup android_backend 21 | */ 22 | 23 | #ifndef ANDROID_SERVICE_H_ 24 | #define ANDROID_SERVICE_H_ 25 | 26 | #include "android_creds.h" 27 | 28 | #include 29 | #include 30 | 31 | typedef struct android_service_t android_service_t; 32 | 33 | /** 34 | * Service that sets up an IKE_SA/CHILD_SA and handles events 35 | */ 36 | struct android_service_t { 37 | 38 | /** 39 | * Implements listener_t. 40 | */ 41 | listener_t listener; 42 | 43 | /** 44 | * Destroy a android_service_t. 45 | */ 46 | void (*destroy)(android_service_t *this); 47 | 48 | }; 49 | 50 | /** 51 | * Create an Android service instance. Queues a job that starts initiation of a 52 | * new IKE SA. 53 | * 54 | * @param creds Android specific credential set 55 | * @param settings configuration settings (gets adopted) 56 | */ 57 | android_service_t *android_service_create(android_creds_t *creds, 58 | settings_t *settings); 59 | 60 | #endif /** ANDROID_SERVICE_H_ @}*/ 61 | -------------------------------------------------------------------------------- /android/src/main/jni/libandroidbridge/byod/imc_android.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2013 Tobias Brunner 3 | * HSR Hochschule fuer Technik Rapperswil 4 | * 5 | * This program is free software; you can redistribute it and/or modify it 6 | * under the terms of the GNU General Public License as published by the 7 | * Free Software Foundation; either version 2 of the License, or (at your 8 | * option) any later version. See . 9 | * 10 | * This program is distributed in the hope that it will be useful, but 11 | * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 12 | * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 13 | * for more details. 14 | */ 15 | 16 | /** 17 | * @defgroup android_imc android_imc 18 | * @{ @ingroup android_byod 19 | */ 20 | 21 | #ifndef ANDROID_IMC_H_ 22 | #define ANDROID_IMC_H_ 23 | 24 | /** 25 | * Callback for the Android IMC plugin 26 | */ 27 | bool imc_android_register(plugin_t *plugin, plugin_feature_t *feature, 28 | bool reg, void *data); 29 | 30 | #endif /** ANDROID_IMC_H_ @}*/ 31 | -------------------------------------------------------------------------------- /android/src/main/jni/libandroidbridge/byod/imc_android_state.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2012 Tobias Brunner 3 | * HSR Hochschule fuer Technik Rapperswil 4 | * 5 | * This program is free software; you can redistribute it and/or modify it 6 | * under the terms of the GNU General Public License as published by the 7 | * Free Software Foundation; either version 2 of the License, or (at your 8 | * option) any later version. See . 9 | * 10 | * This program is distributed in the hope that it will be useful, but 11 | * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 12 | * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 13 | * for more details. 14 | */ 15 | 16 | /** 17 | * @defgroup imc_android_state imc_android_state 18 | * @{ @ingroup android_byod 19 | */ 20 | 21 | #ifndef IMC_ANDROID_STATE_H_ 22 | #define IMC_ANDROID_STATE_H_ 23 | 24 | #include 25 | #include 26 | 27 | typedef struct imc_android_state_t imc_android_state_t; 28 | 29 | /** 30 | * Internal state of an imc_android_t connection instance 31 | */ 32 | struct imc_android_state_t { 33 | 34 | /** 35 | * imc_state_t interface 36 | */ 37 | imc_state_t interface; 38 | 39 | /** 40 | * Get TCG Platform Trust Service (PTS) object 41 | */ 42 | pts_t *(*get_pts)(imc_android_state_t *this); 43 | }; 44 | 45 | /** 46 | * Create an imc_android_state_t instance 47 | * 48 | * @param id connection ID 49 | */ 50 | imc_state_t* imc_android_state_create(TNC_ConnectionID id); 51 | 52 | #endif /** IMC_ANDROID_STATE_H_ @}*/ 53 | -------------------------------------------------------------------------------- /android/src/main/jni/libandroidbridge/kernel/android_ipsec.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2012 Giuliano Grassi 3 | * Copyright (C) 2012 Ralf Sager 4 | * HSR Hochschule fuer Technik Rapperswil 5 | * 6 | * This program is free software; you can redistribute it and/or modify it 7 | * under the terms of the GNU General Public License as published by the 8 | * Free Software Foundation; either version 2 of the License, or (at your 9 | * option) any later version. See . 10 | * 11 | * This program is distributed in the hope that it will be useful, but 12 | * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 13 | * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 14 | * for more details. 15 | */ 16 | 17 | /** 18 | * @defgroup kernel_android_ipsec kernel_android_ipsec 19 | * @{ @ingroup android_kernel 20 | */ 21 | 22 | #ifndef KERNEL_ANDROID_IPSEC_H_ 23 | #define KERNEL_ANDROID_IPSEC_H_ 24 | 25 | #include 26 | #include 27 | 28 | typedef struct kernel_android_ipsec_t kernel_android_ipsec_t; 29 | 30 | /** 31 | * Implementation of the ipsec interface using libipsec on Android 32 | */ 33 | struct kernel_android_ipsec_t { 34 | 35 | /** 36 | * Implements kernel_ipsec_t interface 37 | */ 38 | kernel_ipsec_t interface; 39 | }; 40 | 41 | /** 42 | * Create a android ipsec interface instance. 43 | * 44 | * @return kernel_android_ipsec_t instance 45 | */ 46 | kernel_android_ipsec_t *kernel_android_ipsec_create(); 47 | 48 | #endif /** KERNEL_ANDROID_IPSEC_H_ @}*/ 49 | -------------------------------------------------------------------------------- /android/src/main/jni/libandroidbridge/kernel/android_net.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2012-2015 Tobias Brunner 3 | * HSR Hochschule fuer Technik Rapperswil 4 | * 5 | * This program is free software; you can redistribute it and/or modify it 6 | * under the terms of the GNU General Public License as published by the 7 | * Free Software Foundation; either version 2 of the License, or (at your 8 | * option) any later version. See . 9 | * 10 | * This program is distributed in the hope that it will be useful, but 11 | * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 12 | * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 13 | * for more details. 14 | */ 15 | 16 | /** 17 | * @defgroup android_net android_net 18 | * @{ @ingroup android_kernel 19 | */ 20 | 21 | #ifndef ANDROID_NET_H_ 22 | #define ANDROID_NET_H_ 23 | 24 | #include 25 | #include 26 | 27 | /** 28 | * Create an Android-specific kernel_net_t instance. 29 | * 30 | * @return kernel_net_t instance 31 | */ 32 | kernel_net_t *kernel_android_net_create(); 33 | 34 | 35 | #endif /** ANDROID_NET_H_ @}*/ 36 | -------------------------------------------------------------------------------- /android/src/main/jni/libandroidbridge/kernel/network_manager.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2012-2015 Tobias Brunner 3 | * HSR Hochschule fuer Technik Rapperswil 4 | * 5 | * This program is free software; you can redistribute it and/or modify it 6 | * under the terms of the GNU General Public License as published by the 7 | * Free Software Foundation; either version 2 of the License, or (at your 8 | * option) any later version. See . 9 | * 10 | * This program is distributed in the hope that it will be useful, but 11 | * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 12 | * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 13 | * for more details. 14 | */ 15 | 16 | /** 17 | * @defgroup network_manager network_manager 18 | * @{ @ingroup android_kernel 19 | */ 20 | 21 | #ifndef NETWORK_MANAGER_H_ 22 | #define NETWORK_MANAGER_H_ 23 | 24 | #include 25 | 26 | #include 27 | #include 28 | 29 | typedef struct network_manager_t network_manager_t; 30 | 31 | /** 32 | * Callback called if connectivity changes somehow. 33 | * 34 | * Implementation should be quick as the call is made by the Java apps main 35 | * thread. 36 | * 37 | * @param data data supplied during registration 38 | * @param disconnected TRUE if currently disconnected 39 | */ 40 | typedef void (*connectivity_cb_t)(void *data, bool disconnected); 41 | 42 | /** 43 | * NetworkManager, used to listen for network changes. 44 | * 45 | * Communicates with NetworkManager via JNI 46 | */ 47 | struct network_manager_t { 48 | 49 | /** 50 | * Register a callback that is called if connectivity changes 51 | * 52 | * @note Only the first registered callback is currently used 53 | * 54 | * @param cb callback to register 55 | * @param data data provided to callback 56 | */ 57 | void (*add_connectivity_cb)(network_manager_t *this, connectivity_cb_t cb, 58 | void *data); 59 | 60 | /** 61 | * Unregister a previously registered callback for connectivity changes 62 | * 63 | * @param cb previously registered callback 64 | */ 65 | void (*remove_connectivity_cb)(network_manager_t *this, 66 | connectivity_cb_t cb); 67 | 68 | /** 69 | * Check whether we currently have connectivity 70 | * 71 | * @return TRUE if currently connected 72 | */ 73 | bool (*is_connected)(network_manager_t *this); 74 | 75 | /** 76 | * Destroy a network_manager_t instance 77 | */ 78 | void (*destroy)(network_manager_t *this); 79 | }; 80 | 81 | /** 82 | * Create a network_manager_t instance 83 | * 84 | * @param context Context object 85 | * @return network_manager_t instance 86 | */ 87 | network_manager_t *network_manager_create(jobject context); 88 | 89 | #endif /** NETWORK_MANAGER_H_ @}*/ 90 | -------------------------------------------------------------------------------- /android/src/main/jni/libandroidbridge/vpnservice_builder.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2012-2014 Tobias Brunner 3 | * Copyright (C) 2012 Giuliano Grassi 4 | * Copyright (C) 2012 Ralf Sager 5 | * HSR Hochschule fuer Technik Rapperswil 6 | * 7 | * This program is free software; you can redistribute it and/or modify it 8 | * under the terms of the GNU General Public License as published by the 9 | * Free Software Foundation; either version 2 of the License, or (at your 10 | * option) any later version. See . 11 | * 12 | * This program is distributed in the hope that it will be useful, but 13 | * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 14 | * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 15 | * for more details. 16 | */ 17 | 18 | /** 19 | * @defgroup vpnservice_builder vpnservice_builder 20 | * @{ @ingroup libandroidbridge 21 | */ 22 | 23 | #ifndef VPNSERVICE_BUILDER_H_ 24 | #define VPNSERVICE_BUILDER_H_ 25 | 26 | #include 27 | 28 | #include 29 | #include 30 | 31 | typedef struct vpnservice_builder_t vpnservice_builder_t; 32 | 33 | /** 34 | * VpnService.Builder, used to build a TUN device. 35 | * 36 | * Communicates with CharonVpnService.BuilderAdapter via JNI 37 | */ 38 | struct vpnservice_builder_t { 39 | 40 | /** 41 | * Add an interface address 42 | * 43 | * @param addr the desired interface address 44 | * @return TRUE on success 45 | */ 46 | bool (*add_address)(vpnservice_builder_t *this, host_t *addr); 47 | 48 | /** 49 | * Add a route 50 | * 51 | * @param net the network address 52 | * @param prefix_length the prefix length 53 | * @return TRUE on success 54 | */ 55 | bool (*add_route)(vpnservice_builder_t *this, host_t *net, int prefix); 56 | 57 | /** 58 | * Add a DNS server 59 | * 60 | * @param dns the address of the DNS server 61 | * @return TRUE on success 62 | */ 63 | bool (*add_dns)(vpnservice_builder_t *this, host_t *dns); 64 | 65 | /** 66 | * Set the MTU for the TUN device 67 | * 68 | * @param mtu the MTU to set 69 | * @return TRUE on success 70 | */ 71 | bool (*set_mtu)(vpnservice_builder_t *this, int mtu); 72 | 73 | /** 74 | * Build the TUN device 75 | * 76 | * @return the TUN file descriptor, -1 if failed 77 | */ 78 | int (*establish)(vpnservice_builder_t *this); 79 | 80 | /** 81 | * Build the TUN device without DNS related data 82 | * 83 | * @return the TUN file descriptor, -1 if failed 84 | */ 85 | int (*establish_no_dns)(vpnservice_builder_t *this); 86 | 87 | /** 88 | * Destroy a vpnservice_builder 89 | */ 90 | void (*destroy)(vpnservice_builder_t *this); 91 | 92 | }; 93 | 94 | /** 95 | * Create a vpnservice_builder instance 96 | * 97 | * @param builder CharonVpnService.BuilderAdapter object 98 | * @return vpnservice_builder_t instance 99 | */ 100 | vpnservice_builder_t *vpnservice_builder_create(jobject builder); 101 | 102 | #endif /** VPNSERVICE_BUILDER_H_ @}*/ 103 | -------------------------------------------------------------------------------- /android/src/main/libs/arm64-v8a/libandroidbridge.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cristinaITdeveloper/react-native-ipsec-ikev2/c6239c2de8f00431a414290f03f22caa98929034/android/src/main/libs/arm64-v8a/libandroidbridge.so -------------------------------------------------------------------------------- /android/src/main/libs/arm64-v8a/libcharon.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cristinaITdeveloper/react-native-ipsec-ikev2/c6239c2de8f00431a414290f03f22caa98929034/android/src/main/libs/arm64-v8a/libcharon.so -------------------------------------------------------------------------------- /android/src/main/libs/arm64-v8a/libimcv.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cristinaITdeveloper/react-native-ipsec-ikev2/c6239c2de8f00431a414290f03f22caa98929034/android/src/main/libs/arm64-v8a/libimcv.so -------------------------------------------------------------------------------- /android/src/main/libs/arm64-v8a/libipsec.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cristinaITdeveloper/react-native-ipsec-ikev2/c6239c2de8f00431a414290f03f22caa98929034/android/src/main/libs/arm64-v8a/libipsec.so -------------------------------------------------------------------------------- /android/src/main/libs/arm64-v8a/libstrongswan.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cristinaITdeveloper/react-native-ipsec-ikev2/c6239c2de8f00431a414290f03f22caa98929034/android/src/main/libs/arm64-v8a/libstrongswan.so -------------------------------------------------------------------------------- /android/src/main/libs/arm64-v8a/libtnccs.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cristinaITdeveloper/react-native-ipsec-ikev2/c6239c2de8f00431a414290f03f22caa98929034/android/src/main/libs/arm64-v8a/libtnccs.so -------------------------------------------------------------------------------- /android/src/main/libs/arm64-v8a/libtncif.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cristinaITdeveloper/react-native-ipsec-ikev2/c6239c2de8f00431a414290f03f22caa98929034/android/src/main/libs/arm64-v8a/libtncif.so -------------------------------------------------------------------------------- /android/src/main/libs/arm64-v8a/libtpmtss.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cristinaITdeveloper/react-native-ipsec-ikev2/c6239c2de8f00431a414290f03f22caa98929034/android/src/main/libs/arm64-v8a/libtpmtss.so -------------------------------------------------------------------------------- /android/src/main/libs/armeabi-v7a/libandroidbridge.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cristinaITdeveloper/react-native-ipsec-ikev2/c6239c2de8f00431a414290f03f22caa98929034/android/src/main/libs/armeabi-v7a/libandroidbridge.so -------------------------------------------------------------------------------- /android/src/main/libs/armeabi-v7a/libcharon.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cristinaITdeveloper/react-native-ipsec-ikev2/c6239c2de8f00431a414290f03f22caa98929034/android/src/main/libs/armeabi-v7a/libcharon.so -------------------------------------------------------------------------------- /android/src/main/libs/armeabi-v7a/libimcv.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cristinaITdeveloper/react-native-ipsec-ikev2/c6239c2de8f00431a414290f03f22caa98929034/android/src/main/libs/armeabi-v7a/libimcv.so -------------------------------------------------------------------------------- /android/src/main/libs/armeabi-v7a/libipsec.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cristinaITdeveloper/react-native-ipsec-ikev2/c6239c2de8f00431a414290f03f22caa98929034/android/src/main/libs/armeabi-v7a/libipsec.so -------------------------------------------------------------------------------- /android/src/main/libs/armeabi-v7a/libstrongswan.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cristinaITdeveloper/react-native-ipsec-ikev2/c6239c2de8f00431a414290f03f22caa98929034/android/src/main/libs/armeabi-v7a/libstrongswan.so -------------------------------------------------------------------------------- /android/src/main/libs/armeabi-v7a/libtnccs.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cristinaITdeveloper/react-native-ipsec-ikev2/c6239c2de8f00431a414290f03f22caa98929034/android/src/main/libs/armeabi-v7a/libtnccs.so -------------------------------------------------------------------------------- /android/src/main/libs/armeabi-v7a/libtncif.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cristinaITdeveloper/react-native-ipsec-ikev2/c6239c2de8f00431a414290f03f22caa98929034/android/src/main/libs/armeabi-v7a/libtncif.so -------------------------------------------------------------------------------- /android/src/main/libs/armeabi-v7a/libtpmtss.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cristinaITdeveloper/react-native-ipsec-ikev2/c6239c2de8f00431a414290f03f22caa98929034/android/src/main/libs/armeabi-v7a/libtpmtss.so -------------------------------------------------------------------------------- /android/src/main/libs/x86/libandroidbridge.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cristinaITdeveloper/react-native-ipsec-ikev2/c6239c2de8f00431a414290f03f22caa98929034/android/src/main/libs/x86/libandroidbridge.so -------------------------------------------------------------------------------- /android/src/main/libs/x86/libcharon.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cristinaITdeveloper/react-native-ipsec-ikev2/c6239c2de8f00431a414290f03f22caa98929034/android/src/main/libs/x86/libcharon.so -------------------------------------------------------------------------------- /android/src/main/libs/x86/libimcv.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cristinaITdeveloper/react-native-ipsec-ikev2/c6239c2de8f00431a414290f03f22caa98929034/android/src/main/libs/x86/libimcv.so -------------------------------------------------------------------------------- /android/src/main/libs/x86/libipsec.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cristinaITdeveloper/react-native-ipsec-ikev2/c6239c2de8f00431a414290f03f22caa98929034/android/src/main/libs/x86/libipsec.so -------------------------------------------------------------------------------- /android/src/main/libs/x86/libstrongswan.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cristinaITdeveloper/react-native-ipsec-ikev2/c6239c2de8f00431a414290f03f22caa98929034/android/src/main/libs/x86/libstrongswan.so -------------------------------------------------------------------------------- /android/src/main/libs/x86/libtnccs.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cristinaITdeveloper/react-native-ipsec-ikev2/c6239c2de8f00431a414290f03f22caa98929034/android/src/main/libs/x86/libtnccs.so -------------------------------------------------------------------------------- /android/src/main/libs/x86/libtncif.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cristinaITdeveloper/react-native-ipsec-ikev2/c6239c2de8f00431a414290f03f22caa98929034/android/src/main/libs/x86/libtncif.so -------------------------------------------------------------------------------- /android/src/main/libs/x86/libtpmtss.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cristinaITdeveloper/react-native-ipsec-ikev2/c6239c2de8f00431a414290f03f22caa98929034/android/src/main/libs/x86/libtpmtss.so -------------------------------------------------------------------------------- /android/src/main/libs/x86_64/libandroidbridge.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cristinaITdeveloper/react-native-ipsec-ikev2/c6239c2de8f00431a414290f03f22caa98929034/android/src/main/libs/x86_64/libandroidbridge.so -------------------------------------------------------------------------------- /android/src/main/libs/x86_64/libcharon.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cristinaITdeveloper/react-native-ipsec-ikev2/c6239c2de8f00431a414290f03f22caa98929034/android/src/main/libs/x86_64/libcharon.so -------------------------------------------------------------------------------- /android/src/main/libs/x86_64/libimcv.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cristinaITdeveloper/react-native-ipsec-ikev2/c6239c2de8f00431a414290f03f22caa98929034/android/src/main/libs/x86_64/libimcv.so -------------------------------------------------------------------------------- /android/src/main/libs/x86_64/libipsec.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cristinaITdeveloper/react-native-ipsec-ikev2/c6239c2de8f00431a414290f03f22caa98929034/android/src/main/libs/x86_64/libipsec.so -------------------------------------------------------------------------------- /android/src/main/libs/x86_64/libstrongswan.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cristinaITdeveloper/react-native-ipsec-ikev2/c6239c2de8f00431a414290f03f22caa98929034/android/src/main/libs/x86_64/libstrongswan.so -------------------------------------------------------------------------------- /android/src/main/libs/x86_64/libtnccs.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cristinaITdeveloper/react-native-ipsec-ikev2/c6239c2de8f00431a414290f03f22caa98929034/android/src/main/libs/x86_64/libtnccs.so -------------------------------------------------------------------------------- /android/src/main/libs/x86_64/libtncif.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cristinaITdeveloper/react-native-ipsec-ikev2/c6239c2de8f00431a414290f03f22caa98929034/android/src/main/libs/x86_64/libtncif.so -------------------------------------------------------------------------------- /android/src/main/libs/x86_64/libtpmtss.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cristinaITdeveloper/react-native-ipsec-ikev2/c6239c2de8f00431a414290f03f22caa98929034/android/src/main/libs/x86_64/libtpmtss.so -------------------------------------------------------------------------------- /example/.buckconfig: -------------------------------------------------------------------------------- 1 | 2 | [android] 3 | target = Google Inc.:Google APIs:23 4 | 5 | [maven_repositories] 6 | central = https://repo1.maven.org/maven2 7 | -------------------------------------------------------------------------------- /example/.eslintrc.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | root: true, 3 | extends: '@react-native-community', 4 | }; 5 | -------------------------------------------------------------------------------- /example/.flowconfig: -------------------------------------------------------------------------------- 1 | [ignore] 2 | ; We fork some components by platform 3 | .*/*[.]android.js 4 | 5 | ; Ignore "BUCK" generated dirs 6 | /\.buckd/ 7 | 8 | ; Ignore polyfills 9 | node_modules/react-native/Libraries/polyfills/.* 10 | 11 | ; These should not be required directly 12 | ; require from fbjs/lib instead: require('fbjs/lib/warning') 13 | node_modules/warning/.* 14 | 15 | ; Flow doesn't support platforms 16 | .*/Libraries/Utilities/LoadingView.js 17 | 18 | [untyped] 19 | .*/node_modules/@react-native-community/cli/.*/.* 20 | 21 | [include] 22 | 23 | [libs] 24 | node_modules/react-native/interface.js 25 | node_modules/react-native/flow/ 26 | 27 | [options] 28 | emoji=true 29 | 30 | esproposal.optional_chaining=enable 31 | esproposal.nullish_coalescing=enable 32 | 33 | module.file_ext=.js 34 | module.file_ext=.json 35 | module.file_ext=.ios.js 36 | 37 | munge_underscores=true 38 | 39 | module.name_mapper='^react-native/\(.*\)$' -> '/node_modules/react-native/\1' 40 | module.name_mapper='^@?[./a-zA-Z0-9$_-]+\.\(bmp\|gif\|jpg\|jpeg\|png\|psd\|svg\|webp\|m4v\|mov\|mp4\|mpeg\|mpg\|webm\|aac\|aiff\|caf\|m4a\|mp3\|wav\|html\|pdf\)$' -> '/node_modules/react-native/Libraries/Image/RelativeImageStub' 41 | 42 | suppress_type=$FlowIssue 43 | suppress_type=$FlowFixMe 44 | suppress_type=$FlowFixMeProps 45 | suppress_type=$FlowFixMeState 46 | 47 | suppress_comment=\\(.\\|\n\\)*\\$FlowFixMe\\($\\|[^(]\\|(\\(\\)? *\\(site=[a-z,_]*react_native\\(_ios\\)?_\\(oss\\|fb\\)[a-z,_]*\\)?)\\) 48 | suppress_comment=\\(.\\|\n\\)*\\$FlowIssue\\((\\(\\)? *\\(site=[a-z,_]*react_native\\(_ios\\)?_\\(oss\\|fb\\)[a-z,_]*\\)?)\\)?:? #[0-9]+ 49 | suppress_comment=\\(.\\|\n\\)*\\$FlowExpectedError 50 | 51 | [lints] 52 | sketchy-null-number=warn 53 | sketchy-null-mixed=warn 54 | sketchy-number=warn 55 | untyped-type-import=warn 56 | nonstrict-import=warn 57 | deprecated-type=warn 58 | unsafe-getters-setters=warn 59 | unnecessary-invariant=warn 60 | signature-verification-failure=warn 61 | deprecated-utility=error 62 | 63 | [strict] 64 | deprecated-type 65 | nonstrict-import 66 | sketchy-null 67 | unclear-type 68 | unsafe-getters-setters 69 | untyped-import 70 | untyped-type-import 71 | 72 | [version] 73 | ^0.122.0 74 | -------------------------------------------------------------------------------- /example/.gitattributes: -------------------------------------------------------------------------------- 1 | *.pbxproj -text 2 | -------------------------------------------------------------------------------- /example/.gitignore: -------------------------------------------------------------------------------- 1 | # OSX 2 | # 3 | .DS_Store 4 | 5 | # Xcode 6 | # 7 | build/ 8 | *.pbxuser 9 | !default.pbxuser 10 | *.mode1v3 11 | !default.mode1v3 12 | *.mode2v3 13 | !default.mode2v3 14 | *.perspectivev3 15 | !default.perspectivev3 16 | xcuserdata 17 | *.xccheckout 18 | *.moved-aside 19 | DerivedData 20 | *.hmap 21 | *.ipa 22 | *.xcuserstate 23 | 24 | # Android/IntelliJ 25 | # 26 | build/ 27 | .idea 28 | .gradle 29 | local.properties 30 | *.iml 31 | 32 | # node.js 33 | # 34 | node_modules/ 35 | npm-debug.log 36 | yarn-error.log 37 | 38 | # BUCK 39 | buck-out/ 40 | \.buckd/ 41 | *.keystore 42 | !debug.keystore 43 | !my-upload-key.keystore 44 | 45 | # fastlane 46 | # 47 | # It is recommended to not store the screenshots in the git repo. Instead, use fastlane to re-generate the 48 | # screenshots whenever they are needed. 49 | # For more information about the recommended setup visit: 50 | # https://docs.fastlane.tools/best-practices/source-control/ 51 | 52 | */fastlane/report.xml 53 | */fastlane/Preview.html 54 | */fastlane/screenshots 55 | 56 | # Bundle artifact 57 | *.jsbundle 58 | 59 | # CocoaPods 60 | /ios/Pods/ 61 | 62 | *.lock 63 | -------------------------------------------------------------------------------- /example/.npmignore: -------------------------------------------------------------------------------- 1 | # OSX 2 | # 3 | .DS_Store 4 | 5 | # Xcode 6 | # 7 | build/ 8 | *.pbxuser 9 | !default.pbxuser 10 | *.mode1v3 11 | !default.mode1v3 12 | *.mode2v3 13 | !default.mode2v3 14 | *.perspectivev3 15 | !default.perspectivev3 16 | xcuserdata 17 | *.xccheckout 18 | *.moved-aside 19 | DerivedData 20 | *.hmap 21 | *.ipa 22 | *.xcuserstate 23 | 24 | # Android/IntelliJ 25 | # 26 | build/ 27 | .idea 28 | .gradle 29 | local.properties 30 | *.iml 31 | 32 | # node.js 33 | # 34 | node_modules/ 35 | npm-debug.log 36 | yarn-error.log 37 | 38 | # BUCK 39 | buck-out/ 40 | \.buckd/ 41 | *.keystore 42 | !debug.keystore 43 | !my-upload-key.keystore 44 | 45 | # fastlane 46 | # 47 | # It is recommended to not store the screenshots in the git repo. Instead, use fastlane to re-generate the 48 | # screenshots whenever they are needed. 49 | # For more information about the recommended setup visit: 50 | # https://docs.fastlane.tools/best-practices/source-control/ 51 | 52 | */fastlane/report.xml 53 | */fastlane/Preview.html 54 | */fastlane/screenshots 55 | 56 | # Bundle artifact 57 | *.jsbundle 58 | 59 | # CocoaPods 60 | /ios/Pods/ 61 | -------------------------------------------------------------------------------- /example/.prettierrc.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | bracketSpacing: true, 3 | jsxBracketSameLine: true, 4 | singleQuote: true, 5 | trailingComma: 'all', 6 | jsxSingleQuote: false, 7 | semi: true, 8 | printWidth: 140, 9 | }; 10 | -------------------------------------------------------------------------------- /example/.watchmanconfig: -------------------------------------------------------------------------------- 1 | {} -------------------------------------------------------------------------------- /example/android/.project: -------------------------------------------------------------------------------- 1 | 2 | 3 | android_ 4 | Project android_ created by Buildship. 5 | 6 | 7 | 8 | 9 | org.eclipse.buildship.core.gradleprojectbuilder 10 | 11 | 12 | 13 | 14 | 15 | org.eclipse.buildship.core.gradleprojectnature 16 | 17 | 18 | 19 | 1603066483422 20 | 21 | 30 22 | 23 | org.eclipse.core.resources.regexFilterMatcher 24 | node_modules|.git|__CREATED_BY_JAVA_LANGUAGE_SERVER__ 25 | 26 | 27 | 28 | 29 | -------------------------------------------------------------------------------- /example/android/.settings/org.eclipse.buildship.core.prefs: -------------------------------------------------------------------------------- 1 | arguments= 2 | auto.sync=false 3 | build.scans.enabled=false 4 | connection.gradle.distribution=GRADLE_DISTRIBUTION(WRAPPER) 5 | connection.project.dir= 6 | eclipse.preferences.version=1 7 | gradle.user.home= 8 | java.home=C\:\:\:\:\:\:\:\:\:\:\:\:\:\:\:\:\:\:\:\:\:\:\:\:\:\:\:\:\:\:\:\:\:\:\:\:\:\:\:\:\:\:\:\:\:\:\:\:\:\:\:\:\:\:\:\:\:\:\:\:\:\:\:\:/Program Files/Java/jdk1.8.0_161 9 | jvm.arguments= 10 | offline.mode=false 11 | override.workspace.settings=true 12 | show.console.view=true 13 | show.executions.view=true 14 | -------------------------------------------------------------------------------- /example/android/app/BUCK: -------------------------------------------------------------------------------- 1 | # To learn about Buck see [Docs](https://buckbuild.com/). 2 | # To run your application with Buck: 3 | # - install Buck 4 | # - `npm start` - to start the packager 5 | # - `cd android` 6 | # - `keytool -genkey -v -keystore keystores/debug.keystore -storepass android -alias androiddebugkey -keypass android -dname "CN=Android Debug,O=Android,C=US"` 7 | # - `./gradlew :app:copyDownloadableDepsToLibs` - make all Gradle compile dependencies available to Buck 8 | # - `buck install -r android/app` - compile, install and run application 9 | # 10 | 11 | load(":build_defs.bzl", "create_aar_targets", "create_jar_targets") 12 | 13 | lib_deps = [] 14 | 15 | create_aar_targets(glob(["libs/*.aar"])) 16 | 17 | create_jar_targets(glob(["libs/*.jar"])) 18 | 19 | android_library( 20 | name = "all-libs", 21 | exported_deps = lib_deps, 22 | ) 23 | 24 | android_library( 25 | name = "app-code", 26 | srcs = glob([ 27 | "src/main/java/**/*.java", 28 | ]), 29 | deps = [ 30 | ":all-libs", 31 | ":build_config", 32 | ":res", 33 | ], 34 | ) 35 | 36 | android_build_config( 37 | name = "build_config", 38 | package = "com.example", 39 | ) 40 | 41 | android_resource( 42 | name = "res", 43 | package = "com.example", 44 | res = "src/main/res", 45 | ) 46 | 47 | android_binary( 48 | name = "app", 49 | keystore = "//android/keystores:debug", 50 | manifest = "src/main/AndroidManifest.xml", 51 | package_type = "debug", 52 | deps = [ 53 | ":app-code", 54 | ], 55 | ) 56 | -------------------------------------------------------------------------------- /example/android/app/build_defs.bzl: -------------------------------------------------------------------------------- 1 | """Helper definitions to glob .aar and .jar targets""" 2 | 3 | def create_aar_targets(aarfiles): 4 | for aarfile in aarfiles: 5 | name = "aars__" + aarfile[aarfile.rindex("/") + 1:aarfile.rindex(".aar")] 6 | lib_deps.append(":" + name) 7 | android_prebuilt_aar( 8 | name = name, 9 | aar = aarfile, 10 | ) 11 | 12 | def create_jar_targets(jarfiles): 13 | for jarfile in jarfiles: 14 | name = "jars__" + jarfile[jarfile.rindex("/") + 1:jarfile.rindex(".jar")] 15 | lib_deps.append(":" + name) 16 | prebuilt_jar( 17 | name = name, 18 | binary_jar = jarfile, 19 | ) 20 | -------------------------------------------------------------------------------- /example/android/app/debug.keystore: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cristinaITdeveloper/react-native-ipsec-ikev2/c6239c2de8f00431a414290f03f22caa98929034/example/android/app/debug.keystore -------------------------------------------------------------------------------- /example/android/app/my-upload-key.keystore: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cristinaITdeveloper/react-native-ipsec-ikev2/c6239c2de8f00431a414290f03f22caa98929034/example/android/app/my-upload-key.keystore -------------------------------------------------------------------------------- /example/android/app/proguard-rules.pro: -------------------------------------------------------------------------------- 1 | # Add project specific ProGuard rules here. 2 | # By default, the flags in this file are appended to flags specified 3 | # in /usr/local/Cellar/android-sdk/24.3.3/tools/proguard/proguard-android.txt 4 | # You can edit the include path and order by changing the proguardFiles 5 | # directive in build.gradle. 6 | # 7 | # For more details, see 8 | # http://developer.android.com/guide/developing/tools/proguard.html 9 | 10 | # Add any project specific keep options here: 11 | -------------------------------------------------------------------------------- /example/android/app/src/debug/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /example/android/app/src/debug/java/com/example/ReactNativeFlipper.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) Facebook, Inc. and its affiliates. 3 | * 4 | *

This source code is licensed under the MIT license found in the LICENSE file in the root 5 | * directory of this source tree. 6 | */ 7 | package com.example; 8 | 9 | import android.content.Context; 10 | import com.facebook.flipper.android.AndroidFlipperClient; 11 | import com.facebook.flipper.android.utils.FlipperUtils; 12 | import com.facebook.flipper.core.FlipperClient; 13 | import com.facebook.flipper.plugins.crashreporter.CrashReporterPlugin; 14 | import com.facebook.flipper.plugins.databases.DatabasesFlipperPlugin; 15 | import com.facebook.flipper.plugins.fresco.FrescoFlipperPlugin; 16 | import com.facebook.flipper.plugins.inspector.DescriptorMapping; 17 | import com.facebook.flipper.plugins.inspector.InspectorFlipperPlugin; 18 | import com.facebook.flipper.plugins.network.FlipperOkhttpInterceptor; 19 | import com.facebook.flipper.plugins.network.NetworkFlipperPlugin; 20 | import com.facebook.flipper.plugins.react.ReactFlipperPlugin; 21 | import com.facebook.flipper.plugins.sharedpreferences.SharedPreferencesFlipperPlugin; 22 | import com.facebook.react.ReactInstanceManager; 23 | import com.facebook.react.bridge.ReactContext; 24 | import com.facebook.react.modules.network.NetworkingModule; 25 | import okhttp3.OkHttpClient; 26 | 27 | public class ReactNativeFlipper { 28 | public static void initializeFlipper(Context context, ReactInstanceManager reactInstanceManager) { 29 | if (FlipperUtils.shouldEnableFlipper(context)) { 30 | final FlipperClient client = AndroidFlipperClient.getInstance(context); 31 | 32 | client.addPlugin(new InspectorFlipperPlugin(context, DescriptorMapping.withDefaults())); 33 | client.addPlugin(new ReactFlipperPlugin()); 34 | client.addPlugin(new DatabasesFlipperPlugin(context)); 35 | client.addPlugin(new SharedPreferencesFlipperPlugin(context)); 36 | client.addPlugin(CrashReporterPlugin.getInstance()); 37 | 38 | NetworkFlipperPlugin networkFlipperPlugin = new NetworkFlipperPlugin(); 39 | NetworkingModule.setCustomClientBuilder( 40 | new NetworkingModule.CustomClientBuilder() { 41 | @Override 42 | public void apply(OkHttpClient.Builder builder) { 43 | builder.addNetworkInterceptor(new FlipperOkhttpInterceptor(networkFlipperPlugin)); 44 | } 45 | }); 46 | client.addPlugin(networkFlipperPlugin); 47 | client.start(); 48 | 49 | // Fresco Plugin needs to ensure that ImagePipelineFactory is initialized 50 | // Hence we run if after all native modules have been initialized 51 | ReactContext reactContext = reactInstanceManager.getCurrentReactContext(); 52 | if (reactContext == null) { 53 | reactInstanceManager.addReactInstanceEventListener( 54 | new ReactInstanceManager.ReactInstanceEventListener() { 55 | @Override 56 | public void onReactContextInitialized(ReactContext reactContext) { 57 | reactInstanceManager.removeReactInstanceEventListener(this); 58 | reactContext.runOnNativeModulesQueueThread( 59 | new Runnable() { 60 | @Override 61 | public void run() { 62 | client.addPlugin(new FrescoFlipperPlugin()); 63 | } 64 | }); 65 | } 66 | }); 67 | } else { 68 | client.addPlugin(new FrescoFlipperPlugin()); 69 | } 70 | } 71 | } 72 | } 73 | -------------------------------------------------------------------------------- /example/android/app/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 3 | 4 | 5 | 6 | 13 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | -------------------------------------------------------------------------------- /example/android/app/src/main/res/mipmap-hdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cristinaITdeveloper/react-native-ipsec-ikev2/c6239c2de8f00431a414290f03f22caa98929034/example/android/app/src/main/res/mipmap-hdpi/ic_launcher.png -------------------------------------------------------------------------------- /example/android/app/src/main/res/mipmap-hdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cristinaITdeveloper/react-native-ipsec-ikev2/c6239c2de8f00431a414290f03f22caa98929034/example/android/app/src/main/res/mipmap-hdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /example/android/app/src/main/res/mipmap-mdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cristinaITdeveloper/react-native-ipsec-ikev2/c6239c2de8f00431a414290f03f22caa98929034/example/android/app/src/main/res/mipmap-mdpi/ic_launcher.png -------------------------------------------------------------------------------- /example/android/app/src/main/res/mipmap-mdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cristinaITdeveloper/react-native-ipsec-ikev2/c6239c2de8f00431a414290f03f22caa98929034/example/android/app/src/main/res/mipmap-mdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /example/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cristinaITdeveloper/react-native-ipsec-ikev2/c6239c2de8f00431a414290f03f22caa98929034/example/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png -------------------------------------------------------------------------------- /example/android/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cristinaITdeveloper/react-native-ipsec-ikev2/c6239c2de8f00431a414290f03f22caa98929034/example/android/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /example/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cristinaITdeveloper/react-native-ipsec-ikev2/c6239c2de8f00431a414290f03f22caa98929034/example/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /example/android/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cristinaITdeveloper/react-native-ipsec-ikev2/c6239c2de8f00431a414290f03f22caa98929034/example/android/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /example/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cristinaITdeveloper/react-native-ipsec-ikev2/c6239c2de8f00431a414290f03f22caa98929034/example/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /example/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cristinaITdeveloper/react-native-ipsec-ikev2/c6239c2de8f00431a414290f03f22caa98929034/example/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /example/android/app/src/main/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | example 3 | 4 | -------------------------------------------------------------------------------- /example/android/app/src/main/res/values/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /example/android/build.gradle: -------------------------------------------------------------------------------- 1 | // Top-level build file where you can add configuration options common to all sub-projects/modules. 2 | 3 | buildscript { 4 | ext { 5 | buildToolsVersion = "29.0.2" 6 | minSdkVersion = 16 7 | compileSdkVersion = 29 8 | targetSdkVersion = 29 9 | } 10 | repositories { 11 | google() 12 | jcenter() 13 | } 14 | dependencies { 15 | classpath("com.android.tools.build:gradle:3.5.3") 16 | // NOTE: Do not place your application dependencies here; they belong 17 | // in the individual module build.gradle files 18 | } 19 | } 20 | 21 | allprojects { 22 | repositories { 23 | mavenLocal() 24 | maven { 25 | // All of React Native (JS, Obj-C sources, Android binaries) is installed from npm 26 | url("$rootDir/../node_modules/react-native/android") 27 | } 28 | maven { 29 | // Android JSC is installed from npm 30 | url("$rootDir/../node_modules/jsc-android/dist") 31 | } 32 | 33 | google() 34 | jcenter() 35 | maven { url 'https://www.jitpack.io' } 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /example/android/gradle.properties: -------------------------------------------------------------------------------- 1 | # Project-wide Gradle settings. 2 | 3 | # IDE (e.g. Android Studio) users: 4 | # Gradle settings configured through the IDE *will override* 5 | # any settings specified in this file. 6 | 7 | # For more details on how to configure your build environment visit 8 | # http://www.gradle.org/docs/current/userguide/build_environment.html 9 | 10 | # Specifies the JVM arguments used for the daemon process. 11 | # The setting is particularly useful for tweaking memory settings. 12 | # Default value: -Xmx10248m -XX:MaxPermSize=256m 13 | # org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8 14 | 15 | # When configured, Gradle will run in incubating parallel mode. 16 | # This option should only be used with decoupled projects. More details, visit 17 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects 18 | # org.gradle.parallel=true 19 | 20 | # AndroidX package structure to make it clearer which packages are bundled with the 21 | # Android operating system, and which are packaged with your app's APK 22 | # https://developer.android.com/topic/libraries/support-library/androidx-rn 23 | android.useAndroidX=true 24 | # Automatically convert third-party libraries to use AndroidX 25 | android.enableJetifier=true 26 | 27 | # Version of flipper SDK to use with React Native 28 | FLIPPER_VERSION=0.37.0 29 | 30 | MYAPP_UPLOAD_STORE_FILE=my-upload-key.keystore 31 | MYAPP_UPLOAD_KEY_ALIAS=my-key-alias 32 | MYAPP_UPLOAD_STORE_PASSWORD=123456 33 | MYAPP_UPLOAD_KEY_PASSWORD=123456 34 | -------------------------------------------------------------------------------- /example/android/gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cristinaITdeveloper/react-native-ipsec-ikev2/c6239c2de8f00431a414290f03f22caa98929034/example/android/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /example/android/gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionBase=GRADLE_USER_HOME 2 | distributionPath=wrapper/dists 3 | distributionUrl=https\://services.gradle.org/distributions/gradle-6.2-all.zip 4 | zipStoreBase=GRADLE_USER_HOME 5 | zipStorePath=wrapper/dists 6 | -------------------------------------------------------------------------------- /example/android/gradlew.bat: -------------------------------------------------------------------------------- 1 | @rem 2 | @rem Copyright 2015 the original author or authors. 3 | @rem 4 | @rem Licensed under the Apache License, Version 2.0 (the "License"); 5 | @rem you may not use this file except in compliance with the License. 6 | @rem You may obtain a copy of the License at 7 | @rem 8 | @rem https://www.apache.org/licenses/LICENSE-2.0 9 | @rem 10 | @rem Unless required by applicable law or agreed to in writing, software 11 | @rem distributed under the License is distributed on an "AS IS" BASIS, 12 | @rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | @rem See the License for the specific language governing permissions and 14 | @rem limitations under the License. 15 | @rem 16 | 17 | @if "%DEBUG%" == "" @echo off 18 | @rem ########################################################################## 19 | @rem 20 | @rem Gradle startup script for Windows 21 | @rem 22 | @rem ########################################################################## 23 | 24 | @rem Set local scope for the variables with windows NT shell 25 | if "%OS%"=="Windows_NT" setlocal 26 | 27 | set DIRNAME=%~dp0 28 | if "%DIRNAME%" == "" set DIRNAME=. 29 | set APP_BASE_NAME=%~n0 30 | set APP_HOME=%DIRNAME% 31 | 32 | @rem Resolve any "." and ".." in APP_HOME to make it shorter. 33 | for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi 34 | 35 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 36 | set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m" 37 | 38 | @rem Find java.exe 39 | if defined JAVA_HOME goto findJavaFromJavaHome 40 | 41 | set JAVA_EXE=java.exe 42 | %JAVA_EXE% -version >NUL 2>&1 43 | if "%ERRORLEVEL%" == "0" goto init 44 | 45 | echo. 46 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 47 | echo. 48 | echo Please set the JAVA_HOME variable in your environment to match the 49 | echo location of your Java installation. 50 | 51 | goto fail 52 | 53 | :findJavaFromJavaHome 54 | set JAVA_HOME=%JAVA_HOME:"=% 55 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe 56 | 57 | if exist "%JAVA_EXE%" goto init 58 | 59 | echo. 60 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 61 | echo. 62 | echo Please set the JAVA_HOME variable in your environment to match the 63 | echo location of your Java installation. 64 | 65 | goto fail 66 | 67 | :init 68 | @rem Get command-line arguments, handling Windows variants 69 | 70 | if not "%OS%" == "Windows_NT" goto win9xME_args 71 | 72 | :win9xME_args 73 | @rem Slurp the command line arguments. 74 | set CMD_LINE_ARGS= 75 | set _SKIP=2 76 | 77 | :win9xME_args_slurp 78 | if "x%~1" == "x" goto execute 79 | 80 | set CMD_LINE_ARGS=%* 81 | 82 | :execute 83 | @rem Setup the command line 84 | 85 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar 86 | 87 | @rem Execute Gradle 88 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% 89 | 90 | :end 91 | @rem End local scope for the variables with windows NT shell 92 | if "%ERRORLEVEL%"=="0" goto mainEnd 93 | 94 | :fail 95 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of 96 | rem the _cmd.exe /c_ return code! 97 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 98 | exit /b 1 99 | 100 | :mainEnd 101 | if "%OS%"=="Windows_NT" endlocal 102 | 103 | :omega 104 | -------------------------------------------------------------------------------- /example/android/settings.gradle: -------------------------------------------------------------------------------- 1 | rootProject.name = 'example' 2 | apply from: file("../node_modules/@react-native-community/cli-platform-android/native_modules.gradle"); applyNativeModulesSettingsGradle(settings) 3 | include ':app' 4 | -------------------------------------------------------------------------------- /example/app.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "example", 3 | "displayName": "example" 4 | } -------------------------------------------------------------------------------- /example/babel.config.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | presets: ['module:metro-react-native-babel-preset'], 3 | }; 4 | -------------------------------------------------------------------------------- /example/index.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @format 3 | */ 4 | 5 | import {AppRegistry} from 'react-native'; 6 | import App from './App'; 7 | import {name as appName} from './app.json'; 8 | 9 | AppRegistry.registerComponent(appName, () => App); 10 | -------------------------------------------------------------------------------- /example/ios/Podfile: -------------------------------------------------------------------------------- 1 | require_relative '../node_modules/react-native/scripts/react_native_pods' 2 | require_relative '../node_modules/@react-native-community/cli-platform-ios/native_modules' 3 | 4 | platform :ios, '10.0' 5 | 6 | target 'example' do 7 | config = use_native_modules! 8 | 9 | use_react_native!(:path => config["reactNativePath"]) 10 | 11 | target 'exampleTests' do 12 | inherit! :complete 13 | # Pods for testing 14 | end 15 | 16 | # Enables Flipper. 17 | # 18 | # Note that if you have use_frameworks! enabled, Flipper will not work and 19 | # you should disable these next few lines. 20 | use_flipper! 21 | post_install do |installer| 22 | flipper_post_install(installer) 23 | end 24 | end 25 | 26 | target 'example-tvOS' do 27 | # Pods for example-tvOS 28 | 29 | target 'example-tvOSTests' do 30 | inherit! :search_paths 31 | # Pods for testing 32 | end 33 | end 34 | -------------------------------------------------------------------------------- /example/ios/example-tvOS/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | APPL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | 1 23 | LSRequiresIPhoneOS 24 | 25 | NSAppTransportSecurity 26 | 27 | NSExceptionDomains 28 | 29 | localhost 30 | 31 | NSExceptionAllowsInsecureHTTPLoads 32 | 33 | 34 | 35 | 36 | NSLocationWhenInUseUsageDescription 37 | 38 | UILaunchStoryboardName 39 | LaunchScreen 40 | UIRequiredDeviceCapabilities 41 | 42 | armv7 43 | 44 | UISupportedInterfaceOrientations 45 | 46 | UIInterfaceOrientationPortrait 47 | UIInterfaceOrientationLandscapeLeft 48 | UIInterfaceOrientationLandscapeRight 49 | 50 | UIViewControllerBasedStatusBarAppearance 51 | 52 | 53 | 54 | -------------------------------------------------------------------------------- /example/ios/example-tvOSTests/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | BNDL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | 1 23 | 24 | 25 | -------------------------------------------------------------------------------- /example/ios/example.xcodeproj/xcshareddata/xcschemes/example-tvOS.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 15 | 21 | 22 | 23 | 24 | 25 | 30 | 31 | 33 | 39 | 40 | 41 | 42 | 43 | 53 | 55 | 61 | 62 | 63 | 64 | 70 | 72 | 78 | 79 | 80 | 81 | 83 | 84 | 87 | 88 | 89 | -------------------------------------------------------------------------------- /example/ios/example.xcodeproj/xcshareddata/xcschemes/example.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 15 | 21 | 22 | 23 | 24 | 25 | 30 | 31 | 33 | 39 | 40 | 41 | 42 | 43 | 53 | 55 | 61 | 62 | 63 | 64 | 70 | 72 | 78 | 79 | 80 | 81 | 83 | 84 | 87 | 88 | 89 | -------------------------------------------------------------------------------- /example/ios/example.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /example/ios/example.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | IDEDidComputeMac32BitWarning 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /example/ios/example/AppDelegate.h: -------------------------------------------------------------------------------- 1 | #import 2 | #import 3 | 4 | @interface AppDelegate : UIResponder 5 | 6 | @property (nonatomic, strong) UIWindow *window; 7 | 8 | @end 9 | -------------------------------------------------------------------------------- /example/ios/example/AppDelegate.m: -------------------------------------------------------------------------------- 1 | #import "AppDelegate.h" 2 | 3 | #import 4 | #import 5 | #import 6 | 7 | #ifdef FB_SONARKIT_ENABLED 8 | #import 9 | #import 10 | #import 11 | #import 12 | #import 13 | #import 14 | 15 | static void InitializeFlipper(UIApplication *application) { 16 | FlipperClient *client = [FlipperClient sharedClient]; 17 | SKDescriptorMapper *layoutDescriptorMapper = [[SKDescriptorMapper alloc] initWithDefaults]; 18 | [client addPlugin:[[FlipperKitLayoutPlugin alloc] initWithRootNode:application withDescriptorMapper:layoutDescriptorMapper]]; 19 | [client addPlugin:[[FKUserDefaultsPlugin alloc] initWithSuiteName:nil]]; 20 | [client addPlugin:[FlipperKitReactPlugin new]]; 21 | [client addPlugin:[[FlipperKitNetworkPlugin alloc] initWithNetworkAdapter:[SKIOSNetworkAdapter new]]]; 22 | [client start]; 23 | } 24 | #endif 25 | 26 | @implementation AppDelegate 27 | 28 | - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions 29 | { 30 | #ifdef FB_SONARKIT_ENABLED 31 | InitializeFlipper(application); 32 | #endif 33 | 34 | RCTBridge *bridge = [[RCTBridge alloc] initWithDelegate:self launchOptions:launchOptions]; 35 | RCTRootView *rootView = [[RCTRootView alloc] initWithBridge:bridge 36 | moduleName:@"example" 37 | initialProperties:nil]; 38 | 39 | rootView.backgroundColor = [[UIColor alloc] initWithRed:1.0f green:1.0f blue:1.0f alpha:1]; 40 | 41 | self.window = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds]; 42 | UIViewController *rootViewController = [UIViewController new]; 43 | rootViewController.view = rootView; 44 | self.window.rootViewController = rootViewController; 45 | [self.window makeKeyAndVisible]; 46 | return YES; 47 | } 48 | 49 | - (NSURL *)sourceURLForBridge:(RCTBridge *)bridge 50 | { 51 | #if DEBUG 52 | return [[RCTBundleURLProvider sharedSettings] jsBundleURLForBundleRoot:@"index" fallbackResource:nil]; 53 | #else 54 | return [[NSBundle mainBundle] URLForResource:@"main" withExtension:@"jsbundle"]; 55 | #endif 56 | } 57 | 58 | @end 59 | -------------------------------------------------------------------------------- /example/ios/example/Images.xcassets/AppIcon.appiconset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "iphone", 5 | "size" : "29x29", 6 | "scale" : "2x" 7 | }, 8 | { 9 | "idiom" : "iphone", 10 | "size" : "29x29", 11 | "scale" : "3x" 12 | }, 13 | { 14 | "idiom" : "iphone", 15 | "size" : "40x40", 16 | "scale" : "2x" 17 | }, 18 | { 19 | "idiom" : "iphone", 20 | "size" : "40x40", 21 | "scale" : "3x" 22 | }, 23 | { 24 | "idiom" : "iphone", 25 | "size" : "60x60", 26 | "scale" : "2x" 27 | }, 28 | { 29 | "idiom" : "iphone", 30 | "size" : "60x60", 31 | "scale" : "3x" 32 | } 33 | ], 34 | "info" : { 35 | "version" : 1, 36 | "author" : "xcode" 37 | } 38 | } -------------------------------------------------------------------------------- /example/ios/example/Images.xcassets/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "info" : { 3 | "version" : 1, 4 | "author" : "xcode" 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /example/ios/example/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleDisplayName 8 | example 9 | CFBundleExecutable 10 | $(EXECUTABLE_NAME) 11 | CFBundleIdentifier 12 | $(PRODUCT_BUNDLE_IDENTIFIER) 13 | CFBundleInfoDictionaryVersion 14 | 6.0 15 | CFBundleName 16 | $(PRODUCT_NAME) 17 | CFBundlePackageType 18 | APPL 19 | CFBundleShortVersionString 20 | 1.0 21 | CFBundleSignature 22 | ???? 23 | CFBundleVersion 24 | 1 25 | LSRequiresIPhoneOS 26 | 27 | NSAppTransportSecurity 28 | 29 | NSAllowsArbitraryLoads 30 | 31 | NSExceptionDomains 32 | 33 | localhost 34 | 35 | NSExceptionAllowsInsecureHTTPLoads 36 | 37 | 38 | 39 | 40 | NSLocationWhenInUseUsageDescription 41 | 42 | UILaunchStoryboardName 43 | LaunchScreen 44 | UIRequiredDeviceCapabilities 45 | 46 | armv7 47 | 48 | UISupportedInterfaceOrientations 49 | 50 | UIInterfaceOrientationPortrait 51 | UIInterfaceOrientationLandscapeLeft 52 | UIInterfaceOrientationLandscapeRight 53 | 54 | UIViewControllerBasedStatusBarAppearance 55 | 56 | 57 | 58 | -------------------------------------------------------------------------------- /example/ios/example/main.m: -------------------------------------------------------------------------------- 1 | #import 2 | 3 | #import "AppDelegate.h" 4 | 5 | int main(int argc, char * argv[]) { 6 | @autoreleasepool { 7 | return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class])); 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /example/ios/exampleTests/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | BNDL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | 1 23 | 24 | 25 | -------------------------------------------------------------------------------- /example/ios/exampleTests/exampleTests.m: -------------------------------------------------------------------------------- 1 | #import 2 | #import 3 | 4 | #import 5 | #import 6 | 7 | #define TIMEOUT_SECONDS 600 8 | #define TEXT_TO_LOOK_FOR @"Welcome to React" 9 | 10 | @interface exampleTests : XCTestCase 11 | 12 | @end 13 | 14 | @implementation exampleTests 15 | 16 | - (BOOL)findSubviewInView:(UIView *)view matching:(BOOL(^)(UIView *view))test 17 | { 18 | if (test(view)) { 19 | return YES; 20 | } 21 | for (UIView *subview in [view subviews]) { 22 | if ([self findSubviewInView:subview matching:test]) { 23 | return YES; 24 | } 25 | } 26 | return NO; 27 | } 28 | 29 | - (void)testRendersWelcomeScreen 30 | { 31 | UIViewController *vc = [[[RCTSharedApplication() delegate] window] rootViewController]; 32 | NSDate *date = [NSDate dateWithTimeIntervalSinceNow:TIMEOUT_SECONDS]; 33 | BOOL foundElement = NO; 34 | 35 | __block NSString *redboxError = nil; 36 | #ifdef DEBUG 37 | RCTSetLogFunction(^(RCTLogLevel level, RCTLogSource source, NSString *fileName, NSNumber *lineNumber, NSString *message) { 38 | if (level >= RCTLogLevelError) { 39 | redboxError = message; 40 | } 41 | }); 42 | #endif 43 | 44 | while ([date timeIntervalSinceNow] > 0 && !foundElement && !redboxError) { 45 | [[NSRunLoop mainRunLoop] runMode:NSDefaultRunLoopMode beforeDate:[NSDate dateWithTimeIntervalSinceNow:0.1]]; 46 | [[NSRunLoop mainRunLoop] runMode:NSRunLoopCommonModes beforeDate:[NSDate dateWithTimeIntervalSinceNow:0.1]]; 47 | 48 | foundElement = [self findSubviewInView:vc.view matching:^BOOL(UIView *view) { 49 | if ([view.accessibilityLabel isEqualToString:TEXT_TO_LOOK_FOR]) { 50 | return YES; 51 | } 52 | return NO; 53 | }]; 54 | } 55 | 56 | #ifdef DEBUG 57 | RCTSetLogFunction(RCTDefaultLogFunction); 58 | #endif 59 | 60 | XCTAssertNil(redboxError, @"RedBox error: %@", redboxError); 61 | XCTAssertTrue(foundElement, @"Couldn't find element with text '%@' in %d seconds", TEXT_TO_LOOK_FOR, TIMEOUT_SECONDS); 62 | } 63 | 64 | 65 | @end 66 | -------------------------------------------------------------------------------- /example/metro.config.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Metro configuration for React Native 3 | * https://github.com/facebook/react-native 4 | * 5 | * @format 6 | */ 7 | 8 | module.exports = { 9 | transformer: { 10 | getTransformOptions: async () => ({ 11 | transform: { 12 | experimentalImportSupport: false, 13 | inlineRequires: false, 14 | }, 15 | }), 16 | }, 17 | }; 18 | -------------------------------------------------------------------------------- /example/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "example", 3 | "version": "0.0.1", 4 | "scripts": { 5 | "android": "react-native run-android", 6 | "ios": "react-native run-ios", 7 | "start": "react-native start", 8 | "lint": "eslint ." 9 | }, 10 | "dependencies": { 11 | "react": "16.13.1", 12 | "react-native": "0.63.2", 13 | "react-native-ikev2-ipsec": "1.1.15" 14 | }, 15 | "devDependencies": { 16 | "@babel/core": "^7.8.4", 17 | "@babel/runtime": "^7.8.4", 18 | "@react-native-community/eslint-config": "^1.1.0", 19 | "babel-jest": "^25.1.0", 20 | "eslint": "^6.5.1", 21 | "metro-react-native-babel-preset": "^0.59.0", 22 | "prettier": "2.0.5" 23 | }, 24 | "jest": { 25 | "preset": "react-native" 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /index.d.ts: -------------------------------------------------------------------------------- 1 | import { EmitterSubscription } from "react-native"; 2 | export declare enum VpnState { 3 | disconnected = 0, 4 | connecting = 1, 5 | connected = 2, 6 | disconnecting = 3, 7 | genericError = 4 8 | } 9 | export declare enum CharonErrorState { 10 | NO_ERROR = 0, 11 | AUTH_FAILED = 1, 12 | PEER_AUTH_FAILED = 2, 13 | LOOKUP_FAILED = 3, 14 | UNREACHABLE = 4, 15 | GENERIC_ERROR = 5, 16 | PASSWORD_MISSING = 6, 17 | CERTIFICATE_UNAVAILABLE = 7, 18 | UNDEFINED = 8 19 | } 20 | export declare const STATE_CHANGED_EVENT_NAME: string; 21 | export declare const removeOnStateChangeListener: (stateChangedEvent: EmitterSubscription) => void; 22 | export declare const onStateChangedListener: (callback: (state: { 23 | state: VpnState; 24 | charonState: CharonErrorState; 25 | }) => void) => EmitterSubscription; 26 | export declare const prepare: () => Promise; 27 | export declare enum VpnType { 28 | IKEV2_EAP = "ikev2-eap", 29 | IKEV2_CERT = "ikev2-cert", 30 | IKEV2_CERT_EAP = "ikev2-cert-eap", 31 | IKEV2_EAP_TLS = "ikev2-eap-tls", 32 | IKEV2_BYOD_EAP = "ikev2-byod-eap" 33 | } 34 | export declare const connect: (name: string, address: string, username: string, password: string, vpnType?: VpnType, secret?: string, disconnectOnSleep?: boolean, mtu?: number, b64CaCert?: string, b64UserCert?: string, userCertPassword?: string, certAlias?: string) => Promise; 35 | export declare const getCurrentState: () => Promise; 36 | export declare const getCharonErrorState: () => Promise; 37 | export declare const disconnect: () => Promise; 38 | declare const _default: any; 39 | export default _default; 40 | -------------------------------------------------------------------------------- /index.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | Object.defineProperty(exports, "__esModule", { value: true }); 3 | exports.disconnect = exports.getCharonErrorState = exports.getCurrentState = exports.connect = exports.VpnType = exports.prepare = exports.onStateChangedListener = exports.removeOnStateChangeListener = exports.STATE_CHANGED_EVENT_NAME = exports.CharonErrorState = exports.VpnState = void 0; 4 | const react_native_1 = require("react-native"); 5 | var VpnState; 6 | (function (VpnState) { 7 | VpnState[VpnState["disconnected"] = 0] = "disconnected"; 8 | VpnState[VpnState["connecting"] = 1] = "connecting"; 9 | VpnState[VpnState["connected"] = 2] = "connected"; 10 | VpnState[VpnState["disconnecting"] = 3] = "disconnecting"; 11 | VpnState[VpnState["genericError"] = 4] = "genericError"; 12 | })(VpnState = exports.VpnState || (exports.VpnState = {})); 13 | var CharonErrorState; 14 | (function (CharonErrorState) { 15 | CharonErrorState[CharonErrorState["NO_ERROR"] = 0] = "NO_ERROR"; 16 | CharonErrorState[CharonErrorState["AUTH_FAILED"] = 1] = "AUTH_FAILED"; 17 | CharonErrorState[CharonErrorState["PEER_AUTH_FAILED"] = 2] = "PEER_AUTH_FAILED"; 18 | CharonErrorState[CharonErrorState["LOOKUP_FAILED"] = 3] = "LOOKUP_FAILED"; 19 | CharonErrorState[CharonErrorState["UNREACHABLE"] = 4] = "UNREACHABLE"; 20 | CharonErrorState[CharonErrorState["GENERIC_ERROR"] = 5] = "GENERIC_ERROR"; 21 | CharonErrorState[CharonErrorState["PASSWORD_MISSING"] = 6] = "PASSWORD_MISSING"; 22 | CharonErrorState[CharonErrorState["CERTIFICATE_UNAVAILABLE"] = 7] = "CERTIFICATE_UNAVAILABLE"; 23 | CharonErrorState[CharonErrorState["UNDEFINED"] = 8] = "UNDEFINED"; 24 | })(CharonErrorState = exports.CharonErrorState || (exports.CharonErrorState = {})); 25 | const stateChanged = new react_native_1.NativeEventEmitter(react_native_1.NativeModules.RNIpSecVpn); 26 | exports.STATE_CHANGED_EVENT_NAME = "stateChanged"; 27 | exports.removeOnStateChangeListener = (stateChangedEvent) => { 28 | stateChangedEvent.remove(); 29 | }; 30 | exports.onStateChangedListener = (callback) => { 31 | return stateChanged.addListener(exports.STATE_CHANGED_EVENT_NAME, (e) => callback(e)); 32 | }; 33 | exports.prepare = react_native_1.NativeModules.RNIpSecVpn.prepare; 34 | var VpnType; 35 | (function (VpnType) { 36 | VpnType["IKEV2_EAP"] = "ikev2-eap"; 37 | VpnType["IKEV2_CERT"] = "ikev2-cert"; 38 | VpnType["IKEV2_CERT_EAP"] = "ikev2-cert-eap"; 39 | VpnType["IKEV2_EAP_TLS"] = "ikev2-eap-tls"; 40 | VpnType["IKEV2_BYOD_EAP"] = "ikev2-byod-eap"; 41 | })(VpnType = exports.VpnType || (exports.VpnType = {})); 42 | exports.connect = (name, address, username, password, vpnType, secret, disconnectOnSleep, mtu, b64CaCert, b64UserCert, certAlias, userCertPassword) => react_native_1.NativeModules.RNIpSecVpn.connect(name || "", address || "", username || "", password || "", vpnType || "", secret || "", disconnectOnSleep || false, mtu || 1400, b64CaCert || "", b64UserCert || "", userCertPassword || "", certAlias || ""); 43 | exports.getCurrentState = react_native_1.NativeModules.RNIpSecVpn.getCurrentState; 44 | exports.getCharonErrorState = react_native_1.NativeModules.RNIpSecVpn.getCharonErrorState; 45 | exports.disconnect = react_native_1.NativeModules.RNIpSecVpn.disconnect; 46 | exports.default = react_native_1.NativeModules.RNIpSecVpn; 47 | //# sourceMappingURL=index.js.map -------------------------------------------------------------------------------- /index.js.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"index.js","sourceRoot":"","sources":["index.ts"],"names":[],"mappings":";;;AAAA,+CAAsF;AAGtF,IAAY,QAMX;AAND,WAAY,QAAQ;IAClB,uDAAY,CAAA;IACZ,mDAAU,CAAA;IACV,iDAAS,CAAA;IACT,yDAAa,CAAA;IACb,uDAAY,CAAA;AACd,CAAC,EANW,QAAQ,GAAR,gBAAQ,KAAR,gBAAQ,QAMnB;AAID,IAAY,gBAUX;AAVD,WAAY,gBAAgB;IAC1B,+DAAQ,CAAA;IACR,qEAAW,CAAA;IACX,+EAAgB,CAAA;IAChB,yEAAa,CAAA;IACb,qEAAW,CAAA;IACX,yEAAa,CAAA;IACb,+EAAgB,CAAA;IAChB,6FAAuB,CAAA;IACvB,iEAAS,CAAA;AACX,CAAC,EAVW,gBAAgB,GAAhB,wBAAgB,KAAhB,wBAAgB,QAU3B;AAED,MAAM,YAAY,GAAuB,IAAI,iCAAkB,CAAC,4BAAa,CAAC,UAAU,CAAC,CAAC;AAG7E,QAAA,wBAAwB,GAAW,cAAc,CAAC;AAGlD,QAAA,2BAA2B,GAAqD,CAAC,iBAAiB,EAAE,EAAE;IACjH,iBAAiB,CAAC,MAAM,EAAE,CAAC;AAC7B,CAAC,CAAC;AAGW,QAAA,sBAAsB,GAER,CAAC,QAAQ,EAAE,EAAE;IACtC,OAAO,YAAY,CAAC,WAAW,CAAC,gCAAwB,EAAE,CAAC,CAAqD,EAAE,EAAE,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC;AACpI,CAAC,CAAC;AAeW,QAAA,OAAO,GAAwB,4BAAa,CAAC,UAAU,CAAC,OAAO,CAAC;AAE7E,IAAY,OAMX;AAND,WAAY,OAAO;IACjB,kCAAuB,CAAA;IACrB,oCAAyB,CAAA;IACzB,4CAAiC,CAAA;IACjC,0CAA+B,CAAA;IAC/B,4CAAiC,CAAA;AACrC,CAAC,EANW,OAAO,GAAP,eAAO,KAAP,eAAO,QAMlB;AAOY,QAAA,OAAO,GAAiQ,CACnR,IAAI,EACJ,OAAO,EACP,QAAQ,EACR,QAAQ,EACR,OAAO,EACP,MAAM,EACN,iBAAiB,EACjB,GAAG,EACH,SAAS,EACT,WAAW,EACX,SAAS,EACT,gBAAgB,EAChB,EAAE,CAAC,4BAAa,CAAC,UAAU,CAAC,OAAO,CAAC,IAAI,IAAI,EAAE,EAAE,OAAO,IAAI,EAAE,EAAE,QAAQ,IAAI,EAAE,EAAE,QAAQ,IAAI,EAAE,EAAE,OAAO,IAAI,EAAE,EAAE,MAAM,IAAI,EAAE,EAAE,iBAAiB,IAAI,KAAK,EAAE,GAAG,IAAI,IAAI,EAAE,SAAS,IAAI,EAAE,EAAE,WAAW,IAAI,EAAE,EAAE,gBAAgB,IAAI,EAAE,EAAE,SAAS,IAAI,EAAE,CAAC,CAAC;AAGvO,QAAA,eAAe,GAA4B,4BAAa,CAAC,UAAU,CAAC,eAAe,CAAC;AAKpF,QAAA,mBAAmB,GAAoC,4BAAa,CAAC,UAAU,CAAC,mBAAmB,CAAC;AAIpG,QAAA,UAAU,GAAwB,4BAAa,CAAC,UAAU,CAAC,UAAU,CAAC;AAEnF,kBAAe,4BAAa,CAAC,UAAU,CAAC"} -------------------------------------------------------------------------------- /index.ts: -------------------------------------------------------------------------------- 1 | import { NativeEventEmitter, NativeModules, EmitterSubscription } from "react-native"; 2 | 3 | // the generic VPN state for all platforms. 4 | export enum VpnState { 5 | disconnected, 6 | connecting, 7 | connected, 8 | disconnecting, 9 | genericError, 10 | } 11 | 12 | /// the error state from `VpnStateService`. 13 | /// only available for Android device. 14 | export enum CharonErrorState { 15 | NO_ERROR, 16 | AUTH_FAILED, 17 | PEER_AUTH_FAILED, 18 | LOOKUP_FAILED, 19 | UNREACHABLE, 20 | GENERIC_ERROR, 21 | PASSWORD_MISSING, 22 | CERTIFICATE_UNAVAILABLE, 23 | UNDEFINED, 24 | } 25 | 26 | const stateChanged: NativeEventEmitter = new NativeEventEmitter(NativeModules.RNIpSecVpn); 27 | 28 | // receive state change from VPN service. 29 | export const STATE_CHANGED_EVENT_NAME: string = "stateChanged"; 30 | 31 | // remove change listener 32 | export const removeOnStateChangeListener: (stateChangedEvent: EmitterSubscription) => void = (stateChangedEvent) => { 33 | stateChangedEvent.remove(); 34 | }; 35 | 36 | // set a change listener 37 | export const onStateChangedListener: ( 38 | callback: (state: { state: VpnState; charonState: CharonErrorState }) => void 39 | ) => EmitterSubscription = (callback) => { 40 | return stateChanged.addListener(STATE_CHANGED_EVENT_NAME, (e: { state: VpnState; charonState: CharonErrorState }) => callback(e)); 41 | }; 42 | 43 | // prepare for vpn connection. 44 | // 45 | // android: 46 | // for first connection it will show a dialog to ask for permission. 47 | // when your connection was interrupted by another VPN connection, 48 | // you should prepare again before reconnect. 49 | // also if activity isn't running yet, 50 | // the activity can be null and will raise an exception 51 | // in this case prepare should be called once again when the activity is running. 52 | // 53 | // ios: 54 | // create a watch for state change 55 | // does not raise anything 56 | export const prepare: () => Promise = NativeModules.RNIpSecVpn.prepare; 57 | 58 | export enum VpnType { 59 | IKEV2_EAP = "ikev2-eap", 60 | IKEV2_CERT = "ikev2-cert", 61 | IKEV2_CERT_EAP = "ikev2-cert-eap", 62 | IKEV2_EAP_TLS = "ikev2-eap-tls", 63 | IKEV2_BYOD_EAP = "ikev2-byod-eap", 64 | } 65 | 66 | // connect to VPN. 67 | // 68 | // use given credentials to connect VPN (ikev2-eap). 69 | // this will create a background VPN service. 70 | // mtu is only available on android. 71 | export const connect: (name: string, address: string, username: string, password: string, vpnType?: VpnType, secret?: string, disconnectOnSleep?: boolean, mtu?: number, b64CaCert?: string, b64UserCert?: string, userCertPassword?: string, certAlias?: string) => Promise = ( 72 | name, 73 | address, 74 | username, 75 | password, 76 | vpnType, 77 | secret, 78 | disconnectOnSleep, 79 | mtu, 80 | b64CaCert, 81 | b64UserCert, 82 | certAlias, 83 | userCertPassword, 84 | ) => NativeModules.RNIpSecVpn.connect(name || "", address || "", username || "", password || "", vpnType || "", secret || "", disconnectOnSleep || false, mtu || 1400, b64CaCert || "", b64UserCert || "", userCertPassword || "", certAlias || ""); 85 | 86 | // get current state 87 | export const getCurrentState: () => Promise = NativeModules.RNIpSecVpn.getCurrentState; 88 | 89 | // get current error state from `VpnStateService`. (Android only will recieve no error on ios) 90 | // when [VpnState.genericError] is receivedon android, details of error can be 91 | // inspected by [CharonErrorState]. 92 | export const getCharonErrorState: () => Promise = NativeModules.RNIpSecVpn.getCharonErrorState; 93 | 94 | // disconnect and stop VPN service. 95 | // does not raise any exception 96 | export const disconnect: () => Promise = NativeModules.RNIpSecVpn.disconnect; 97 | 98 | export default NativeModules.RNIpSecVpn; 99 | -------------------------------------------------------------------------------- /ios/RNIpSecVpn.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /ios/RNIpSecVpn.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | IDEDidComputeMac32BitWarning 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /ios/RNIpSecVpnBridge.h: -------------------------------------------------------------------------------- 1 | // 2 | // Use this file to import your target's public headers that you would like to expose to Swift. 3 | // 4 | #import 5 | #import 6 | -------------------------------------------------------------------------------- /ios/RNIpSecVpnBridge.m: -------------------------------------------------------------------------------- 1 | // 2 | // RNIpSecVpnBridge.m 3 | // RNIpSecVpn 4 | // 5 | // Copyright © 2019 Sijav. All rights reserved. 6 | // 7 | 8 | #import 9 | #import 10 | 11 | @interface RCT_EXTERN_MODULE(RNIpSecVpn, RCTEventEmitter) 12 | 13 | RCT_EXTERN_METHOD(prepare:(RCTPromiseResolveBlock)findEventsWithResolver rejecter:(RCTPromiseRejectBlock)rejecter) 14 | RCT_EXTERN_METHOD(connect:(NSString *)name address:(NSString *)address username:(NSString *)username password:(NSString *)password vpnType:(NSString *)vpnType secret:(NSString *) disconnectOnSleep:(BOOL) mtu:(NSNumber *_Nonnull)mtu b64CaCert:(NSString *)b64CaCert b64UserCert:(NSString *)b64UserCert userCertPassword:(NSString *)userCertPassword certAlias:(NSString *)certAlias findEventsWithResolver:(RCTPromiseResolveBlock)findEventsWithResolver rejecter:(RCTPromiseRejectBlock)rejecter) 15 | RCT_EXTERN_METHOD(disconnect:(RCTPromiseResolveBlock)findEventsWithResolver rejecter:(RCTPromiseRejectBlock)rejecter) 16 | RCT_EXTERN_METHOD(getCurrentState:(RCTPromiseResolveBlock)findEventsWithResolver rejecter:(RCTPromiseRejectBlock)rejecter) 17 | RCT_EXTERN_METHOD(getCharonErrorState:(RCTPromiseResolveBlock)findEventsWithResolver rejecter:(RCTPromiseRejectBlock)rejecter) 18 | 19 | @end 20 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "react-native-ikev2-ipsec", 3 | "title": "React Native IPSec IKEV2 Vpn", 4 | "version": "1.1.15", 5 | "description": "React Native IPSec IKEV2 Vpn Module", 6 | "homepage": "https://github.com/cristinaITdeveloper/react-native-ipsec-ikev2.git#readme", 7 | "main": "index.js", 8 | "types": "index.d.ts", 9 | "files": [ 10 | "README.md", 11 | "android", 12 | "index.js", 13 | "index.ts", 14 | "index.d.ts", 15 | "ios", 16 | "react-native-ip-sec-vpn.podspec" 17 | ], 18 | "scripts": { 19 | "prepare": "yarn run compile", 20 | "compile": "tsc -p tsconfig.json" 21 | }, 22 | "repository": { 23 | "type": "git", 24 | "url": "git+https://github.com/cristinaITdeveloper/react-native-ipsec-ikev2.git", 25 | "baseUrl": "https://github.com/cristinaITdeveloper/react-native-ipsec-ikev2.git" 26 | }, 27 | "keywords": [ 28 | "react-native", 29 | "ikev", 30 | "ipsec", 31 | "ipsec vpn", 32 | "vpn" 33 | ], 34 | "author": { 35 | "name": "Sijav", 36 | "email": "sinajavaheri@gmail.com" 37 | }, 38 | "license": "MIT", 39 | "licenseFilename": "LICENSE", 40 | "readmeFilename": "README.md", 41 | "peerDependencies": { 42 | "react": "^16.8.1", 43 | "react-native": ">=0.60.0-rc.0 <1.0.x" 44 | }, 45 | "devDependencies": { 46 | "@types/react-native": "0.63.2", 47 | "prettier": "2.0.5", 48 | "react": "16.13.1", 49 | "react-native": "0.63.2", 50 | "typescript": "3.9.7" 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /react-native-ip-sec-vpn.podspec: -------------------------------------------------------------------------------- 1 | require "json" 2 | 3 | package = JSON.parse(File.read(File.join(__dir__, "package.json"))) 4 | 5 | Pod::Spec.new do |s| 6 | s.name = "react-native-ip-sec-vpn" 7 | s.version = package["version"] 8 | s.summary = package["description"] 9 | s.description = <<-DESC 10 | react-native-ip-sec-vpn 11 | DESC 12 | s.homepage = "https://github.com/github_account/react-native-ip-sec-vpn" 13 | # brief license entry: 14 | s.license = "MIT" 15 | # optional - use expanded license entry instead: 16 | # s.license = { :type => "MIT", :file => "LICENSE" } 17 | s.authors = { "Your Name" => "sinajavaheri@email.com" } 18 | s.platforms = { :ios => "9.0" } 19 | s.source = { :git => "https://github.com/sijav/react-native-ip-sec-vpn.git", :tag => "#{s.version}" } 20 | 21 | s.source_files = "ios/**/*.{h,c,m,swift}" 22 | s.requires_arc = true 23 | 24 | s.dependency "React" 25 | # ... 26 | # s.dependency "..." 27 | end 28 | -------------------------------------------------------------------------------- /tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "allowUnreachableCode": false, 4 | "allowUnusedLabels": false, 5 | "declaration": true, 6 | "forceConsistentCasingInFileNames": true, 7 | "lib": ["es2018"], 8 | "module": "commonjs", 9 | "noEmitOnError": true, 10 | "noFallthroughCasesInSwitch": true, 11 | "noImplicitReturns": true, 12 | "pretty": true, 13 | "sourceMap": true, 14 | "strict": true, 15 | "target": "es2018", 16 | "jsx": "react-native", 17 | "noUnusedLocals": true, 18 | "noUnusedParameters": true, 19 | "outDir": "./", 20 | "removeComments": true, 21 | "noImplicitAny": true 22 | }, 23 | "include": ["./index.ts"], 24 | "exclude": ["node_modules"] 25 | } 26 | --------------------------------------------------------------------------------