Default metadata

This commit is contained in:
Neil Alexander 2018-12-15 10:56:46 +00:00
parent 8b63e841ea
commit d07e0ddfa0
No known key found for this signature in database
GPG Key ID: A02A2019A2BB0944
2 changed files with 17 additions and 2 deletions

View File

@ -325,7 +325,12 @@ func (a *admin) init(c *Core, listenaddr string) {
a.addHandler("getMeta", []string{"box_pub_key", "coords"}, func(in admin_info) (admin_info, error) {
result, err := a.admin_getMeta(in["box_pub_key"].(string), in["coords"].(string))
if err == nil {
return admin_info{"metadata": string(result)}, nil
var m map[string]interface{}
if err = json.Unmarshal(result, &m); err == nil {
return admin_info{"metadata": m}, nil
} else {
return admin_info{}, err
}
} else {
return admin_info{}, err
}

View File

@ -2,11 +2,13 @@ package yggdrasil
import (
"encoding/hex"
"encoding/json"
"fmt"
"io/ioutil"
"log"
"net"
"regexp"
"runtime"
"github.com/yggdrasil-network/yggdrasil-go/src/config"
"github.com/yggdrasil-network/yggdrasil-go/src/defaults"
@ -124,7 +126,15 @@ func (c *Core) Start(nc *config.NodeConfig, log *log.Logger) error {
c.admin.init(c, nc.AdminListen)
c.metadata.init(c)
c.metadata.setMetadata(metadataPayload("HIYA, THIS IS METADATA"))
m := map[string]string{
"buildname": GetBuildName(),
"buildversion": GetBuildVersion(),
"buildplatform": runtime.GOOS,
"buildarch": runtime.GOARCH,
}
if json, err := json.Marshal(m); err == nil {
c.metadata.setMetadata(json)
}
if err := c.tcp.init(c, nc.Listen, nc.ReadTimeout); err != nil {
c.log.Println("Failed to start TCP interface")