mirror of
https://github.com/xjasonlyu/tun2socks.git
synced 2025-10-06 01:07:03 +08:00
23 lines
508 B
Go
23 lines
508 B
Go
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{}
|
|
setControl(d)
|
|
return d.DialContext(ctx, network, address)
|
|
}
|
|
|
|
func ListenPacket(network, address string) (net.PacketConn, error) {
|
|
lc := &net.ListenConfig{}
|
|
setControl(lc)
|
|
return lc.ListenPacket(context.Background(), network, address)
|
|
}
|