mirror of
https://gitclone.com/github.com/MetaCubeX/Clash.Meta
synced 2024-11-14 05:11:17 +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)
|
|
})
|
|
}
|