This commit is contained in:
crusader 2018-09-05 11:17:43 +09:00
parent 3135a11708
commit 6161d7fade

View File

@ -1,8 +1,6 @@
package pcap
import (
"log"
"github.com/google/gopacket"
"github.com/google/gopacket/layers"
)
@ -77,11 +75,12 @@ func handlePacketARP(ps *pCapScan, packet gopacket.Packet) {
arp := arpLayer.(*layers.ARP)
for _, ch := range ps.arpListenerChans {
select {
case ch <- arp:
default:
log.Print("handlePacketARP cannot send to channel")
}
ch <- arp
// select {
// case ch <- arp:
// default:
// log.Print("handlePacketARP cannot send to channel")
// }
}
}
@ -93,11 +92,12 @@ func handlePacketICMP4(ps *pCapScan, packet gopacket.Packet) {
// icmp4 := icmp4Layer.(*layers.ICMPv4)
for _, ch := range ps.icmp4ListenerChans {
select {
case ch <- packet:
default:
log.Print("handlePacketICMP4 cannot send to channel")
}
ch <- packet
// select {
// case ch <- packet:
// default:
// log.Print("handlePacketICMP4 cannot send to channel")
// }
}
}
@ -109,11 +109,12 @@ func handlePacketICMP6(ps *pCapScan, packet gopacket.Packet) {
// icmp6 := icmp6Layer.(*layers.ICMPv6)
for _, ch := range ps.icmp6ListenerChans {
select {
case ch <- packet:
default:
log.Print("handlePacketICMP6 cannot send to channel")
}
ch <- packet
// select {
// case ch <- packet:
// default:
// log.Print("handlePacketICMP6 cannot send to channel")
// }
}
}
@ -135,11 +136,12 @@ func handlePacketTCP(ps *pCapScan, packet gopacket.Packet) {
chs, ok := ps.tcpListenerChans[ip]
if ok {
for _, ch := range chs {
select {
case ch <- tcp:
default:
log.Print("handlePacketTCP cannot send to channel")
}
ch <- tcp
// select {
// case ch <- tcp:
// default:
// log.Print("handlePacketTCP cannot send to channel")
// }
}
}
}
@ -158,11 +160,12 @@ func handlePacketUDP(ps *pCapScan, packet gopacket.Packet) {
chs, ok := ps.udpListenerChans[ip]
if ok {
for _, ch := range chs {
select {
case ch <- packet:
default:
log.Print("handlePacketUDP cannot send to channel")
}
ch <- packet
// select {
// case ch <- packet:
// default:
// log.Print("handlePacketUDP cannot send to channel")
// }
}
}
}