diff --git a/go.mod b/go.mod index 6e370546..45766572 100644 --- a/go.mod +++ b/go.mod @@ -46,7 +46,7 @@ require ( golang.org/x/term v0.0.0-20220722155259-a9ba230a4035 ) -require github.com/matryer/is v1.4.0 // indirect +require github.com/matryer/is v1.4.0 require ( cloud.google.com/go/compute v1.7.0 // indirect diff --git a/models/node.go b/models/node.go index 1139d869..ae786498 100644 --- a/models/node.go +++ b/models/node.go @@ -43,6 +43,13 @@ var seededRand *rand.Rand = rand.New( type NodeCheckin struct { Version string Connected string + Ifaces []Iface +} + +// Iface struct for local interfaces of a node +type Iface struct { + Name string + Address net.IPNet } // Node - struct for node model @@ -52,6 +59,7 @@ type Node struct { Address string `json:"address" bson:"address" yaml:"address" validate:"omitempty,ipv4"` Address6 string `json:"address6" bson:"address6" yaml:"address6" validate:"omitempty,ipv6"` LocalAddress string `json:"localaddress" bson:"localaddress" yaml:"localaddress" validate:"omitempty"` + Interfaces []Iface `json:"interfaces" yaml:"interfaces"` Name string `json:"name" bson:"name" yaml:"name" validate:"omitempty,max=62,in_charset"` NetworkSettings Network `json:"networksettings" bson:"networksettings" yaml:"networksettings" validate:"-"` ListenPort int32 `json:"listenport" bson:"listenport" yaml:"listenport" validate:"omitempty,numeric,min=1024,max=65535"` diff --git a/mq/handlers.go b/mq/handlers.go index a4b77bf4..ce36a49e 100644 --- a/mq/handlers.go +++ b/mq/handlers.go @@ -52,6 +52,7 @@ func Ping(client mqtt.Client, msg mqtt.Message) { node.SetLastCheckIn() node.Version = checkin.Version node.Connected = checkin.Connected + node.Interfaces = checkin.Ifaces if err := logic.UpdateNode(&node, &node); err != nil { logger.Log(0, "error updating node", node.Name, node.ID, " on checkin", err.Error()) return