diff --git a/cmd/syncthing/main.go b/cmd/syncthing/main.go index 9f95f5795..483402ee2 100644 --- a/cmd/syncthing/main.go +++ b/cmd/syncthing/main.go @@ -615,7 +615,7 @@ next: } func discovery(extPort int) *discover.Discoverer { - disc, err := discover.NewDiscoverer(myID, cfg.Options.ListenAddress) + disc, err := discover.NewDiscoverer(myID, cfg.Options.ListenAddress, cfg.Options.LocalAnnPort) if err != nil { l.Warnf("No discovery possible (%v)", err) return nil diff --git a/config/config.go b/config/config.go index a08491953..37c79ad3a 100644 --- a/config/config.go +++ b/config/config.go @@ -55,6 +55,7 @@ type OptionsConfiguration struct { GlobalAnnServer string `xml:"globalAnnounceServer" default:"announce.syncthing.net:22025"` GlobalAnnEnabled bool `xml:"globalAnnounceEnabled" default:"true"` LocalAnnEnabled bool `xml:"localAnnounceEnabled" default:"true"` + LocalAnnPort int `xml:"localAnnouncePort" default:"21025"` ParallelRequests int `xml:"parallelRequests" default:"16"` MaxSendKbps int `xml:"maxSendKbps"` RescanIntervalS int `xml:"rescanIntervalS" default:"60"` diff --git a/config/config_test.go b/config/config_test.go index ece912f11..34f5f7061 100644 --- a/config/config_test.go +++ b/config/config_test.go @@ -14,6 +14,7 @@ func TestDefaultValues(t *testing.T) { GlobalAnnServer: "announce.syncthing.net:22025", GlobalAnnEnabled: true, LocalAnnEnabled: true, + LocalAnnPort: 21025, ParallelRequests: 16, MaxSendKbps: 0, RescanIntervalS: 60, @@ -145,6 +146,7 @@ func TestOverriddenValues(t *testing.T) { syncthing.nym.se:22025 false false + 42123 32 1234 600 @@ -161,6 +163,7 @@ func TestOverriddenValues(t *testing.T) { GlobalAnnServer: "syncthing.nym.se:22025", GlobalAnnEnabled: false, LocalAnnEnabled: false, + LocalAnnPort: 42123, ParallelRequests: 32, MaxSendKbps: 1234, RescanIntervalS: 600, diff --git a/discover/discover.go b/discover/discover.go index d407285d7..1ded17cbd 100644 --- a/discover/discover.go +++ b/discover/discover.go @@ -13,10 +13,6 @@ import ( "github.com/calmh/syncthing/buffers" ) -const ( - AnnouncementPort = 21025 -) - type Discoverer struct { myID string listenAddrs []string @@ -42,8 +38,8 @@ var ( // When we hit this many errors in succession, we stop. const maxErrors = 30 -func NewDiscoverer(id string, addresses []string) (*Discoverer, error) { - b, err := beacon.New(21025) +func NewDiscoverer(id string, addresses []string, localPort int) (*Discoverer, error) { + b, err := beacon.New(localPort) if err != nil { return nil, err }