fix(ss): address review findings for PR #96 — nil guards, resource leaks, dead code

- Bump go-shadowsocks2 to v0.1.3 (new API symbols)
- Return error instead of nil when Target() is empty in TCP handler
- Reset wbuf unconditionally on write error to prevent unbounded growth
- Add nil guard on targetAddr before WriteTo to prevent panic
- Remove duplicate NewClientConfig call and dead ClientConfig literal
- Remove unused noDelay metadata field
- Fix buffer-size guard to catch negative values (len(b)==0 → bufSize<=0)
- Add address context to parse/session error messages
This commit is contained in:
ginuerzh
2026-05-22 21:40:33 +08:00
parent 5433ca580c
commit 3f73c82d00
7 changed files with 19 additions and 28 deletions
+1 -4
View File
@@ -36,10 +36,7 @@ func (c *shadowConn) Write(b []byte) (n int, err error) {
c.wbuf.Write(b) // append the data to the cached header
written, err := c.Conn.Write(c.wbuf.Bytes())
if err != nil {
// If short write, keep unwritten bytes
if written > 0 && written < c.wbuf.Len() {
c.wbuf.Next(written)
}
c.wbuf.Reset()
return written, err
}
c.wbuf.Reset()