Searches called from api.go, various other tweaks, searches now have a callback for success/failure, node ID now reported by admin socket

This commit is contained in:
Neil Alexander 2019-04-18 23:38:23 +01:00
parent eef2a02d0a
commit 160e01e84f
No known key found for this signature in database
GPG key ID: A02A2019A2BB0944
7 changed files with 177 additions and 81 deletions

View file

@ -10,6 +10,7 @@ import (
"os/signal"
"strings"
"syscall"
"time"
"golang.org/x/text/encoding/unicode"
@ -267,6 +268,18 @@ func main() {
defer func() {
n.core.Stop()
}()
// Some stuff
go func() {
time.Sleep(time.Second * 2)
session, err := n.core.Dial("nodeid", "babd4e4bccb216f77bb723c1b034b63a652060aabfe9506b51f687183e9b0fd13f438876f5a3ab21cac9c8101eb88e2613fe2a8b0724add09d7ef5a72146c31f")
logger.Println(session, err)
b := []byte{1, 2, 3, 4, 5}
for {
logger.Println(session.Write(b))
logger.Println(session.Read(b))
time.Sleep(time.Second)
}
}()
// Make some nice output that tells us what our IPv6 address and subnet are.
// This is just logged to stdout for the user.
address := n.core.Address()

View file

@ -277,6 +277,9 @@ func main() {
fmt.Println("Coords:", coords)
}
if *verbose {
if nodeID, ok := v.(map[string]interface{})["node_id"].(string); ok {
fmt.Println("Node ID:", nodeID)
}
if boxPubKey, ok := v.(map[string]interface{})["box_pub_key"].(string); ok {
fmt.Println("Public encryption key:", boxPubKey)
}