mirror of
https://github.com/MetaCubeX/mihomo.git
synced 2024-11-16 11:42:43 +08:00
28 lines
743 B
Go
28 lines
743 B
Go
package dialer
|
|
|
|
import (
|
|
"context"
|
|
"net"
|
|
"syscall"
|
|
)
|
|
|
|
// SocketControl
|
|
// never change type traits because it's used in CMFA
|
|
type SocketControl func(network, address string, conn syscall.RawConn) error
|
|
|
|
// DefaultSocketHook
|
|
// never change type traits because it's used in CMFA
|
|
var DefaultSocketHook SocketControl
|
|
|
|
func socketHookToToDialer(dialer *net.Dialer) {
|
|
addControlToDialer(dialer, func(ctx context.Context, network, address string, c syscall.RawConn) error {
|
|
return DefaultSocketHook(network, address, c)
|
|
})
|
|
}
|
|
|
|
func socketHookToListenConfig(lc *net.ListenConfig) {
|
|
addControlToListenConfig(lc, func(ctx context.Context, network, address string, c syscall.RawConn) error {
|
|
return DefaultSocketHook(network, address, c)
|
|
})
|
|
}
|