Merge branch 'descriptive' into metadata

This commit is contained in:
Neil Alexander 2018-12-12 18:04:49 +00:00
commit 6200136fce
No known key found for this signature in database
GPG key ID: A02A2019A2BB0944
11 changed files with 219 additions and 50 deletions

View file

@ -23,6 +23,7 @@ type Core struct {
boxPriv boxPrivKey
sigPub sigPubKey
sigPriv sigPrivKey
metadata metadata
switchTable switchTable
peers peers
sessions sessions
@ -40,7 +41,8 @@ type Core struct {
func (c *Core) init(bpub *boxPubKey,
bpriv *boxPrivKey,
spub *sigPubKey,
spriv *sigPrivKey) {
spriv *sigPrivKey,
metadata metadata) {
// TODO separate init and start functions
// Init sets up structs
// Start launches goroutines that depend on structs being set up
@ -51,6 +53,7 @@ func (c *Core) init(bpub *boxPubKey,
}
c.boxPub, c.boxPriv = *bpub, *bpriv
c.sigPub, c.sigPriv = *spub, *spriv
c.metadata = metadata
c.admin.core = c
c.searches.init(c)
c.dht.init(c)
@ -80,6 +83,11 @@ func GetBuildVersion() string {
return buildVersion
}
// Gets the friendly name of this node, as specified in the NodeConfig.
func (c *Core) GetMeta() metadata {
return c.metadata
}
// Starts up Yggdrasil using the provided NodeConfig, and outputs debug logging
// through the provided log.Logger. The started stack will include TCP and UDP
// sockets, a multicast discovery socket, an admin socket, router, switch and
@ -121,7 +129,13 @@ func (c *Core) Start(nc *config.NodeConfig, log *log.Logger) error {
copy(sigPub[:], sigPubHex)
copy(sigPriv[:], sigPrivHex)
c.init(&boxPub, &boxPriv, &sigPub, &sigPriv)
meta := metadata{
name: nc.Metadata.Name,
location: nc.Metadata.Location,
contact: nc.Metadata.Contact,
}
c.init(&boxPub, &boxPriv, &sigPub, &sigPriv, meta)
c.admin.init(c, nc.AdminListen)
if err := c.tcp.init(c, nc.Listen, nc.ReadTimeout); err != nil {