Wrap the metadata with a mutex to guarantee thread safety across core/router/sessions

This commit is contained in:
Neil Alexander 2018-12-12 22:40:49 +00:00
parent 97464feba9
commit 042a3400fe
No known key found for this signature in database
GPG key ID: A02A2019A2BB0944
4 changed files with 40 additions and 14 deletions

View file

@ -80,11 +80,6 @@ func GetBuildVersion() string {
return buildVersion
}
// Gets the friendly name of this node, as specified in the NodeConfig.
func (c *Core) GetMeta() metadata {
return c.sessions.myMetadata
}
// 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
@ -245,6 +240,16 @@ func (c *Core) GetSubnet() *net.IPNet {
return &net.IPNet{IP: subnet, Mask: net.CIDRMask(64, 128)}
}
// Gets the node metadata.
func (c *Core) GetMetadata() metadata {
return c.sessions.getMetadata()
}
// Sets the node metadata.
func (c *Core) SetMetadata(meta metadata) {
c.sessions.setMetadata(meta)
}
// Sets the output logger of the Yggdrasil node after startup. This may be
// useful if you want to redirect the output later.
func (c *Core) SetLogger(log *log.Logger) {