mirror of
https://github.com/nadoo/glider.git
synced 2025-02-23 17:35:40 +08:00
doc: update for custom dnsrecord
This commit is contained in:
parent
a226637bfb
commit
04c6f74343
22
README.md
22
README.md
@ -91,7 +91,7 @@ glider -config CONFIGPATH -listen :8080 -verbose
|
||||
|
||||
## Usage
|
||||
```bash
|
||||
glider v0.6.3 usage:
|
||||
glider v0.6.5 usage:
|
||||
-checkduration int
|
||||
proxy check duration(seconds) (default 30)
|
||||
-checkwebsite string
|
||||
@ -100,6 +100,8 @@ glider v0.6.3 usage:
|
||||
config file path
|
||||
-dns string
|
||||
dns forwarder server listen address
|
||||
-dnsrecord value
|
||||
custom dns record, format: domain/ip
|
||||
-dnsserver value
|
||||
remote dns server
|
||||
-forward value
|
||||
@ -154,7 +156,7 @@ Available securities for vmess:
|
||||
TLS scheme:
|
||||
tls://host:port[?skipVerify=true]
|
||||
|
||||
TLS with a specified proxy protocol(proxy over tls):
|
||||
TLS with a specified proxy protocol:
|
||||
tls://host:port[?skipVerify=true],scheme://
|
||||
tls://host:port[?skipVerify=true],http://[user:pass@]
|
||||
tls://host:port[?skipVerify=true],socks5://[user:pass@]
|
||||
@ -163,18 +165,25 @@ TLS with a specified proxy protocol(proxy over tls):
|
||||
Websocket scheme:
|
||||
ws://host:port[/path]
|
||||
|
||||
Websocket with a specified proxy protocol(proxy over websocket):
|
||||
Websocket with a specified proxy protocol:
|
||||
ws://host:port[/path],scheme://
|
||||
ws://host:port[/path],http://[user:pass@]
|
||||
ws://host:port[/path],socks5://[user:pass@]
|
||||
ws://host:port[/path],vmess://[security:]uuid@?alterID=num
|
||||
|
||||
TLS and Websocket with a specified proxy protocol(proxy over websocket over tls):
|
||||
TLS and Websocket with a specified proxy protocol:
|
||||
tls://host:port[?skipVerify=true],ws://[@/path],scheme://
|
||||
tls://host:port[?skipVerify=true],ws://[@/path],http://[user:pass@]
|
||||
tls://host:port[?skipVerify=true],ws://[@/path],socks5://[user:pass@]
|
||||
tls://host:port[?skipVerify=true],ws://[@/path],vmess://[security:]uuid@?alterID=num
|
||||
|
||||
DNS forwarding server:
|
||||
dns=:53
|
||||
dnsserver=8.8.8.8:53
|
||||
dnsserver=1.1.1.1:53
|
||||
dnsrecord=www.example.com/1.2.3.4
|
||||
dnsrecord=www.example.com/2606:2800:220:1:248:1893:25c8:1946
|
||||
|
||||
Available forward strategies:
|
||||
rr: Round Robin mode
|
||||
ha: High Availability mode
|
||||
@ -228,11 +237,14 @@ Examples:
|
||||
glider -listen socks5://:1080 -listen http://:8080 -forward ss://method:pass@1.1.1.1:8443
|
||||
-listen on :1080 as socks5 server, :8080 as http proxy server, forward all requests via remote ss server.
|
||||
|
||||
glider -listen redir://:1081 -dns://:53 -dnsserver://8.8.8.8:53 -forward ss://method:pass@server1:port1,ss://method:pass@server2:port2
|
||||
glider -listen redir://:1081 -dns=:53 -dnsserver=8.8.8.8:53 -forward ss://method:pass@server1:port1,ss://method:pass@server2:port2
|
||||
-listen on :1081 as transparent redirect server, :53 as dns server, use forward chain: server1 -> server2.
|
||||
|
||||
glider -listen socks5://:1080 -forward ss://method:pass@server1:port1 -forward ss://method:pass@server2:port2 -strategy rr
|
||||
-listen on :1080 as socks5 server, forward requests via server1 and server2 in round robin mode.
|
||||
|
||||
glider -verbose -dns=:53 -dnsserver=8.8.8.8:53 -dnsrecord=www.example.com/1.2.3.4
|
||||
-listen on :53 as dns server, forward dns requests to 8.8.8.8:53, return 1.2.3.4 when resolving www.example.com.
|
||||
```
|
||||
|
||||
## Advanced Usage
|
||||
|
15
conf.go
15
conf.go
@ -44,7 +44,7 @@ func confInit() {
|
||||
|
||||
flag.StringVar(&conf.DNS, "dns", "", "dns forwarder server listen address")
|
||||
flag.StringSliceUniqVar(&conf.DNSServer, "dnsserver", []string{"8.8.8.8:53"}, "remote dns server")
|
||||
flag.StringSliceUniqVar(&conf.DNSRecord, "dnsrecord", nil, "custom dns record")
|
||||
flag.StringSliceUniqVar(&conf.DNSRecord, "dnsrecord", nil, "custom dns record, format: domain/ip")
|
||||
|
||||
flag.StringVar(&conf.IPSet, "ipset", "", "ipset name")
|
||||
|
||||
@ -230,6 +230,14 @@ func usage() {
|
||||
fmt.Fprintf(os.Stderr, " tls://host:port[?skipVerify=true],ws://[@/path],vmess://[security:]uuid@?alterID=num\n")
|
||||
fmt.Fprintf(os.Stderr, "\n")
|
||||
|
||||
fmt.Fprintf(os.Stderr, "DNS forwarding server:\n")
|
||||
fmt.Fprintf(os.Stderr, " dns=:53\n")
|
||||
fmt.Fprintf(os.Stderr, " dnsserver=8.8.8.8:53\n")
|
||||
fmt.Fprintf(os.Stderr, " dnsserver=1.1.1.1:53\n")
|
||||
fmt.Fprintf(os.Stderr, " dnsrecord=www.example.com/1.2.3.4\n")
|
||||
fmt.Fprintf(os.Stderr, " dnsrecord=www.example.com/2606:2800:220:1:248:1893:25c8:1946\n")
|
||||
fmt.Fprintf(os.Stderr, "\n")
|
||||
|
||||
fmt.Fprintf(os.Stderr, "Available forward strategies:\n")
|
||||
fmt.Fprintf(os.Stderr, " rr: Round Robin mode\n")
|
||||
fmt.Fprintf(os.Stderr, " ha: High Availability mode\n")
|
||||
@ -285,10 +293,13 @@ func usage() {
|
||||
fmt.Fprintf(os.Stderr, " "+app+" -listen socks5://:1080 -listen http://:8080 -forward ss://method:pass@1.1.1.1:8443\n")
|
||||
fmt.Fprintf(os.Stderr, " -listen on :1080 as socks5 server, :8080 as http proxy server, forward all requests via remote ss server.\n")
|
||||
fmt.Fprintf(os.Stderr, "\n")
|
||||
fmt.Fprintf(os.Stderr, " "+app+" -listen redir://:1081 -dns://:53 -dnsserver://8.8.8.8:53 -forward ss://method:pass@server1:port1,ss://method:pass@server2:port2\n")
|
||||
fmt.Fprintf(os.Stderr, " "+app+" -listen redir://:1081 -dns=:53 -dnsserver=8.8.8.8:53 -forward ss://method:pass@server1:port1,ss://method:pass@server2:port2\n")
|
||||
fmt.Fprintf(os.Stderr, " -listen on :1081 as transparent redirect server, :53 as dns server, use forward chain: server1 -> server2.\n")
|
||||
fmt.Fprintf(os.Stderr, "\n")
|
||||
fmt.Fprintf(os.Stderr, " "+app+" -listen socks5://:1080 -forward ss://method:pass@server1:port1 -forward ss://method:pass@server2:port2 -strategy rr\n")
|
||||
fmt.Fprintf(os.Stderr, " -listen on :1080 as socks5 server, forward requests via server1 and server2 in round robin mode.\n")
|
||||
fmt.Fprintf(os.Stderr, "\n")
|
||||
fmt.Fprintf(os.Stderr, " "+app+" -verbose -dns=:53 -dnsserver=8.8.8.8:53 -dnsrecord=www.example.com/1.2.3.4\n")
|
||||
fmt.Fprintf(os.Stderr, " -listen on :53 as dns server, forward dns requests to 8.8.8.8:53, return 1.2.3.4 when resolving www.example.com.\n")
|
||||
fmt.Fprintf(os.Stderr, "\n")
|
||||
}
|
||||
|
@ -125,6 +125,10 @@ checkduration=30
|
||||
dns=:53
|
||||
# global remote dns server (you can specify different dns server in rule file)
|
||||
dnsserver=8.8.8.8:53
|
||||
dnsserver=1.1.1.1:53
|
||||
# custom records
|
||||
dnsrecord=www.example.com/1.2.3.4
|
||||
dnsrecord=www.example.com/2606:2800:220:1:248:1893:25c8:1946
|
||||
|
||||
|
||||
# IPSET MANAGEMENT
|
||||
|
@ -97,7 +97,7 @@ func (c *Client) Exchange(reqBytes []byte, clientAddr string) ([]byte, error) {
|
||||
return respBytes, err
|
||||
}
|
||||
|
||||
ttl := 0
|
||||
ttl := DefaultTTL
|
||||
ips := []string{}
|
||||
for _, answer := range resp.Answers {
|
||||
if answer.TYPE == QTypeA || answer.TYPE == QTypeAAAA {
|
||||
@ -109,14 +109,12 @@ func (c *Client) Exchange(reqBytes []byte, clientAddr string) ([]byte, error) {
|
||||
ips = append(ips, answer.IP)
|
||||
}
|
||||
|
||||
if answer.TTL != 0 {
|
||||
ttl = int(answer.TTL)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// if ttl in packet is 0, set it to default value
|
||||
if ttl == 0 {
|
||||
ttl = DefaultTTL
|
||||
}
|
||||
|
||||
// add to cache
|
||||
|
Loading…
Reference in New Issue
Block a user