npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

react-native-simple-openvpn

v2.1.1

Published

React Native Open VPN Module

Downloads

214

Readme

react-native-simple-openvpn github stars

npm latest download month download total PRs welcome all contributors platforms GNU General Public License

English | 简体中文

A simple react native module to interact with OpenVPN

If this project has helped you out, please support us with a star 🌟

Versions

| RNSimpleOpenvpn | React Native | | --------------- | ------------- | | 1.0.0 ~ 1.2.0 | 0.56 ~ 0.66 | | >= 2.0.0 | >= 0.63 |

See CHANGELOG for details

Preview

Installation

Adding dependencies

# npm
npm install --save react-native-simple-openvpn

# or use yarn
yarn add react-native-simple-openvpn

Link

From react-native 0.60 autolinking will take care of the link step

react-native link react-native-simple-openvpn

Android

Add the following to android/settings.gradle :

rootProject.name = 'example'
+ include ':vpnLib'
+ project(':vpnLib').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-simple-openvpn/vpnLib')
apply from: file("../node_modules/@react-native-community/cli-platform-android/native_modules.gradle"); applyNativeModulesSettingsGradle(settings)
include ':app'

Import jniLibs

Due to file size limitations, jniLibs are too big to be published on npm. Use the assets on GitHub Releases instead

Download and unzip the resources you need for the corresponding architecture, and put them in android/app/src/main/jniLibs (create a new jniLibs folder if you don't have one)

project
├── android
│   ├── app
│   │   └── src
│   │       └── main
│   │           └── jniLibs
│   │               ├── arm64-v8a
│   │               ├── armeabi-v7a
│   │               ├── x86
│   │               └── x86_64
│   └── ...
├── ios
└── ...

iOS

If using CocoaPods, run it in the ios/ directory

pod install

See iOS Guide for iOS side Network Extension configuration and OpenVPN integration

Disable VPN connection when app is terminated in iOS

Add the following to your project's AppDelegate.m :

+ #import "RNSimpleOpenvpn.h"

@implementation AppDelegate

// ...

+ - (void)applicationWillTerminate:(UIApplication *)application
+ {
+   [RNSimpleOpenvpn dispose];
+ }

@end

Please make sure the Header Search Paths of Build Settings contain the following paths:

$(SRCROOT)/../node_modules/react-native-simple-openvpn/ios

Or, if using CocoaPods, the following paths should be automatically included there:

"${PODS_ROOT}/Headers/Public/react-native-simple-openvpn"

Example

Example

Usage

import React, { useEffect } from 'react';
import { Platform } from 'react-native';
import RNSimpleOpenvpn, { addVpnStateListener, removeVpnStateListener } from 'react-native-simple-openvpn';

const isIPhone = Platform.OS === 'ios';

const App = () => {
  useEffect(() => {
    async function observeVpn() {
      if (isIPhone) {
        await RNSimpleOpenvpn.observeState();
      }

      addVpnStateListener((e) => {
        // ...
      });
    }

    observeVpn();

    return async () => {
      if (isIPhone) {
        await RNSimpleOpenvpn.stopObserveState();
      }

      removeVpnStateListener();
    };
  });

  async function startOvpn() {
    try {
      await RNSimpleOpenvpn.connect({
        remoteAddress: '192.168.1.1 3000',
        ovpnFileName: 'client',
        assetsPath: 'ovpn/',
        providerBundleIdentifier: 'com.example.RNSimpleOvpnTest.NEOpenVPN',
        localizedDescription: 'RNSimpleOvpn',
      });
    } catch (error) {
      // ...
    }
  }

  async function stopOvpn() {
    try {
      await RNSimpleOpenvpn.disconnect();
    } catch (error) {
      // ...
    }
  }

  function printVpnState() {
    console.log(JSON.stringify(RNSimpleOpenvpn.VpnState, undefined, 2));
  }

  // ...
};

export default App;

For more, read the API Reference

OpenVPN library

The following items were used in this project

Todo

  • [x] Resolve RN 0.65 warning
  • [x] Upgrade to the latest Android OpenVPN library

Star History

star history chart

Contributors

Thanks to all the people who contribute

contributors list

License

GPLv2 © Nor Cod