mirror of
https://github.com/yggdrasil-network/yggdrasil-go.git
synced 2025-04-29 06:35:07 +03:00
Start factoring out the admin socket into a separate module (not all functions implemented yet)
This commit is contained in:
parent
7ca5a2533d
commit
8ef1978cb1
4 changed files with 123 additions and 286 deletions
File diff suppressed because it is too large
Load diff
|
@ -36,6 +36,7 @@ type SwitchPeer struct {
|
|||
BytesRecvd uint64
|
||||
Port uint64
|
||||
Protocol string
|
||||
Endpoint string
|
||||
}
|
||||
|
||||
// DHTEntry represents a single DHT entry that has been learned or cached from
|
||||
|
@ -127,6 +128,7 @@ func (c *Core) GetSwitchPeers() []SwitchPeer {
|
|||
BytesRecvd: atomic.LoadUint64(&peer.bytesRecvd),
|
||||
Port: uint64(elem.port),
|
||||
Protocol: peer.intf.info.linkType,
|
||||
Endpoint: peer.intf.info.remote,
|
||||
}
|
||||
copy(info.PublicKey[:], peer.box[:])
|
||||
switchpeers = append(switchpeers, info)
|
||||
|
@ -289,6 +291,12 @@ func (c *Core) BoxPubKey() string {
|
|||
return hex.EncodeToString(c.boxPub[:])
|
||||
}
|
||||
|
||||
// Coords returns the current coordinates of the node.
|
||||
func (c *Core) Coords() []byte {
|
||||
table := c.switchTable.table.Load().(lookupTable)
|
||||
return table.self.getCoords()
|
||||
}
|
||||
|
||||
// Address gets the IPv6 address of the Yggdrasil node. This is always a /128
|
||||
// address.
|
||||
func (c *Core) Address() *net.IP {
|
||||
|
@ -359,5 +367,6 @@ func (c *Core) CallPeer(addr string, sintf string) error {
|
|||
// AddAllowedEncryptionPublicKey adds an allowed public key. This allow peerings
|
||||
// to be restricted only to keys that you have selected.
|
||||
func (c *Core) AddAllowedEncryptionPublicKey(boxStr string) error {
|
||||
return c.admin.addAllowedEncryptionPublicKey(boxStr)
|
||||
//return c.admin.addAllowedEncryptionPublicKey(boxStr)
|
||||
return nil
|
||||
}
|
||||
|
|
|
@ -30,7 +30,6 @@ type Core struct {
|
|||
sessions sessions
|
||||
router router
|
||||
dht dht
|
||||
admin admin
|
||||
searches searches
|
||||
link link
|
||||
log *log.Logger
|
||||
|
@ -69,7 +68,6 @@ func (c *Core) init() error {
|
|||
copy(c.sigPub[:], sigPubHex)
|
||||
copy(c.sigPriv[:], sigPrivHex)
|
||||
|
||||
c.admin.init(c)
|
||||
c.searches.init(c)
|
||||
c.dht.init(c)
|
||||
c.sessions.init(c)
|
||||
|
@ -118,7 +116,6 @@ func (c *Core) UpdateConfig(config *config.NodeConfig) {
|
|||
errors := 0
|
||||
|
||||
components := []chan chan error{
|
||||
c.admin.reconfigure,
|
||||
c.searches.reconfigure,
|
||||
c.dht.reconfigure,
|
||||
c.sessions.reconfigure,
|
||||
|
@ -189,11 +186,6 @@ func (c *Core) Start(nc *config.NodeConfig, log *log.Logger) (*config.NodeState,
|
|||
return nil, err
|
||||
}
|
||||
|
||||
if err := c.admin.start(); err != nil {
|
||||
c.log.Errorln("Failed to start admin socket")
|
||||
return nil, err
|
||||
}
|
||||
|
||||
go c.addPeerLoop()
|
||||
|
||||
c.log.Infoln("Startup complete")
|
||||
|
@ -203,5 +195,4 @@ func (c *Core) Start(nc *config.NodeConfig, log *log.Logger) (*config.NodeState,
|
|||
// Stop shuts down the Yggdrasil node.
|
||||
func (c *Core) Stop() {
|
||||
c.log.Infoln("Stopping...")
|
||||
c.admin.close()
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue