mihomo/component/dialer/socket_hook.go

28 lines
743 B
Go
Raw Normal View History

2024-08-14 13:01:06 +08:00
package dialer
import (
"context"
"net"
"syscall"
)
// SocketControl
2024-09-09 09:08:24 +08:00
// never change type traits because it's used in CMFA
2024-08-14 13:01:06 +08:00
type SocketControl func(network, address string, conn syscall.RawConn) error
// DefaultSocketHook
2024-09-09 09:08:24 +08:00
// never change type traits because it's used in CMFA
2024-08-14 13:01:06 +08:00
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)
})
}