sshvpn_flutter 1.0.0 copy "sshvpn_flutter: ^1.0.0" to clipboard
sshvpn_flutter: ^1.0.0 copied to clipboard

PlatformiOS

A Flutter plugin for managing SSH VPN connections

SSH Vpn Flutter Plugin (iOS Only) #

A Flutter plugin for managing SSH VPN connections on iOS. This plugin provides methods to set up, connect, disconnect, and check the status of VPN connections using SSH.


Features #

  • Setup VPN: Configure VPN with hostname, credentials, and protocol settings.
  • Connect to VPN: Establish a VPN connection.
  • Disconnect VPN: Terminate an active VPN session.
  • Retrieve Connection Status: Get the last known status of the VPN connection.

Note: This plugin currently supports iOS only.


Installation #

Add the package to your pubspec.yaml:

dependencies:
  sshvpn_flutter: ^latest_version

Run the command:

flutter pub get

Import the package in your Dart code:

import 'package:sshvpn_flutter/sshvpn_flutter.dart';

iOS Setup #

1. Add Capabillity #

Add Network Extensions capabillity on Runner's Target and enable Packet Tunnel

2. Add New Target #

Click + button on bottom left, Choose NETWORK EXTENSION. And set Language and Provider Type to Objective-C and Packet Tunnel as image below.

3. Add Capabillity to sshvpn_extension #

Repeat the step 1 for new target you created on previous step (sshvpn_extension)

4. Add Framework Search Path #

Select sshvpn_extension and add the following lines to your Build Setting > Framework Search Path:

$(SRCROOT)/.symlinks/plugins/sshvpn_flutter/ios/include

5. Copy Paste #

Open sshvpn_extension > PacketTunnelProvider.m and copy paste this script PacketTunnelProvider.m

Usage #

Setting up the VPN #

To configure the VPN connection, use the setup method and pass an SSHServer instance with the required configuration:

import 'package:sshvpn_flutter/sshvpn_flutter.dart';

final sshVpnFlutterPlugin = SshvpnFlutter();

    SSHServer server = SSHServer(
      host: hostNameController.text,
      port: int.parse(
          sslPortController.text.isEmpty ? '443' : sslPortController.text),
      username: userNameController.text,
      password: passController.text,
      udpgw: udpgwController.text,
      udpgwPort: int.parse(
          udpgwPortController.text.isEmpty ? '7300' : udpgwPortController.text),
      iosConfiguration: SSHIOSConfiguration(
        enableMSCHAP2: true,
        enableCHAP: false,
        enablePAP: false,
        enableTLS: false,
      ),
    );
    await sshVpnFlutterPlugin.setup(server: server);

Connecting to VPN #

To connect to the VPN:

await sshVpnFlutterPlugin.connect();

Disconnecting from VPN #

To disconnect from the VPN:

await sshVpnFlutterPlugin.disconnect();

Checking Connection Status #

To get the last known VPN connection status:

String status = await sshVpnFlutterPlugin.lastStatus() ?? 'disconnected'
print('Last VPN status: $status');

Limitations #

  • Platform: This plugin is only supported on iOS. Android support is not currently available.
  • Dependencies: Ensure your iOS project is properly configured for VPN usage.

Contributions and Issues #

Feel free to contribute to this project by submitting pull requests or reporting issues on the GitHub repository.

This addition emphasizes that the purpose of the plugin is to provide a secure means for web surfing using SSH VPN connections. Adjustments can be made based on your specific requirements.

Support this Project #

If you find this project helpful, consider supporting it by making a donation. Major of Your contribution will spend on charity every month.

"Buy Me A Coffee"

"زرین پال"

  • Bitcoin (BTC): bc1qgwfqm5e3fhyw879ycy23zljcxl2pvs575c3j7w
  • USDT (TRC20): TJc5v4ktoFaG3WamjY5rvSZy7v2F6tFuuE

Thank you for your support! 🚀

License #


Copyright 2024 Navid Shokoufeh

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

1. Redistributions of source code must retain the above copyright notice, this list of conditions, and the following disclaimer.

2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions, and the following disclaimer in the documentation and/or other materials provided with the distribution.

3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

2
likes
140
points
22
downloads

Publisher

verified publishernaviddev.info

Weekly Downloads

A Flutter plugin for managing SSH VPN connections

Repository (GitHub)

Documentation

API reference

License

BSD-3-Clause (license)

Dependencies

flutter, plugin_platform_interface

More

Packages that depend on sshvpn_flutter