mirror of
https://github.com/daeuniverse/dae.git
synced 2025-07-16 10:50:01 +07:00
Use bpf_sk_assign at tproxy_wan_ingress (#383)
This commit is contained in:
@ -44,36 +44,8 @@ func (c *ControlPlane) handleConn(lConn net.Conn) (err error) {
|
||||
dst := lConn.LocalAddr().(*net.TCPAddr).AddrPort()
|
||||
routingResult, err := c.core.RetrieveRoutingResult(src, dst, unix.IPPROTO_TCP)
|
||||
if err != nil {
|
||||
// WAN. Old method.
|
||||
var value bpfDstRoutingResult
|
||||
ip6 := src.Addr().As16()
|
||||
if e := c.core.bpf.TcpDstMap.Lookup(bpfIpPort{
|
||||
Ip: struct{ U6Addr8 [16]uint8 }{U6Addr8: ip6},
|
||||
Port: common.Htons(src.Port()),
|
||||
}, &value); e != nil {
|
||||
if c.tproxyPortProtect {
|
||||
return fmt.Errorf("failed to retrieve target info %v: %v, %v", src.String(), err, e)
|
||||
} else {
|
||||
routingResult = &bpfRoutingResult{
|
||||
Mark: 0,
|
||||
Must: 0,
|
||||
Mac: [6]uint8{},
|
||||
Outbound: uint8(consts.OutboundControlPlaneRouting),
|
||||
Pname: [16]uint8{},
|
||||
Pid: 0,
|
||||
}
|
||||
goto destRetrieved
|
||||
}
|
||||
}
|
||||
routingResult = &value.RoutingResult
|
||||
|
||||
dstAddr, ok := netip.AddrFromSlice(common.Ipv6Uint32ArrayToByteSlice(value.Ip))
|
||||
if !ok {
|
||||
return fmt.Errorf("failed to parse dest ip: %v", value.Ip)
|
||||
}
|
||||
dst = netip.AddrPortFrom(dstAddr, common.Htons(value.Port))
|
||||
return fmt.Errorf("failed to retrieve target info %v: %v", dst.String(), err)
|
||||
}
|
||||
destRetrieved:
|
||||
src = common.ConvergeAddrPort(src)
|
||||
dst = common.ConvergeAddrPort(dst)
|
||||
|
||||
|
Reference in New Issue
Block a user