|
| 1 | +# Socket Broker |
| 2 | + |
| 3 | +[](https://github.com/exceptionfactory/socketbroker/actions/workflows/build.yml) |
| 4 | + |
| 5 | +Java Socket library supporting SOCKS and HTTP proxy servers with authentication |
| 6 | + |
| 7 | +# Requirements |
| 8 | + |
| 9 | +- Java 8 |
| 10 | +- Maven 3 |
| 11 | + |
| 12 | +# Versioning |
| 13 | + |
| 14 | +Socket Broker follows the [Semantic Versioning Specification 2.0.0](https://semver.org/). |
| 15 | + |
| 16 | +The public API consists of interfaces and classes in the following Java packages: |
| 17 | + |
| 18 | +- com.exceptionfactory.socketbroker |
| 19 | +- com.exceptionfactory.socketbroker.configuration |
| 20 | + |
| 21 | +# Standards |
| 22 | + |
| 23 | +Socket Broker supports client capabilities for several protocols defined in referenced standards. |
| 24 | + |
| 25 | +## SOCKS |
| 26 | + |
| 27 | +- [RFC 1928: SOCKS Protocol Version 5](https://tools.ietf.org/html/rfc1928) |
| 28 | +- [RFC 1929: Username/Password Authentication for SOCKS V5](https://tools.ietf.org/html/rfc1929) |
| 29 | + |
| 30 | +## HTTP |
| 31 | + |
| 32 | +- [RFC 7231: Hypertext Transfer Protocol (HTTP/1.1): Semantics and Content](https://tools.ietf.org/html/rfc7231) |
| 33 | +- [RFC 7235: Hypertext Transfer Protocol (HTTP/1.1): Authentication](https://tools.ietf.org/html/rfc7235) |
| 34 | +- [RFC 7617: The 'Basic' HTTP Authentication Scheme](https://tools.ietf.org/html/rfc7617) |
| 35 | + |
| 36 | +# Building |
| 37 | + |
| 38 | +Run the following Maven command to build the library: |
| 39 | + |
| 40 | +``` |
| 41 | +mvn clean install |
| 42 | +``` |
| 43 | + |
| 44 | +# Integrating |
| 45 | + |
| 46 | +The `BrokeredSocketFactory` class provides the primary point of integration for external applications. |
| 47 | + |
| 48 | +## Configuration |
| 49 | + |
| 50 | +The `BrokerConfiguration` interface and `StandardBrokerConfiguration` class provide the proxy protocol, proxy server |
| 51 | +address, and optional authentication credentials necessary for creating a connection through a proxy server. |
| 52 | + |
| 53 | +### Proxy Type |
| 54 | + |
| 55 | +The `ProxyType` enumeration defines supported protocols including `SOCKS5` and `HTTP_CONNECT`. |
| 56 | + |
| 57 | +### Proxy Socket Address |
| 58 | + |
| 59 | +The proxy server address must be defined using an instance |
| 60 | +of [java.net.InetSocketAddress](https://docs.oracle.com/javase/8/docs/api/java/net/InetSocketAddress.html) that includes |
| 61 | +the server address and port number. |
| 62 | + |
| 63 | +### Authentication Credentials |
| 64 | + |
| 65 | +Access to proxy servers that require authentication involves configuring an instance of `AuthenticationCredentials`. |
| 66 | +The `StandardUsernamePasswordAuthenticationCredentials` class supports defining a username string and a password |
| 67 | +character array. |
| 68 | + |
| 69 | +### Socket Factory |
| 70 | + |
| 71 | +The `BrokeredSocketFactory` class requires an instance of `BrokerConfiguration` as well as |
| 72 | +a [javax.net.SocketFactory](https://docs.oracle.com/javase/8/docs/api/javax/net/SocketFactory.html). The `SocketFactory` |
| 73 | +provides the opportunity to supply standard settings for the connection to the configured proxy server. The |
| 74 | +`SocketFactory.getDefault()` method is sufficient for standard integrations. |
| 75 | + |
| 76 | +# Alternatives |
| 77 | + |
| 78 | +Several alternative implementations are available depending on usage requirements. |
| 79 | + |
| 80 | +## Java Socket Proxy |
| 81 | + |
| 82 | +The [java.net.Socket](https://docs.oracle.com/javase/8/docs/api/java/net/Socket.html) class can be configured using an |
| 83 | +instance of [java.net.Proxy](https://docs.oracle.com/javase/8/docs/api/java/net/Proxy.html) for connections to SOCKS or |
| 84 | +HTTP proxies that do not require authentication. |
| 85 | + |
| 86 | +The standard [java.net.Authenticator](https://docs.oracle.com/javase/8/docs/api/java/net/Authenticator.html) class |
| 87 | +supports configurable proxy authentication through the static `setDefault()` method. Standard `Socket` implementations |
| 88 | +invoke password request methods on a configured `Authenticator` to return instances of |
| 89 | +[java.net.PasswordAuthentication](https://docs.oracle.com/javase/8/docs/api/java/net/PasswordAuthentication.html). This |
| 90 | +integration approach is sufficient for applications that allow defining an instance of the `Authenticator` class for the |
| 91 | +Java Virtual Machine. |
| 92 | + |
| 93 | +## Netty |
| 94 | + |
| 95 | +The [Netty](https://netty.io) project provides component modules that support both SOCKS 4 and SOCKS 5 as well as HTTP. |
| 96 | +Netty does not provide a direct implementation of `java.net.Socket` supporting proxy connections, but applications using |
| 97 | +Netty can integrate support for proxy access using available components. |
| 98 | + |
| 99 | +## SocksLib |
| 100 | + |
| 101 | +The [SocksLib](https://github.com/fengyouchao/sockslib) library provides client and server socket implementations for |
| 102 | +the SOCKS 5 protocol. SocksLib supports both TCP and UDP client connections. |
| 103 | + |
| 104 | +# Licensing |
| 105 | + |
| 106 | +Socket Broker is released under the [Apache License, Version 2.0](https://www.apache.org/licenses/LICENSE-2.0). |
0 commit comments