Code Monkey home page Code Monkey logo

react-native-ip-sec-vpn's Introduction

react-native-ip-sec-vpn

Getting started

Plugin can be installed using npm
With yarn:
$ yarn add react-native-ip-sec-vpn --save
Or with npm:
$ npm install react-native-ip-sec-vpn --save

Mostly automatic installation

on react native >60 no need to do anything but for manualing installation run the code below

$ react-native link react-native-ip-sec-vpn

Example

To run example:

  • make sure the module folder has no node_modules
  • install the dependencies on the example folder using yarn or npm i
  • run the project:
npx react-native run-android

Usage

import {prepare, connect} from "react-native-ip-sec-vpn";
...
useEffect(() => {
	prepare();
}); /// or use componentDidmount in case of a class component
...
connect(address, username, password)

see example folder.

Methods

Name arguments returns Description
prepare None Promise Android: This will ask permission and do necessary setups
IOS: This will listen for status change on vpn
connect address: string (address of VPN)
username: string (username of VPN's credentials)
password: string (username of VPN's credentials)
vpnType: string | undefined (Android only, not implemented yet)
mtu: number | undefiend (Android only, VPN's maximum transmission unit)
Promise Connect to vpn with provided credentials
getCurrentState None Promise Get current VPN state
getCharonErrorState (Android only) None Promise Get current VPN Error state (Android only)
disconnect None Promise Disconnect the VPN
onStateChangedListener callback: (state: { state: VpnState; charonState: CharonErrorState }) => void EmitterSubscription Will call the callback on state change
removeOnStateChangeListener stateChangedEvent: EmitterSubscription void Remove the state change listener

Enums

Name Values Description
VpnState disconnected = 0 (VPN is disconnected)
connecting = 1 (VPN is connecting)
connected = 2 (VPN is connected)
disconnecting = 3 (VPN is disconnecting)
genericError = 4 (VPN encountered an error charon state on android to find out the error)
VPN current state
CharonErrorState NO_ERROR = 0 (VPN has no error)
AUTH_FAILED = 1 (Wrong credentials)
PEER_AUTH_FAILED = 2
LOOKUP_FAILED = 3 (Wrong VPN URL)
UNREACHABLE = 4 (VPN URL is unreachable)
GENERIC_ERROR = 5
PASSWORD_MISSING = 6 (No password has been provided)
CERTIFICATE_UNAVAILABLE = 7 (Certification has not been provided)
UNDEFINED = 8 (Unknown error)
VPN Error

react-native-ip-sec-vpn's People

Contributors

sijav avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

react-native-ip-sec-vpn's Issues

android device

iOS works but I could not connect from the android device.

Pre-shared key

Hi,

I'm using L2TP/IPsec servers and would like to know if we need to supply the pre-shared key for this library.

Is it compatible with Expo SDK 39 + React native 0.63.3?

Hello, I tried to use this lib with Expo SDK 39 + React native 0.63.3 and when trying to start the app, the errors appear:

`TypeError: null is not an object (evaluating 'react_native_1.NativeModules.RNIpSecVpn.prepare')

Invariant Violation: "main" has not been registered. This can happen if:

  • Metro (the local dev server) is run from the wrong folder. Check if Metro is running, stop it and restart it in the current project.
  • A module failed to load due to an error and AppRegistry.registerComponent wasn't called.`

Does anyone know how to tell me it is compatible? I am in urgent need of a VPN client for react native.

Cannot install in React Native v73

I want to install this package in latest React Native, but it showed error.

`

Could not resolve dependency:
peer react@"^16.8.1" from [email protected]
node_modules/react-native-ip-sec-vpn
react-native-ip-sec-vpn@"*" from the root project

`

Please update this package for latest version.

Router generated IKEv2 IPsec VPN

Does anyone have experience connecting to a IKEv2 IPsec VPN created by a cellular router? Using some Zyxel products we were able to create the VPN but are now having trouble connecting to it. We used the public ip for the address and various combinations for the username and password but nothing has worked. None of us have a background in networking so we're clueless as to what the issue is. Would love some help!

How to connect to specific port ?

If I've a IPSec server listening to port (500) how can I connect to it ?

I'm trying to set in address something like : (ip_address:port) but I can't connect

How to get current VPN state after connected and the app is killed or put in background

Thanks for creating such amazing project! With little effort I can connect to my VPN server.

After connected, then I killed my App and relaunched my App, it seems getCurrentState() always return 0 even it was connected. When my App is in the foreground, connect/disconnect/getCurrentState everything work as expected. Not sure this is expected result or maybe the way I used it was wrong. If you could shed some light on how to get the current VPN state in this case would be appreciated.

Thanks again!

npm install not working in example folder

package.json in example folder contains

"react-native-ip-sec-vpn": "link:../" line

and when I try to use npm install on example folder, it returns below error.

npm ERR! code EUNSUPPORTEDPROTOCOL
npm ERR! Unsupported URL Type "link:": link:../

Only unreachable ,not working on android device !!!

used react-native-ip-sec-vpn to make normal vpn connecting app. I used connect (address,username,password) from react-native-ip-sec-vpn . For that I used some free vpn server address ,username and password from this one . But everytime my app shows Server is unreachable . I used several free vpn server addresses but didn't get success. My demo code like this const [credentials, setCredentials] = useState({ address: 'vpn684845985.opengw.net', username: 'vpn', password: 'vpn' });
connect(credentials.address, credentials.username, credentials.password) Is there anything wrong in my code? Or I misunderstood regarding using of vpn sever and react-native-ip-sec-vpn . Anyone can help ?

Android application traffic bypasses VPN connection

I'm currently building an app using react-native. The app will be used for watching live video streams, and it'll be possible to join the live stream (RTSP link) via a specific IP address (provided by VPN). In iOS, the connection is established without a problem, and I can watch the live stream. As for Android, it's not possible to watch the live stream. It seems to me that the application traffic bypasses the VPN connection. I can only watch the live stream in Android (with the VPN connection being enabled) if I minimize the app and use the VLC player.
Can you please help me understand if there's any issue on Android's side? Which one?

AUTHENTICATION_FAILED

I setup server using the following
https://github.com/hwdsl2/setup-ipsec-vpn
But, When I try to connect to the server using this app, it says 'AUTHENTICATION_FAILED'.
Help me with this.

My code:
connect( credentials.address, credentials.username, credentials.password, ) .then(() => console.log('connected')) .catch(console.log)
Is this correct and is there anything to add ?

Using proxy instead of VPN address

are there anyways to use Proxy instead of vpn ? i want to use Proxy for my application and i want to be able to change it programmatically , as far as i know i can change the vpn address from inside the application , is anything similar to this available for proxies ?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.