From 9241320f388aa9ee69af2ba3c2c6e624cb8b3efb Mon Sep 17 00:00:00 2001 From: gVisor bot Date: Tue, 31 Jan 2023 18:05:46 +0800 Subject: [PATCH] fix: Handle error earlier in DialContextWithDialer. chore: Fix typo. --- adapter/outbound/vless.go | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/adapter/outbound/vless.go b/adapter/outbound/vless.go index a24f2a6e..a14bd528 100644 --- a/adapter/outbound/vless.go +++ b/adapter/outbound/vless.go @@ -236,12 +236,15 @@ func (v *Vless) DialContextWithDialer(ctx context.Context, dialer C.Dialer, meta }(c) c, err = v.StreamConn(c, metadata) + if err != nil { + return nil, fmt.Errorf("%s connect error: %s", v.addr, err.Error()) + } return NewConn(c, v), err } // ListenPacketContext implements C.ProxyAdapter func (v *Vless) ListenPacketContext(ctx context.Context, metadata *C.Metadata, opts ...dialer.Option) (_ C.PacketConn, err error) { - // vless use stream-oriented udp with a special address, so we needs a net.UDPAddr + // vless use stream-oriented udp with a special address, so we need a net.UDPAddr if !metadata.Resolved() { ip, err := resolver.ResolveIP(ctx, metadata.Host) if err != nil { @@ -282,7 +285,7 @@ func (v *Vless) ListenPacketContext(ctx context.Context, metadata *C.Metadata, o // ListenPacketWithDialer implements C.ProxyAdapter func (v *Vless) ListenPacketWithDialer(ctx context.Context, dialer C.Dialer, metadata *C.Metadata) (_ C.PacketConn, err error) { - // vless use stream-oriented udp with a special address, so we needs a net.UDPAddr + // vless use stream-oriented udp with a special address, so we need a net.UDPAddr if !metadata.Resolved() { ip, err := resolver.ResolveIP(ctx, metadata.Host) if err != nil {