diff --git a/README.md b/README.md index b4e4574..2025004 100644 --- a/README.md +++ b/README.md @@ -91,7 +91,7 @@ glider -config CONFIGPATH -listen :8080 -verbose ## Usage ```bash -glider v0.5.3 usage: +glider v0.5.2 usage: -checkduration int proxy check duration(seconds) (default 30) -checkwebsite string @@ -175,7 +175,7 @@ Examples: glider -listen redir://:1081 -forward ss://method:pass@1.1.1.1:8443 -listen on :1081 as a transparent redirect server, forward all requests via remote ss server. - glider -listen redir://:1081 -forward ssr://method:pass@1.1.1.1:8444?protocol=a&protocol_param=b&obfs=c&obfs_param=d + glider -listen redir://:1081 -forward "ssr://method:pass@1.1.1.1:8444?protocol=a&protocol_param=b&obfs=c&obfs_param=d" -listen on :1081 as a transparent redirect server, forward all requests via remote ssr server. glider -listen tcptun://:80=2.2.2.2:80 -forward ss://method:pass@1.1.1.1:8443 diff --git a/conf.go b/conf.go index 7e55cb2..fcd6bd9 100644 --- a/conf.go +++ b/conf.go @@ -200,7 +200,7 @@ func usage() { fmt.Fprintf(os.Stderr, " "+app+" -listen redir://:1081 -forward ss://method:pass@1.1.1.1:8443\n") fmt.Fprintf(os.Stderr, " -listen on :1081 as a transparent redirect server, forward all requests via remote ss server.\n") fmt.Fprintf(os.Stderr, "\n") - fmt.Fprintf(os.Stderr, " "+app+" -listen redir://:1081 -forward ssr://method:pass@1.1.1.1:8444?protocol=a&protocol_param=b&obfs=c&obfs_param=d\n") + fmt.Fprintf(os.Stderr, " "+app+" -listen redir://:1081 -forward \"ssr://method:pass@1.1.1.1:8444?protocol=a&protocol_param=b&obfs=c&obfs_param=d\"\n") fmt.Fprintf(os.Stderr, " -listen on :1081 as a transparent redirect server, forward all requests via remote ssr server.\n") fmt.Fprintf(os.Stderr, "\n") fmt.Fprintf(os.Stderr, " "+app+" -listen tcptun://:80=2.2.2.2:80 -forward ss://method:pass@1.1.1.1:8443\n") diff --git a/config/README.md b/config/README.md index cc110f1..89da5d8 100644 --- a/config/README.md +++ b/config/README.md @@ -39,7 +39,7 @@ checkduration=30 # Setup a dns forwarding server -dns://53 +dns=:53 # global remote dns server (you can specify different dns server in rule file) dnsserver=8.8.8.8:53 diff --git a/http.go b/http.go index aebc5df..69fedd7 100644 --- a/http.go +++ b/http.go @@ -118,7 +118,7 @@ func (s *HTTP) Serve(c net.Conn) { url, err := url.ParseRequestURI(requestURI) if err != nil { - logf("parse request url error: %s", err) + logf("proxy-http parse request url error: %s", err) return } @@ -150,9 +150,11 @@ func (s *HTTP) Serve(c net.Conn) { // copy the left request bytes to remote server. eg. length specificed or chunked body. go func() { - io.Copy(rc, reqR) - rc.SetDeadline(time.Now()) - c.SetDeadline(time.Now()) + if _, err := reqR.Peek(1); err == nil { + io.Copy(rc, reqR) + rc.SetDeadline(time.Now()) + c.SetDeadline(time.Now()) + } }() respR := bufio.NewReader(rc) @@ -197,7 +199,7 @@ func (s *HTTP) servHTTPS(method, requestURI, proto string, c net.Conn) { c.Write([]byte("HTTP/1.0 200 Connection established\r\n\r\n")) - logf("proxy-http %s <-> %s [connect]", c.RemoteAddr(), requestURI) + logf("proxy-http %s <-> %s [c]", c.RemoteAddr(), requestURI) _, _, err = relay(c, rc) if err != nil { diff --git a/main.go b/main.go index 3a5ec29..5c80aea 100644 --- a/main.go +++ b/main.go @@ -9,7 +9,7 @@ import ( ) // VERSION . -const VERSION = "0.5.3" +const VERSION = "0.5.2" func dialerFromConf() Dialer { // global forwarders in xx.conf diff --git a/ss.go b/ss.go index 08788fb..c65f90f 100644 --- a/ss.go +++ b/ss.go @@ -25,7 +25,7 @@ type SS struct { func NewSS(addr, method, pass string, dialer Dialer) (*SS, error) { ciph, err := core.PickCipher(method, nil, pass) if err != nil { - log.Fatalf("PickCipher for '%s', error: %s", method, err) + log.Fatalf("proxy-ss PickCipher for '%s', error: %s", method, err) } s := &SS{ diff --git a/ssr.go b/ssr.go index 991d082..8fc369e 100644 --- a/ssr.go +++ b/ssr.go @@ -92,6 +92,10 @@ func (s *SSR) Dial(network, addr string) (net.Conn, error) { port, _ := strconv.Atoi(rs[1]) ssrconn.IObfs = obfs.NewObfs(s.Obfs) + if ssrconn.IObfs == nil { + return nil, errors.New("proxy-ssr unsupported obfs type: " + s.Obfs) + } + obfsServerInfo := &ssr.ServerInfoForObfs{ Host: rs[0], Port: uint16(port), @@ -99,7 +103,12 @@ func (s *SSR) Dial(network, addr string) (net.Conn, error) { Param: s.ObfsParam, } ssrconn.IObfs.SetServerInfo(obfsServerInfo) + ssrconn.IProtocol = protocol.NewProtocol(s.Protocol) + if ssrconn.IProtocol == nil { + return nil, errors.New("proxy-ssr unsupported protocol type: " + s.Protocol) + } + protocolServerInfo := &ssr.ServerInfoForObfs{ Host: rs[0], Port: uint16(port),