From 1caabf84adc7e3f42827d4154973263117efc160 Mon Sep 17 00:00:00 2001 From: ginuerzh Date: Thu, 28 Nov 2019 21:21:34 +0800 Subject: [PATCH] self-defined profiling server address --- .gitignore | 1 + cmd/gost/main.go | 15 ++++++++++++--- go.mod | 2 ++ gost.go | 4 ++-- ss.go | 8 -------- 5 files changed, 17 insertions(+), 13 deletions(-) diff --git a/.gitignore b/.gitignore index fc7960b..1d6095c 100644 --- a/.gitignore +++ b/.gitignore @@ -8,6 +8,7 @@ _obj _test release debian +bin # Architecture specific extensions/prefixes *.[568vq] diff --git a/cmd/gost/main.go b/cmd/gost/main.go index a7bfad0..fd520d6 100644 --- a/cmd/gost/main.go +++ b/cmd/gost/main.go @@ -18,6 +18,8 @@ import ( var ( configureFile string baseCfg = &baseConfig{} + pprofAddr string + pprofEnabled = os.Getenv("PROFILING") != "" ) func init() { @@ -28,10 +30,13 @@ func init() { ) flag.Var(&baseCfg.route.ChainNodes, "F", "forward address, can make a forward chain") - flag.Var(&baseCfg.route.ServeNodes, "L", "listen address, can listen on multiple ports") + flag.Var(&baseCfg.route.ServeNodes, "L", "listen address, can listen on multiple ports (required)") flag.StringVar(&configureFile, "C", "", "configure file") flag.BoolVar(&baseCfg.Debug, "D", false, "enable debug log") flag.BoolVar(&printVersion, "V", false, "print version") + if pprofEnabled { + flag.StringVar(&pprofAddr, "P", ":6060", "profiling HTTP server address") + } flag.Parse() if printVersion { @@ -54,9 +59,10 @@ func init() { } func main() { - if os.Getenv("PROFILING") != "" { + if pprofEnabled { go func() { - log.Log(http.ListenAndServe("127.0.0.1:16060", nil)) + log.Log("profiling server on", pprofAddr) + log.Log(http.ListenAndServe(pprofAddr, nil)) }() } @@ -72,7 +78,10 @@ func main() { tlsConfig = &tls.Config{ Certificates: []tls.Certificate{cert}, } + } else { + log.Log("load TLS certificate files OK") } + gost.DefaultTLSConfig = tlsConfig if err := start(); err != nil { diff --git a/go.mod b/go.mod index ec10b66..08d4cca 100644 --- a/go.mod +++ b/go.mod @@ -1,5 +1,7 @@ module github.com/ginuerzh/gost +go 1.13 + require ( git.torproject.org/pluggable-transports/goptlib.git v0.0.0-20180321061416-7d56ec4f381e git.torproject.org/pluggable-transports/obfs4.git v0.0.0-20181103133120-08f4d470188e diff --git a/gost.go b/gost.go index 471945f..fca06d2 100644 --- a/gost.go +++ b/gost.go @@ -20,7 +20,7 @@ import ( ) // Version is the gost version. -const Version = "2.8.1" +const Version = "2.8.2-dev" // Debug is a flag that enables the debug log. var Debug bool @@ -76,7 +76,7 @@ var ( DefaultTLSConfig *tls.Config // DefaultUserAgent is the default HTTP User-Agent header used by HTTP and websocket. - DefaultUserAgent = "Chrome/60.0.3112.90" + DefaultUserAgent = "Chrome/78.0.3904.106" ) // SetLogger sets a new logger for internal log system. diff --git a/ss.go b/ss.go index b3fad4f..3cfe0e2 100644 --- a/ss.go +++ b/ss.go @@ -525,19 +525,11 @@ func (h *shadowUDPdHandler) transportUDP(sc net.Conn, cc net.PacketConn) error { // Due to in/out byte length is inconsistent of the shadowsocks.Conn.Write, // we wrap around it to make io.Copy happy. type shadowConn struct { - wbuf bytes.Buffer net.Conn } func (c *shadowConn) Write(b []byte) (n int, err error) { n = len(b) // force byte length consistent - - if c.wbuf.Len() > 0 { - c.wbuf.Write(b) // append the data to the cached header - _, err = c.Conn.Write(c.wbuf.Bytes()) - c.wbuf.Reset() - return - } _, err = c.Conn.Write(b) return }