github.com/yggdrasil-network/yggdrasil-go@v0.5.6/src/admin/getself.go (about)

     1  package admin
     2  
     3  import (
     4  	"encoding/hex"
     5  
     6  	"github.com/yggdrasil-network/yggdrasil-go/src/version"
     7  )
     8  
     9  type GetSelfRequest struct{}
    10  
    11  type GetSelfResponse struct {
    12  	BuildName      string `json:"build_name"`
    13  	BuildVersion   string `json:"build_version"`
    14  	PublicKey      string `json:"key"`
    15  	IPAddress      string `json:"address"`
    16  	RoutingEntries uint64 `json:"routing_entries"`
    17  	Subnet         string `json:"subnet"`
    18  }
    19  
    20  func (a *AdminSocket) getSelfHandler(req *GetSelfRequest, res *GetSelfResponse) error {
    21  	self := a.core.GetSelf()
    22  	snet := a.core.Subnet()
    23  	res.BuildName = version.BuildName()
    24  	res.BuildVersion = version.BuildVersion()
    25  	res.PublicKey = hex.EncodeToString(self.Key[:])
    26  	res.IPAddress = a.core.Address().String()
    27  	res.Subnet = snet.String()
    28  	res.RoutingEntries = self.RoutingEntries
    29  	return nil
    30  }