diff --git a/main.go b/main.go index a830d62..774f679 100644 --- a/main.go +++ b/main.go @@ -15,7 +15,7 @@ import ( "github.com/sipcapture/heplify/sniffer" ) -const version = "heplify 1.66.9" +const version = "heplify 1.66.10" func createFlags() { diff --git a/publish/marshal.go b/publish/marshal.go index 078059f..3844523 100644 --- a/publish/marshal.go +++ b/publish/marshal.go @@ -183,13 +183,6 @@ func (h *HepMsg) MarshalTo(dAtA []byte) (int, error) { i += copy(dAtA[i:], h.NodePW) } - if h.Payload != nil { - i += copy(dAtA[i:], []byte{0x00, 0x00, 0x00, 0x0f}) - binary.BigEndian.PutUint16(dAtA[i:], 6+uint16(len(h.Payload))) - i += 2 - i += copy(dAtA[i:], h.Payload) - } - if h.CID != nil { i += copy(dAtA[i:], []byte{0x00, 0x00, 0x00, 0x11}) binary.BigEndian.PutUint16(dAtA[i:], 6+uint16(len(h.CID))) @@ -208,6 +201,13 @@ func (h *HepMsg) MarshalTo(dAtA []byte) (int, error) { i += copy(dAtA[i:], h.NodeName) } + if h.Payload != nil { + i += copy(dAtA[i:], []byte{0x00, 0x00, 0x00, 0x0f}) + binary.BigEndian.PutUint16(dAtA[i:], 6+uint16(len(h.Payload))) + i += 2 + i += copy(dAtA[i:], h.Payload) + } + return i, nil } @@ -230,9 +230,7 @@ func (h *HepMsg) Size() (n int) { if h.NodePW != "" { n += 4 + 2 + len(h.NodePW) // len(vendor) + len(chunk) + len(NodePW) } - if h.Payload != nil { - n += 4 + 2 + len(h.Payload) // len(vendor) + len(chunk) + len(Payload) - } + if h.CID != nil { n += 4 + 2 + len(h.CID) // len(vendor) + len(chunk) + len(CID) } @@ -240,6 +238,11 @@ func (h *HepMsg) Size() (n int) { if h.NodeName != "" { n += 4 + 2 + len(h.NodeName) // len(vendor) + len(chunk) + len(NodeName) } + + if h.Payload != nil { + n += 4 + 2 + len(h.Payload) // len(vendor) + len(chunk) + len(Payload) + } + return n } diff --git a/publish/publisher.go b/publish/publisher.go index 000350a..b7e6ebe 100644 --- a/publish/publisher.go +++ b/publish/publisher.go @@ -72,12 +72,12 @@ func (pub *Publisher) Start(pq chan *decoder.Packet) { if pkt.Version == 100 { if config.Cfg.ReplaceToken { - msg, err := DecodeHEP(pkt.Payload) + tmpver, err := DecodeHEP(pkt.Payload) if err == nil { - msg.NodePW = config.Cfg.HepNodePW - pkt.Payload, err = msg.Marshal() + tmpver.NodePW = config.Cfg.HepNodePW + forwardMsg, err := tmpver.Marshal() if err == nil { - pub.output(pkt.Payload) + pub.output(forwardMsg) } else { logp.Warn("Bad HEP marshal: %v", err) }