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

@ -50,7 +50,7 @@ DNS Forwarding Server (udp2tcp):
IPSet Management: IPSet Management:
- Add ip/cidrs from rule files on startup - Add ip/cidrs from rule files on startup
- Add resolved ips for domains from rule files by dns forwarding server - Add resolved ips for domains from rule files by dns forwarding server
General: General:
@ -109,19 +109,25 @@ glider -config CONFIGPATH -listen :8080 -verbose
## Usage ## Usage
```bash ```bash
glider v0.6.5 usage: glider v0.6.6 usage:
-checkduration int -checkduration int
proxy check duration(seconds) (default 30) proxy check interval(seconds) (default 30)
-checkwebsite string -checkwebsite string
proxy check HTTP(NOT HTTPS) website address, format: HOST[:PORT], default port: 80 (default "www.apple.com") proxy check HTTP(NOT HTTPS) website address, format: HOST[:PORT], default port: 80 (default "www.apple.com")
-config string -config string
config file path config file path
-dns string -dns string
dns forwarder server listen address 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 -dnsrecord value
custom dns record, format: domain/ip custom dns record, format: domain/ip
-dnsserver value -dnsserver value
remote dns server remote dns server
-dnstimeout int
timeout value used in multiple dnsservers switch(seconds) (default 3)
-forward value -forward value
forward url, format: SCHEME://[USER|METHOD:PASSWORD@][HOST]:PORT?PARAMS[,SCHEME://[USER|METHOD:PASSWORD@][HOST]:PORT?PARAMS] forward url, format: SCHEME://[USER|METHOD:PASSWORD@][HOST]:PORT?PARAMS[,SCHEME://[USER|METHOD:PASSWORD@][HOST]:PORT?PARAMS]
-ipset string -ipset string

View File

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

View File

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