mirror of
https://github.com/yggdrasil-network/yggdrasil-go.git
synced 2025-04-29 22:55:06 +03:00
update to ironwood v0.0.0-20230513191034-495699d87ae4 with API changes
This commit is contained in:
parent
1345960d5f
commit
5e95246c26
11 changed files with 235 additions and 198 deletions
|
@ -1,45 +0,0 @@
|
|||
package admin
|
||||
|
||||
import (
|
||||
"encoding/hex"
|
||||
"net"
|
||||
"sort"
|
||||
"strings"
|
||||
|
||||
"github.com/yggdrasil-network/yggdrasil-go/src/address"
|
||||
)
|
||||
|
||||
type GetDHTRequest struct{}
|
||||
|
||||
type GetDHTResponse struct {
|
||||
DHT []DHTEntry `json:"dht"`
|
||||
}
|
||||
|
||||
type DHTEntry struct {
|
||||
IPAddress string `json:"address"`
|
||||
PublicKey string `json:"key"`
|
||||
Parent string `json:"parent"`
|
||||
Sequence uint64 `json:"sequence"`
|
||||
//Port uint64 `json:"port"`
|
||||
//Rest uint64 `json:"rest"`
|
||||
}
|
||||
|
||||
func (a *AdminSocket) getDHTHandler(req *GetDHTRequest, res *GetDHTResponse) error {
|
||||
dht := a.core.GetDHT()
|
||||
res.DHT = make([]DHTEntry, 0, len(dht))
|
||||
for _, d := range dht {
|
||||
addr := address.AddrForKey(d.Key)
|
||||
res.DHT = append(res.DHT, DHTEntry{
|
||||
IPAddress: net.IP(addr[:]).String(),
|
||||
PublicKey: hex.EncodeToString(d.Key[:]),
|
||||
Parent: hex.EncodeToString(d.Parent[:]),
|
||||
Sequence: d.Sequence,
|
||||
//Port: d.Port,
|
||||
//Rest: d.Rest,
|
||||
})
|
||||
}
|
||||
sort.SliceStable(res.DHT, func(i, j int) bool {
|
||||
return strings.Compare(res.DHT[i].PublicKey, res.DHT[j].PublicKey) < 0
|
||||
})
|
||||
return nil
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue