diff --git a/.flowconfig b/.flowconfig deleted file mode 100644 index 3cf7ab7..0000000 --- a/.flowconfig +++ /dev/null @@ -1,32 +0,0 @@ -[ignore] - -# We fork some components by platform. -.*/*.web.js -.*/*.android.js - -# Some modules have their own node_modules with overlap -.*/node_modules/node-haste/.* - -# Ignore react-tools where there are overlaps, but don't ignore anything that -# react-native relies on -.*/node_modules/react-tools/src/vendor/core/ExecutionEnvironment.js -.*/node_modules/react-tools/src/browser/eventPlugins/ResponderEventPlugin.js -.*/node_modules/react-tools/src/browser/ui/React.js -.*/node_modules/react-tools/src/core/ReactInstanceHandles.js -.*/node_modules/react-tools/src/event/EventPropagators.js -.*/node_modules/flux/lib/invariant.js - -# Ignore jest -.*/node_modules/jest-cli/.* - -# Ignore examples -.*/Examples/.* - -[include] - -[libs] -node_modules/react-native/Libraries/react-native/react-native-interface.js -interfaces.js - -[options] -module.system=haste diff --git a/.gitignore b/.gitignore index b927355..d877ecf 100644 --- a/.gitignore +++ b/.gitignore @@ -26,3 +26,6 @@ project.xcworkspace # node_modules/ npm-debug.log + +.idea/ +.gradle/ diff --git a/.vscode/settings.json b/.vscode/settings.json deleted file mode 100644 index 01586d6..0000000 --- a/.vscode/settings.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "files.exclude": { - "**/.classpath": true, - "**/.project": true, - "**/.settings": true, - "**/.factorypath": true - } -} \ No newline at end of file diff --git a/LICENSE b/LICENSE index 6f9227d..863f38a 100644 --- a/LICENSE +++ b/LICENSE @@ -1,6 +1,6 @@ -The MIT License (MIT) +MIT License -Copyright (c) 2019 Dmitri Vasiliev +Copyright (c) 2022 Samet Kızılaslan Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/README.md b/README.md index 2d79fa7..cc03732 100644 --- a/README.md +++ b/README.md @@ -1,92 +1,50 @@ -# react-native-vpn-detect - -A React Native wrapper to determine if the current iOS network connection is on a VPN (NetInfo supplies this for Android). - -## Installation - -```bash -npm i --save react-native-vpn-detect # npm syntax -yarn add react-native-vpn-detect # yarn syntax -``` -then enter the `ios` directory and run `pod install` to link the pod to your React Native project. - -## Usage - -Import the library along with the NativeEventEmitter exported from React Native: -``` -import { ..., NativeEventEmitter } from "react-native"; -import RNVPNDetect from "react-native-vpn-detect"; -``` - -## Setup: - -in componentDidMount, instantiate a new NativeEventEmitter, passing in RNVPNDetect. - -``` -const RNVPNDetectEmitter = new NativeEventEmitter(RNVPNDetect); - -``` - -Then, add a listener to the EventEmitter instance, and make sure to store it somewhere globally available on the component (e.g. instance variable) so you can unsubscribe from it later. - -The listener should take: ```"RNVPNDetect.vpnStateDidChange"``` as the event name to listen to, and a handler of your choosing as the second argument. -``` -RootContainer._iosVpnDetectSubscribe = RNVPNDetectEmitter.addListener( - "RNVPNDetect.vpnStateDidChange", - this._handleVpnStateChanged -); +# react-native-vpn-detect +Buy Me A Coffee -``` +## Getting started -RNVPNDetect can be used in two ways: -- Using a timer, which will check for a change in the VPN state at the provided interval, and send an event IF the state has changed -- Manually asking for the current vpn state +`$ npm install react-native-vpn-detect --save` -## Use Timer +### Mostly automatic installation -After following the setup steps above: +`$ react-native link react-native-vpn-detect` -You can then initialize the timer with an interval of your choosing. It defaults to 3s (3000ms) if nothing is passed in. +### Manual installation -``` -RNVPNDetect.startTimer(5000) -``` -Make sure to unsubscribe from the listener when your component unmounts. +#### iOS -``` -componentDidUnmount { - ... - if (RootContainer._iosVpnDetectSubscribe) { - RootContainer._iosVpnDetectSubscribe.remove(); - RootContainer._iosVpnDetectSubscribe = null; - RNVPNDetect.stopTimer(); - } -} +1. In XCode, in the project navigator, right click `Libraries` ➜ `Add Files to [your project's name]` +2. Go to `node_modules` ➜ `react-native-vpn-detect` and add `RNNativeVpnDetect.xcodeproj` +3. In XCode, in the project navigator, select your project. Add `libRNNativeVpnDetect.a` to your project's `Build Phases` ➜ `Link Binary With Libraries` +4. Run your project (`Cmd+R`)< -``` +#### Android -## Manual +1. Open up `android/app/src/main/java/[...]/MainActivity.java` + - Add `import com.reactlibrary.RNNativeVpnDetectPackage;` to the imports at the top of the file + - Add `new RNNativeVpnDetectPackage()` to the list returned by the `getPackages()` method +2. Append the following lines to `android/settings.gradle`: + ``` + include ':react-native-vpn-detect' + project(':react-native-vpn-detect').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-vpn-detect/android') + ``` +3. Insert the following lines inside the dependencies block in `android/app/build.gradle`: + ``` + compile project(':react-native-vpn-detect') + ``` -After following the steps above, you can manually query the current vpn state by calling: -``` -RNVPNDetect.checkIsVpnConnected() -``` - -This will check the current vpn state and trigger the listener you set up in ```componentDidMount```. - -You should still unsubscribe from the listener on unmount, but you can skip the ```stopTimer``` call if you never started one ;) - -``` -componentDidUnmount { - ... - if (RootContainer._iosVpnDetectSubscribe) { - RootContainer._iosVpnDetectSubscribe.remove(); - RootContainer._iosVpnDetectSubscribe = null; - } +## Usage +```javascript +* Import Library +import Security from "react-native-vpn-detect"; + +* Example Usage +async function checkSecurity() { + let detectVPN = await Security.detectVPN().then(response => { return response }); + let detectProxy = await Security.detectProxy().then(response => { return response }); } - +checkSecurity(); ``` - diff --git a/RNNativeVpnDetect.podspec b/RNNativeVpnDetect.podspec new file mode 100644 index 0000000..f30b781 --- /dev/null +++ b/RNNativeVpnDetect.podspec @@ -0,0 +1,22 @@ +require 'json' + +package = JSON.parse(File.read(File.join(__dir__, 'package.json'))) + +Pod::Spec.new do |s| + s.name = "RNNativeVpnDetect" + s.version = package['version'] + s.summary = package['description'] + s.description = package['description'] + s.license = package['license'] + s.author = package['author'] + s.homepage = package['homepage'] + + s.platforms = { :ios => "9.0", :tvos => "11.0" } + s.ios.deployment_target = '9.0' + + s.preserve_paths = 'README.md', 'package.json', 'index.js' + s.source_files = 'iOS/*.{h,m}' + s.source = { :git => 'https://github.com/kzlsnn/react-native-vpn-detect.git' } + + s.dependency 'React' +end diff --git a/RNVPNDetect.xcodeproj/project.pbxproj b/RNVPNDetect.xcodeproj/project.pbxproj deleted file mode 100644 index 401db0a..0000000 --- a/RNVPNDetect.xcodeproj/project.pbxproj +++ /dev/null @@ -1,383 +0,0 @@ -// !$*UTF8*$! -{ - archiveVersion = 1; - classes = { - }; - objectVersion = 46; - objects = { - -/* Begin PBXBuildFile section */ - 46FEDE831AFF192F00D3261C /* RNVPNDetect.h in CopyFiles */ = {isa = PBXBuildFile; fileRef = 46FEDE821AFF192F00D3261C /* RNVPNDetect.h */; }; - 46FEDE851AFF192F00D3261C /* RNVPNDetect.m in Sources */ = {isa = PBXBuildFile; fileRef = 46FEDE841AFF192F00D3261C /* RNVPNDetect.m */; }; - 46FEDE8B1AFF192F00D3261C /* libRNVPNDetect.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 46FEDE7F1AFF192F00D3261C /* libRNVPNDetect.a */; }; -/* End PBXBuildFile section */ - -/* Begin PBXContainerItemProxy section */ - 46FEDE8C1AFF192F00D3261C /* PBXContainerItemProxy */ = { - isa = PBXContainerItemProxy; - containerPortal = 46FEDE771AFF192F00D3261C /* Project object */; - proxyType = 1; - remoteGlobalIDString = 46FEDE7E1AFF192F00D3261C; - remoteInfo = RNVPNDetect; - }; -/* End PBXContainerItemProxy section */ - -/* Begin PBXCopyFilesBuildPhase section */ - 46FEDE7D1AFF192F00D3261C /* CopyFiles */ = { - isa = PBXCopyFilesBuildPhase; - buildActionMask = 2147483647; - dstPath = "include/$(PRODUCT_NAME)"; - dstSubfolderSpec = 16; - files = ( - 46FEDE831AFF192F00D3261C /* RNVPNDetect.h in CopyFiles */, - ); - runOnlyForDeploymentPostprocessing = 0; - }; -/* End PBXCopyFilesBuildPhase section */ - -/* Begin PBXFileReference section */ - 46FEDE7F1AFF192F00D3261C /* libRNVPNDetect.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = libRNVPNDetect.a; sourceTree = BUILT_PRODUCTS_DIR; }; - 46FEDE821AFF192F00D3261C /* RNVPNDetect.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = RNVPNDetect.h; sourceTree = ""; }; - 46FEDE841AFF192F00D3261C /* RNVPNDetect.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = RNVPNDetect.m; sourceTree = ""; }; - 46FEDE8A1AFF192F00D3261C /* RNVPNDetectTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = RNVPNDetectTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; - 46FEDE901AFF192F00D3261C /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; -/* End PBXFileReference section */ - -/* Begin PBXFrameworksBuildPhase section */ - 46FEDE7C1AFF192F00D3261C /* Frameworks */ = { - isa = PBXFrameworksBuildPhase; - buildActionMask = 2147483647; - files = ( - ); - runOnlyForDeploymentPostprocessing = 0; - }; - 46FEDE871AFF192F00D3261C /* Frameworks */ = { - isa = PBXFrameworksBuildPhase; - buildActionMask = 2147483647; - files = ( - 46FEDE8B1AFF192F00D3261C /* libRNVPNDetect.a in Frameworks */, - ); - runOnlyForDeploymentPostprocessing = 0; - }; -/* End PBXFrameworksBuildPhase section */ - -/* Begin PBXGroup section */ - 46FEDE761AFF192F00D3261C = { - isa = PBXGroup; - children = ( - 46FEDE811AFF192F00D3261C /* RNVPNDetect */, - 46FEDE8E1AFF192F00D3261C /* RNVPNDetectTests */, - 46FEDE801AFF192F00D3261C /* Products */, - ); - sourceTree = ""; - }; - 46FEDE801AFF192F00D3261C /* Products */ = { - isa = PBXGroup; - children = ( - 46FEDE7F1AFF192F00D3261C /* libRNVPNDetect.a */, - 46FEDE8A1AFF192F00D3261C /* RNVPNDetectTests.xctest */, - ); - name = Products; - sourceTree = ""; - }; - 46FEDE811AFF192F00D3261C /* RNVPNDetect */ = { - isa = PBXGroup; - children = ( - 46FEDE821AFF192F00D3261C /* RNVPNDetect.h */, - 46FEDE841AFF192F00D3261C /* RNVPNDetect.m */, - ); - path = RNVPNDetect; - sourceTree = ""; - }; - 46FEDE8E1AFF192F00D3261C /* RNVPNDetectTests */ = { - isa = PBXGroup; - children = ( - 46FEDE8F1AFF192F00D3261C /* Supporting Files */, - ); - path = RNVPNDetectTests; - sourceTree = ""; - }; - 46FEDE8F1AFF192F00D3261C /* Supporting Files */ = { - isa = PBXGroup; - children = ( - 46FEDE901AFF192F00D3261C /* Info.plist */, - ); - name = "Supporting Files"; - sourceTree = ""; - }; -/* End PBXGroup section */ - -/* Begin PBXNativeTarget section */ - 46FEDE7E1AFF192F00D3261C /* RNVPNDetect */ = { - isa = PBXNativeTarget; - buildConfigurationList = 46FEDE931AFF192F00D3261C /* Build configuration list for PBXNativeTarget "RNVPNDetect" */; - buildPhases = ( - 46FEDE7B1AFF192F00D3261C /* Sources */, - 46FEDE7C1AFF192F00D3261C /* Frameworks */, - 46FEDE7D1AFF192F00D3261C /* CopyFiles */, - ); - buildRules = ( - ); - dependencies = ( - ); - name = RNVPNDetect; - productName = RNVPNDetect; - productReference = 46FEDE7F1AFF192F00D3261C /* libRNVPNDetect.a */; - productType = "com.apple.product-type.library.static"; - }; - 46FEDE891AFF192F00D3261C /* RNVPNDetectTests */ = { - isa = PBXNativeTarget; - buildConfigurationList = 46FEDE961AFF192F00D3261C /* Build configuration list for PBXNativeTarget "RNVPNDetectTests" */; - buildPhases = ( - 46FEDE861AFF192F00D3261C /* Sources */, - 46FEDE871AFF192F00D3261C /* Frameworks */, - 46FEDE881AFF192F00D3261C /* Resources */, - ); - buildRules = ( - ); - dependencies = ( - 46FEDE8D1AFF192F00D3261C /* PBXTargetDependency */, - ); - name = RNVPNDetectTests; - productName = RNVPNDetectTests; - productReference = 46FEDE8A1AFF192F00D3261C /* RNVPNDetectTests.xctest */; - productType = "com.apple.product-type.bundle.unit-test"; - }; -/* End PBXNativeTarget section */ - -/* Begin PBXProject section */ - 46FEDE771AFF192F00D3261C /* Project object */ = { - isa = PBXProject; - attributes = { - LastUpgradeCheck = 0710; - ORGANIZATIONNAME = "Dmitri Vassilev"; - TargetAttributes = { - 46FEDE7E1AFF192F00D3261C = { - CreatedOnToolsVersion = 6.3.1; - }; - 46FEDE891AFF192F00D3261C = { - CreatedOnToolsVersion = 6.3.1; - }; - }; - }; - buildConfigurationList = 46FEDE7A1AFF192F00D3261C /* Build configuration list for PBXProject "RNVPNDetect" */; - compatibilityVersion = "Xcode 3.2"; - developmentRegion = English; - hasScannedForEncodings = 0; - knownRegions = ( - English, - en, - ); - mainGroup = 46FEDE761AFF192F00D3261C; - productRefGroup = 46FEDE801AFF192F00D3261C /* Products */; - projectDirPath = ""; - projectRoot = ""; - targets = ( - 46FEDE7E1AFF192F00D3261C /* RNVPNDetect */, - 46FEDE891AFF192F00D3261C /* RNVPNDetectTests */, - ); - }; -/* End PBXProject section */ - -/* Begin PBXResourcesBuildPhase section */ - 46FEDE881AFF192F00D3261C /* Resources */ = { - isa = PBXResourcesBuildPhase; - buildActionMask = 2147483647; - files = ( - ); - runOnlyForDeploymentPostprocessing = 0; - }; -/* End PBXResourcesBuildPhase section */ - -/* Begin PBXSourcesBuildPhase section */ - 46FEDE7B1AFF192F00D3261C /* Sources */ = { - isa = PBXSourcesBuildPhase; - buildActionMask = 2147483647; - files = ( - 46FEDE851AFF192F00D3261C /* RNVPNDetect.m in Sources */, - ); - runOnlyForDeploymentPostprocessing = 0; - }; - 46FEDE861AFF192F00D3261C /* Sources */ = { - isa = PBXSourcesBuildPhase; - buildActionMask = 2147483647; - files = ( - ); - runOnlyForDeploymentPostprocessing = 0; - }; -/* End PBXSourcesBuildPhase section */ - -/* Begin PBXTargetDependency section */ - 46FEDE8D1AFF192F00D3261C /* PBXTargetDependency */ = { - isa = PBXTargetDependency; - target = 46FEDE7E1AFF192F00D3261C /* RNVPNDetect */; - targetProxy = 46FEDE8C1AFF192F00D3261C /* PBXContainerItemProxy */; - }; -/* End PBXTargetDependency section */ - -/* Begin XCBuildConfiguration section */ - 46FEDE911AFF192F00D3261C /* Debug */ = { - isa = XCBuildConfiguration; - buildSettings = { - ALWAYS_SEARCH_USER_PATHS = NO; - CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; - CLANG_CXX_LIBRARY = "libc++"; - CLANG_ENABLE_MODULES = YES; - CLANG_ENABLE_OBJC_ARC = YES; - CLANG_WARN_BOOL_CONVERSION = YES; - CLANG_WARN_CONSTANT_CONVERSION = YES; - CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; - CLANG_WARN_EMPTY_BODY = YES; - CLANG_WARN_ENUM_CONVERSION = YES; - CLANG_WARN_INT_CONVERSION = YES; - CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; - CLANG_WARN_UNREACHABLE_CODE = YES; - CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; - COPY_PHASE_STRIP = NO; - DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; - ENABLE_STRICT_OBJC_MSGSEND = YES; - ENABLE_TESTABILITY = YES; - GCC_C_LANGUAGE_STANDARD = gnu99; - GCC_DYNAMIC_NO_PIC = NO; - GCC_NO_COMMON_BLOCKS = YES; - GCC_OPTIMIZATION_LEVEL = 0; - GCC_PREPROCESSOR_DEFINITIONS = ( - "DEBUG=1", - "$(inherited)", - ); - GCC_SYMBOLS_PRIVATE_EXTERN = NO; - GCC_WARN_64_TO_32_BIT_CONVERSION = YES; - GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; - GCC_WARN_UNDECLARED_SELECTOR = YES; - GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; - GCC_WARN_UNUSED_FUNCTION = YES; - GCC_WARN_UNUSED_VARIABLE = YES; - IPHONEOS_DEPLOYMENT_TARGET = 7.0; - MTL_ENABLE_DEBUG_INFO = YES; - ONLY_ACTIVE_ARCH = YES; - SDKROOT = iphoneos; - }; - name = Debug; - }; - 46FEDE921AFF192F00D3261C /* Release */ = { - isa = XCBuildConfiguration; - buildSettings = { - ALWAYS_SEARCH_USER_PATHS = NO; - CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; - CLANG_CXX_LIBRARY = "libc++"; - CLANG_ENABLE_MODULES = YES; - CLANG_ENABLE_OBJC_ARC = YES; - CLANG_WARN_BOOL_CONVERSION = YES; - CLANG_WARN_CONSTANT_CONVERSION = YES; - CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; - CLANG_WARN_EMPTY_BODY = YES; - CLANG_WARN_ENUM_CONVERSION = YES; - CLANG_WARN_INT_CONVERSION = YES; - CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; - CLANG_WARN_UNREACHABLE_CODE = YES; - CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; - COPY_PHASE_STRIP = NO; - DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; - ENABLE_NS_ASSERTIONS = NO; - ENABLE_STRICT_OBJC_MSGSEND = YES; - GCC_C_LANGUAGE_STANDARD = gnu99; - GCC_NO_COMMON_BLOCKS = YES; - GCC_WARN_64_TO_32_BIT_CONVERSION = YES; - GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; - GCC_WARN_UNDECLARED_SELECTOR = YES; - GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; - GCC_WARN_UNUSED_FUNCTION = YES; - GCC_WARN_UNUSED_VARIABLE = YES; - IPHONEOS_DEPLOYMENT_TARGET = 7.0; - MTL_ENABLE_DEBUG_INFO = NO; - SDKROOT = iphoneos; - VALIDATE_PRODUCT = YES; - }; - name = Release; - }; - 46FEDE941AFF192F00D3261C /* Debug */ = { - isa = XCBuildConfiguration; - buildSettings = { - OTHER_LDFLAGS = "-ObjC"; - PRODUCT_NAME = "$(TARGET_NAME)"; - SKIP_INSTALL = YES; - }; - name = Debug; - }; - 46FEDE951AFF192F00D3261C /* Release */ = { - isa = XCBuildConfiguration; - buildSettings = { - OTHER_LDFLAGS = "-ObjC"; - PRODUCT_NAME = "$(TARGET_NAME)"; - SKIP_INSTALL = YES; - }; - name = Release; - }; - 46FEDE971AFF192F00D3261C /* Debug */ = { - isa = XCBuildConfiguration; - buildSettings = { - "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; - FRAMEWORK_SEARCH_PATHS = ( - "$(SDKROOT)/Developer/Library/Frameworks", - "$(inherited)", - ); - GCC_PREPROCESSOR_DEFINITIONS = ( - "DEBUG=1", - "$(inherited)", - ); - INFOPLIST_FILE = RNVPNDetectTests/Info.plist; - LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; - PRODUCT_BUNDLE_IDENTIFIER = "cj.$(PRODUCT_NAME:rfc1034identifier)"; - PRODUCT_NAME = "$(TARGET_NAME)"; - }; - name = Debug; - }; - 46FEDE981AFF192F00D3261C /* Release */ = { - isa = XCBuildConfiguration; - buildSettings = { - "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; - FRAMEWORK_SEARCH_PATHS = ( - "$(SDKROOT)/Developer/Library/Frameworks", - "$(inherited)", - ); - INFOPLIST_FILE = RNVPNDetectTests/Info.plist; - LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; - PRODUCT_BUNDLE_IDENTIFIER = "cj.$(PRODUCT_NAME:rfc1034identifier)"; - PRODUCT_NAME = "$(TARGET_NAME)"; - }; - name = Release; - }; -/* End XCBuildConfiguration section */ - -/* Begin XCConfigurationList section */ - 46FEDE7A1AFF192F00D3261C /* Build configuration list for PBXProject "RNVPNDetect" */ = { - isa = XCConfigurationList; - buildConfigurations = ( - 46FEDE911AFF192F00D3261C /* Debug */, - 46FEDE921AFF192F00D3261C /* Release */, - ); - defaultConfigurationIsVisible = 0; - defaultConfigurationName = Release; - }; - 46FEDE931AFF192F00D3261C /* Build configuration list for PBXNativeTarget "RNVPNDetect" */ = { - isa = XCConfigurationList; - buildConfigurations = ( - 46FEDE941AFF192F00D3261C /* Debug */, - 46FEDE951AFF192F00D3261C /* Release */, - ); - defaultConfigurationIsVisible = 0; - defaultConfigurationName = Release; - }; - 46FEDE961AFF192F00D3261C /* Build configuration list for PBXNativeTarget "RNVPNDetectTests" */ = { - isa = XCConfigurationList; - buildConfigurations = ( - 46FEDE971AFF192F00D3261C /* Debug */, - 46FEDE981AFF192F00D3261C /* Release */, - ); - defaultConfigurationIsVisible = 0; - defaultConfigurationName = Release; - }; -/* End XCConfigurationList section */ - }; - rootObject = 46FEDE771AFF192F00D3261C /* Project object */; -} diff --git a/RNVPNDetect/RNVPNDetect.h b/RNVPNDetect/RNVPNDetect.h deleted file mode 100644 index 39e3fee..0000000 --- a/RNVPNDetect/RNVPNDetect.h +++ /dev/null @@ -1,6 +0,0 @@ -#import -#import - -@interface RNVPNDetect : RCTEventEmitter - -@end diff --git a/RNVPNDetect/RNVPNDetect.m b/RNVPNDetect/RNVPNDetect.m deleted file mode 100644 index 896d0b1..0000000 --- a/RNVPNDetect/RNVPNDetect.m +++ /dev/null @@ -1,93 +0,0 @@ -#import "RNVPNDetect.h" - -@implementation RNVPNDetect -{ - BOOL hasListeners; - BOOL isVpnConnected; - NSTimer *timer; -} - -RCT_EXPORT_MODULE(); - --(void)startObserving { - hasListeners = YES; -} - --(void)stopObserving { - hasListeners = NO; -} - -- (NSArray *)supportedEvents -{ - return @[@"RNVPNDetect.vpnStateDidChange"]; -} - -- (void)sendIsVpnConnected:(NSTimer *)timer { - BOOL nextIsVpnConnected = [self isVpnConnected]; - - if ((isVpnConnected && nextIsVpnConnected) || (!isVpnConnected && !nextIsVpnConnected)) { - return; - } - - isVpnConnected = nextIsVpnConnected; - if (hasListeners) { - if ([self bridge] != nil) { - [self sendEventWithName:@"RNVPNDetect.vpnStateDidChange" body:@(isVpnConnected)]; - } - } -} - -- (BOOL)isVpnConnected { - CFDictionaryRef cfDict = CFNetworkCopySystemProxySettings(); - NSDictionary *nsDict = (__bridge NSDictionary*)cfDict; - NSDictionary *keys = [nsDict valueForKey:@"__SCOPED__"]; - BOOL isConnected = NO; - - for (id key in keys) { - if ([@"tap" isEqual: key] || [@"tun" isEqual: key] || [@"ppp" isEqual: key] || [@"ipsec" isEqual: key] || [@"ipsec0" isEqual: key] || [key containsString: @"utun"]) { - isConnected = YES; - } else { - isConnected = NO; - } - } - - return isConnected; -} - -RCT_EXPORT_METHOD(startTimer:(NSTimeInterval)timerInterval) -{ - NSLog(@"%@", [NSDecimalNumber numberWithDouble:timerInterval]); - - NSTimeInterval interval; - if (timerInterval) { - interval = timerInterval; - } else { - interval = 3000; - } - - timer = [NSTimer timerWithTimeInterval:interval target:self selector:@selector(sendIsVpnConnected:) userInfo:nil repeats:YES]; - [[NSRunLoop mainRunLoop] addTimer:timer forMode:NSRunLoopCommonModes]; -} - -RCT_EXPORT_METHOD(stopTimer) -{ - if (timer) { - [timer invalidate]; - } - timer = nil; -} - - -RCT_EXPORT_METHOD(checkIsVpnConnected) -{ - isVpnConnected = [self isVpnConnected]; - - if (hasListeners) { - if ([self bridge] != nil) { - [self sendEventWithName:@"RNVPNDetect.vpnStateDidChange" body:@(isVpnConnected)]; - } - } -} -@end - - diff --git a/RNVPNDetectTests/Info.plist b/RNVPNDetectTests/Info.plist deleted file mode 100644 index ba72822..0000000 --- a/RNVPNDetectTests/Info.plist +++ /dev/null @@ -1,24 +0,0 @@ - - - - - CFBundleDevelopmentRegion - en - CFBundleExecutable - $(EXECUTABLE_NAME) - CFBundleIdentifier - $(PRODUCT_BUNDLE_IDENTIFIER) - CFBundleInfoDictionaryVersion - 6.0 - CFBundleName - $(PRODUCT_NAME) - CFBundlePackageType - BNDL - CFBundleShortVersionString - 1.0 - CFBundleSignature - ???? - CFBundleVersion - 1 - - diff --git a/android/build.gradle b/android/build.gradle new file mode 100644 index 0000000..4d16e7e --- /dev/null +++ b/android/build.gradle @@ -0,0 +1,54 @@ +buildscript { + // The Android Gradle plugin is only required when opening the android folder stand-alone. + // This avoids unnecessary downloads and potential conflicts when the library is included as a + // module dependency in an application project. + if (project == rootProject) { + repositories { + google() + mavenCentral() + } + + dependencies { + classpath("com.android.tools.build:gradle:4.2.2") + } + } +} + +def getExtOrIntegerDefault(name) { + return rootProject.ext.has(name) ? rootProject.ext.get(name) : (project.properties['ReactNativeVPNDetect_' + name]).toInteger() +} + +apply plugin: 'com.android.library' + +android { + compileSdkVersion getExtOrIntegerDefault('compileSdkVersion') + + compileOptions { + sourceCompatibility JavaVersion.VERSION_1_8 + targetCompatibility JavaVersion.VERSION_1_8 + } + + defaultConfig { + minSdkVersion getExtOrIntegerDefault('minSdkVersion') + targetSdkVersion getExtOrIntegerDefault('targetSdkVersion') + } + lintOptions{ + abortOnError false + } +} + +repositories { + maven { + // All of React Native (JS, Obj-C sources, Android binaries) is installed from npm + url "$rootDir/../node_modules/react-native/android" + } + google() + mavenLocal() + mavenCentral() +} + +dependencies { + //noinspection GradleDynamicVersion + implementation 'com.facebook.react:react-native:+' + +} \ No newline at end of file diff --git a/android/gradle.properties b/android/gradle.properties new file mode 100644 index 0000000..c945bc8 --- /dev/null +++ b/android/gradle.properties @@ -0,0 +1,4 @@ +ReactNativeVPNDetect_compileSdkVersion=30 +ReactNativeVPNDetect_buildToolsVersion=30.0.2 +ReactNativeVPNDetect_targetSdkVersion=30 +ReactNativeVPNDetect_minSdkVersion=16 diff --git a/android/gradle/wrapper/gradle-wrapper.jar b/android/gradle/wrapper/gradle-wrapper.jar new file mode 100644 index 0000000..e708b1c Binary files /dev/null and b/android/gradle/wrapper/gradle-wrapper.jar differ diff --git a/android/gradle/wrapper/gradle-wrapper.properties b/android/gradle/wrapper/gradle-wrapper.properties new file mode 100644 index 0000000..da9702f --- /dev/null +++ b/android/gradle/wrapper/gradle-wrapper.properties @@ -0,0 +1,5 @@ +distributionBase=GRADLE_USER_HOME +distributionPath=wrapper/dists +distributionUrl=https\://services.gradle.org/distributions/gradle-6.8-bin.zip +zipStoreBase=GRADLE_USER_HOME +zipStorePath=wrapper/dists diff --git a/android/gradlew b/android/gradlew new file mode 100755 index 0000000..4f906e0 --- /dev/null +++ b/android/gradlew @@ -0,0 +1,185 @@ +#!/usr/bin/env sh + +# +# Copyright 2015 the original author or authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +############################################################################## +## +## Gradle start up script for UN*X +## +############################################################################## + +# Attempt to set APP_HOME +# Resolve links: $0 may be a link +PRG="$0" +# Need this for relative symlinks. +while [ -h "$PRG" ] ; do + ls=`ls -ld "$PRG"` + link=`expr "$ls" : '.*-> \(.*\)$'` + if expr "$link" : '/.*' > /dev/null; then + PRG="$link" + else + PRG=`dirname "$PRG"`"/$link" + fi +done +SAVED="`pwd`" +cd "`dirname \"$PRG\"`/" >/dev/null +APP_HOME="`pwd -P`" +cd "$SAVED" >/dev/null + +APP_NAME="Gradle" +APP_BASE_NAME=`basename "$0"` + +# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' + +# Use the maximum available, or set MAX_FD != -1 to use that value. +MAX_FD="maximum" + +warn () { + echo "$*" +} + +die () { + echo + echo "$*" + echo + exit 1 +} + +# OS specific support (must be 'true' or 'false'). +cygwin=false +msys=false +darwin=false +nonstop=false +case "`uname`" in + CYGWIN* ) + cygwin=true + ;; + Darwin* ) + darwin=true + ;; + MINGW* ) + msys=true + ;; + NONSTOP* ) + nonstop=true + ;; +esac + +CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar + + +# Determine the Java command to use to start the JVM. +if [ -n "$JAVA_HOME" ] ; then + if [ -x "$JAVA_HOME/jre/sh/java" ] ; then + # IBM's JDK on AIX uses strange locations for the executables + JAVACMD="$JAVA_HOME/jre/sh/java" + else + JAVACMD="$JAVA_HOME/bin/java" + fi + if [ ! -x "$JAVACMD" ] ; then + die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME + +Please set the JAVA_HOME variable in your environment to match the +location of your Java installation." + fi +else + JAVACMD="java" + which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. + +Please set the JAVA_HOME variable in your environment to match the +location of your Java installation." +fi + +# Increase the maximum file descriptors if we can. +if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then + MAX_FD_LIMIT=`ulimit -H -n` + if [ $? -eq 0 ] ; then + if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then + MAX_FD="$MAX_FD_LIMIT" + fi + ulimit -n $MAX_FD + if [ $? -ne 0 ] ; then + warn "Could not set maximum file descriptor limit: $MAX_FD" + fi + else + warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" + fi +fi + +# For Darwin, add options to specify how the application appears in the dock +if $darwin; then + GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" +fi + +# For Cygwin or MSYS, switch paths to Windows format before running java +if [ "$cygwin" = "true" -o "$msys" = "true" ] ; then + APP_HOME=`cygpath --path --mixed "$APP_HOME"` + CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` + + JAVACMD=`cygpath --unix "$JAVACMD"` + + # We build the pattern for arguments to be converted via cygpath + ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` + SEP="" + for dir in $ROOTDIRSRAW ; do + ROOTDIRS="$ROOTDIRS$SEP$dir" + SEP="|" + done + OURCYGPATTERN="(^($ROOTDIRS))" + # Add a user-defined pattern to the cygpath arguments + if [ "$GRADLE_CYGPATTERN" != "" ] ; then + OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" + fi + # Now convert the arguments - kludge to limit ourselves to /bin/sh + i=0 + for arg in "$@" ; do + CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` + CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option + + if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition + eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` + else + eval `echo args$i`="\"$arg\"" + fi + i=`expr $i + 1` + done + case $i in + 0) set -- ;; + 1) set -- "$args0" ;; + 2) set -- "$args0" "$args1" ;; + 3) set -- "$args0" "$args1" "$args2" ;; + 4) set -- "$args0" "$args1" "$args2" "$args3" ;; + 5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; + 6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; + 7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; + 8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; + 9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; + esac +fi + +# Escape application args +save () { + for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done + echo " " +} +APP_ARGS=`save "$@"` + +# Collect all arguments for the java command, following the shell quoting and substitution rules +eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS" + +exec "$JAVACMD" "$@" diff --git a/android/gradlew.bat b/android/gradlew.bat new file mode 100644 index 0000000..107acd3 --- /dev/null +++ b/android/gradlew.bat @@ -0,0 +1,89 @@ +@rem +@rem Copyright 2015 the original author or authors. +@rem +@rem Licensed under the Apache License, Version 2.0 (the "License"); +@rem you may not use this file except in compliance with the License. +@rem You may obtain a copy of the License at +@rem +@rem https://www.apache.org/licenses/LICENSE-2.0 +@rem +@rem Unless required by applicable law or agreed to in writing, software +@rem distributed under the License is distributed on an "AS IS" BASIS, +@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +@rem See the License for the specific language governing permissions and +@rem limitations under the License. +@rem + +@if "%DEBUG%" == "" @echo off +@rem ########################################################################## +@rem +@rem Gradle startup script for Windows +@rem +@rem ########################################################################## + +@rem Set local scope for the variables with windows NT shell +if "%OS%"=="Windows_NT" setlocal + +set DIRNAME=%~dp0 +if "%DIRNAME%" == "" set DIRNAME=. +set APP_BASE_NAME=%~n0 +set APP_HOME=%DIRNAME% + +@rem Resolve any "." and ".." in APP_HOME to make it shorter. +for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi + +@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m" + +@rem Find java.exe +if defined JAVA_HOME goto findJavaFromJavaHome + +set JAVA_EXE=java.exe +%JAVA_EXE% -version >NUL 2>&1 +if "%ERRORLEVEL%" == "0" goto execute + +echo. +echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. +echo. +echo Please set the JAVA_HOME variable in your environment to match the +echo location of your Java installation. + +goto fail + +:findJavaFromJavaHome +set JAVA_HOME=%JAVA_HOME:"=% +set JAVA_EXE=%JAVA_HOME%/bin/java.exe + +if exist "%JAVA_EXE%" goto execute + +echo. +echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% +echo. +echo Please set the JAVA_HOME variable in your environment to match the +echo location of your Java installation. + +goto fail + +:execute +@rem Setup the command line + +set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar + + +@rem Execute Gradle +"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* + +:end +@rem End local scope for the variables with windows NT shell +if "%ERRORLEVEL%"=="0" goto mainEnd + +:fail +rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of +rem the _cmd.exe /c_ return code! +if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 +exit /b 1 + +:mainEnd +if "%OS%"=="Windows_NT" endlocal + +:omega diff --git a/android/local.properties b/android/local.properties new file mode 100644 index 0000000..da29215 --- /dev/null +++ b/android/local.properties @@ -0,0 +1,8 @@ +## This file must *NOT* be checked into Version Control Systems, +# as it contains information specific to your local configuration. +# +# Location of the SDK. This is only used by Gradle. +# For customization when using a Version Control System, please read the +# header note. +#Fri Jan 07 16:58:11 TRT 2022 +sdk.dir=/Users/mixerdating/Library/Android/sdk diff --git a/android/src/main/AndroidManifest.xml b/android/src/main/AndroidManifest.xml new file mode 100644 index 0000000..8f19719 --- /dev/null +++ b/android/src/main/AndroidManifest.xml @@ -0,0 +1,6 @@ + + + + + \ No newline at end of file diff --git a/android/src/main/java/com/reactlibrarynativevpndetect/RNNativeVpnDetectModule.java b/android/src/main/java/com/reactlibrarynativevpndetect/RNNativeVpnDetectModule.java new file mode 100644 index 0000000..c559b63 --- /dev/null +++ b/android/src/main/java/com/reactlibrarynativevpndetect/RNNativeVpnDetectModule.java @@ -0,0 +1,48 @@ + +package com.reactlibrarynativevpndetect; + +import android.content.Context; +import android.net.ConnectivityManager; +import android.net.Network; +import android.net.NetworkCapabilities; + +import com.facebook.react.bridge.ReactApplicationContext; +import com.facebook.react.bridge.ReactContextBaseJavaModule; +import com.facebook.react.bridge.ReactMethod; +import com.facebook.react.bridge.Promise; + +public class RNNativeVpnDetectModule extends ReactContextBaseJavaModule { + + private final ReactApplicationContext reactContext; + + public RNNativeVpnDetectModule(ReactApplicationContext reactContext) { + super(reactContext); + this.reactContext = reactContext; + } + + @Override + public String getName() { + return "RNNativeVpnDetect"; + } + + @ReactMethod + public void detectVPN(Promise promise){ + ConnectivityManager cm = (ConnectivityManager)reactContext.getSystemService(Context.CONNECTIVITY_SERVICE); + Network[] networks = cm.getAllNetworks(); + + boolean isRunningVPN = false; + for (Network value : networks) { + NetworkCapabilities caps = cm.getNetworkCapabilities(value); + if (caps != null && (caps.hasTransport(NetworkCapabilities.TRANSPORT_VPN) || !caps.hasCapability(NetworkCapabilities.NET_CAPABILITY_NOT_VPN))) { + isRunningVPN = true; + break; + } + } + promise.resolve(isRunningVPN); + } + + @ReactMethod + public void detectProxy(Promise promise){ + promise.resolve(System.getProperty("http.proxyPort") != null); + } +} diff --git a/android/src/main/java/com/reactlibrarynativevpndetect/RNNativeVpnDetectPackage.java b/android/src/main/java/com/reactlibrarynativevpndetect/RNNativeVpnDetectPackage.java new file mode 100644 index 0000000..1c1f92b --- /dev/null +++ b/android/src/main/java/com/reactlibrarynativevpndetect/RNNativeVpnDetectPackage.java @@ -0,0 +1,28 @@ + +package com.reactlibrarynativevpndetect; + +import java.util.Arrays; +import java.util.Collections; +import java.util.List; + +import com.facebook.react.ReactPackage; +import com.facebook.react.bridge.NativeModule; +import com.facebook.react.bridge.ReactApplicationContext; +import com.facebook.react.uimanager.ViewManager; +import com.facebook.react.bridge.JavaScriptModule; +public class RNNativeVpnDetectPackage implements ReactPackage { + @Override + public List createNativeModules(ReactApplicationContext reactContext) { + return Arrays.asList(new RNNativeVpnDetectModule(reactContext)); + } + + // Deprecated from RN 0.47 + public List> createJSModules() { + return Collections.emptyList(); + } + + @Override + public List createViewManagers(ReactApplicationContext reactContext) { + return Collections.emptyList(); + } +} \ No newline at end of file diff --git a/index.js b/index.js index e1c9dfb..293fb6c 100644 --- a/index.js +++ b/index.js @@ -1,3 +1,6 @@ -import { NativeModules } from "react-native"; -export default NativeModules.RNVPNDetect; +import { NativeModules } from 'react-native'; + +const { RNNativeVpnDetect } = NativeModules; + +export default RNNativeVpnDetect; diff --git a/ios/RNNativeVpnDetect.h b/ios/RNNativeVpnDetect.h new file mode 100644 index 0000000..adef4ec --- /dev/null +++ b/ios/RNNativeVpnDetect.h @@ -0,0 +1,11 @@ + +#if __has_include("RCTBridgeModule.h") +#import "RCTBridgeModule.h" +#else +#import +#endif + +@interface RNNativeVpnDetect : NSObject + +@end + diff --git a/ios/RNNativeVpnDetect.m b/ios/RNNativeVpnDetect.m new file mode 100644 index 0000000..33705b2 --- /dev/null +++ b/ios/RNNativeVpnDetect.m @@ -0,0 +1,46 @@ + +#import "RNNativeVpnDetect.h" + +@implementation RNNativeVpnDetect + +- (dispatch_queue_t)methodQueue +{ + return dispatch_get_main_queue(); +} + +RCT_EXPORT_MODULE() + +RCT_EXPORT_METHOD(detectVPN:(RCTPromiseResolveBlock)resolve + reject:(RCTPromiseRejectBlock)reject) +{ + CFDictionaryRef cfDict = CFNetworkCopySystemProxySettings(); + NSDictionary *nsDict = (__bridge NSDictionary*)cfDict; + NSDictionary *keys = [nsDict valueForKey:@"__SCOPED__"]; + BOOL isConnected = NO; + + for (id key in keys) { + if ([@"tap" isEqual: key] || [@"tun" isEqual: key] || [@"ppp" isEqual: key] || [@"ipsec" isEqual: key] || [@"ipsec0" isEqual: key] || [key containsString: @"utun"]) { + isConnected = YES; + } + } + resolve(@(isConnected)); +} + +RCT_EXPORT_METHOD(detectProxy:(RCTPromiseResolveBlock)resolve + reject:(RCTPromiseRejectBlock)reject) +{ + NSDictionary *proxySettings = CFBridgingRelease(CFNetworkCopySystemProxySettings()); + NSArray *proxies = (__bridge NSArray *)(CFNetworkCopyProxiesForURL((__bridge CFURLRef _Nonnull)([NSURL URLWithString:@"http://www.google.com"]), (__bridge CFDictionaryRef _Nonnull)(proxySettings))); + NSDictionary *settings = proxies[0]; + BOOL isConnected = NO; + if ([[settings objectForKey:(NSString *)kCFProxyTypeKey] isEqualToString:@"kCFProxyTypeNone"]){ + isConnected = NO; + } + else{ + isConnected = YES; + } + resolve(@(isConnected)); +} + + +@end \ No newline at end of file diff --git a/ios/RNNativeVpnDetect.podspec b/ios/RNNativeVpnDetect.podspec new file mode 100644 index 0000000..a2919ad --- /dev/null +++ b/ios/RNNativeVpnDetect.podspec @@ -0,0 +1,24 @@ + +Pod::Spec.new do |s| + s.name = "RNNativeVpnDetect" + s.version = "1.0.0" + s.summary = "RNNativeVpnDetect" + s.description = <<-DESC + RNNativeVpnDetect + DESC + s.homepage = "" + s.license = "MIT" + # s.license = { :type => "MIT", :file => "FILE_LICENSE" } + s.author = { "author" => "author@domain.cn" } + s.platform = :ios, "7.0" + s.source = { :git => "https://github.com/author/RNNativeVpnDetect.git", :tag => "master" } + s.source_files = "RNNativeVpnDetect/**/*.{h,m}" + s.requires_arc = true + + + s.dependency "React" + #s.dependency "others" + +end + + \ No newline at end of file diff --git a/ios/RNNativeVpnDetect.xcodeproj/project.pbxproj b/ios/RNNativeVpnDetect.xcodeproj/project.pbxproj new file mode 100644 index 0000000..05839b0 --- /dev/null +++ b/ios/RNNativeVpnDetect.xcodeproj/project.pbxproj @@ -0,0 +1,261 @@ +// !$*UTF8*$! +{ + archiveVersion = 1; + classes = { + }; + objectVersion = 46; + objects = { + +/* Begin PBXBuildFile section */ + B3E7B58A1CC2AC0600A0062D /* RNNativeVpnDetect.m in Sources */ = {isa = PBXBuildFile; fileRef = B3E7B5891CC2AC0600A0062D /* RNNativeVpnDetect.m */; }; +/* End PBXBuildFile section */ + +/* Begin PBXCopyFilesBuildPhase section */ + 58B511D91A9E6C8500147676 /* CopyFiles */ = { + isa = PBXCopyFilesBuildPhase; + buildActionMask = 2147483647; + dstPath = "include/$(PRODUCT_NAME)"; + dstSubfolderSpec = 16; + files = ( + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXCopyFilesBuildPhase section */ + +/* Begin PBXFileReference section */ + 134814201AA4EA6300B7C361 /* libRNNativeVpnDetect.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = libRNNativeVpnDetect.a; sourceTree = BUILT_PRODUCTS_DIR; }; + B3E7B5881CC2AC0600A0062D /* RNNativeVpnDetect.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RNNativeVpnDetect.h; sourceTree = ""; }; + B3E7B5891CC2AC0600A0062D /* RNNativeVpnDetect.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = RNNativeVpnDetect.m; sourceTree = ""; }; +/* End PBXFileReference section */ + +/* Begin PBXFrameworksBuildPhase section */ + 58B511D81A9E6C8500147676 /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXFrameworksBuildPhase section */ + +/* Begin PBXGroup section */ + 134814211AA4EA7D00B7C361 /* Products */ = { + isa = PBXGroup; + children = ( + 134814201AA4EA6300B7C361 /* libRNNativeVpnDetect.a */, + ); + name = Products; + sourceTree = ""; + }; + 58B511D21A9E6C8500147676 = { + isa = PBXGroup; + children = ( + B3E7B5881CC2AC0600A0062D /* RNNativeVpnDetect.h */, + B3E7B5891CC2AC0600A0062D /* RNNativeVpnDetect.m */, + 134814211AA4EA7D00B7C361 /* Products */, + ); + sourceTree = ""; + }; +/* End PBXGroup section */ + +/* Begin PBXNativeTarget section */ + 58B511DA1A9E6C8500147676 /* RNNativeVpnDetect */ = { + isa = PBXNativeTarget; + buildConfigurationList = 58B511EF1A9E6C8500147676 /* Build configuration list for PBXNativeTarget "RNNativeVpnDetect" */; + buildPhases = ( + 58B511D71A9E6C8500147676 /* Sources */, + 58B511D81A9E6C8500147676 /* Frameworks */, + 58B511D91A9E6C8500147676 /* CopyFiles */, + ); + buildRules = ( + ); + dependencies = ( + ); + name = RNNativeVpnDetect; + productName = RCTDataManager; + productReference = 134814201AA4EA6300B7C361 /* libRNNativeVpnDetect.a */; + productType = "com.apple.product-type.library.static"; + }; +/* End PBXNativeTarget section */ + +/* Begin PBXProject section */ + 58B511D31A9E6C8500147676 /* Project object */ = { + isa = PBXProject; + attributes = { + LastUpgradeCheck = 0830; + ORGANIZATIONNAME = Facebook; + TargetAttributes = { + 58B511DA1A9E6C8500147676 = { + CreatedOnToolsVersion = 6.1.1; + }; + }; + }; + buildConfigurationList = 58B511D61A9E6C8500147676 /* Build configuration list for PBXProject "RNNativeVpnDetect" */; + compatibilityVersion = "Xcode 3.2"; + developmentRegion = English; + hasScannedForEncodings = 0; + knownRegions = ( + English, + en, + Base, + ); + mainGroup = 58B511D21A9E6C8500147676; + productRefGroup = 58B511D21A9E6C8500147676; + projectDirPath = ""; + projectRoot = ""; + targets = ( + 58B511DA1A9E6C8500147676 /* RNNativeVpnDetect */, + ); + }; +/* End PBXProject section */ + +/* Begin PBXSourcesBuildPhase section */ + 58B511D71A9E6C8500147676 /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + B3E7B58A1CC2AC0600A0062D /* RNNativeVpnDetect.m in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXSourcesBuildPhase section */ + +/* Begin XCBuildConfiguration section */ + 58B511ED1A9E6C8500147676 /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; + CLANG_CXX_LIBRARY = "libc++"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INFINITE_RECURSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_SUSPICIOUS_MOVE = YES; + CLANG_WARN_UNREACHABLE_CODE = YES; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + COPY_PHASE_STRIP = NO; + ENABLE_STRICT_OBJC_MSGSEND = YES; + ENABLE_TESTABILITY = YES; + GCC_C_LANGUAGE_STANDARD = gnu99; + GCC_DYNAMIC_NO_PIC = NO; + GCC_NO_COMMON_BLOCKS = YES; + GCC_OPTIMIZATION_LEVEL = 0; + GCC_PREPROCESSOR_DEFINITIONS = ( + "DEBUG=1", + "$(inherited)", + ); + GCC_SYMBOLS_PRIVATE_EXTERN = NO; + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNDECLARED_SELECTOR = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + IPHONEOS_DEPLOYMENT_TARGET = 8.0; + MTL_ENABLE_DEBUG_INFO = YES; + ONLY_ACTIVE_ARCH = YES; + SDKROOT = iphoneos; + }; + name = Debug; + }; + 58B511EE1A9E6C8500147676 /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; + CLANG_CXX_LIBRARY = "libc++"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INFINITE_RECURSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_SUSPICIOUS_MOVE = YES; + CLANG_WARN_UNREACHABLE_CODE = YES; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + COPY_PHASE_STRIP = YES; + ENABLE_NS_ASSERTIONS = NO; + ENABLE_STRICT_OBJC_MSGSEND = YES; + GCC_C_LANGUAGE_STANDARD = gnu99; + GCC_NO_COMMON_BLOCKS = YES; + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNDECLARED_SELECTOR = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + IPHONEOS_DEPLOYMENT_TARGET = 8.0; + MTL_ENABLE_DEBUG_INFO = NO; + SDKROOT = iphoneos; + VALIDATE_PRODUCT = YES; + }; + name = Release; + }; + 58B511F01A9E6C8500147676 /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + HEADER_SEARCH_PATHS = ( + "$(inherited)", + /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include, + "$(SRCROOT)/../../../React/**", + "$(SRCROOT)/../../react-native/React/**", + ); + LIBRARY_SEARCH_PATHS = "$(inherited)"; + OTHER_LDFLAGS = "-ObjC"; + PRODUCT_NAME = RNNativeVpnDetect; + SKIP_INSTALL = YES; + }; + name = Debug; + }; + 58B511F11A9E6C8500147676 /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + HEADER_SEARCH_PATHS = ( + "$(inherited)", + /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include, + "$(SRCROOT)/../../../React/**", + "$(SRCROOT)/../../react-native/React/**", + ); + LIBRARY_SEARCH_PATHS = "$(inherited)"; + OTHER_LDFLAGS = "-ObjC"; + PRODUCT_NAME = RNNativeVpnDetect; + SKIP_INSTALL = YES; + }; + name = Release; + }; +/* End XCBuildConfiguration section */ + +/* Begin XCConfigurationList section */ + 58B511D61A9E6C8500147676 /* Build configuration list for PBXProject "RNNativeVpnDetect" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 58B511ED1A9E6C8500147676 /* Debug */, + 58B511EE1A9E6C8500147676 /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; + 58B511EF1A9E6C8500147676 /* Build configuration list for PBXNativeTarget "RNNativeVpnDetect" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 58B511F01A9E6C8500147676 /* Debug */, + 58B511F11A9E6C8500147676 /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; +/* End XCConfigurationList section */ + }; + rootObject = 58B511D31A9E6C8500147676 /* Project object */; +} diff --git a/ios/RNNativeVpnDetect.xcodeproj/project.xcworkspace/contents.xcworkspacedata b/ios/RNNativeVpnDetect.xcodeproj/project.xcworkspace/contents.xcworkspacedata new file mode 100644 index 0000000..919434a --- /dev/null +++ b/ios/RNNativeVpnDetect.xcodeproj/project.xcworkspace/contents.xcworkspacedata @@ -0,0 +1,7 @@ + + + + + diff --git a/ios/RNNativeVpnDetect.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist b/ios/RNNativeVpnDetect.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist new file mode 100644 index 0000000..18d9810 --- /dev/null +++ b/ios/RNNativeVpnDetect.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist @@ -0,0 +1,8 @@ + + + + + IDEDidComputeMac32BitWarning + + + diff --git a/ios/RNNativeVpnDetect.xcodeproj/project.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings b/ios/RNNativeVpnDetect.xcodeproj/project.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings new file mode 100644 index 0000000..f9b0d7c --- /dev/null +++ b/ios/RNNativeVpnDetect.xcodeproj/project.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings @@ -0,0 +1,8 @@ + + + + + PreviewsEnabled + + + diff --git a/ios/RNNativeVpnDetect.xcodeproj/project.xcworkspace/xcuserdata/mixerdating.xcuserdatad/UserInterfaceState.xcuserstate b/ios/RNNativeVpnDetect.xcodeproj/project.xcworkspace/xcuserdata/mixerdating.xcuserdatad/UserInterfaceState.xcuserstate new file mode 100644 index 0000000..8e01498 Binary files /dev/null and b/ios/RNNativeVpnDetect.xcodeproj/project.xcworkspace/xcuserdata/mixerdating.xcuserdatad/UserInterfaceState.xcuserstate differ diff --git a/ios/RNNativeVpnDetect.xcodeproj/project.xcworkspace/xcuserdata/mixerdating.xcuserdatad/WorkspaceSettings.xcsettings b/ios/RNNativeVpnDetect.xcodeproj/project.xcworkspace/xcuserdata/mixerdating.xcuserdatad/WorkspaceSettings.xcsettings new file mode 100644 index 0000000..379adbe --- /dev/null +++ b/ios/RNNativeVpnDetect.xcodeproj/project.xcworkspace/xcuserdata/mixerdating.xcuserdatad/WorkspaceSettings.xcsettings @@ -0,0 +1,18 @@ + + + + + BuildLocationStyle + UseAppPreferences + CustomBuildLocationType + RelativeToDerivedData + DerivedDataLocationStyle + Default + IssueFilterStyle + ShowActiveSchemeOnly + LiveSourceIssuesEnabled + + ShowSharedSchemesAutomaticallyEnabled + + + diff --git a/RNVPNDetect.xcodeproj/xcshareddata/xcschemes/RNVPNDetect.xcscheme b/ios/RNNativeVpnDetect.xcodeproj/xcshareddata/xcschemes/RNNativeVpnDetect.xcscheme similarity index 67% rename from RNVPNDetect.xcodeproj/xcshareddata/xcschemes/RNVPNDetect.xcscheme rename to ios/RNNativeVpnDetect.xcodeproj/xcshareddata/xcschemes/RNNativeVpnDetect.xcscheme index f7d7835..840775f 100644 --- a/RNVPNDetect.xcodeproj/xcshareddata/xcschemes/RNVPNDetect.xcscheme +++ b/ios/RNNativeVpnDetect.xcodeproj/xcshareddata/xcschemes/RNNativeVpnDetect.xcscheme @@ -1,6 +1,6 @@ + BlueprintIdentifier = "58B511DA1A9E6C8500147676" + BuildableName = "libRNNativeVpnDetect.a" + BlueprintName = "RNNativeVpnDetect" + ReferencedContainer = "container:RNNativeVpnDetect.xcodeproj"> @@ -28,16 +28,6 @@ selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB" shouldUseLaunchSchemeArgsEnv = "YES"> - - - - + BlueprintIdentifier = "58B511DA1A9E6C8500147676" + BuildableName = "libRNNativeVpnDetect.a" + BlueprintName = "RNNativeVpnDetect" + ReferencedContainer = "container:RNNativeVpnDetect.xcodeproj"> diff --git a/ios/RNNativeVpnDetect.xcodeproj/xcuserdata/mixerdating.xcuserdatad/xcschemes/xcschememanagement.plist b/ios/RNNativeVpnDetect.xcodeproj/xcuserdata/mixerdating.xcuserdatad/xcschemes/xcschememanagement.plist new file mode 100644 index 0000000..ffc182a --- /dev/null +++ b/ios/RNNativeVpnDetect.xcodeproj/xcuserdata/mixerdating.xcuserdatad/xcschemes/xcschememanagement.plist @@ -0,0 +1,22 @@ + + + + + SchemeUserState + + RNNativeVpnDetect.xcscheme_^#shared#^_ + + orderHint + 0 + + + SuppressBuildableAutocreation + + 58B511DA1A9E6C8500147676 + + primary + + + + + diff --git a/ios/RNNativeVpnDetect.xcworkspace/contents.xcworkspacedata b/ios/RNNativeVpnDetect.xcworkspace/contents.xcworkspacedata new file mode 100644 index 0000000..2f13424 --- /dev/null +++ b/ios/RNNativeVpnDetect.xcworkspace/contents.xcworkspacedata @@ -0,0 +1,9 @@ +// !$*UTF8*$! + + + + + + \ No newline at end of file diff --git a/package-lock.json b/package-lock.json deleted file mode 100644 index 1bc672a..0000000 --- a/package-lock.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "name": "react-native-vpn-detect", - "version": "1.0.0", - "lockfileVersion": 1 -} diff --git a/package.json b/package.json index 340a472..ae31b71 100644 --- a/package.json +++ b/package.json @@ -1,23 +1,33 @@ { "name": "react-native-vpn-detect", - "version": "1.0.0", - "description": "Checks for VPN on iOS", - "author": { - "name": "Dmitri Vasiliev", - "email": "dvasiliev@gagosian.com", - "url": "https://gagosian.com" - }, - "license": "MIT", - "repository": { - "type": "git", - "url": "git@github.com:mincedmit/react-native-vpn-detect.git" + "version": "1.0.9", + "description": "Checks for VPN & Proxy", + "main": "index.js", + "scripts": { + "test": "echo \"Error: no test specified\" && exit 1" }, "keywords": [ "react", "react-native", "react-component", "ios", + "android", "vpn", - "network" - ] + "proxy", + "network", + "vpn-detection", + "proxy-detection", + "vpn detection", + "proxy detection" + ], + "author": { + "name": "Samet Kızılaslan", + "email": "sametkzl94@gmail.com", + "url": "https://www.buymeacoffee.com/kzlsn" + }, + "license": "MIT", + "dependencies": { + "react-native": "^0.70.0" + }, + "homepage": "https://github.com/kzlsnn/react-native-vpn-detect" } diff --git a/react-native-vpn-detect.podspec b/react-native-vpn-detect.podspec deleted file mode 100644 index 458eca5..0000000 --- a/react-native-vpn-detect.podspec +++ /dev/null @@ -1,18 +0,0 @@ -require 'json' -pjson = JSON.parse(File.read('package.json')) - -Pod::Spec.new do |s| - - s.name = pjson["name"] - s.version = pjson["version"] - s.homepage = "https://github.com/mincedmit/react-native-vpn-detect" - s.summary = pjson["description"] - s.license = pjson["license"] - s.author = { "Dmitri Vasiliev" => "dvasiliev@gagosian.com" } - s.platform = :ios, "12.0" - s.source = { :git => "https://github.com/mincedmit/react-native-vpn-detect", :tag => "v#{s.version}" } - s.source_files = 'RNVPNDetect/*.{h,m}' - - s.dependency 'React' - -end diff --git a/yarn.lock b/yarn.lock deleted file mode 100644 index fb57ccd..0000000 --- a/yarn.lock +++ /dev/null @@ -1,4 +0,0 @@ -# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY. -# yarn lockfile v1 - -