Fix discovery in the absence of listen addresses (fixes #4418)
This makes it OK to not have any listeners working. Specifically, - We don't complain about an empty listener address - We don't complain about not having anything to announce to global discovery servers - We don't send local discovery packets when there is nothing to announce. The last point also fixes a thing where the list of addresses for local discovery was set at startup time and never refreshed. GitHub-Pull-Request: https://github.com/syncthing/syncthing/pull/4517
This commit is contained in:
committed by
Audrius Butkevicius
parent
aecd7c64ce
commit
7ebf58f1bc
@@ -7,13 +7,14 @@
|
||||
package discover
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"net"
|
||||
"testing"
|
||||
|
||||
"github.com/syncthing/syncthing/lib/protocol"
|
||||
)
|
||||
|
||||
func TestRandomLocalInstanceID(t *testing.T) {
|
||||
func TestLocalInstanceID(t *testing.T) {
|
||||
c, err := NewLocal(protocol.LocalDeviceID, ":0", &fakeAddressLister{})
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
@@ -23,9 +24,15 @@ func TestRandomLocalInstanceID(t *testing.T) {
|
||||
|
||||
lc := c.(*localClient)
|
||||
|
||||
p0 := lc.announcementPkt()
|
||||
p1 := lc.announcementPkt()
|
||||
if p0.InstanceID == p1.InstanceID {
|
||||
p0, ok := lc.announcementPkt(1, nil)
|
||||
if !ok {
|
||||
t.Fatal("unexpectedly not ok")
|
||||
}
|
||||
p1, ok := lc.announcementPkt(2, nil)
|
||||
if !ok {
|
||||
t.Fatal("unexpectedly not ok")
|
||||
}
|
||||
if bytes.Equal(p0, p1) {
|
||||
t.Error("each generated packet should have a new instance id")
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user