Configurable local announcement port (fixes #256)
This commit is contained in:
parent
2e1c33206f
commit
ae0193b724
|
@ -615,7 +615,7 @@ next:
|
||||||
}
|
}
|
||||||
|
|
||||||
func discovery(extPort int) *discover.Discoverer {
|
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 {
|
if err != nil {
|
||||||
l.Warnf("No discovery possible (%v)", err)
|
l.Warnf("No discovery possible (%v)", err)
|
||||||
return nil
|
return nil
|
||||||
|
|
|
@ -55,6 +55,7 @@ type OptionsConfiguration struct {
|
||||||
GlobalAnnServer string `xml:"globalAnnounceServer" default:"announce.syncthing.net:22025"`
|
GlobalAnnServer string `xml:"globalAnnounceServer" default:"announce.syncthing.net:22025"`
|
||||||
GlobalAnnEnabled bool `xml:"globalAnnounceEnabled" default:"true"`
|
GlobalAnnEnabled bool `xml:"globalAnnounceEnabled" default:"true"`
|
||||||
LocalAnnEnabled bool `xml:"localAnnounceEnabled" default:"true"`
|
LocalAnnEnabled bool `xml:"localAnnounceEnabled" default:"true"`
|
||||||
|
LocalAnnPort int `xml:"localAnnouncePort" default:"21025"`
|
||||||
ParallelRequests int `xml:"parallelRequests" default:"16"`
|
ParallelRequests int `xml:"parallelRequests" default:"16"`
|
||||||
MaxSendKbps int `xml:"maxSendKbps"`
|
MaxSendKbps int `xml:"maxSendKbps"`
|
||||||
RescanIntervalS int `xml:"rescanIntervalS" default:"60"`
|
RescanIntervalS int `xml:"rescanIntervalS" default:"60"`
|
||||||
|
|
|
@ -14,6 +14,7 @@ func TestDefaultValues(t *testing.T) {
|
||||||
GlobalAnnServer: "announce.syncthing.net:22025",
|
GlobalAnnServer: "announce.syncthing.net:22025",
|
||||||
GlobalAnnEnabled: true,
|
GlobalAnnEnabled: true,
|
||||||
LocalAnnEnabled: true,
|
LocalAnnEnabled: true,
|
||||||
|
LocalAnnPort: 21025,
|
||||||
ParallelRequests: 16,
|
ParallelRequests: 16,
|
||||||
MaxSendKbps: 0,
|
MaxSendKbps: 0,
|
||||||
RescanIntervalS: 60,
|
RescanIntervalS: 60,
|
||||||
|
@ -145,6 +146,7 @@ func TestOverriddenValues(t *testing.T) {
|
||||||
<globalAnnounceServer>syncthing.nym.se:22025</globalAnnounceServer>
|
<globalAnnounceServer>syncthing.nym.se:22025</globalAnnounceServer>
|
||||||
<globalAnnounceEnabled>false</globalAnnounceEnabled>
|
<globalAnnounceEnabled>false</globalAnnounceEnabled>
|
||||||
<localAnnounceEnabled>false</localAnnounceEnabled>
|
<localAnnounceEnabled>false</localAnnounceEnabled>
|
||||||
|
<localAnnouncePort>42123</localAnnouncePort>
|
||||||
<parallelRequests>32</parallelRequests>
|
<parallelRequests>32</parallelRequests>
|
||||||
<maxSendKbps>1234</maxSendKbps>
|
<maxSendKbps>1234</maxSendKbps>
|
||||||
<rescanIntervalS>600</rescanIntervalS>
|
<rescanIntervalS>600</rescanIntervalS>
|
||||||
|
@ -161,6 +163,7 @@ func TestOverriddenValues(t *testing.T) {
|
||||||
GlobalAnnServer: "syncthing.nym.se:22025",
|
GlobalAnnServer: "syncthing.nym.se:22025",
|
||||||
GlobalAnnEnabled: false,
|
GlobalAnnEnabled: false,
|
||||||
LocalAnnEnabled: false,
|
LocalAnnEnabled: false,
|
||||||
|
LocalAnnPort: 42123,
|
||||||
ParallelRequests: 32,
|
ParallelRequests: 32,
|
||||||
MaxSendKbps: 1234,
|
MaxSendKbps: 1234,
|
||||||
RescanIntervalS: 600,
|
RescanIntervalS: 600,
|
||||||
|
|
|
@ -13,10 +13,6 @@ import (
|
||||||
"github.com/calmh/syncthing/buffers"
|
"github.com/calmh/syncthing/buffers"
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
|
||||||
AnnouncementPort = 21025
|
|
||||||
)
|
|
||||||
|
|
||||||
type Discoverer struct {
|
type Discoverer struct {
|
||||||
myID string
|
myID string
|
||||||
listenAddrs []string
|
listenAddrs []string
|
||||||
|
@ -42,8 +38,8 @@ var (
|
||||||
// When we hit this many errors in succession, we stop.
|
// When we hit this many errors in succession, we stop.
|
||||||
const maxErrors = 30
|
const maxErrors = 30
|
||||||
|
|
||||||
func NewDiscoverer(id string, addresses []string) (*Discoverer, error) {
|
func NewDiscoverer(id string, addresses []string, localPort int) (*Discoverer, error) {
|
||||||
b, err := beacon.New(21025)
|
b, err := beacon.New(localPort)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue