chore: better safeConnClose

This commit is contained in:
gVisor bot 2022-12-16 22:15:44 +08:00
parent cad40326f3
commit 78a2dbd9d8
8 changed files with 18 additions and 18 deletions

View file

@ -67,9 +67,9 @@ func (h *Http) DialContext(ctx context.Context, metadata *C.Metadata, opts ...di
} }
tcpKeepAlive(c) tcpKeepAlive(c)
defer func() { defer func(c net.Conn) {
safeConnClose(c, err) safeConnClose(c, err)
}() }(c)
c, err = h.StreamConn(c, metadata) c, err = h.StreamConn(c, metadata)
if err != nil { if err != nil {

View file

@ -90,9 +90,9 @@ func (ss *ShadowSocks) DialContext(ctx context.Context, metadata *C.Metadata, op
} }
tcpKeepAlive(c) tcpKeepAlive(c)
defer func() { defer func(c net.Conn) {
safeConnClose(c, err) safeConnClose(c, err)
}() }(c)
c, err = ss.StreamConn(c, metadata) c, err = ss.StreamConn(c, metadata)
return NewConn(c, ss), err return NewConn(c, ss), err

View file

@ -66,9 +66,9 @@ func (ssr *ShadowSocksR) DialContext(ctx context.Context, metadata *C.Metadata,
} }
tcpKeepAlive(c) tcpKeepAlive(c)
defer func() { defer func(c net.Conn) {
safeConnClose(c, err) safeConnClose(c, err)
}() }(c)
c, err = ssr.StreamConn(c, metadata) c, err = ssr.StreamConn(c, metadata)
return NewConn(c, ssr), err return NewConn(c, ssr), err

View file

@ -84,9 +84,9 @@ func (s *Snell) DialContext(ctx context.Context, metadata *C.Metadata, opts ...d
} }
tcpKeepAlive(c) tcpKeepAlive(c)
defer func() { defer func(c net.Conn) {
safeConnClose(c, err) safeConnClose(c, err)
}() }(c)
c, err = s.StreamConn(c, metadata) c, err = s.StreamConn(c, metadata)
return NewConn(c, s), err return NewConn(c, s), err

View file

@ -71,9 +71,9 @@ func (ss *Socks5) DialContext(ctx context.Context, metadata *C.Metadata, opts ..
} }
tcpKeepAlive(c) tcpKeepAlive(c)
defer func() { defer func(c net.Conn) {
safeConnClose(c, err) safeConnClose(c, err)
}() }(c)
c, err = ss.StreamConn(c, metadata) c, err = ss.StreamConn(c, metadata)
if err != nil { if err != nil {
@ -99,9 +99,9 @@ func (ss *Socks5) ListenPacketContext(ctx context.Context, metadata *C.Metadata,
c = cc c = cc
} }
defer func() { defer func(c net.Conn) {
safeConnClose(c, err) safeConnClose(c, err)
}() }(c)
tcpKeepAlive(c) tcpKeepAlive(c)
var user *socks5.User var user *socks5.User

View file

@ -127,9 +127,9 @@ func (t *Trojan) DialContext(ctx context.Context, metadata *C.Metadata, opts ...
} }
tcpKeepAlive(c) tcpKeepAlive(c)
defer func() { defer func(c net.Conn) {
safeConnClose(c, err) safeConnClose(c, err)
}() }(c)
c, err = t.StreamConn(c, metadata) c, err = t.StreamConn(c, metadata)
if err != nil { if err != nil {

View file

@ -225,9 +225,9 @@ func (v *Vless) DialContext(ctx context.Context, metadata *C.Metadata, opts ...d
return nil, fmt.Errorf("%s connect error: %s", v.addr, err.Error()) return nil, fmt.Errorf("%s connect error: %s", v.addr, err.Error())
} }
tcpKeepAlive(c) tcpKeepAlive(c)
defer func() { defer func(c net.Conn) {
safeConnClose(c, err) safeConnClose(c, err)
}() }(c)
c, err = v.StreamConn(c, metadata) c, err = v.StreamConn(c, metadata)
return NewConn(c, v), err return NewConn(c, v), err

View file

@ -238,9 +238,9 @@ func (v *Vmess) DialContext(ctx context.Context, metadata *C.Metadata, opts ...d
return nil, fmt.Errorf("%s connect error: %s", v.addr, err.Error()) return nil, fmt.Errorf("%s connect error: %s", v.addr, err.Error())
} }
tcpKeepAlive(c) tcpKeepAlive(c)
defer func() { defer func(c net.Conn) {
safeConnClose(c, err) safeConnClose(c, err)
}() }(c)
c, err = v.StreamConn(c, metadata) c, err = v.StreamConn(c, metadata)
return NewConn(c, v), err return NewConn(c, v), err