Skip to content

Commit

Permalink
fix: added replace token for incoming collector
Browse files Browse the repository at this point in the history
  • Loading branch information
adubovikov committed Oct 30, 2024
1 parent c4cc4eb commit f30c25b
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 0 deletions.
1 change: 1 addition & 0 deletions config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ type Config struct {
Zip bool
HepCollector string
CollectOnlySip bool
ReplaceToken bool
HepServer string
HepNodePW string
HepNodeID uint
Expand Down
1 change: 1 addition & 0 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ func createFlags() {
flag.StringVar(&config.Cfg.HEPBufferFile, "hep-buffer-file", "HEP-Buffer.dump", "filename and location for hep-buffer file")
flag.StringVar(&config.Cfg.PrometheusIPPort, "prometheus", ":8090", "prometheus metrics - ip:port. By default all IPs")
flag.BoolVar(&config.Cfg.CollectOnlySip, "collectonlysip", false, "collect only sip")
flag.BoolVar(&config.Cfg.ReplaceToken, "replacetoken", false, "replace token for collector")
flag.BoolVar(&config.Cfg.Reassembly, "tcpassembly", false, "If true, tcpassembly will be enabled")
flag.BoolVar(&config.Cfg.SipAssembly, "sipassembly", false, "If true, sipassembly will be enabled")
flag.UintVar(&config.Cfg.SendRetries, "tcpsendretries", 0, "Number of retries for sending before giving up and reconnecting")
Expand Down
15 changes: 15 additions & 0 deletions publish/publisher.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,21 @@ func (pub *Publisher) Start(pq chan *decoder.Packet) {

//Version == 100 just for forwarding...
if pkt.Version == 100 {

if config.Cfg.ReplaceToken {
msg, err := DecodeHEP(pkt.Payload)
if err == nil {
msg.NodePW = config.Cfg.HepNodePW
pkt.Payload, err = msg.Marshal()
if err != nil {
pub.output(pkt.Payload)
}
} else {
logp.Warn("Bad HEP: %v", err)
}
continue
}

pub.output(pkt.Payload)
logp.Debug("publisher", "sent hep message from collector")
} else if pkt.Version == 0 {
Expand Down

0 comments on commit f30c25b

Please sign in to comment.