Skip to content

XomaDev/KSocks5

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

KSocks5

Standard Socks5 Server implementation in Java

Features

  • TCP Streaming, Bind
  • Username/Password Authentication
  • Intercept/Monitor incoming clients and connections
  • Reverse Proxy

Written in pure Java, no additional libraries, requires Java >= 8

Setup

<dependency>
    <groupId>space.themelon</groupId>
    <artifactId>KSocks5</artifactId>
    <version>1.1</version>
</dependency>
implementation("space.themelon:KSocks5:1.1")

Usage

  • Spawn a simple open proxy server
ProxyServer server = new ProxyServer.Builder(port).build();
...
server.close();
  • Create a proxy server with Username / Password Authentication
AuthMode userPassAuth = new AuthMode((username, password) -> 
    username.equals("secureusername") && password.equals("securepassword"));

ProxyServer proxy = new ProxyServer.Builder(port)
    .auth(userPassAuth)
    .build();
  • Monitor incoming client connections (clientMonitor)
ClientCallback monitor = address -> {
  System.out.println("New client " + address);
  return true; // approve client
};
ProxyServer server = new ProxyServer.Builder(port)
    .clientMonitor(monitor)
    .build();
  • Monitor outgoing connection requests (connectionMonitor)
ConnectionCallback monitor = (client, destination, port) -> {
  if (isBlacklisted(destination)) {
    System.out.println("Blocking connection to " + destination);
    return false;
  }
  return true;
};

ProxyServer server = new ProxyServer.Builder(port)
    .connectionMonitor(monitor)
    .build();
  • Create a reverse proxy to outside, rather than awaiting connection
ProxyServer server = new ProxyServer.Builder(remoteHost, remotePort)
    .reverseProxy()
    .build();

About

Standard Socks5 server implementation in pure Java

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages