From 058dec0cca25cae5d81369babfa1c64d28e36d89 Mon Sep 17 00:00:00 2001 From: Neil Alexander Date: Sun, 16 May 2021 21:01:59 +0100 Subject: [PATCH] Fix getself, gettuntap etc --- src/admin/getself.go | 20 +++++++++++++------- src/tuntap/admin.go | 12 +++++++++--- 2 files changed, 22 insertions(+), 10 deletions(-) diff --git a/src/admin/getself.go b/src/admin/getself.go index 895411b..bec084c 100644 --- a/src/admin/getself.go +++ b/src/admin/getself.go @@ -10,22 +10,28 @@ import ( type GetSelfRequest struct{} type GetSelfResponse struct { + Self map[string]SelfEntry `json:"self"` +} + +type SelfEntry struct { BuildName string `json:"build_name"` BuildVersion string `json:"build_version"` PublicKey string `json:"key"` Coords []uint64 `json:"coords"` - IPAddress string `json:"address"` Subnet string `json:"subnet"` } func (a *AdminSocket) getSelfHandler(req *GetSelfRequest, res *GetSelfResponse) error { - res.BuildName = version.BuildName() - res.BuildVersion = version.BuildVersion() + res.Self = make(map[string]SelfEntry) public := a.core.PrivateKey().Public().(ed25519.PublicKey) - res.PublicKey = hex.EncodeToString(public[:]) - res.IPAddress = a.core.Address().String() + addr := a.core.Address().String() snet := a.core.Subnet() - res.Subnet = snet.String() - // TODO: res.coords + res.Self[addr] = SelfEntry{ + BuildName: version.BuildName(), + BuildVersion: version.BuildVersion(), + PublicKey: hex.EncodeToString(public[:]), + Subnet: snet.String(), + // TODO: coords + } return nil } diff --git a/src/tuntap/admin.go b/src/tuntap/admin.go index 15a7463..862a3c6 100644 --- a/src/tuntap/admin.go +++ b/src/tuntap/admin.go @@ -7,11 +7,17 @@ import ( ) type GetTUNRequest struct{} -type GetTUNResponse map[string]uint64 +type GetTUNResponse map[string]TUNEntry + +type TUNEntry struct { + MTU uint64 `json:"mtu"` +} func (t *TunAdapter) getTUNHandler(req *GetTUNRequest, res *GetTUNResponse) error { - res = &GetTUNResponse{ - t.Name(): t.MTU(), + *res = GetTUNResponse{ + t.Name(): TUNEntry{ + MTU: t.MTU(), + }, } return nil }