fix: should check index before finding outbound

This commit is contained in:
mzz2017 2023-03-16 22:32:48 +08:00
parent 160e17f6e7
commit 94f56fcccb

View File

@ -86,11 +86,11 @@ func (c *ControlPlane) handleConn(lConn net.Conn) (err error) {
}
default:
}
outbound := c.outbounds[outboundIndex]
// TODO: Set-up ip to domain mapping and show domain if possible.
if outboundIndex < 0 || int(outboundIndex) >= len(c.outbounds) {
return fmt.Errorf("outbound id from bpf is out of range: %v not in [0, %v]", outboundIndex, len(c.outbounds)-1)
}
outbound := c.outbounds[outboundIndex]
networkType := &dialer.NetworkType{
L4Proto: consts.L4ProtoStr_TCP,
IpVersion: consts.IpVersionFromAddr(dst.Addr()),