mirror of
https://github.com/yggdrasil-network/yggdrasil-go.git
synced 2024-11-30 13:35:19 +00:00
34 lines
660 B
Go
34 lines
660 B
Go
package admin
|
|
|
|
import (
|
|
"encoding/hex"
|
|
"net"
|
|
|
|
"github.com/yggdrasil-network/yggdrasil-go/src/address"
|
|
)
|
|
|
|
type GetPathsRequest struct {
|
|
}
|
|
|
|
type GetPathsResponse struct {
|
|
Paths map[string]PathEntry `json:"paths"`
|
|
}
|
|
|
|
type PathEntry struct {
|
|
PublicKey string `json:"key"`
|
|
Path []uint64 `json:"path"`
|
|
}
|
|
|
|
func (a *AdminSocket) getPathsHandler(req *GetPathsRequest, res *GetPathsResponse) error {
|
|
res.Paths = map[string]PathEntry{}
|
|
for _, p := range a.core.GetPaths() {
|
|
addr := address.AddrForKey(p.Key)
|
|
so := net.IP(addr[:]).String()
|
|
res.Paths[so] = PathEntry{
|
|
PublicKey: hex.EncodeToString(p.Key),
|
|
Path: p.Path,
|
|
}
|
|
}
|
|
return nil
|
|
}
|