Skip to content

Commit

Permalink
fix mos positioning
Browse files Browse the repository at this point in the history
  • Loading branch information
adubovikov committed Nov 6, 2024
1 parent 2de94d6 commit 8ec6d59
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 15 deletions.
2 changes: 1 addition & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import (
"github.com/sipcapture/heplify/sniffer"
)

const version = "heplify 1.66.9"
const version = "heplify 1.66.10"

func createFlags() {

Expand Down
23 changes: 13 additions & 10 deletions publish/marshal.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)))
Expand All @@ -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
}

Expand All @@ -230,16 +230,19 @@ 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)
}
n += 4 + 2 + 2 // len(vendor) + len(chunk) + len(Vlan)
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
}

Expand Down
8 changes: 4 additions & 4 deletions publish/publisher.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down

0 comments on commit 8ec6d59

Please sign in to comment.