ws: fixed a bug when ws used as a middle layer protocol(tls,ws,vmess)

This commit is contained in:
nadoo 2018-08-08 00:03:32 +08:00
parent a26e437b5d
commit 2fcef7b00c
3 changed files with 17 additions and 4 deletions

View File

@ -109,19 +109,25 @@ glider -config CONFIGPATH -listen :8080 -verbose
## Usage
```bash
glider v0.6.5 usage:
glider v0.6.6 usage:
-checkduration int
proxy check duration(seconds) (default 30)
proxy check interval(seconds) (default 30)
-checkwebsite string
proxy check HTTP(NOT HTTPS) website address, format: HOST[:PORT], default port: 80 (default "www.apple.com")
-config string
config file path
-dns string
dns forwarder server listen address
-dnsmaxttl int
maximum TTL value for entries in the CACHE(seconds) (default 1800)
-dnsminttl int
minimum TTL value for entries in the CACHE(seconds)
-dnsrecord value
custom dns record, format: domain/ip
-dnsserver value
remote dns server
-dnstimeout int
timeout value used in multiple dnsservers switch(seconds) (default 3)
-forward value
forward url, format: SCHEME://[USER|METHOD:PASSWORD@][HOST]:PORT?PARAMS[,SCHEME://[USER|METHOD:PASSWORD@][HOST]:PORT?PARAMS]
-ipset string

View File

@ -91,9 +91,11 @@ func (c *Client) Exchange(reqBytes []byte, clientAddr string, preferTCP bool) ([
if answer.IP != "" {
ips = append(ips, answer.IP)
}
if answer.TTL != 0 {
ttl = int(answer.TTL)
}
}
}
if ttl > c.config.MaxTTL {
ttl = c.config.MaxTTL

View File

@ -32,6 +32,11 @@ func NewWS(s string, dialer proxy.Dialer) (*WS, error) {
addr := u.Host
// TODO:
if addr == "" {
addr = dialer.Addr()
}
colonPos := strings.LastIndex(addr, ":")
if colonPos == -1 {
colonPos = len(addr)