socks5 0.1.2

  • Readme
  • Changelog
  • Example
  • Installing
  • 65

socks #

A SOCKS5 connection handler

Example #

/// [SOCKSSocket] uses a raw socket to authorize 
/// and request a connection, connect to your socks proxy server
final sock = await RawSocket.connect(InternetAddress.loopbackIPv4, 9050);

/// pass the socket to [SOCKSSocket]
final proxy = SOCKSSocket(sock);

/// request the proxy to connect to a host
/// this call will throw exceptions if connection attempt fails from the proxy
await proxy.connect("google.com:80");

/// Now you can use the [sock] from earlier, since we can only listen
/// once on a [RawSocket] we must set the [onData] function to intercept 
/// the events from the socket
proxy.subscription.onData((RawSocketEvent event) {
    /// [RawSocketEvent] messages are here
    /// read from here.. 
    if (event == RawSocketEvent.read) {
      final data = sock.read(sock.available());
      ...
    }
});

/// To connect with an [InternetAddress] use:
/// await s.connectIp(InternetAddress.loopbackIPv4, 80);

/// keepOpen=false will call close the [RawSocket]
await proxy.close(keepOpen: false);

[0.0.1] - Init

  • Basic SOCKS5 support

[0.1.0] - Bump Version

  • Bump version for pub.dev package health

[0.1.1] - Remove flutter dependency

  • Remove empty flutter dependency

[0.1.2] - Add Username/Password auth

  • Add Username/Password auth

example/main.dart

import 'dart:io';

import 'package:socks5/socks5.dart';

void main() async {
  /// [SOCKSSocket] uses a raw socket to authorize
  /// and request a connection, connect to your socks proxy server
  final sock = await RawSocket.connect(InternetAddress.loopbackIPv4, 9050);

  /// pass the socket to [SOCKSSocket]
  final proxy = SOCKSSocket(sock);

  /// request the proxy to connect to a host
  /// this call will throw exceptions if connection attempt fails from the proxy
  await proxy.connect("google.com:80");

  /// Now you can use the [sock] from earlier, since we can only listen
  /// once on a [RawSocket] we must set the [onData] function to intercept
  /// the events from the socket
  proxy.subscription.onData((RawSocketEvent event) {
    /// [RawSocketEvent] messages are here
    /// read from here..
    if (event == RawSocketEvent.read) {
      final data = sock.read(sock.available());
      print("Got ${data.length} bytes");
    }
  });

  /// To connect with an [InternetAddress] use:
  /// await s.connectIp(InternetAddress.loopbackIPv4, 80);

  /// keepOpen=false will call close the [RawSocket]
  await proxy.close(keepOpen: false);
}

Use this package as a library

1. Depend on it

Add this to your package's pubspec.yaml file:


dependencies:
  socks5: ^0.1.2

2. Install it

You can install packages from the command line:

with pub:


$ pub get

with Flutter:


$ flutter pub get

Alternatively, your editor might support pub get or flutter pub get. Check the docs for your editor to learn more.

3. Import it

Now in your Dart code, you can use:


import 'package:socks5/socks5.dart';
  
Popularity:
Describes how popular the package is relative to other packages. [more]
32
Health:
Code health derived from static analysis. [more]
98
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
100
Overall:
Weighted score of the above. [more]
65
Learn more about scoring.

We analyzed this package on Dec 13, 2019, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.7.0
  • pana: 0.13.1+4

Health suggestions

Fix lib/socks5.dart. (-1.99 points)

Analysis of lib/socks5.dart reported 4 hints:

line 284 col 15: The value of the local variable 'version' isn't used.

line 315 col 15: The value of the local variable 'version' isn't used.

line 319 col 19: The value of the local variable 'addr' isn't used.

line 320 col 13: The value of the local variable 'port' isn't used.

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.3.0 <3.0.0
Dev dependencies
flutter_test