Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit ef3d7e4

Browse files
committed
chore: remove unneeded dns resolve when proxydialer dial udp
1 parent a1c7881 commit ef3d7e4

File tree

1 file changed

+6
-9
lines changed

1 file changed

+6
-9
lines changed

component/proxydialer/proxydialer.go

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,13 @@ package proxydialer
22

33
import (
44
"context"
5-
"errors"
65
"fmt"
76
"net"
87
"net/netip"
98
"strings"
109

1110
N "github.com/metacubex/mihomo/common/net"
1211
"github.com/metacubex/mihomo/component/dialer"
13-
"github.com/metacubex/mihomo/component/resolver"
1412
C "github.com/metacubex/mihomo/constant"
1513
"github.com/metacubex/mihomo/tunnel"
1614
"github.com/metacubex/mihomo/tunnel/statistic"
@@ -40,17 +38,16 @@ func (p proxyDialer) DialContext(ctx context.Context, network, address string) (
4038
return nil, err
4139
}
4240
if strings.Contains(network, "udp") { // using in wireguard outbound
43-
if !currentMeta.Resolved() {
44-
ip, err := resolver.ResolveIP(ctx, currentMeta.Host)
45-
if err != nil {
46-
return nil, errors.New("can't resolve ip")
47-
}
48-
currentMeta.DstIP = ip
49-
}
5041
pc, err := p.listenPacket(ctx, currentMeta)
5142
if err != nil {
5243
return nil, err
5344
}
45+
if !currentMeta.Resolved() { // should not happen, maybe by a wrongly implemented proxy, but we can handle this (:
46+
err = pc.ResolveUDP(ctx, currentMeta)
47+
if err != nil {
48+
return nil, err
49+
}
50+
}
5451
return N.NewBindPacketConn(pc, currentMeta.UDPAddr()), nil
5552
}
5653
var conn C.Conn

0 commit comments

Comments
 (0)