ing
This commit is contained in:
parent
6653ea4a87
commit
4f409f59f3
|
@ -2,7 +2,6 @@ package pcap
|
|||
|
||||
import (
|
||||
"fmt"
|
||||
"sort"
|
||||
"sync"
|
||||
|
||||
omd "git.loafle.net/overflow/model/discovery"
|
||||
|
@ -123,13 +122,12 @@ func (ps *pCapScan) CloseARP(ch chan *layers.ARP) {
|
|||
ps.arpListenerChanMtx.Lock()
|
||||
defer ps.arpListenerChanMtx.Unlock()
|
||||
|
||||
i := sort.Search(len(ps.arpListenerChans), func(i int) bool {
|
||||
return ch == ps.arpListenerChans[i]
|
||||
})
|
||||
|
||||
if -1 != i {
|
||||
close(ch)
|
||||
ps.arpListenerChans = append(ps.arpListenerChans[:i], ps.arpListenerChans[i+1:]...)
|
||||
for indexI := 0; indexI < len(ps.arpListenerChans); indexI++ {
|
||||
if ch == ps.arpListenerChans[indexI] {
|
||||
close(ch)
|
||||
ps.arpListenerChans = append(ps.arpListenerChans[:indexI], ps.arpListenerChans[indexI+1:]...)
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -145,13 +143,12 @@ func (ps *pCapScan) CloseICMP4(ch chan gopacket.Packet) {
|
|||
ps.icmp4ListenerChanMtx.Lock()
|
||||
defer ps.icmp4ListenerChanMtx.Unlock()
|
||||
|
||||
i := sort.Search(len(ps.icmp4ListenerChans), func(i int) bool {
|
||||
return ch == ps.icmp4ListenerChans[i]
|
||||
})
|
||||
|
||||
if -1 != i {
|
||||
close(ch)
|
||||
ps.icmp4ListenerChans = append(ps.icmp4ListenerChans[:i], ps.icmp4ListenerChans[i+1:]...)
|
||||
for indexI := 0; indexI < len(ps.icmp4ListenerChans); indexI++ {
|
||||
if ch == ps.icmp4ListenerChans[indexI] {
|
||||
close(ch)
|
||||
ps.icmp4ListenerChans = append(ps.icmp4ListenerChans[:indexI], ps.icmp4ListenerChans[indexI+1:]...)
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -167,13 +164,12 @@ func (ps *pCapScan) CloseICMP6(ch chan gopacket.Packet) {
|
|||
ps.icmp6ListenerChanMtx.Lock()
|
||||
defer ps.icmp6ListenerChanMtx.Unlock()
|
||||
|
||||
i := sort.Search(len(ps.icmp6ListenerChans), func(i int) bool {
|
||||
return ch == ps.icmp6ListenerChans[i]
|
||||
})
|
||||
|
||||
if -1 != i {
|
||||
close(ch)
|
||||
ps.icmp6ListenerChans = append(ps.icmp6ListenerChans[:i], ps.icmp6ListenerChans[i+1:]...)
|
||||
for indexI := 0; indexI < len(ps.icmp6ListenerChans); indexI++ {
|
||||
if ch == ps.icmp6ListenerChans[indexI] {
|
||||
close(ch)
|
||||
ps.icmp6ListenerChans = append(ps.icmp6ListenerChans[:indexI], ps.icmp6ListenerChans[indexI+1:]...)
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -198,14 +194,16 @@ func (ps *pCapScan) CloseTCP(ip string, ch chan *layers.TCP) {
|
|||
return
|
||||
}
|
||||
|
||||
chs := ps.tcpListenerChans[ip]
|
||||
i := sort.Search(len(chs), func(i int) bool {
|
||||
return ch == chs[i]
|
||||
})
|
||||
|
||||
if -1 != i && len(chs) > i {
|
||||
close(ch)
|
||||
ps.tcpListenerChans[ip] = append(ps.tcpListenerChans[ip][:i], ps.tcpListenerChans[ip][i+1:]...)
|
||||
chs, ok := ps.tcpListenerChans[ip]
|
||||
if !ok {
|
||||
return
|
||||
}
|
||||
for indexI := 0; indexI < len(chs); indexI++ {
|
||||
if ch == chs[indexI] {
|
||||
close(ch)
|
||||
ps.tcpListenerChans[ip] = append(ps.tcpListenerChans[ip][:indexI], ps.tcpListenerChans[ip][indexI+1:]...)
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -231,14 +229,16 @@ func (ps *pCapScan) CloseUDP(ip string, ch chan gopacket.Packet) {
|
|||
return
|
||||
}
|
||||
|
||||
chs := ps.udpListenerChans[ip]
|
||||
i := sort.Search(len(chs), func(i int) bool {
|
||||
return ch == chs[i]
|
||||
})
|
||||
|
||||
if -1 != i {
|
||||
close(ch)
|
||||
ps.udpListenerChans[ip] = append(ps.udpListenerChans[ip][:i], ps.udpListenerChans[ip][i+1:]...)
|
||||
chs, ok := ps.udpListenerChans[ip]
|
||||
if !ok {
|
||||
return
|
||||
}
|
||||
for indexI := 0; indexI < len(chs); indexI++ {
|
||||
if ch == chs[indexI] {
|
||||
close(ch)
|
||||
ps.udpListenerChans[ip] = append(ps.udpListenerChans[ip][:indexI], ps.udpListenerChans[ip][indexI+1:]...)
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user