From 6ce16d819245bcdecb1a8be5698f0a5970fda1dd Mon Sep 17 00:00:00 2001 From: Arceliar Date: Sun, 6 May 2018 19:48:26 -0500 Subject: [PATCH] debug admin socket --- src/yggdrasil/admin.go | 4 ++-- src/yggdrasil/core.go | 1 + src/yggdrasil/debug.go | 9 +++++---- yggdrasil.go | 11 ++++------- 4 files changed, 12 insertions(+), 13 deletions(-) diff --git a/src/yggdrasil/admin.go b/src/yggdrasil/admin.go index 8ddcd63..78e6cd4 100644 --- a/src/yggdrasil/admin.go +++ b/src/yggdrasil/admin.go @@ -377,7 +377,7 @@ func (a *admin) getAuthBoxPubs() string { func (a *admin) addAuthBoxPub(bstr string) (err error) { boxBytes, err := hex.DecodeString(bstr) - if err != nil { + if err == nil { var box boxPubKey copy(box[:], boxBytes) a.core.peers.addAuthBoxPub(&box) @@ -387,7 +387,7 @@ func (a *admin) addAuthBoxPub(bstr string) (err error) { func (a *admin) removeAuthBoxPub(bstr string) (err error) { boxBytes, err := hex.DecodeString(bstr) - if err != nil { + if err == nil { var box boxPubKey copy(box[:], boxBytes) a.core.peers.removeAuthBoxPub(&box) diff --git a/src/yggdrasil/core.go b/src/yggdrasil/core.go index be0c6ae..838feef 100644 --- a/src/yggdrasil/core.go +++ b/src/yggdrasil/core.go @@ -44,6 +44,7 @@ func (c *Core) init(bpub *boxPubKey, c.log = log.New(ioutil.Discard, "", 0) c.boxPub, c.boxPriv = *bpub, *bpriv c.sigPub, c.sigPriv = *spub, *spriv + c.admin.core = c c.sigs.init() c.searches.init(c) c.dht.init(c) diff --git a/src/yggdrasil/debug.go b/src/yggdrasil/debug.go index 55a896c..68f19c9 100644 --- a/src/yggdrasil/debug.go +++ b/src/yggdrasil/debug.go @@ -397,10 +397,11 @@ func (c *Core) DEBUG_setIfceExpr(expr *regexp.Regexp) { c.ifceExpr = expr } -func (c *Core) DEBUG_addAuthBoxPub(boxBytes []byte) { - var box boxPubKey - copy(box[:], boxBytes) - c.peers.addAuthBoxPub(&box) +func (c *Core) DEBUG_addAuthBoxPub(boxStr string) { + err := c.admin.addAuthBoxPub(boxStr) + if err != nil { + panic(err) + } } //////////////////////////////////////////////////////////////////////////////// diff --git a/yggdrasil.go b/yggdrasil.go index 11acd82..b9a45da 100644 --- a/yggdrasil.go +++ b/yggdrasil.go @@ -58,13 +58,6 @@ func (n *node) init(cfg *nodeConfig, logger *log.Logger) { panic(err) } n.core.DEBUG_setIfceExpr(ifceExpr) - for _, pBoxStr := range cfg.PeerBoxPubs { - pbox, err := hex.DecodeString(pBoxStr) - if err != nil { - panic(err) - } - n.core.DEBUG_addAuthBoxPub(pbox) - } logger.Println("Starting interface...") n.core.DEBUG_setupAndStartGlobalTCPInterface(cfg.Listen) // Listen for peers on TCP @@ -73,6 +66,10 @@ func (n *node) init(cfg *nodeConfig, logger *log.Logger) { logger.Println("Starting admin socket...") n.core.DEBUG_setupAndStartAdminInterface(cfg.AdminListen) logger.Println("Started admin socket") + for _, pBoxStr := range cfg.PeerBoxPubs { + n.core.DEBUG_addAuthBoxPub(pBoxStr) + } + go func() { if len(cfg.Peers) == 0 { return