feat: drop frame in kernel to take advance of happy eyeballs if outbound shoud fail

This commit is contained in:
mzz2017
2023-02-08 20:54:28 +08:00
committed by mzz
parent 5e7b68822a
commit 2ef332b018
10 changed files with 110 additions and 23 deletions

View File

@ -23,12 +23,12 @@ func (c *ControlPlane) handleConn(lConn net.Conn) (err error) {
defer lConn.Close()
src := lConn.RemoteAddr().(*net.TCPAddr).AddrPort()
dst := lConn.LocalAddr().(*net.TCPAddr).AddrPort()
outboundIndex, err := c.RetrieveOutboundIndex(src, dst, unix.IPPROTO_TCP)
outboundIndex, err := c.core.RetrieveOutboundIndex(src, dst, unix.IPPROTO_TCP)
if err != nil {
// WAN. Old method.
var value bpfIpPortOutbound
ip6 := src.Addr().As16()
if e := c.bpf.TcpDstMap.Lookup(bpfIpPort{
if e := c.core.bpf.TcpDstMap.Lookup(bpfIpPort{
Ip: common.Ipv6ByteSliceToUint32Array(ip6[:]),
Port: internal.Htons(src.Port()),
}, &value); e != nil {