sockslibs

A Java library for SOCKS5 client and SOCKS5 server

License

License

GroupId

GroupId

com.github.mike10004
ArtifactId

ArtifactId

fengyouchao-sockslib
Last Version

Last Version

1.0.6
Release Date

Release Date

Type

Type

jar
Description

Description

sockslibs
A Java library for SOCKS5 client and SOCKS5 server
Project URL

Project URL

https://fengyouchao.github.io/sockslib/
Source Code Management

Source Code Management

https://github.com/fengyouchao/sockslib

Download fengyouchao-sockslib

How to add to project

<!-- https://jarcasting.com/artifacts/com.github.mike10004/fengyouchao-sockslib/ -->
<dependency>
    <groupId>com.github.mike10004</groupId>
    <artifactId>fengyouchao-sockslib</artifactId>
    <version>1.0.6</version>
</dependency>
// https://jarcasting.com/artifacts/com.github.mike10004/fengyouchao-sockslib/
implementation 'com.github.mike10004:fengyouchao-sockslib:1.0.6'
// https://jarcasting.com/artifacts/com.github.mike10004/fengyouchao-sockslib/
implementation ("com.github.mike10004:fengyouchao-sockslib:1.0.6")
'com.github.mike10004:fengyouchao-sockslib:jar:1.0.6'
<dependency org="com.github.mike10004" name="fengyouchao-sockslib" rev="1.0.6">
  <artifact name="fengyouchao-sockslib" type="jar" />
</dependency>
@Grapes(
@Grab(group='com.github.mike10004', module='fengyouchao-sockslib', version='1.0.6')
)
libraryDependencies += "com.github.mike10004" % "fengyouchao-sockslib" % "1.0.6"
[com.github.mike10004/fengyouchao-sockslib "1.0.6"]

Dependencies

compile (3)

Group / Artifact Type Version
org.slf4j : slf4j-api jar 1.7.12
com.google.guava : guava jar 19.0
com.google.code.findbugs : jsr305 jar 3.0.0

provided (1)

Group / Artifact Type Version
org.mongodb : mongo-java-driver jar 3.0.3

test (5)

Group / Artifact Type Version
org.apache.logging.log4j : log4j-core jar 2.4
org.apache.logging.log4j : log4j-slf4j-impl jar 2.4
org.apache.tomcat : dbcp jar 6.0.44
com.h2database : h2 jar 1.4.188
junit : junit jar 4.9

Project Modules

There are no modules declared in this project.

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

Versions

Version
1.0.6
1.0.5
1.0.3
1.0.2
1.0.1
1.0.0