chore: mix the proxy adapter and interface to dns client

This commit is contained in:
MetaCubeX
2022-06-04 21:18:49 +08:00
parent c045a4f2a7
commit 43d3a0c8ea
6 changed files with 275 additions and 18 deletions

View File

@ -168,15 +168,19 @@ func (dc *quicClient) openSession() (quic.Connection, error) {
}
} else {
conn, err := dialContextWithProxyAdapter(context.Background(), dc.proxyAdapter, "udp", ip, port)
if err != nil {
if err == errProxyNotFound {
options := []dialer.Option{dialer.WithInterface(dc.proxyAdapter), dialer.WithRoutingMark(0)}
conn, err = dialContextWithProxyAdapter(context.Background(), dc.proxyAdapter, "udp", ip, port, options...)
if err != nil {
return nil, err
}
} else {
return nil, err
}
wrapConn, ok := conn.(*wrapPacketConn)
if !ok {
return nil, fmt.Errorf("quio create packet failed")
}
udp = wrapConn
}