Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/xomadev/ksocks5

Standard Socks5 server implementation in pure Java
https://github.com/xomadev/ksocks5

pure-java socks5 socks5-server

Last synced: about 1 month ago
JSON representation

Standard Socks5 server implementation in pure Java

Awesome Lists containing this project

README

        

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

```xml

space.themelon
KSocks5
1.1

```

```kotlin
implementation("space.themelon:KSocks5:1.1")
```

## Usage

- Spawn a simple open proxy server

```java
ProxyServer server = new ProxyServer.Builder(port).build();
...
server.close();
```

- Create a proxy server with Username / Password Authentication

```java
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`)

```java
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`)

```java
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

```java
ProxyServer server = new ProxyServer.Builder(remoteHost, remotePort)
.reverseProxy()
.build();
```