mirror of
https://github.com/yggdrasil-network/yggdrasil-go.git
synced 2025-04-28 22:25:07 +03:00
Refactor admin socket, export request/response structs, remove types package
This commit is contained in:
parent
dfca87ba80
commit
2d01386d6e
13 changed files with 290 additions and 218 deletions
31
src/admin/getself.go
Normal file
31
src/admin/getself.go
Normal file
|
@ -0,0 +1,31 @@
|
|||
package admin
|
||||
|
||||
import (
|
||||
"crypto/ed25519"
|
||||
"encoding/hex"
|
||||
|
||||
"github.com/yggdrasil-network/yggdrasil-go/src/version"
|
||||
)
|
||||
|
||||
type GetSelfRequest struct{}
|
||||
|
||||
type GetSelfResponse 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()
|
||||
public := a.core.PrivateKey().Public().(ed25519.PublicKey)
|
||||
res.PublicKey = hex.EncodeToString(public[:])
|
||||
res.IPAddress = a.core.Address().String()
|
||||
snet := a.core.Subnet()
|
||||
res.Subnet = snet.String()
|
||||
// TODO: res.coords
|
||||
return nil
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue