fix: some safeConnClose forget using original

This commit is contained in:
wwqgtxx 2022-12-22 12:31:45 +08:00
parent 980454beb2
commit daf0b23805
3 changed files with 16 additions and 16 deletions

View file

@ -153,9 +153,9 @@ func (t *Trojan) ListenPacketContext(ctx context.Context, metadata *C.Metadata,
if err != nil { if err != nil {
return nil, fmt.Errorf("%s connect error: %w", t.addr, err) return nil, fmt.Errorf("%s connect error: %w", t.addr, err)
} }
defer func() { defer func(c net.Conn) {
safeConnClose(c, err) safeConnClose(c, err)
}() }(c)
err = t.instance.WriteHeader(c, trojan.CommandUDP, serializesSocksAddr(metadata)) err = t.instance.WriteHeader(c, trojan.CommandUDP, serializesSocksAddr(metadata))
if err != nil { if err != nil {
return nil, err return nil, err
@ -173,9 +173,9 @@ func (t *Trojan) ListenPacketWithDialer(ctx context.Context, dialer C.Dialer, me
if err != nil { if err != nil {
return nil, fmt.Errorf("%s connect error: %w", t.addr, err) return nil, fmt.Errorf("%s connect error: %w", t.addr, err)
} }
defer func() { defer func(c net.Conn) {
safeConnClose(c, err) safeConnClose(c, err)
}() }(c)
tcpKeepAlive(c) tcpKeepAlive(c)
c, err = t.plainStream(c) c, err = t.plainStream(c)
if err != nil { if err != nil {

View file

@ -208,9 +208,9 @@ func (v *Vless) DialContext(ctx context.Context, metadata *C.Metadata, opts ...d
if err != nil { if err != nil {
return nil, err return nil, err
} }
defer func() { defer func(c net.Conn) {
safeConnClose(c, err) safeConnClose(c, err)
}() }(c)
c, err = v.client.StreamConn(c, parseVlessAddr(metadata)) c, err = v.client.StreamConn(c, parseVlessAddr(metadata))
if err != nil { if err != nil {
@ -255,9 +255,9 @@ func (v *Vless) ListenPacketContext(ctx context.Context, metadata *C.Metadata, o
if err != nil { if err != nil {
return nil, err return nil, err
} }
defer func() { defer func(c net.Conn) {
safeConnClose(c, err) safeConnClose(c, err)
}() }(c)
c, err = v.client.StreamConn(c, parseVlessAddr(metadata)) c, err = v.client.StreamConn(c, parseVlessAddr(metadata))
@ -285,9 +285,9 @@ func (v *Vless) ListenPacketWithDialer(ctx context.Context, dialer C.Dialer, met
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)

View file

@ -221,9 +221,9 @@ func (v *Vmess) DialContext(ctx context.Context, metadata *C.Metadata, opts ...d
if err != nil { if err != nil {
return nil, err return nil, err
} }
defer func() { defer func(c net.Conn) {
safeConnClose(c, err) safeConnClose(c, err)
}() }(c)
c, err = v.client.DialConn(c, M.ParseSocksaddr(metadata.RemoteAddress())) c, err = v.client.DialConn(c, M.ParseSocksaddr(metadata.RemoteAddress()))
if err != nil { if err != nil {
@ -275,9 +275,9 @@ func (v *Vmess) ListenPacketContext(ctx context.Context, metadata *C.Metadata, o
if err != nil { if err != nil {
return nil, err return nil, err
} }
defer func() { defer func(c net.Conn) {
safeConnClose(c, err) safeConnClose(c, err)
}() }(c)
if v.option.XUDP { if v.option.XUDP {
c, err = v.client.DialXUDPPacketConn(c, M.ParseSocksaddr(metadata.RemoteAddress())) c, err = v.client.DialXUDPPacketConn(c, M.ParseSocksaddr(metadata.RemoteAddress()))
@ -295,9 +295,9 @@ func (v *Vmess) ListenPacketContext(ctx context.Context, metadata *C.Metadata, o
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 v.ListenPacketWithDialer(ctx, dialer.NewDialer(v.Base.DialOptions(opts...)...), metadata) return v.ListenPacketWithDialer(ctx, dialer.NewDialer(v.Base.DialOptions(opts...)...), metadata)