chore: doc updates

This commit is contained in:
nadoo 2022-03-14 13:06:26 +08:00
parent 420ec26368
commit 3740375569
7 changed files with 69 additions and 21 deletions

View File

@ -231,6 +231,10 @@ glider 0.16.0, https://github.com/nadoo/glider (glider.proxy@gmail.com)
<summary><code>glider -scheme all</code></summary> <summary><code>glider -scheme all</code></summary>
```bash ```bash
Http scheme:
http://[user:pass@]host:port
--
KCP scheme: KCP scheme:
kcp://CRYPT:KEY@host:port[?dataShards=NUM&parityShards=NUM&mode=MODE] kcp://CRYPT:KEY@host:port[?dataShards=NUM&parityShards=NUM&mode=MODE]
@ -240,10 +244,6 @@ Available crypt types for KCP:
Available modes for KCP: Available modes for KCP:
fast, fast2, fast3, normal, default: fast fast, fast2, fast3, normal, default: fast
--
Socks5 scheme:
socks://[user:pass@]host:port
-- --
Simple-Obfs scheme: Simple-Obfs scheme:
simple-obfs://host:port[?type=TYPE&host=HOST&uri=URI&ua=UA] simple-obfs://host:port[?type=TYPE&host=HOST&uri=URI&ua=UA]
@ -255,6 +255,14 @@ Available types for simple-obfs:
Smux scheme: Smux scheme:
smux://host:port smux://host:port
--
Socks4 scheme:
socks4://host:port
--
Socks5 scheme:
socks5://[user:pass@]host:port
-- --
SS scheme: SS scheme:
ss://method:pass@host:port ss://method:pass@host:port
@ -265,7 +273,7 @@ SS scheme:
Stream Ciphers: Stream Ciphers:
AES-128-CFB AES-128-CTR AES-192-CFB AES-192-CTR AES-256-CFB AES-256-CTR CHACHA20-IETF XCHACHA20 CHACHA20 RC4-MD5 AES-128-CFB AES-128-CTR AES-192-CFB AES-192-CTR AES-256-CFB AES-256-CTR CHACHA20-IETF XCHACHA20 CHACHA20 RC4-MD5
Alias: Alias:
chacha20-ietf-poly1305 = AEAD_CHACHA20_POLY1305, xchacha20-ietf-poly1305 = AEAD_XCHACHA20_POLY1305 chacha20-ietf-poly1305 = AEAD_CHACHA20_POLY1305, xchacha20-ietf-poly1305 = AEAD_XCHACHA20_POLY1305
Plain: NONE Plain: NONE
-- --
@ -305,6 +313,10 @@ Trojan server scheme:
trojan://pass@host:port?cert=PATH&key=PATH[&fallback=127.0.0.1] trojan://pass@host:port?cert=PATH&key=PATH[&fallback=127.0.0.1]
trojanc://pass@host:port[?fallback=127.0.0.1] (cleartext, without TLS) trojanc://pass@host:port[?fallback=127.0.0.1] (cleartext, without TLS)
--
Unix domain socket scheme:
unix://path
-- --
VLESS scheme: VLESS scheme:
vless://uuid@host:port[?fallback=127.0.0.1:80] vless://uuid@host:port[?fallback=127.0.0.1:80]
@ -392,11 +404,10 @@ Examples:
## Service ## Service
- dhcpd / dhcpd-failover: - dhcpd / dhcpd-failover:
- service=dhcpd,INTERFACE,START_IP,END_IP,LEASE_MINUTES[,MAC=IP,MAC=IP...] - service=dhcpd,INTERFACE,START_IP,END_IP,LEASE_MINUTES[,MAC=IP,MAC=IP...]
- service=dhcpd-failover,INTERFACE,START_IP,END_IP,LEASE_MINUTES[,MAC=IP,MAC=IP...] - service=dhcpd,eth1,192.168.1.100,192.168.1.199,720,fc:23:34:9e:25:01=192.168.1.101
- service=dhcpd,eth1,192.168.1.100,192.168.1.199,720 - service=dhcpd-failover,eth2,192.168.2.100,192.168.2.199,720
- service=dhcpd-failover,eth2,192.168.2.100,192.168.2.199,720,fc:23:34:9e:25:01=192.168.2.101
- note: `dhcpd-failover` only serves requests when there's no other dhcp server exists in lan - note: `dhcpd-failover` only serves requests when there's no other dhcp server exists in lan
- detect interval: 1min - detect interval: 1min
@ -404,6 +415,27 @@ Examples:
- systemd: [https://github.com/nadoo/glider/blob/master/systemd/](https://github.com/nadoo/glider/blob/master/systemd/) - systemd: [https://github.com/nadoo/glider/blob/master/systemd/](https://github.com/nadoo/glider/blob/master/systemd/)
- <details> <summary>docker: click to see details</summary>
- run glider
```
docker run -d --name glider --net host --restart=always -v /etc/glider:/etc/glider nadoo/glider:latest -config=/etc/glider/glider.conf
```
- run watchtower(if you need auto update for glider)
```
docker run -d --name watchtower --restart=always \
-v /var/run/docker.sock:/var/run/docker.sock \
containrrr/watchtower \
--interval 21600 --cleanup true glider
```
- open udp ports(if you need nat fullcone)
```
iptables -A INPUT -p udp -m udp --dport 1024:65535 -j ACCEPT
```
</details>
## Customize Build ## Customize Build
<details><summary>You can customize and build glider if you want a smaller binary (click to see details)</summary> <details><summary>You can customize and build glider if you want a smaller binary (click to see details)</summary>
@ -425,7 +457,7 @@ Examples:
go build -v -ldflags "-s -w" go build -v -ldflags "-s -w"
``` ```
</details> </details>
## Proxy & Protocol Chains ## Proxy & Protocol Chains
<details><summary>In glider, you can easily chain several proxy servers or protocols together (click to see details)</summary> <details><summary>In glider, you can easily chain several proxy servers or protocols together (click to see details)</summary>

2
go.mod
View File

@ -9,7 +9,7 @@ require (
github.com/dgryski/go-rc2 v0.0.0-20150621095337-8a9021637152 github.com/dgryski/go-rc2 v0.0.0-20150621095337-8a9021637152
github.com/insomniacslk/dhcp v0.0.0-20220119180841-3c283ff8b7dd github.com/insomniacslk/dhcp v0.0.0-20220119180841-3c283ff8b7dd
github.com/nadoo/conflag v0.3.1 github.com/nadoo/conflag v0.3.1
github.com/nadoo/ipset v0.4.1-0.20220218075046-ca3cdce74266 github.com/nadoo/ipset v0.5.0
github.com/xtaci/kcp-go/v5 v5.6.1 github.com/xtaci/kcp-go/v5 v5.6.1
golang.org/x/crypto v0.0.0-20220313003712-b769efc7c000 golang.org/x/crypto v0.0.0-20220313003712-b769efc7c000
golang.org/x/sys v0.0.0-20220310020820-b874c991c1a5 golang.org/x/sys v0.0.0-20220310020820-b874c991c1a5

4
go.sum
View File

@ -74,8 +74,8 @@ github.com/mdlayher/socket v0.2.1/go.mod h1:QLlNPkFR88mRUNQIzRBMfXxwKal8H7u1h3bL
github.com/mmcloughlin/avo v0.0.0-20200803215136-443f81d77104/go.mod h1:wqKykBG2QzQDJEzvRkcS8x6MiSJkF52hXZsXcjaB3ls= github.com/mmcloughlin/avo v0.0.0-20200803215136-443f81d77104/go.mod h1:wqKykBG2QzQDJEzvRkcS8x6MiSJkF52hXZsXcjaB3ls=
github.com/nadoo/conflag v0.3.1 h1:4pHkLIz8PUsfg6ajNYRRSY3bt6m2LPsu6KOzn5uIXQw= github.com/nadoo/conflag v0.3.1 h1:4pHkLIz8PUsfg6ajNYRRSY3bt6m2LPsu6KOzn5uIXQw=
github.com/nadoo/conflag v0.3.1/go.mod h1:dzFfDUpXdr2uS2oV+udpy5N2vfNOu/bFzjhX1WI52co= github.com/nadoo/conflag v0.3.1/go.mod h1:dzFfDUpXdr2uS2oV+udpy5N2vfNOu/bFzjhX1WI52co=
github.com/nadoo/ipset v0.4.1-0.20220218075046-ca3cdce74266 h1:lv9VKGAyAQAyS3lQoznfWoXYJD2C8/PITORX5r7f5rk= github.com/nadoo/ipset v0.5.0 h1:5GJUAuZ7ITQQQGne5J96AmFjRtI8Avlbk6CabzYWVUc=
github.com/nadoo/ipset v0.4.1-0.20220218075046-ca3cdce74266/go.mod h1:rYF5DQLRGGoQ8ZSWeK+6eX5amAuPqwFkWjhQlEITGJQ= github.com/nadoo/ipset v0.5.0/go.mod h1:rYF5DQLRGGoQ8ZSWeK+6eX5amAuPqwFkWjhQlEITGJQ=
github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4= github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4=
github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=

View File

@ -112,3 +112,10 @@ func extractUserPass(auth string) (username, password string, ok bool) {
return s[:idx], s[idx+1:], true return s[:idx], s[idx+1:], true
} }
func init() {
proxy.AddUsage("http", `
Http scheme:
http://[user:pass@]host:port
`)
}

View File

@ -20,19 +20,21 @@ type Proxy interface {
Record(dialer Dialer, success bool) Record(dialer Dialer, success bool)
} }
var usages = make(map[string]string) var (
msg strings.Builder
usages = make(map[string]string)
)
// AddUsage adds help message for the named proxy. // AddUsage adds help message for the named proxy.
func AddUsage(name, usage string) { usages[name] = usage } func AddUsage(name, usage string) {
usages[name] = usage
msg.WriteString(usage)
msg.WriteString("\n--")
}
// Usage returns help message of the named proxy. // Usage returns help message of the named proxy.
func Usage(name string) string { func Usage(name string) string {
if name == "all" { if name == "all" {
var msg strings.Builder
for _, usage := range usages {
msg.WriteString(usage)
msg.WriteString("\n--")
}
return msg.String() return msg.String()
} }

View File

@ -189,3 +189,10 @@ func (s *SOCKS4) connect(conn net.Conn, target string) error {
return err return err
} }
func init() {
proxy.AddUsage("socks4", `
Socks4 scheme:
socks4://host:port
`)
}

View File

@ -55,6 +55,6 @@ func NewSocks5(s string, d proxy.Dialer, p proxy.Proxy) (*Socks5, error) {
func init() { func init() {
proxy.AddUsage("socks5", ` proxy.AddUsage("socks5", `
Socks5 scheme: Socks5 scheme:
socks://[user:pass@]host:port socks5://[user:pass@]host:port
`) `)
} }