socks5_proxy 2.0.0 copy "socks5_proxy: ^2.0.0" to clipboard
socks5_proxy: ^2.0.0 copied to clipboard

Socks5 server and client with ability to catch packet in both direction, chain proxies and more.

example/example.md

import 'dart:convert';
import 'dart:io';

import 'package:socks5_proxy/socks_client.dart';
import 'package:socks5_proxy/socks_server.dart';

Future<void> initServer() async {
    // Create server instance
    final proxy = SocksServer();

    // Listen to all tcp and udp connections
    proxy.connections.listen((connection) async {
        // Apply default handler or create own handler to spy on connections.
        await connection.forward();
    }).onError(print);

    // Bind servers
    await proxy.bind(InternetAddress.loopbackIPv4, 1080);
}

Future<void> main() async {
    // Initialize socks server.
    await initServer();

    // List of proxies
    final proxies = [
    ProxySettings(InternetAddress.loopbackIPv4, 1080),
    ];

    // Create HttpClient object
    final client = HttpClient();

    // Assign connection factory
    SocksTCPClient.assignToHttpClientWithSecureOptions(client, proxies, 
        // Log tls keys
        keyLog: print,
    );

    // GET request
    final request = await client.getUrl(Uri.parse('https://example.com'));
    final response = await request.close();
    // Print response
    print(await utf8.decodeStream(response));
    // Close client
    client.close();
}
copied to clipboard

See more client examples See more server examples

8
likes
150
points
1.92k
downloads

Publisher

unverified uploader

Weekly Downloads

2024.09.14 - 2025.03.29

Socks5 server and client with ability to catch packet in both direction, chain proxies and more.

Repository (GitHub)

Documentation

API reference

License

MIT (license)

Dependencies

async, meta

More

Packages that depend on socks5_proxy