(ctx context.Context, network string, destination netip.Addr, port string, opt option)
| 121 | } |
| 122 | |
| 123 | func dialContext(ctx context.Context, network string, destination netip.Addr, port string, opt option) (net.Conn, error) { |
| 124 | var address string |
| 125 | destination, port = resolver.LookupIP4P(destination, port) |
| 126 | address = net.JoinHostPort(destination.String(), port) |
| 127 | |
| 128 | netDialer := opt.netDialer |
| 129 | switch netDialer.(type) { |
| 130 | case nil: |
| 131 | netDialer = &net.Dialer{} |
| 132 | case *net.Dialer: |
| 133 | _netDialer := *netDialer.(*net.Dialer) |
| 134 | netDialer = &_netDialer // make a copy |
| 135 | default: |
| 136 | return netDialer.DialContext(ctx, network, address) |
| 137 | } |
| 138 | |
| 139 | dialer := netDialer.(*net.Dialer) |
| 140 | keepalive.SetNetDialer(dialer) |
| 141 | mptcp.SetNetDialer(dialer, opt.mpTcp) |
| 142 | |
| 143 | if DefaultSocketHook != nil { // ignore interfaceName, routingMark and tfo when DefaultSocketHook not null (in CMFA) |
| 144 | socketHookToToDialer(dialer) |
| 145 | } else { |
| 146 | if opt.interfaceName == "" { |
| 147 | opt.interfaceName = DefaultInterface.Load() |
| 148 | } |
| 149 | if opt.interfaceName == "" { |
| 150 | if finder := DefaultInterfaceFinder.Load(); finder != nil { |
| 151 | opt.interfaceName = finder.FindInterfaceName(destination) |
| 152 | } |
| 153 | } |
| 154 | if opt.interfaceName != "" { |
| 155 | bind := bindIfaceToDialer |
| 156 | if opt.fallbackBind { |
| 157 | bind = fallbackBindIfaceToDialer |
| 158 | } |
| 159 | if err := bind(opt.interfaceName, dialer, network, destination); err != nil { |
| 160 | return nil, err |
| 161 | } |
| 162 | } |
| 163 | if opt.routingMark == 0 { |
| 164 | opt.routingMark = int(DefaultRoutingMark.Load()) |
| 165 | } |
| 166 | if opt.routingMark != 0 { |
| 167 | bindMarkToDialer(opt.routingMark, dialer, network, destination) |
| 168 | } |
| 169 | if opt.tfo && !DisableTFO { |
| 170 | return dialTFO(ctx, *dialer, network, address) |
| 171 | } |
| 172 | } |
| 173 | |
| 174 | return dialer.DialContext(ctx, network, address) |
| 175 | } |
| 176 | |
| 177 | func ICMPControl(destination netip.Addr) func(network, address string, conn syscall.RawConn) error { |
| 178 | return func(network, address string, conn syscall.RawConn) error { |
no test coverage detected