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