Fix HandshakeFailure usages

This commit is contained in:
世界 2024-11-14 19:45:41 +08:00
parent 7f621fdd78
commit e52e04f721
No known key found for this signature in database
GPG key ID: CD109927C34A63C4
3 changed files with 10 additions and 7 deletions

View file

@ -13,10 +13,6 @@ type Dialer interface {
ListenPacket(ctx context.Context, destination M.Socksaddr) (net.PacketConn, error)
}
type PayloadDialer interface {
DialPayloadContext(ctx context.Context, network string, destination M.Socksaddr, payload [][]byte) (net.Conn, error)
}
type ParallelDialer interface {
Dialer
DialParallel(ctx context.Context, network string, destination M.Socksaddr, destinationAddresses []netip.Addr) (net.Conn, error)

View file

@ -36,7 +36,13 @@ func ReportHandshakeFailure(reporter any, err error) error {
func CloseOnHandshakeFailure(reporter any, onClose CloseHandlerFunc, err error) error {
if err != nil {
if handshakeConn, isHandshakeConn := common.Cast[HandshakeFailure](reporter); isHandshakeConn {
err = E.Append(err, handshakeConn.HandshakeFailure(err), func(err error) error {
hErr := handshakeConn.HandshakeFailure(err)
err = E.Append(err, hErr, func(err error) error {
if closer, isCloser := reporter.(io.Closer); isCloser {
err = E.Append(err, closer.Close(), func(err error) error {
return E.Cause(err, "close")
})
}
return E.Cause(err, "write handshake failure")
})
} else {