https://github.com/bbottema/java-socks-proxy-server
Java SOCKS 4/5 server implementation for Java
https://github.com/bbottema/java-socks-proxy-server
Last synced: 9 months ago
JSON representation
Java SOCKS 4/5 server implementation for Java
- Host: GitHub
- URL: https://github.com/bbottema/java-socks-proxy-server
- Owner: bbottema
- Created: 2019-12-04T11:12:57.000Z (about 6 years ago)
- Default Branch: master
- Last Pushed: 2024-10-02T09:05:48.000Z (over 1 year ago)
- Last Synced: 2025-03-28T22:14:31.835Z (10 months ago)
- Language: Java
- Size: 75.2 KB
- Stars: 95
- Watchers: 3
- Forks: 33
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE-2.0.txt
Awesome Lists containing this project
- awesome-java - Java SOCKS Proxy Server
README
[](LICENSE-2.0.txt)
[](http://search.maven.org/#search%7Cgav%7C1%7Cg%3A%22com.github.bbottema%22%20AND%20a%3A%22java-socks-proxy-server%22)
[](http://www.javadoc.io/doc/com.github.bbottema/java-socks-proxy-server)
[](https://www.codacy.com/gh/bbottema/java-socks-proxy-server)
# java-socks-proxy-server
*java-socks-proxy-server* is a SOCKS 4/5 server for Java. Includes a JUnit Rule for easy testing with a SOCKS server.
It is a continuation of https://github.com/damico/java-socks-proxy-server.
```xml
com.github.bbottema
java-socks-proxy-server
4.1.2
```
## Usage:
```java
// start serving clients on port 1234
SocksServer server = new SocksServer(1234).start();
...
server.stop(); // stop serving any new proxy requests
```
Or you can supply your own `ServerSocketFactory`:
```java
// e.g. SSL on port 7132
SocksServer server = new SocksServer(1234, myCustomServerFactory).start();
```
> By default, library uses `NO_AUTH` authentication mode
### Username and Password Authentication
If you want to authenticate the clients, before proxying, you can set a `UsernamePasswordAuthenticator`, library supports standard Username/Password protocol.
```java
new SocksServer(1234)
.setAuthenticator(new UsernamePasswordAuthenticator(false) {
@Override
public boolean validate(String username, String password) {
// validate credentials here, e.g. check your local database
return username.equals("mysecureusername") && password.equals("mysecurepassword");
}
}).start();
```
> Supply a `true` value to constructor `UsernamePasswordAuthenticator()`, if you also want to prefer `NO_AUTH` mode over Username and password.
For use in junit 5 tests (for Junit 4 use a version < 3.0.0):
```
@RegisterExtension
static SockServerExtension sockServerRule = new SockServerExtension(PROXY_SERVER_PORT);
// or
@RegisterExtension
static SockServerExtension sockServerRule = new SockServerExtension(PROXY_SERVER_PORT, myServerSocketFactory);
```
And that's it!
## Change history
v4.1.2 (02-October-2024)
- [#15](https://github.com/bbottema/java-socks-proxy-server/issues/15): [bug+maintenance] Current version doesn't assign default authentication handler properly, address nullability and superfluous method chaining.
v4.1.0 (15-May-2024)
v4.1.1 (duplicate release)
- [#14](https://github.com/bbottema/java-socks-proxy-server/issues/14): Enhanced dynamic username/password authentication support for custom validation strategies.
- Minor performance improvements based on SpotBugs recommendations.
NOTE: the start methods have been marked deprecated. For serving clienst on multiple ports, create a new instance of the server for each port.
v4.0.0 (21-April-2024)
- Maintenance release: upgraded parent POM version, switched to Junit5, updated dependencies, added SpotBugs checks.
v3.0.0 (22-Januray-2024)
- [#12](https://github.com/bbottema/java-socks-proxy-server/issues/12): Added a more robust server adaptation with synchronous startup (including retries), shutdown closes all connections. With thanks to @kllbzz
v2.0.0 (26-December-2021)
- Switched to Java 8 and included fix for recent log4j security issue
v1.1.0 (15-April-2021)
- [#4](https://github.com/bbottema/java-socks-proxy-server/issues/4) added support for custom server socket factory (so you are free to configure SSL)
v1.0.2 (5-July-2020)
- Bumped log4j-core from 2.6.1 to 2.13.2
v1.0.1 (6-December-2019)
- Removed Jacoco instrumentation from production code
v1.0.0 (6-December-2019)
Initial release
4-December-2019
Initial upload