mirror of
https://github.com/nadoo/glider.git
synced 2025-02-23 17:35:40 +08:00
ws: use default port if not specified
This commit is contained in:
parent
53fe94251f
commit
879e736f01
@ -321,7 +321,7 @@ Examples:
|
|||||||
./glider -listen :8443 -verbose
|
./glider -listen :8443 -verbose
|
||||||
-listen on :8443, serve as http/socks5 proxy on the same port, in verbose mode.
|
-listen on :8443, serve as http/socks5 proxy on the same port, in verbose mode.
|
||||||
|
|
||||||
./glider -listen ss://AEAD_CHACHA20_POLY1305:pass@:8443 -verbose
|
./glider -listen ss://AEAD_AES_128_GCM:pass@:8443 -verbose
|
||||||
-listen on 0.0.0.0:8443 as a ss server.
|
-listen on 0.0.0.0:8443 as a ss server.
|
||||||
|
|
||||||
./glider -listen tls://:443?cert=crtFilePath&key=keyFilePath,http:// -verbose
|
./glider -listen tls://:443?cert=crtFilePath&key=keyFilePath,http:// -verbose
|
||||||
|
@ -301,7 +301,7 @@ func usage() {
|
|||||||
fmt.Fprintf(w, " "+app+" -listen :8443 -verbose\n")
|
fmt.Fprintf(w, " "+app+" -listen :8443 -verbose\n")
|
||||||
fmt.Fprintf(w, " -listen on :8443, serve as http/socks5 proxy on the same port, in verbose mode.\n")
|
fmt.Fprintf(w, " -listen on :8443, serve as http/socks5 proxy on the same port, in verbose mode.\n")
|
||||||
fmt.Fprintf(w, "\n")
|
fmt.Fprintf(w, "\n")
|
||||||
fmt.Fprintf(w, " "+app+" -listen ss://AEAD_CHACHA20_POLY1305:pass@:8443 -verbose\n")
|
fmt.Fprintf(w, " "+app+" -listen ss://AEAD_AES_128_GCM:pass@:8443 -verbose\n")
|
||||||
fmt.Fprintf(w, " -listen on 0.0.0.0:8443 as a ss server.\n")
|
fmt.Fprintf(w, " -listen on 0.0.0.0:8443 as a ss server.\n")
|
||||||
fmt.Fprintf(w, "\n")
|
fmt.Fprintf(w, "\n")
|
||||||
fmt.Fprintf(w, " "+app+" -listen tls://:443?cert=crtFilePath&key=keyFilePath,http:// -verbose\n")
|
fmt.Fprintf(w, " "+app+" -listen tls://:443?cert=crtFilePath&key=keyFilePath,http:// -verbose\n")
|
||||||
|
@ -120,8 +120,8 @@ func (c *Client) handleAnswer(respBytes []byte, clientAddr, dnsServer, network,
|
|||||||
}
|
}
|
||||||
|
|
||||||
c.cache.Set(qKey(resp.Question), valCopy(respBytes), ttl)
|
c.cache.Set(qKey(resp.Question), valCopy(respBytes), ttl)
|
||||||
log.F("[dns] %s <-> %s(%s) via %s, %s/%d: %d %s",
|
log.F("[dns] %s <-> %s(%s) via %s, %s/%d: %s, %ds",
|
||||||
clientAddr, dnsServer, network, dialerAddr, resp.Question.QNAME, resp.Question.QTYPE, ttl, strings.Join(ips, ","))
|
clientAddr, dnsServer, network, dialerAddr, resp.Question.QNAME, resp.Question.QTYPE, strings.Join(ips, ","), ttl)
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
@ -73,7 +73,6 @@ func NewTLSDialer(s string, d proxy.Dialer) (proxy.Dialer, error) {
|
|||||||
p.config = &stdtls.Config{
|
p.config = &stdtls.Config{
|
||||||
ServerName: p.serverName,
|
ServerName: p.serverName,
|
||||||
InsecureSkipVerify: p.skipVerify,
|
InsecureSkipVerify: p.skipVerify,
|
||||||
ClientSessionCache: stdtls.NewLRUClientSessionCache(64),
|
|
||||||
MinVersion: stdtls.VersionTLS12,
|
MinVersion: stdtls.VersionTLS12,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -34,7 +34,6 @@ func NewTrojanDialer(s string, d proxy.Dialer) (proxy.Dialer, error) {
|
|||||||
ServerName: t.serverName,
|
ServerName: t.serverName,
|
||||||
InsecureSkipVerify: t.skipVerify,
|
InsecureSkipVerify: t.skipVerify,
|
||||||
NextProtos: []string{"http/1.1"},
|
NextProtos: []string{"http/1.1"},
|
||||||
ClientSessionCache: tls.NewLRUClientSessionCache(64),
|
|
||||||
MinVersion: tls.VersionTLS12,
|
MinVersion: tls.VersionTLS12,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -4,6 +4,7 @@ import (
|
|||||||
"crypto/rand"
|
"crypto/rand"
|
||||||
"crypto/sha1"
|
"crypto/sha1"
|
||||||
"encoding/base64"
|
"encoding/base64"
|
||||||
|
"net"
|
||||||
"net/url"
|
"net/url"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
@ -35,17 +36,22 @@ func NewWS(s string, d proxy.Dialer, p proxy.Proxy) (*WS, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
addr := u.Host
|
addr := u.Host
|
||||||
if addr == "" && d != nil {
|
if addr != "" {
|
||||||
|
if _, port, _ := net.SplitHostPort(addr); port == "" {
|
||||||
|
addr = net.JoinHostPort(addr, "80")
|
||||||
|
}
|
||||||
|
} else if d != nil {
|
||||||
addr = d.Addr()
|
addr = d.Addr()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
query := u.Query()
|
||||||
w := &WS{
|
w := &WS{
|
||||||
dialer: d,
|
dialer: d,
|
||||||
proxy: p,
|
proxy: p,
|
||||||
addr: addr,
|
addr: addr,
|
||||||
host: u.Query().Get("host"),
|
|
||||||
path: u.Path,
|
path: u.Path,
|
||||||
origin: u.Query().Get("origin"),
|
host: query.Get("host"),
|
||||||
|
origin: query.Get("origin"),
|
||||||
}
|
}
|
||||||
|
|
||||||
if w.host == "" {
|
if w.host == "" {
|
||||||
|
Loading…
Reference in New Issue
Block a user