Do not start relay service unless explicitly asked for, or global announcement server is running

This commit is contained in:
Audrius Butkevicius 2015-07-24 19:55:52 +01:00
parent 6cccd9b6fc
commit 031804827f
4 changed files with 10 additions and 3 deletions

View File

@ -630,7 +630,7 @@ func syncthingMain() {
m.StartDeadlockDetector(time.Duration(it) * time.Second) m.StartDeadlockDetector(time.Duration(it) * time.Second)
} }
} else if !IsRelease || IsBeta { } else if !IsRelease || IsBeta {
m.StartDeadlockDetector(20 * 60 * time.Second) m.StartDeadlockDetector(20 * time.Minute)
} }
// Clear out old indexes for other devices. Otherwise we'll start up and // Clear out old indexes for other devices. Otherwise we'll start up and
@ -674,9 +674,12 @@ func syncthingMain() {
// Start the relevant services // Start the relevant services
connectionSvc := newConnectionSvc(cfg, myID, m, tlsCfg) connectionSvc := newConnectionSvc(cfg, myID, m, tlsCfg)
mainSvc.Add(connectionSvc)
if opts.GlobalAnnEnabled || opts.RelayWithoutGlobalAnn {
relaySvc = relay.NewSvc(cfg, tlsCfg, connectionSvc.conns) relaySvc = relay.NewSvc(cfg, tlsCfg, connectionSvc.conns)
connectionSvc.Add(relaySvc) connectionSvc.Add(relaySvc)
mainSvc.Add(connectionSvc) }
// Start discovery // Start discovery

View File

@ -224,6 +224,7 @@ type OptionsConfiguration struct {
MaxRecvKbps int `xml:"maxRecvKbps" json:"maxRecvKbps"` MaxRecvKbps int `xml:"maxRecvKbps" json:"maxRecvKbps"`
ReconnectIntervalS int `xml:"reconnectionIntervalS" json:"reconnectionIntervalS" default:"60"` ReconnectIntervalS int `xml:"reconnectionIntervalS" json:"reconnectionIntervalS" default:"60"`
RelayReconnectIntervalM int `xml:"relayReconnectIntervalM" json:"relayReconnectIntervalM" default:"10"` RelayReconnectIntervalM int `xml:"relayReconnectIntervalM" json:"relayReconnectIntervalM" default:"10"`
RelayWithoutGlobalAnn bool `xml:"relayWithoutGlobalAnn" json:"relayWithoutGlobalAnn" default:"false"`
StartBrowser bool `xml:"startBrowser" json:"startBrowser" default:"true"` StartBrowser bool `xml:"startBrowser" json:"startBrowser" default:"true"`
UPnPEnabled bool `xml:"upnpEnabled" json:"upnpEnabled" default:"true"` UPnPEnabled bool `xml:"upnpEnabled" json:"upnpEnabled" default:"true"`
UPnPLeaseM int `xml:"upnpLeaseMinutes" json:"upnpLeaseMinutes" default:"60"` UPnPLeaseM int `xml:"upnpLeaseMinutes" json:"upnpLeaseMinutes" default:"60"`

View File

@ -42,6 +42,7 @@ func TestDefaultValues(t *testing.T) {
MaxRecvKbps: 0, MaxRecvKbps: 0,
ReconnectIntervalS: 60, ReconnectIntervalS: 60,
RelayReconnectIntervalM: 10, RelayReconnectIntervalM: 10,
RelayWithoutGlobalAnn: false,
StartBrowser: true, StartBrowser: true,
UPnPEnabled: true, UPnPEnabled: true,
UPnPLeaseM: 60, UPnPLeaseM: 60,
@ -155,6 +156,7 @@ func TestOverriddenValues(t *testing.T) {
MaxRecvKbps: 2341, MaxRecvKbps: 2341,
ReconnectIntervalS: 6000, ReconnectIntervalS: 6000,
RelayReconnectIntervalM: 20, RelayReconnectIntervalM: 20,
RelayWithoutGlobalAnn: true,
StartBrowser: false, StartBrowser: false,
UPnPEnabled: false, UPnPEnabled: false,
UPnPLeaseM: 90, UPnPLeaseM: 90,

View File

@ -14,6 +14,7 @@
<maxRecvKbps>2341</maxRecvKbps> <maxRecvKbps>2341</maxRecvKbps>
<reconnectionIntervalS>6000</reconnectionIntervalS> <reconnectionIntervalS>6000</reconnectionIntervalS>
<relayReconnectIntervalM>20</relayReconnectIntervalM> <relayReconnectIntervalM>20</relayReconnectIntervalM>
<relayWithoutGlobalAnn>true</relayWithoutGlobalAnn>
<startBrowser>false</startBrowser> <startBrowser>false</startBrowser>
<upnpEnabled>false</upnpEnabled> <upnpEnabled>false</upnpEnabled>
<upnpLeaseMinutes>90</upnpLeaseMinutes> <upnpLeaseMinutes>90</upnpLeaseMinutes>