Skip to content

A Java library of SOCKS5 protocol including client and server

License

Notifications You must be signed in to change notification settings

Horstexplorer/sockslib

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

SocksLib

SocksLib is a Java library for SOCKS5 protocol.

References

Features

⚠ This fork includes the following changes ⚠

  • Updated dependencies
  • Removed MongoDB related features

Obtain this library via Github or Jitpack using Maven or Gradle

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+

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();

About

A Java library of SOCKS5 protocol including client and server

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Languages

  • Java 100.0%