style: refine control plane log print

This commit is contained in:
mzz2017
2023-02-01 13:14:22 +08:00
parent 43b39093a3
commit 832b5e4df9
4 changed files with 40 additions and 16 deletions

View File

@ -47,7 +47,8 @@ func (c *ControlPlane) handleConn(lConn net.Conn) (err error) {
}
outbound := c.outbounds[value.Outbound]
// TODO: Set-up ip to domain mapping and show domain if possible.
c.log.Infof("TCP: %v <-[%v]-> %v", lConn.RemoteAddr(), outbound.Name, dst.String())
src := lConn.RemoteAddr().(*net.TCPAddr).AddrPort()
c.log.Infof("TCP: %v <-[%v]-> %v", RefineSourceToShow(src, dst.Addr()), outbound.Name, RefineAddrPortToShow(dst))
if value.Outbound < 0 || int(value.Outbound) >= len(c.outbounds) {
return fmt.Errorf("outbound id from bpf is out of range: %v not in [0, %v]", value.Outbound, len(c.outbounds)-1)
}