mirror of
https://github.com/cwinfo/yggdrasil-go.git
synced 2024-11-26 00:11:36 +00:00
Default metadata
This commit is contained in:
parent
8b63e841ea
commit
d07e0ddfa0
@ -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
|
||||
}
|
||||
|
@ -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")
|
||||
|
Loading…
Reference in New Issue
Block a user