5
0
mirror of https://github.com/cwinfo/yggdrasil-go.git synced 2024-11-22 15:20:30 +00:00

debug admin socket

This commit is contained in:
Arceliar 2018-05-06 19:48:26 -05:00
parent 94dd231e13
commit 6ce16d8192
4 changed files with 12 additions and 13 deletions

View File

@ -377,7 +377,7 @@ func (a *admin) getAuthBoxPubs() string {
func (a *admin) addAuthBoxPub(bstr string) (err error) { func (a *admin) addAuthBoxPub(bstr string) (err error) {
boxBytes, err := hex.DecodeString(bstr) boxBytes, err := hex.DecodeString(bstr)
if err != nil { if err == nil {
var box boxPubKey var box boxPubKey
copy(box[:], boxBytes) copy(box[:], boxBytes)
a.core.peers.addAuthBoxPub(&box) 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) { func (a *admin) removeAuthBoxPub(bstr string) (err error) {
boxBytes, err := hex.DecodeString(bstr) boxBytes, err := hex.DecodeString(bstr)
if err != nil { if err == nil {
var box boxPubKey var box boxPubKey
copy(box[:], boxBytes) copy(box[:], boxBytes)
a.core.peers.removeAuthBoxPub(&box) a.core.peers.removeAuthBoxPub(&box)

View File

@ -44,6 +44,7 @@ func (c *Core) init(bpub *boxPubKey,
c.log = log.New(ioutil.Discard, "", 0) c.log = log.New(ioutil.Discard, "", 0)
c.boxPub, c.boxPriv = *bpub, *bpriv c.boxPub, c.boxPriv = *bpub, *bpriv
c.sigPub, c.sigPriv = *spub, *spriv c.sigPub, c.sigPriv = *spub, *spriv
c.admin.core = c
c.sigs.init() c.sigs.init()
c.searches.init(c) c.searches.init(c)
c.dht.init(c) c.dht.init(c)

View File

@ -397,10 +397,11 @@ func (c *Core) DEBUG_setIfceExpr(expr *regexp.Regexp) {
c.ifceExpr = expr c.ifceExpr = expr
} }
func (c *Core) DEBUG_addAuthBoxPub(boxBytes []byte) { func (c *Core) DEBUG_addAuthBoxPub(boxStr string) {
var box boxPubKey err := c.admin.addAuthBoxPub(boxStr)
copy(box[:], boxBytes) if err != nil {
c.peers.addAuthBoxPub(&box) panic(err)
}
} }
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////

View File

@ -58,13 +58,6 @@ func (n *node) init(cfg *nodeConfig, logger *log.Logger) {
panic(err) panic(err)
} }
n.core.DEBUG_setIfceExpr(ifceExpr) 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...") logger.Println("Starting interface...")
n.core.DEBUG_setupAndStartGlobalTCPInterface(cfg.Listen) // Listen for peers on TCP 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...") logger.Println("Starting admin socket...")
n.core.DEBUG_setupAndStartAdminInterface(cfg.AdminListen) n.core.DEBUG_setupAndStartAdminInterface(cfg.AdminListen)
logger.Println("Started admin socket") logger.Println("Started admin socket")
for _, pBoxStr := range cfg.PeerBoxPubs {
n.core.DEBUG_addAuthBoxPub(pBoxStr)
}
go func() { go func() {
if len(cfg.Peers) == 0 { if len(cfg.Peers) == 0 {
return return