From aa217977bf15caf3166fad2c3fbd856a80c205bd Mon Sep 17 00:00:00 2001 From: gVisor bot Date: Sun, 7 Jun 2020 16:54:41 +0800 Subject: [PATCH] Chore: code adjustments --- README.md | 5 ++++- component/trojan/trojan.go | 4 ++-- constant/metadata.go | 4 ++-- 3 files changed, 8 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index d069e87f..80c02f9c 100644 --- a/README.md +++ b/README.md @@ -81,6 +81,9 @@ port: 7890 # port of SOCKS5 socks-port: 7891 +# (HTTP and SOCKS5 in one port) +# mixed-port: 7890 + # redir port for Linux and macOS # redir-port: 7892 @@ -394,4 +397,4 @@ https://clash.gitbook.io/ - [x] Redir proxy - [x] UDP support - [x] Connection manager -- [ ] Event API +- ~~[ ] Event API~~ diff --git a/component/trojan/trojan.go b/component/trojan/trojan.go index 2ae8d07f..ef440d62 100644 --- a/component/trojan/trojan.go +++ b/component/trojan/trojan.go @@ -70,8 +70,8 @@ func (t *Trojan) StreamConn(conn net.Conn) (net.Conn, error) { func (t *Trojan) WriteHeader(w io.Writer, command Command, socks5Addr []byte) error { buf := bufPool.Get().(*bytes.Buffer) - defer buf.Reset() defer bufPool.Put(buf) + defer buf.Reset() buf.Write(t.hexPassword) buf.Write(crlf) @@ -92,8 +92,8 @@ func (t *Trojan) PacketConn(conn net.Conn) net.PacketConn { func writePacket(w io.Writer, socks5Addr, payload []byte) (int, error) { buf := bufPool.Get().(*bytes.Buffer) - defer buf.Reset() defer bufPool.Put(buf) + defer buf.Reset() buf.Write(socks5Addr) binary.Write(buf, binary.BigEndian, uint16(len(payload))) diff --git a/constant/metadata.go b/constant/metadata.go index 61ce4343..647b332d 100644 --- a/constant/metadata.go +++ b/constant/metadata.go @@ -23,8 +23,8 @@ const ( type NetWork int -func (n *NetWork) String() string { - if *n == TCP { +func (n NetWork) String() string { + if n == TCP { return "tcp" } return "udp"