-
Notifications
You must be signed in to change notification settings - Fork 55
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
81 additions
and
66 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
// Copyright 2023 Jigsaw Operations LLC | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// https://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
/* | ||
Package config provides convenience functions to create dialer objects based on a text config. | ||
This is experimental and mostly for illustrative purposes at this point. | ||
Configurable transports simplifies the way you create and manage transports. | ||
With the config package, you can use [NewPacketDialer] and [NewStreamDialer] to create dialers using a simple text string. | ||
Key Benefits: | ||
- Ease of Use: Create transports effortlessly by providing a textual configuration, reducing boilerplate code. | ||
- Serialization: Easily share configurations with users or between different parts of your application, including your Go backend. | ||
- Dynamic Configuration: Set your app's transport settings at runtime. | ||
- DPI Evasion: Advanced nesting and configuration options help you evade Deep Packet Inspection (DPI). | ||
# Config Format | ||
The configuration string is composed of parts separated by the `|` symbol, which define nested dialers. | ||
For example, `A|B` means dialer `B` takes dialer `A` as its input. | ||
An empty string represents the direct TCP/UDP dialer, and is used as the input to the first cofigured dialer. | ||
Each dialer configuration follows a URL format, where the scheme defines the type of Dialer. Supported formats include: | ||
Shadowsocks proxy (compatible with Outline's access keys, package [transport/shadowsocks]) | ||
ss://[USERINFO]@[HOST]:[PORT]?prefix=[PREFIX] | ||
SOCKS5 proxy (currently streams only, package [transport/socks5]) | ||
socks5://[HOST]:[PORT] | ||
Stream split transport (streams only, package [transport/split]) | ||
It takes the length of the prefix. The stream will be split when PREFIX_LENGTH bytes are first written. | ||
split:[PREFIX_LENGTH] | ||
TLS transport (currently streams only, package [x/tls]) | ||
The sni parameter defines the name to be sent in the TLS SNI. It can be empty. | ||
The certname parameter defines what name to validate against the server certificate. | ||
tls:sni=[SNI]&certname=[CERT_NAME] | ||
# Examples | ||
Packet splitting - To split outgoing streams on bytes 2 and 123, you can use: | ||
split:2|split:123 | ||
SOCKS5-over-TLS, with domain-fronting - To tunnel SOCKS5 over TLS, and set the SNI to decoy.example.com, while still validating against your host name, use: | ||
tls:sni=decoy.example.com&certname=[HOST]|socks5:[HOST]:[PORT] | ||
Onion Routing with Shadowsocks - To route your traffic through three Shadowsocks servers, similar to [Onion Routing], use: | ||
ss://[USERINFO1]@[HOST1]:[PORT1]|ss://[USERINFO2]@[HOST2]:[PORT2]|ss://[USERINFO3]@[HOST3]:[PORT3] | ||
In that case, HOST1 will be your entry node, and HOST3 will be your exit node. | ||
DPI Evasion - To add packet splitting to a Shadowsocks server for enhanced DPI evasion, use: | ||
split:2|ss://[USERINFO]@[HOST]:[PORT] | ||
[Onion Routing]: https://en.wikipedia.org/wiki/Onion_routing | ||
*/ | ||
package config |