local interfaces

This commit is contained in:
Matthew R. Kasun 2022-11-28 12:58:24 -05:00
parent 4df672de68
commit c5919b347c
3 changed files with 10 additions and 1 deletions

2
go.mod
View file

@ -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

View file

@ -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"`

View file

@ -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