mirror of
https://github.com/MetaCubeX/mihomo.git
synced 2024-11-16 19:56:51 +08:00
chore: dns interface name
This commit is contained in:
parent
0c2014bb40
commit
bb2b64ba42
33
dns/util.go
33
dns/util.go
|
@ -152,17 +152,9 @@ func (wpc *wrapPacketConn) LocalAddr() net.Addr {
|
||||||
}
|
}
|
||||||
|
|
||||||
func dialContextExtra(ctx context.Context, adapterName string, network string, dstIP netip.Addr, port string, opts ...dialer.Option) (net.Conn, error) {
|
func dialContextExtra(ctx context.Context, adapterName string, network string, dstIP netip.Addr, port string, opts ...dialer.Option) (net.Conn, error) {
|
||||||
adapter, ok := tunnel.Proxies()[adapterName]
|
|
||||||
if !ok {
|
|
||||||
opts = append(opts, dialer.WithInterface(adapterName))
|
|
||||||
adapter, _ = tunnel.Proxies()[tunnel.Direct.String()]
|
|
||||||
}
|
|
||||||
|
|
||||||
networkType := C.TCP
|
networkType := C.TCP
|
||||||
if network == "udp" {
|
if network == "udp" {
|
||||||
if !adapter.SupportUDP() {
|
|
||||||
return nil, fmt.Errorf("proxy adapter [%s] UDP is not supported", adapterName)
|
|
||||||
}
|
|
||||||
networkType = C.UDP
|
networkType = C.UDP
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -179,6 +171,29 @@ func dialContextExtra(ctx context.Context, adapterName string, network string, d
|
||||||
DstPort: port,
|
DstPort: port,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
adapter, ok := tunnel.Proxies()[adapterName]
|
||||||
|
if !ok {
|
||||||
|
opts = append(opts, dialer.WithInterface(adapterName))
|
||||||
|
if C.TCP == networkType {
|
||||||
|
return dialer.DialContext(ctx, network, dstIP.String()+":"+port, opts...)
|
||||||
|
} else {
|
||||||
|
packetConn, err := dialer.ListenPacket(ctx, network, dstIP.String()+":"+port, opts...)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return &wrapPacketConn{
|
||||||
|
PacketConn: packetConn,
|
||||||
|
rAddr: metadata.UDPAddr(),
|
||||||
|
}, nil
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if networkType == C.UDP && !adapter.SupportUDP() {
|
||||||
|
return nil, fmt.Errorf("proxy adapter [%s] UDP is not supported", adapterName)
|
||||||
|
}
|
||||||
|
|
||||||
if networkType == C.UDP {
|
if networkType == C.UDP {
|
||||||
packetConn, err := adapter.ListenPacketContext(ctx, metadata, opts...)
|
packetConn, err := adapter.ListenPacketContext(ctx, metadata, opts...)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
Loading…
Reference in New Issue
Block a user