mirror of
https://github.com/SagerNet/sing.git
synced 2025-04-03 03:47:38 +03:00
Fix CloseOnHandshakeFailure
This commit is contained in:
parent
809d8eca13
commit
957166799e
1 changed files with 4 additions and 6 deletions
|
@ -33,7 +33,7 @@ func ReportHandshakeFailure(reporter any, err error) error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func CloseOnHandshakeFailure(reporter any, onClose CloseHandlerFunc, err error) error {
|
func CloseOnHandshakeFailure(reporter io.Closer, onClose CloseHandlerFunc, err error) error {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if handshakeConn, isHandshakeConn := common.Cast[HandshakeFailure](reporter); isHandshakeConn {
|
if handshakeConn, isHandshakeConn := common.Cast[HandshakeFailure](reporter); isHandshakeConn {
|
||||||
hErr := handshakeConn.HandshakeFailure(err)
|
hErr := handshakeConn.HandshakeFailure(err)
|
||||||
|
@ -51,12 +51,10 @@ func CloseOnHandshakeFailure(reporter any, onClose CloseHandlerFunc, err error)
|
||||||
}](reporter); isTCPConn {
|
}](reporter); isTCPConn {
|
||||||
tcpConn.SetLinger(0)
|
tcpConn.SetLinger(0)
|
||||||
}
|
}
|
||||||
if closer, isCloser := reporter.(io.Closer); isCloser {
|
|
||||||
err = E.Append(err, closer.Close(), func(err error) error {
|
|
||||||
return E.Cause(err, "close")
|
|
||||||
})
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
err = E.Append(err, reporter.Close(), func(err error) error {
|
||||||
|
return E.Cause(err, "close")
|
||||||
|
})
|
||||||
}
|
}
|
||||||
if onClose != nil {
|
if onClose != nil {
|
||||||
onClose(err)
|
onClose(err)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue