Files
tun2socks/component/dialer/dialer.go
xjasonlyu 90d7d2dfe6 Refactor
2021-02-05 20:02:29 +08:00

31 lines
606 B
Go
Executable File

package dialer
import (
"context"
"net"
)
func Dial(network, address string) (net.Conn, error) {
return DialContext(context.Background(), network, address)
}
func DialContext(ctx context.Context, network, address string) (net.Conn, error) {
d := &net.Dialer{}
if _boundInterface != nil {
d.Control = bindToInterface
}
return d.DialContext(ctx, network, address)
}
func ListenPacket(network, address string) (net.PacketConn, error) {
lc := &net.ListenConfig{}
if _boundInterface != nil {
lc.Control = bindToInterface
}
return lc.ListenPacket(context.Background(), network, address)
}