make RPC new-host new-node also highlight the ID of created host/node, as well fix bugs in these RPC calls
This commit is contained in:
parent
a8029bc8d5
commit
f5c7956c94
3 changed files with 12 additions and 3 deletions
6
main.go
6
main.go
|
|
@ -710,6 +710,8 @@ func rpcMain() {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Fprintf(os.Stderr, "failed to save host keystore: %v\n", err)
|
fmt.Fprintf(os.Stderr, "failed to save host keystore: %v\n", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fmt.Printf("New host ID: %s\n", rpcRes.NewHostID)
|
||||||
}
|
}
|
||||||
|
|
||||||
if rpcNewNode != "" {
|
if rpcNewNode != "" {
|
||||||
|
|
@ -741,10 +743,12 @@ func rpcMain() {
|
||||||
}
|
}
|
||||||
|
|
||||||
// deserialize keystore
|
// deserialize keystore
|
||||||
_, err = crypto.LuxKeyStoreFromRpc(rpcRes.Keystore, rpcNewHost)
|
_, err = crypto.LuxKeyStoreFromRpc(rpcRes.Keystore, rpcNewNode)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Fprintf(os.Stderr, "failed to save node keystore: %v\n", err)
|
fmt.Fprintf(os.Stderr, "failed to save node keystore: %v\n", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fmt.Printf("New neighbor node ID: %s\n", rpcRes.NewNodeID)
|
||||||
}
|
}
|
||||||
|
|
||||||
if rpcQueryHost != "" || rpcQueryHostname != "" {
|
if rpcQueryHost != "" || rpcQueryHostname != "" {
|
||||||
|
|
|
||||||
|
|
@ -343,7 +343,8 @@ func (node *LuxNode) Handle(request rpc.LuxRpcRequest, rpcType rpc.LuxRpcType) (
|
||||||
ksHost.Put(host)
|
ksHost.Put(host)
|
||||||
|
|
||||||
return rpc.LuxRpcResponse{
|
return rpc.LuxRpcResponse{
|
||||||
Keystore: crypto.LuxKeyStoreIntoRpc(&ksHost),
|
Keystore: crypto.LuxKeyStoreIntoRpc(&ksHost),
|
||||||
|
NewHostID: host.Id.String(),
|
||||||
}, rpc.LuxRpcError{}, true
|
}, rpc.LuxRpcError{}, true
|
||||||
} else if request.Command == "new-node" {
|
} else if request.Command == "new-node" {
|
||||||
if rpcType != rpc.LuxRpcTypeRoot {
|
if rpcType != rpc.LuxRpcTypeRoot {
|
||||||
|
|
@ -364,7 +365,8 @@ func (node *LuxNode) Handle(request rpc.LuxRpcRequest, rpcType rpc.LuxRpcType) (
|
||||||
|
|
||||||
// yeah we just serialize our own keystore
|
// yeah we just serialize our own keystore
|
||||||
return rpc.LuxRpcResponse{
|
return rpc.LuxRpcResponse{
|
||||||
Keystore: crypto.LuxKeyStoreIntoRpc(ks),
|
Keystore: crypto.LuxKeyStoreIntoRpc(ks),
|
||||||
|
NewNodeID: newNode.Id.String(),
|
||||||
}, rpc.LuxRpcError{}, true
|
}, rpc.LuxRpcError{}, true
|
||||||
} else if request.Command == "query" {
|
} else if request.Command == "query" {
|
||||||
// now we get host states either by ID or hostname
|
// now we get host states either by ID or hostname
|
||||||
|
|
|
||||||
|
|
@ -119,6 +119,9 @@ type LuxRpcResponse struct {
|
||||||
Keystore LuxRpcKeyStore `xml:"keystore"`
|
Keystore LuxRpcKeyStore `xml:"keystore"`
|
||||||
Routes []LuxRpcRoute `xml:"route"`
|
Routes []LuxRpcRoute `xml:"route"`
|
||||||
Hosts []LuxRpcHost `xml:"host"`
|
Hosts []LuxRpcHost `xml:"host"`
|
||||||
|
|
||||||
|
NewHostID string `xml:"newHostId"`
|
||||||
|
NewNodeID string `xml:"newNodeId"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type LuxRpcError struct {
|
type LuxRpcError struct {
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue