Skip to content

Commit 43fe395

Browse files
Initial commit of Socket Broker
1 parent 88f0504 commit 43fe395

File tree

101 files changed

+7189
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

101 files changed

+7189
-0
lines changed

.github/workflows/build.yml

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
name: build
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
pull_request:
8+
branches:
9+
- main
10+
11+
jobs:
12+
build:
13+
runs-on: ubuntu-latest
14+
steps:
15+
- name: Checkout Sources
16+
uses: actions/checkout@v2
17+
- name: Setup Java JDK
18+
uses: actions/setup-java@v2
19+
with:
20+
java-version: '8'
21+
distribution: 'zulu'
22+
cache: 'maven'
23+
- name: Build
24+
run: mvn --batch-mode --update-snapshots verify

.gitignore

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
# Compiled class file
2+
*.class
3+
target/
4+
5+
# Log file
6+
*.log
7+
8+
# BlueJ files
9+
*.ctxt
10+
11+
# Mobile Tools for Java (J2ME)
12+
.mtj.tmp/
13+
14+
# Package Files #
15+
*.jar
16+
*.war
17+
*.nar
18+
*.ear
19+
*.zip
20+
*.tar.gz
21+
*.rar
22+
23+
# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
24+
hs_err_pid*
25+
26+
# IntelliJ
27+
.idea/

HEADER

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
/**
2+
* Copyright 2021 Socket Broker Contributors
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/

README.md

Lines changed: 106 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,106 @@
1+
# Socket Broker
2+
3+
[![build](https://github.com/exceptionfactory/socketbroker/actions/workflows/build.yml/badge.svg)](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

Comments
 (0)