handle packet fowarding

This commit is contained in:
Abhishek Kondur 2022-11-21 18:27:54 +05:30
parent 669b417898
commit 1beee3ff02

View file

@ -160,13 +160,9 @@ func StartSniffer(ctx context.Context, ifaceName, ingGwAddr, extClientAddr strin
(ip.DstIP.String() == extClientAddr && ip.SrcIP.String() != ingGwAddr) {
log.Println("-----> Fowarding PKT From: ", ip.SrcIP, " to: ", ip.DstIP)
c, err := net.Dial("ip", ip.DstIP.String())
if err == nil {
c.Write(ip.Payload)
c.Close()
} else {
log.Println("------> Failed to forward packet from sniffer: ", err)
err := handle.WritePacketData(packet.Data())
if err != nil {
log.Println("----> failed to send packet data: ", err)
}
}