Allow packet capture with effective sample rate 100%

This commit is contained in:
Peter Bourgon
2015-07-31 15:34:58 +02:00
parent c7a06d2a43
commit 64ebedccb1
2 changed files with 6 additions and 3 deletions

View File

@@ -115,9 +115,6 @@ func main() {
}
if *captureEnabled {
if *captureOn > *captureOff {
log.Fatalf("-capture.on (%s) must be <= -capture.off (%s)", *captureOn, *captureOff)
}
for _, iface := range strings.Split(*captureInterfaces, ",") {
source, err := sniff.NewSource(iface)
if err != nil {

View File

@@ -64,6 +64,12 @@ func (s *Sniffer) loop(src gopacket.ZeroCopyPacketDataSource, on, off time.Durat
done = make(chan struct{}) // when src is finished, we're done too
)
// As a special case, if our off duty cycle is zero, i.e. 100% sample
// rate, we simply disable the turn-off signal channel.
if off == 0 {
turnOff = nil
}
go func() {
s.read(src, packets, &process, &total, &count)
close(done)