GithubHelp home page GithubHelp logo

tempbottle / sockslib Goto Github PK

View Code? Open in Web Editor NEW

This project forked from fengyouchao/sockslib

0.0 1.0 0.0 635 KB

A Java library of SOCKS5 protocol including client and server

License: Apache License 2.0

Java 100.00%

sockslib's Introduction

SocksLib Build Status Coverage Status Coverity Scan Build Status

SocksLib is a Java library for SOCKS5 protocol.

See Java API Documentation

See Wiki Page (Chinese)

If you are looking for a SOCKS5 server instead of a SOKCS5 library, I hope Esocks can help you.

References

Features

Client

  • TCP proxy
  • UDP proxy
  • Bind
  • Anonymous authentication
  • USERNAME/PASSWORD authentication
  • Proxy chain

Server

  • TCP proxy
  • UDP proxy
  • Bind
  • Anonymous authentication
  • USERNAME/PASSWORD authentication
  • Proxy chain
  • Black or white IP lists for clients

Quick start

Environment

  • JDK 8+

Dependencies

You should put following libraries in your project's CLASSPATH:

SOCKS5 Client

CONNECT

    SocksProxy proxy = new Socks5(new InetSocketAddress("localhost",1080));
    Socket socket = new SocksSocket(proxy, new InetSocketAddress("whois.internic.net",43));

Connect SOCKS5 server using SSL connection

    SSLConfigurationBuilder builder = SSLConfigurationBuilder.newBuilder();
    builder.setTrustKeyStorePath("client-trust-keystore.jks");
    builder.setTrustKeyStorePassword("123456");
    SocksProxy proxy = new SSLSocks5(new InetSocketAddress("localhost", 1081), builder.build());
    Socket socket = new SocksSocket(proxy, new InetSocketAddress("whois.internic.net",43));

BIND

    SocksServerSocket serverSocket = new SocksServerSocket(proxy, inetAddress,8080);
    InetAddress bindAddress = serverSocket.getBindAddress();
    int bindPort  = serverSocket.getBindPort();
    Socket socket = serverSocket.accept();

UDP ASSOCIATE

     DatagramSocket socket = new Socks5DatagramSocket(proxy);

SOCKS5 Server

     SocksProxyServer proxyServer = SocksServerBuilder.buildAnonymousSocks5Server(); 
     proxyServer.start();// Creat a SOCKS5 server bind at port 1080

SSL socks server

    SSLConfigurationBuilder builder = SSLConfigurationBuilder.newBuilder();
    builder.setKeyStorePath("server-keystore.jks");
    builder.setKeyStorePassword("123456");
    builder.setClientAuth(false);
    socksProxyServer = SocksServerBuilder.buildAnonymousSSLSocks5Server(1081, builder.build());
    socksProxyServer.start();

sockslib's People

Contributors

fengyouchao avatar gamerson avatar

Watchers

 avatar

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.