Skip to content

Commit e5add21

Browse files
authored
Merge pull request #280 from sipcapture/exit_eof
added exit on end of file
2 parents 04e5b6d + 6152c67 commit e5add21

File tree

3 files changed

+10
-1
lines changed

3 files changed

+10
-1
lines changed

config/config.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ type InterfacesConfig struct {
5656
ReadSpeed bool `config:"top_speed"`
5757
OneAtATime bool `config:"one_at_a_time"`
5858
Loop int `config:"loop"`
59+
EOFExit bool `config:"eof_exit"`
5960
FanoutID uint `config:"fanout_id"`
6061
FanoutWorker int `config:"fanout_worker"`
6162
CustomBPF string `config:"custom_bpf"`

main.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ import (
1515
"github.com/sipcapture/heplify/sniffer"
1616
)
1717

18-
const version = "heplify 1.66.1"
18+
const version = "heplify 1.66.2"
1919

2020
func createFlags() {
2121

@@ -82,6 +82,7 @@ func createFlags() {
8282
flag.IntVar(&ifaceConfig.RotationTime, "rt", 60, "Pcap rotation time in minutes")
8383
flag.BoolVar(&config.Cfg.Zip, "zf", false, "Enable pcap compression")
8484
flag.IntVar(&ifaceConfig.Loop, "lp", 1, "Loop count over ReadFile. Use 0 to loop forever")
85+
flag.BoolVar(&ifaceConfig.EOFExit, "eof-exit", false, "Exit on EOF of ReadFile")
8586
flag.BoolVar(&ifaceConfig.ReadSpeed, "rs", false, "Use packet timestamps with maximum pcap read speed")
8687
flag.StringVar(&ifaceConfig.PortRange, "pr", "5060-5090", "Portrange to capture SIP")
8788
flag.BoolVar(&sys, "sl", false, "Log to syslog")

sniffer/sniffer.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -458,7 +458,14 @@ LOOP:
458458
}
459459

460460
if err == io.EOF {
461+
461462
logp.Debug("sniffer", "End of file")
463+
464+
if sniffer.config.EOFExit {
465+
sniffer.Close()
466+
os.Exit(0)
467+
}
468+
462469
loopCount++
463470
if sniffer.config.Loop > 0 && loopCount > sniffer.config.Loop {
464471
// Give the publish goroutine 200 ms to flush

0 commit comments

Comments
 (0)