Skip to content

Commit 763e5ae

Browse files
authored
Merge pull request #255 from sipcapture/ping
Ping
2 parents d9f110c + f4fb3b9 commit 763e5ae

File tree

3 files changed

+30
-1
lines changed

3 files changed

+30
-1
lines changed

decoder/decoder.go

+13
Original file line numberDiff line numberDiff line change
@@ -531,3 +531,16 @@ func (d *Decoder) ProcessHEPPacket(data []byte) {
531531

532532
PacketQueue <- pkt
533533
}
534+
535+
func (d *Decoder) SendPingHEPPacket() {
536+
537+
var data = []byte{0x48, 0x45, 0x50, 0x33, 0x3, 0xa}
538+
pkt := &Packet{
539+
Version: 0,
540+
Payload: data,
541+
}
542+
543+
atomic.AddUint64(&d.hepCount, 1)
544+
545+
PacketQueue <- pkt
546+
}

main.go

+6-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import (
1212
"github.com/sipcapture/heplify/sniffer"
1313
)
1414

15-
const version = "heplify 1.65.2"
15+
const version = "heplify 1.65.3"
1616

1717
func createFlags() {
1818

@@ -139,6 +139,11 @@ func main() {
139139

140140
wg.Add(1)
141141
go func() {
142+
143+
if config.Cfg.HepNodePW != "" {
144+
capture.SendPing()
145+
}
146+
142147
err = capture.Run()
143148
checkCritErr(err)
144149
wg.Done()

sniffer/sniffer.go

+11
Original file line numberDiff line numberDiff line change
@@ -51,11 +51,13 @@ type SnifferSetup struct {
5151
type MainWorker struct {
5252
publisher *publish.Publisher
5353
decoder *decoder.Decoder
54+
ping *decoder.Decoder
5455
}
5556

5657
type Worker interface {
5758
OnPacket(data []byte, ci *gopacket.CaptureInfo)
5859
OnHEPPacket(data []byte)
60+
SendPingHEPPacket()
5961
}
6062

6163
type stats struct {
@@ -95,6 +97,10 @@ func (mw *MainWorker) OnHEPPacket(data []byte) {
9597
mw.decoder.ProcessHEPPacket(data)
9698
}
9799

100+
func (mw *MainWorker) SendPingHEPPacket() {
101+
mw.decoder.SendPingHEPPacket()
102+
}
103+
98104
func (sniffer *SnifferSetup) setFromConfig() error {
99105
var err error
100106

@@ -315,6 +321,11 @@ func New(cfgMain *config.Config) (*SnifferSetup, error) {
315321
return sniffer, nil
316322
}
317323

324+
func (sniffer *SnifferSetup) SendPing() error {
325+
sniffer.worker.SendPingHEPPacket()
326+
return nil
327+
}
328+
318329
func (sniffer *SnifferSetup) Run() error {
319330
var (
320331
loopCount = 1

0 commit comments

Comments
 (0)