Commit ccc5066b authored by George MacRorie's avatar George MacRorie

Renaming node -> device and repository -> folder

parent 1013b5c1
This source diff could not be displayed because it is too large. You can view the blob instead.
......@@ -88,10 +88,10 @@ func startGUI(cfg config.GUIConfiguration, assetDir string, m *model.Model) erro
getRestMux.HandleFunc("/rest/model", withModel(m, restGetModel))
getRestMux.HandleFunc("/rest/model/version", withModel(m, restGetModelVersion))
getRestMux.HandleFunc("/rest/need", withModel(m, restGetNeed))
getRestMux.HandleFunc("/rest/nodeid", restGetNodeID)
getRestMux.HandleFunc("/rest/deviceid", restGetDeviceID)
getRestMux.HandleFunc("/rest/system", restGetSystem)
getRestMux.HandleFunc("/rest/version", restGetVersion)
getRestMux.HandleFunc("/rest/stats/node", withModel(m, restGetNodeStats))
getRestMux.HandleFunc("/rest/stats/device", withModel(m, restGetDeviceStats))
// Debug endpoints, not for general use
getRestMux.HandleFunc("/rest/debug/peerCompletion", withModel(m, restGetPeerCompletion))
......@@ -218,16 +218,16 @@ func restGetVersion(w http.ResponseWriter, r *http.Request) {
func restGetCompletion(m *model.Model, w http.ResponseWriter, r *http.Request) {
var qs = r.URL.Query()
var repo = qs.Get("repo")
var nodeStr = qs.Get("node")
var deviceStr = qs.Get("device")
node, err := protocol.NodeIDFromString(nodeStr)
device, err := protocol.DeviceIDFromString(deviceStr)
if err != nil {
http.Error(w, err.Error(), 500)
return
}
res := map[string]float64{
"completion": m.Completion(node, repo),
"completion": m.Completion(device, repo),
}
w.Header().Set("Content-Type", "application/json; charset=utf-8")
......@@ -250,7 +250,7 @@ func restGetModel(m *model.Model, w http.ResponseWriter, r *http.Request) {
var repo = qs.Get("repo")
var res = make(map[string]interface{})
for _, cr := range cfg.Repositories {
for _, cr := range cfg.Folders {
if cr.ID == repo {
res["invalid"] = cr.Invalid
break
......@@ -297,8 +297,8 @@ func restGetConnections(m *model.Model, w http.ResponseWriter, r *http.Request)
json.NewEncoder(w).Encode(res)
}
func restGetNodeStats(m *model.Model, w http.ResponseWriter, r *http.Request) {
var res = m.NodeStatistics()
func restGetDeviceStats(m *model.Model, w http.ResponseWriter, r *http.Request) {
var res = m.DeviceStatistics()
w.Header().Set("Content-Type", "application/json; charset=utf-8")
json.NewEncoder(w).Encode(res)
}
......@@ -349,7 +349,7 @@ func restPostRestart(w http.ResponseWriter, r *http.Request) {
func restPostReset(w http.ResponseWriter, r *http.Request) {
flushResponse(`{"ok": "resetting repos"}`, w)
resetRepositories()
resetFolders()
go restart()
}
......@@ -422,10 +422,10 @@ func showGuiError(l logger.LogLevel, err string) {
func restPostDiscoveryHint(w http.ResponseWriter, r *http.Request) {
var qs = r.URL.Query()
var node = qs.Get("node")
var device = qs.Get("device")
var addr = qs.Get("addr")
if len(node) != 0 && len(addr) != 0 && discoverer != nil {
discoverer.Hint(node, []string{addr})
if len(device) != 0 && len(addr) != 0 && discoverer != nil {
discoverer.Hint(device, []string{addr})
}
}
......@@ -490,10 +490,10 @@ func restGetEvents(w http.ResponseWriter, r *http.Request) {
json.NewEncoder(w).Encode(evs)
}
func restGetNodeID(w http.ResponseWriter, r *http.Request) {
func restGetDeviceID(w http.ResponseWriter, r *http.Request) {
qs := r.URL.Query()
idStr := qs.Get("id")
id, err := protocol.NodeIDFromString(idStr)
id, err := protocol.DeviceIDFromString(idStr)
w.Header().Set("Content-Type", "application/json; charset=utf-8")
if err == nil {
json.NewEncoder(w).Encode(map[string]string{
......@@ -544,21 +544,21 @@ func restGetPeerCompletion(m *model.Model, w http.ResponseWriter, r *http.Reques
tot := map[string]float64{}
count := map[string]float64{}
for _, repo := range cfg.Repositories {
for _, node := range repo.NodeIDs() {
nodeStr := node.String()
if m.ConnectedTo(node) {
tot[nodeStr] += m.Completion(node, repo.ID)
for _, repo := range cfg.Folders {
for _, device := range repo.DeviceIDs() {
deviceStr := device.String()
if m.ConnectedTo(device) {
tot[deviceStr] += m.Completion(device, repo.ID)
} else {
tot[nodeStr] = 0
tot[deviceStr] = 0
}
count[nodeStr]++
count[deviceStr]++
}
}
comp := map[string]int{}
for node := range tot {
comp[node] = int(tot[node] / count[node])
for device := range tot {
comp[device] = int(tot[device] / count[device])
}
w.Header().Set("Content-Type", "application/json; charset=utf-8")
......
This diff is collapsed.
......@@ -19,8 +19,8 @@ func main() {
log.SetFlags(0)
log.SetOutput(os.Stdout)
repo := flag.String("repo", "default", "Repository ID")
node := flag.String("node", "", "Node ID (blank for global)")
repo := flag.String("repo", "default", "Folder ID")
device := flag.String("device", "", "Device ID (blank for global)")
flag.Parse()
db, err := leveldb.OpenFile(flag.Arg(0), nil)
......@@ -30,7 +30,7 @@ func main() {
fs := files.NewSet(*repo, db)
if *node == "" {
if *device == "" {
log.Printf("*** Global index for repo %q", *repo)
fs.WithGlobalTruncated(func(fi protocol.FileIntf) bool {
f := fi.(protocol.FileInfoTruncated)
......@@ -39,11 +39,11 @@ func main() {
return true
})
} else {
n, err := protocol.NodeIDFromString(*node)
n, err := protocol.DeviceIDFromString(*device)
if err != nil {
log.Fatal(err)
}
log.Printf("*** Have index for repo %q node %q", *repo, n)
log.Printf("*** Have index for repo %q device %q", *repo, n)
fs.WithHaveTruncated(n, func(fi protocol.FileIntf) bool {
f := fi.(protocol.FileInfoTruncated)
fmt.Println(f)
......
......@@ -19,9 +19,9 @@ import (
var trans = make(map[string]string)
var attrRe = regexp.MustCompile(`\{\{'([^']+)'\s+\|\s+translate\}\}`)
func generalNode(n *html.Node) {
func generalDevice(n *html.Device) {
translate := false
if n.Type == html.ElementNode {
if n.Type == html.ElementDevice {
for _, a := range n.Attr {
if a.Key == "translate" {
translate = true
......@@ -32,10 +32,10 @@ func generalNode(n *html.Node) {
}
}
}
} else if n.Type == html.TextNode {
} else if n.Type == html.TextDevice {
v := strings.TrimSpace(n.Data)
if len(v) > 1 && !(strings.HasPrefix(v, "{{") && strings.HasSuffix(v, "}}")) {
log.Println("Untranslated text node:")
log.Println("Untranslated text device:")
log.Print("\t" + v)
}
}
......@@ -43,20 +43,20 @@ func generalNode(n *html.Node) {
if translate {
inTranslate(c)
} else {
generalNode(c)
generalDevice(c)
}
}
}
func inTranslate(n *html.Node) {
if n.Type == html.TextNode {
func inTranslate(n *html.Device) {
if n.Type == html.TextDevice {
translation(n.Data)
} else {
log.Println("translate node with non-text child <")
log.Println("translate device with non-text child <")
log.Println(n)
}
if n.FirstChild != nil {
log.Println("translate node has children:")
log.Println("translate device has children:")
log.Println(n.Data)
}
}
......@@ -91,7 +91,7 @@ func main() {
}
fd.Close()
generalNode(doc)
generalDevice(doc)
bs, err := json.MarshalIndent(trans, "", " ")
if err != nil {
log.Fatal(err)
......
This diff is collapsed.
......@@ -12,13 +12,13 @@ import (
"source.ind.ie/project/pulse/protocol"
)
var node1, node2, node3, node4 protocol.NodeID
var device1, device2, device3, device4 protocol.DeviceID
func init() {
node1, _ = protocol.NodeIDFromString("AIR6LPZ7K4PTTUXQSMUUCPQ5YWOEDFIIQJUG7772YQXXR5YD6AWQ")
node2, _ = protocol.NodeIDFromString("GYRZZQB-IRNPV4Z-T7TC52W-EQYJ3TT-FDQW6MW-DFLMU42-SSSU6EM-FBK2VAY")
node3, _ = protocol.NodeIDFromString("LGFPDIT-7SKNNJL-VJZA4FC-7QNCRKA-CE753K7-2BW5QDK-2FOZ7FR-FEP57QJ")
node4, _ = protocol.NodeIDFromString("P56IOI7-MZJNU2Y-IQGDREY-DM2MGTI-MGL3BXN-PQ6W5BM-TBBZ4TJ-XZWICQ2")
device1, _ = protocol.DeviceIDFromString("AIR6LPZ7K4PTTUXQSMUUCPQ5YWOEDFIIQJUG7772YQXXR5YD6AWQ")
device2, _ = protocol.DeviceIDFromString("GYRZZQB-IRNPV4Z-T7TC52W-EQYJ3TT-FDQW6MW-DFLMU42-SSSU6EM-FBK2VAY")
device3, _ = protocol.DeviceIDFromString("LGFPDIT-7SKNNJL-VJZA4FC-7QNCRKA-CE753K7-2BW5QDK-2FOZ7FR-FEP57QJ")
device4, _ = protocol.DeviceIDFromString("P56IOI7-MZJNU2Y-IQGDREY-DM2MGTI-MGL3BXN-PQ6W5BM-TBBZ4TJ-XZWICQ2")
}
func TestDefaultValues(t *testing.T) {
......@@ -40,60 +40,60 @@ func TestDefaultValues(t *testing.T) {
RestartOnWakeup: true,
}
cfg := New("test", node1)
cfg := New("test", device1)
if !reflect.DeepEqual(cfg.Options, expected) {
t.Errorf("Default config differs;\n E: %#v\n A: %#v", expected, cfg.Options)
}
}
func TestNodeConfig(t *testing.T) {
func TestDeviceConfig(t *testing.T) {
for i, ver := range []string{"v1"} {
cfg, err := Load("testdata/"+ver+".xml", node1)
cfg, err := Load("testdata/"+ver+".xml", device1)
if err != nil {
t.Error(err)
}
expectedRepos := []RepositoryConfiguration{
expectedRepos := []FolderConfiguration{
{
ID: "test",
Directory: "~/Sync",
Nodes: []RepositoryNodeConfiguration{{NodeID: node1}, {NodeID: node4}},
Devices: []FolderDeviceConfiguration{{DeviceID: device1}, {DeviceID: device4}},
ReadOnly: true,
RescanIntervalS: 600,
},
}
expectedNodes := []NodeConfiguration{
expectedDevices := []DeviceConfiguration{
{
NodeID: node1,
DeviceID: device1,
Name: "device one",
Addresses: []string{"a"},
Compression: true,
},
{
NodeID: node4,
DeviceID: device4,
Name: "device two",
Addresses: []string{"b"},
Compression: true,
},
}
expectedNodeIDs := []protocol.NodeID{node1, node4}
expectedDeviceIDs := []protocol.DeviceID{device1, device4}
if cfg.Version != 1 {
t.Errorf("%d: Incorrect version %d != 1", i, cfg.Version)
}
if !reflect.DeepEqual(cfg.Repositories, expectedRepos) {
t.Errorf("%d: Incorrect Repositories\n A: %#v\n E: %#v", i, cfg.Repositories, expectedRepos)
if !reflect.DeepEqual(cfg.Folders, expectedRepos) {
t.Errorf("%d: Incorrect Folders\n A: %#v\n E: %#v", i, cfg.Folders, expectedRepos)
}
if !reflect.DeepEqual(cfg.Nodes, expectedNodes) {
t.Errorf("%d: Incorrect Nodes\n A: %#v\n E: %#v", i, cfg.Nodes, expectedNodes)
if !reflect.DeepEqual(cfg.Devices, expectedDevices) {
t.Errorf("%d: Incorrect Devices\n A: %#v\n E: %#v", i, cfg.Devices, expectedDevices)
}
if !reflect.DeepEqual(cfg.Repositories[0].NodeIDs(), expectedNodeIDs) {
t.Errorf("%d: Incorrect NodeIDs\n A: %#v\n E: %#v", i, cfg.Repositories[0].NodeIDs(), expectedNodeIDs)
if !reflect.DeepEqual(cfg.Folders[0].DeviceIDs(), expectedDeviceIDs) {
t.Errorf("%d: Incorrect DeviceIDs\n A: %#v\n E: %#v", i, cfg.Folders[0].DeviceIDs(), expectedDeviceIDs)
}
if len(cfg.NodeMap()) != len(expectedNodes) {
t.Errorf("Unexpected number of NodeMap() entries")
if len(cfg.DeviceMap()) != len(expectedDevices) {
t.Errorf("Unexpected number of DeviceMap() entries")
}
if len(cfg.RepoMap()) != len(expectedRepos) {
t.Errorf("Unexpected number of RepoMap() entries")
......@@ -102,7 +102,7 @@ func TestNodeConfig(t *testing.T) {
}
func TestNoListenAddress(t *testing.T) {
cfg, err := Load("testdata/nolistenaddress.xml", node1)
cfg, err := Load("testdata/nolistenaddress.xml", device1)
if err != nil {
t.Error(err)
}
......@@ -132,7 +132,7 @@ func TestOverriddenValues(t *testing.T) {
RestartOnWakeup: false,
}
cfg, err := Load("testdata/overridenvalues.xml", node1)
cfg, err := Load("testdata/overridenvalues.xml", device1)
if err != nil {
t.Error(err)
}
......@@ -142,80 +142,80 @@ func TestOverriddenValues(t *testing.T) {
}
}
func TestNodeAddressesDynamic(t *testing.T) {
func TestDeviceAddressesDynamic(t *testing.T) {
name, _ := os.Hostname()
expected := []NodeConfiguration{
expected := []DeviceConfiguration{
{
NodeID: node1,
DeviceID: device1,
Addresses: []string{"dynamic"},
Compression: false,
},
{
NodeID: node2,
DeviceID: device2,
Addresses: []string{"dynamic"},
Compression: false,
},
{
NodeID: node3,
DeviceID: device3,
Addresses: []string{"dynamic"},
Compression: false,
},
{
NodeID: node4,
DeviceID: device4,
Name: name, // Set when auto created
Addresses: []string{"dynamic"},
},
}
cfg, err := Load("testdata/nodeaddressesdynamic.xml", node4)
cfg, err := Load("testdata/deviceaddressesdynamic.xml", device4)
if err != nil {
t.Error(err)
}
if !reflect.DeepEqual(cfg.Nodes, expected) {
t.Errorf("Nodes differ;\n E: %#v\n A: %#v", expected, cfg.Nodes)
if !reflect.DeepEqual(cfg.Devices, expected) {
t.Errorf("Devices differ;\n E: %#v\n A: %#v", expected, cfg.Devices)
}
}
func TestNodeAddressesStatic(t *testing.T) {
func TestDeviceAddressesStatic(t *testing.T) {
name, _ := os.Hostname()
expected := []NodeConfiguration{
expected := []DeviceConfiguration{
{
NodeID: node1,
DeviceID: device1,
Addresses: []string{"192.0.2.1", "192.0.2.2"},
},
{
NodeID: node2,
DeviceID: device2,
Addresses: []string{"192.0.2.3:6070", "[2001:db8::42]:4242"},
},
{
NodeID: node3,
DeviceID: device3,
Addresses: []string{"[2001:db8::44]:4444", "192.0.2.4:6090"},
},
{
NodeID: node4,
DeviceID: device4,
Name: name, // Set when auto created
Addresses: []string{"dynamic"},
},
}
cfg, err := Load("testdata/nodeaddressesstatic.xml", node4)
cfg, err := Load("testdata/deviceaddressesstatic.xml", device4)
if err != nil {
t.Error(err)
}
if !reflect.DeepEqual(cfg.Nodes, expected) {
t.Errorf("Nodes differ;\n E: %#v\n A: %#v", expected, cfg.Nodes)
if !reflect.DeepEqual(cfg.Devices, expected) {
t.Errorf("Devices differ;\n E: %#v\n A: %#v", expected, cfg.Devices)
}
}
func TestVersioningConfig(t *testing.T) {
cfg, err := Load("testdata/versioningconfig.xml", node4)
cfg, err := Load("testdata/versioningconfig.xml", device4)
if err != nil {
t.Error(err)
}
vc := cfg.Repositories[0].Versioning
vc := cfg.Folders[0].Versioning
if vc.Type != "simple" {
t.Errorf(`vc.Type %q != "simple"`, vc.Type)
}
......@@ -241,7 +241,7 @@ func TestNewSaveLoad(t *testing.T) {
return err == nil
}
cfg := New(path, node1)
cfg := New(path, device1)
// To make the equality pass later
cfg.XMLName.Local = "configuration"
......@@ -258,7 +258,7 @@ func TestNewSaveLoad(t *testing.T) {
t.Error(path, "does not exist")
}
cfg2, err := Load(path, node1)
cfg2, err := Load(path, device1)
if err != nil {
t.Error(err)
}
......@@ -270,7 +270,7 @@ func TestNewSaveLoad(t *testing.T) {
cfg.GUI.User = "test"
cfg.Save()
cfg2, err = Load(path, node1)
cfg2, err = Load(path, device1)
if err != nil {
t.Error(err)
}
......@@ -285,13 +285,13 @@ func TestNewSaveLoad(t *testing.T) {
func TestPrepare(t *testing.T) {
var cfg Configuration
if cfg.Repositories != nil || cfg.Nodes != nil || cfg.Options.ListenAddress != nil {
if cfg.Folders != nil || cfg.Devices != nil || cfg.Options.ListenAddress != nil {
t.Error("Expected nil")
}
cfg.prepare(node1)
cfg.prepare(device1)
if cfg.Repositories == nil || cfg.Nodes == nil || cfg.Options.ListenAddress == nil {
if cfg.Folders == nil || cfg.Devices == nil || cfg.Options.ListenAddress == nil {
t.Error("Unexpected nil")
}
}
......@@ -20,7 +20,7 @@ import (
)
type Discoverer struct {
myID protocol.NodeID
myID protocol.DeviceID
listenAddrs []string
localBcastIntv time.Duration
globalBcastIntv time.Duration
......@@ -28,7 +28,7 @@ type Discoverer struct {
cacheLifetime time.Duration
broadcastBeacon beacon.Interface
multicastBeacon beacon.Interface
registry map[protocol.NodeID][]cacheEntry
registry map[protocol.DeviceID][]cacheEntry
registryLock sync.RWMutex
extServer string
extPort uint16
......@@ -49,7 +49,7 @@ var (
ErrIncorrectMagic = errors.New("incorrect magic number")
)
func NewDiscoverer(id protocol.NodeID, addresses []string) *Discoverer {
func NewDiscoverer(id protocol.DeviceID, addresses []string) *Discoverer {
return &Discoverer{
myID: id,
listenAddrs: addresses,
......@@ -57,7 +57,7 @@ func NewDiscoverer(id protocol.NodeID, addresses []string) *Discoverer {
globalBcastIntv: 1800 * time.Second,
errorRetryIntv: 60 * time.Second,
cacheLifetime: 5 * time.Minute,
registry: make(map[protocol.NodeID][]cacheEntry),
registry: make(map[protocol.DeviceID][]cacheEntry),
}
}
......@@ -120,9 +120,9 @@ func (d *Discoverer) ExtAnnounceOK() bool {
return d.extAnnounceOK
}
func (d *Discoverer) Lookup(node protocol.NodeID) []string {
func (d *Discoverer) Lookup(device protocol.DeviceID) []string {
d.registryLock.Lock()
cached := d.filterCached(d.registry[node])
cached := d.filterCached(d.registry[device])
d.registryLock.Unlock()
if len(cached) > 0 {
......@@ -132,7 +132,7 @@ func (d *Discoverer) Lookup(node protocol.NodeID) []string {
}
return addrs
} else if len(d.extServer) != 0 {
addrs := d.externalLookup(node)
addrs := d.externalLookup(device)
cached = make([]cacheEntry, len(addrs))
for i := range addrs {
cached[i] = cacheEntry{
......@@ -142,32 +142,32 @@ func (d *Discoverer) Lookup(node protocol.NodeID) []string {
}
d.registryLock.Lock()
d.registry[node] = cached
d.registry[device] = cached
d.registryLock.Unlock()
}
return nil
}
func (d *Discoverer) Hint(node string, addrs []string) {
func (d *Discoverer) Hint(device string, addrs []string) {
resAddrs := resolveAddrs(addrs)
var id protocol.NodeID
id.UnmarshalText([]byte(node))
d.registerNode(nil, Node{
var id protocol.DeviceID
id.UnmarshalText([]byte(device))
d.registerDevice(nil, Device{
Addresses: resAddrs,
ID: id[:],
})
}
func (d *Discoverer) All() map[protocol.NodeID][]cacheEntry {
func (d *Discoverer) All() map[protocol.DeviceID][]cacheEntry {
d.registryLock.RLock()
nodes := make(map[protocol.NodeID][]cacheEntry, len(d.registry))
for node, addrs := range d.registry {
devices := make(map[protocol.DeviceID][]cacheEntry, len(d.registry))
for device, addrs := range d.registry {
addrsCopy := make([]cacheEntry, len(addrs))
copy(addrsCopy, addrs)
nodes[node] = addrsCopy
devices[device] = addrsCopy
}
d.registryLock.RUnlock()
return nodes
return devices
}
func (d *Discoverer) announcementPkt() []byte {
......@@ -190,7 +190,7 @@ func (d *Discoverer) announcementPkt() []byte {
}
var pkt = Announce{
Magic: AnnouncementMagic,
This: Node{d.myID[:], addrs},
This: Device{d.myID[:], addrs},
}
return pkt.MarshalXDR()
}
......@@ -200,7 +200,7 @@ func (d *Discoverer) sendLocalAnnouncements() {
var pkt = Announce{
Magic: AnnouncementMagic,
This: Node{d.myID[:], addrs},
This: Device{d.myID[:], addrs},
}
msg := pkt.MarshalXDR()
......@@ -240,7 +240,7 @@ func (d *Discoverer) sendExternalAnnouncements() {
if d.extPort != 0 {
var pkt = Announce{
Magic: AnnouncementMagic,
This: Node{d.myID[:], []Address{{Port: d.extPort}}},
This: Device{d.myID[:], []Address{{Port: d.extPort}}},
}
buf = pkt.MarshalXDR()
} else {
......@@ -264,7 +264,7 @@ func (d *Discoverer) sendExternalAnnouncements() {
}
ok = false
} else {
// Verify that the announce server responds positively for our node ID
// Verify that the announce server responds positively for our device ID
time.Sleep(1 * time.Second)
res := d.externalLookup(d.myID)
......@@ -321,12 +321,12 @@ func (d *Discoverer) recvAnnouncements(b beacon.Interface) {
continue
}
var newNode bool
var newDevice bool
if bytes.Compare(pkt.This.ID, d.myID[:]) != 0 {
newNode = d.registerNode(addr, pkt.This)
newDevice = d.registerDevice(addr, pkt.This)
}
if newNode {
if newDevice {
select {
case d.forcedBcastTick <- time.Now():
}
......@@ -334,9 +334,9 @@ func (d *Discoverer) recvAnnouncements(b beacon.Interface) {
}
}
func (d *Discoverer) registerNode(addr net.Addr, node Node) bool {
var id protocol.NodeID
copy(id[:], node.ID)
func (d *Discoverer) registerDevice(addr net.Addr, device Device) bool {
var id protocol.DeviceID
copy(id[:], device.ID)
d.registryLock.RLock()
current := d.filterCached(d.registry[id])
......@@ -344,23 +344,23 @@ func (d *Discoverer) registerNode(addr net.Addr, node Node) bool {
orig := current
for _, a := range node.Addresses {
var nodeAddr string
for _, a := range device.Addresses {
var deviceAddr string
if len(a.IP) > 0 {
nodeAddr = net.JoinHostPort(net.IP(a.IP).String(), strconv.Itoa(int(a.Port)))
deviceAddr = net.JoinHostPort(net.IP(a.IP).String(), strconv.Itoa(int(a.Port)))
} else if addr != nil {
ua := addr.(*net.UDPAddr)
ua.Port = int(a.Port)
nodeAddr = ua.String()
deviceAddr = ua.String()
}
for i := range current {
if current[i].addr == nodeAddr {
if current[i].addr == deviceAddr {
current[i].seen = time.Now()
goto done
}
}
current = append(current, cacheEntry{
addr: nodeAddr,
addr: deviceAddr,
seen: time.Now(),
})
done:
......@@ -379,8 +379,8 @@ func (d *Discoverer) registerNode(addr net.Addr, node Node) bool {
for i := range current {
addrs[i] = current[i].addr
}
events.Default.Log(events.NodeDiscovered, map[string]interface{}{
"node": id.String(),
events.Default.Log(events.DeviceDiscovered, map[string]interface{}{
"device": id.String(),
"addrs": addrs,
})
}
......@@ -388,7 +388,7 @@ func (d *Discoverer) registerNode(addr net.Addr, node Node) bool {
return len(current) > len(orig)
}
func (d *Discoverer) externalLookup(node protocol.NodeID) []string {
func (d *Discoverer) externalLookup(device protocol.DeviceID) []string {
extIP, err := net.ResolveUDPAddr("udp", d.extServer)
if err != nil {
if debug {
......@@ -414,7 +414,7 @@ func (d *Discoverer) externalLookup(node protocol.NodeID) []string {
return nil
}
buf := Query{QueryMagic, node[:]}.MarshalXDR()
buf := Query{QueryMagic, device[:]}.MarshalXDR()