Fix close conn

This commit is contained in:
世界 2022-08-18 23:14:32 +08:00
parent 484a11603b
commit 7cbd7d6346
No known key found for this signature in database
GPG key ID: CD109927C34A63C4
4 changed files with 31 additions and 13 deletions

25
Makefile Normal file
View file

@ -0,0 +1,25 @@
.PHONY: test
fmt:
@gofumpt -l -w .
@gofmt -s -w .
@gci write -s "standard,prefix(github.com/sagernet/),default" .
fmt_install:
go install -v mvdan.cc/gofumpt@latest
go install -v github.com/daixiang0/gci@v0.4.0
lint:
GOOS=linux golangci-lint run ./...
GOOS=windows golangci-lint run ./...
GOOS=darwin golangci-lint run ./...
GOOS=freebsd golangci-lint run ./...
lint_install:
go install github.com/golangci/golangci-lint/cmd/golangci-lint@latest
test:
@go test -v . && \
pushd test && \
go test -v . && \
popd

View file

@ -1,7 +0,0 @@
package shadowsocks
//go:generate go install -v mvdan.cc/gofumpt@latest
//go:generate go install -v github.com/daixiang0/gci@v0.4.0
//go:generate gofumpt -l -w .
//go:generate gofmt -s -w .
//go:generate gci write -s "standard,prefix(github.com/sagernet/),default" .

View file

@ -222,7 +222,7 @@ type clientConn struct {
net.Conn
destination M.Socksaddr
requestSalt []byte
reader io.Reader
reader *shadowaead.Reader
writer *shadowaead.Writer
}
@ -485,8 +485,8 @@ func (c *clientConn) Upstream() any {
func (c *clientConn) Close() error {
return common.Close(
c.Conn,
c.reader,
c.writer,
common.PtrOrNil(c.reader),
common.PtrOrNil(c.writer),
)
}

View file

@ -239,7 +239,7 @@ type serverConn struct {
uPSK []byte
access sync.Mutex
headerType byte
reader io.Reader
reader *shadowaead.Reader
writer *shadowaead.Writer
requestSalt []byte
}
@ -369,8 +369,8 @@ func (c *serverConn) WriteTo(w io.Writer) (n int64, err error) {
func (c *serverConn) Close() error {
return common.Close(
c.Conn,
c.reader,
c.writer,
common.PtrOrNil(c.reader),
common.PtrOrNil(c.writer),
)
}