mirror of
https://github.com/yggdrasil-network/yggdrasil-go.git
synced 2024-11-27 12:05:23 +00:00
fix nodeinfo and debug admin functions, this is ugly / a hack, but it works i guess...
This commit is contained in:
parent
736c619057
commit
8f91f0c050
@ -83,6 +83,7 @@ func (a *AdminSocket) Init(c *core.Core, nc *config.NodeConfig, log *log.Logger,
|
|||||||
}
|
}
|
||||||
return res, nil
|
return res, nil
|
||||||
})
|
})
|
||||||
|
a.core.SetAdmin(a)
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -142,6 +143,10 @@ func (a *AdminSocket) SetupAdminHandlers(na *AdminSocket) {
|
|||||||
}
|
}
|
||||||
return res, nil
|
return res, nil
|
||||||
})
|
})
|
||||||
|
//_ = a.AddHandler("getNodeInfo", []string{"key"}, t.proto.nodeinfo.nodeInfoAdminHandler)
|
||||||
|
//_ = a.AddHandler("debug_remoteGetSelf", []string{"key"}, t.proto.getSelfHandler)
|
||||||
|
//_ = a.AddHandler("debug_remoteGetPeers", []string{"key"}, t.proto.getPeersHandler)
|
||||||
|
//_ = a.AddHandler("debug_remoteGetDHT", []string{"key"}, t.proto.getDHTHandler)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Start runs the admin API socket to listen for / respond to admin API calls.
|
// Start runs the admin API socket to listen for / respond to admin API calls.
|
||||||
|
@ -3,6 +3,7 @@ package core
|
|||||||
import (
|
import (
|
||||||
"crypto/ed25519"
|
"crypto/ed25519"
|
||||||
//"encoding/hex"
|
//"encoding/hex"
|
||||||
|
"encoding/json"
|
||||||
//"errors"
|
//"errors"
|
||||||
//"fmt"
|
//"fmt"
|
||||||
"net"
|
"net"
|
||||||
@ -259,3 +260,27 @@ func (c *Core) Close() error {
|
|||||||
c.Stop()
|
c.Stop()
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Hack to get the admin stuff working, TODO something cleaner
|
||||||
|
|
||||||
|
type AddHandler interface {
|
||||||
|
AddHandler(name string, args []string, handlerfunc func(json.RawMessage) (interface{}, error)) error
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetAdmin must be called after Init and before Start.
|
||||||
|
// It sets the admin handler for NodeInfo and the Debug admin functions.
|
||||||
|
func (c *Core) SetAdmin(a AddHandler) error {
|
||||||
|
if err := a.AddHandler("getNodeInfo", []string{"key"}, c.proto.nodeinfo.nodeInfoAdminHandler); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
if err := a.AddHandler("debug_remoteGetSelf", []string{"key"}, c.proto.getSelfHandler); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
if err := a.AddHandler("debug_remoteGetPeers", []string{"key"}, c.proto.getPeersHandler); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
if err := a.AddHandler("debug_remoteGetDHT", []string{"key"}, c.proto.getDHTHandler); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
@ -34,8 +34,4 @@ func (t *TunAdapter) SetupAdminHandlers(a *admin.AdminSocket) {
|
|||||||
}
|
}
|
||||||
return res, nil
|
return res, nil
|
||||||
})
|
})
|
||||||
//_ = a.AddHandler("getNodeInfo", []string{"key"}, t.proto.nodeinfo.nodeInfoAdminHandler)
|
|
||||||
//_ = a.AddHandler("debug_remoteGetSelf", []string{"key"}, t.proto.getSelfHandler)
|
|
||||||
//_ = a.AddHandler("debug_remoteGetPeers", []string{"key"}, t.proto.getPeersHandler)
|
|
||||||
//_ = a.AddHandler("debug_remoteGetDHT", []string{"key"}, t.proto.getDHTHandler)
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user