Skip to content

Commit

Permalink
v0.2.1
Browse files Browse the repository at this point in the history
  • Loading branch information
MatejLach committed Sep 25, 2023
1 parent 7a05471 commit 08c9e30
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 6 deletions.
8 changes: 6 additions & 2 deletions provider/turris/delta.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import (
type Delta struct {
Operation string
IP net.IP
Serial uint16
Serial uint32
Timestamp time.Time
}

Expand All @@ -38,7 +38,11 @@ func (c *Client) decodeDelta(rawMsg []byte) (Delta, error) {

operation := rawMap["delta"].(string)
ip := rawMap["ip"].(string)
serial := rawMap["serial"].(uint16)
serial, ok := rawMap["serial"].(uint32)
if !ok {
serial = uint32(rawMap["serial"].(uint16))
}

ts := rawMap["ts"].(uint32)

return Delta{
Expand Down
8 changes: 6 additions & 2 deletions provider/turris/list.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import (

type List struct {
Version time.Time
Serial uint16
Serial uint32
Blacklist []net.IP
Timestamp time.Time
}
Expand All @@ -38,7 +38,11 @@ func (c *Client) decodeList(rawMsg []byte) (List, error) {
}

version := rawMap["version"].(uint32)
serial := rawMap["serial"].(uint16)
serial, ok := rawMap["serial"].(uint32)
if !ok {
serial = uint32(rawMap["serial"].(uint16))
}

rawBlocklist := rawMap["list"].([]interface{})
ts := rawMap["ts"].(uint32)

Expand Down
4 changes: 2 additions & 2 deletions provider/turris/turris.go
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ func (c *Client) Connect() error {
}

func (c *Client) RequestMessages(ctx context.Context) {
var previousDeltaSerial uint16
var previousDeltaSerial uint32
refreshList := true // upon launch, initialize the list

for {
Expand Down Expand Up @@ -173,7 +173,7 @@ func (c *Client) RequestMessages(ctx context.Context) {
}
}

func serialOk(oldSerial, currentSerial uint16) bool {
func serialOk(oldSerial, currentSerial uint32) bool {
if (oldSerial+1 == currentSerial) || oldSerial == 0 {
return true
}
Expand Down

0 comments on commit 08c9e30

Please sign in to comment.