diff --git a/Godeps/Godeps.json b/Godeps/Godeps.json
index 2221775dd..e31097eef 100644
--- a/Godeps/Godeps.json
+++ b/Godeps/Godeps.json
@@ -35,7 +35,7 @@
},
{
"ImportPath": "github.com/syncthing/protocol",
- "Rev": "e19e2c123e520d68b919740731140faee950e69d"
+ "Rev": "9f871a372629080e07662db3ccf4f075bdac7a6f"
},
{
"ImportPath": "github.com/syndtr/goleveldb/leveldb",
diff --git a/Godeps/_workspace/src/github.com/syncthing/protocol/protocol.go b/Godeps/_workspace/src/github.com/syncthing/protocol/protocol.go
index 605de4781..50115c09c 100644
--- a/Godeps/_workspace/src/github.com/syncthing/protocol/protocol.go
+++ b/Godeps/_workspace/src/github.com/syncthing/protocol/protocol.go
@@ -140,9 +140,9 @@ type isEofer interface {
IsEOF() bool
}
-const (
- pingTimeout = 30 * time.Second
- pingIdleTime = 60 * time.Second
+var (
+ PingTimeout = 30 * time.Second
+ PingIdleTime = 60 * time.Second
)
func NewConnection(deviceID DeviceID, reader io.Reader, writer io.Writer, receiver Model, name string, compress Compression) Connection {
@@ -684,17 +684,17 @@ func (c *rawConnection) idGenerator() {
func (c *rawConnection) pingerLoop() {
var rc = make(chan bool, 1)
- ticker := time.Tick(pingIdleTime / 2)
+ ticker := time.Tick(PingIdleTime / 2)
for {
select {
case <-ticker:
- if d := time.Since(c.cr.Last()); d < pingIdleTime {
+ if d := time.Since(c.cr.Last()); d < PingIdleTime {
if debug {
l.Debugln(c.id, "ping skipped after rd", d)
}
continue
}
- if d := time.Since(c.cw.Last()); d < pingIdleTime {
+ if d := time.Since(c.cw.Last()); d < PingIdleTime {
if debug {
l.Debugln(c.id, "ping skipped after wr", d)
}
@@ -714,7 +714,7 @@ func (c *rawConnection) pingerLoop() {
if !ok {
c.close(fmt.Errorf("ping failure"))
}
- case <-time.After(pingTimeout):
+ case <-time.After(PingTimeout):
c.close(fmt.Errorf("ping timeout"))
case <-c.closed:
return
diff --git a/cmd/syncthing/main.go b/cmd/syncthing/main.go
index 3fe62c2cb..7f513190f 100644
--- a/cmd/syncthing/main.go
+++ b/cmd/syncthing/main.go
@@ -565,6 +565,9 @@ func syncthingMain() {
symlinks.Supported = false
}
+ protocol.PingTimeout = time.Duration(opts.PingTimeoutS) * time.Second
+ protocol.PingIdleTime = time.Duration(opts.PingIdleTimeS) * time.Second
+
if opts.MaxSendKbps > 0 {
writeRateLimit = ratelimit.NewBucketWithRate(float64(1000*opts.MaxSendKbps), int64(5*1000*opts.MaxSendKbps))
}
diff --git a/internal/config/config.go b/internal/config/config.go
index 375484dcd..2cb89efea 100644
--- a/internal/config/config.go
+++ b/internal/config/config.go
@@ -237,6 +237,8 @@ type OptionsConfiguration struct {
SymlinksEnabled bool `xml:"symlinksEnabled" json:"symlinksEnabled" default:"true"`
LimitBandwidthInLan bool `xml:"limitBandwidthInLan" json:"limitBandwidthInLan" default:"false"`
DatabaseBlockCacheMiB int `xml:"databaseBlockCacheMiB" json:"databaseBlockCacheMiB" default:"0"`
+ PingTimeoutS int `xml:"pingTimeoutS" json:"pingTimeoutS" default:"30"`
+ PingIdleTimeS int `xml:"pingIdleTimeS" json:"pingIdleTimeS" default:"60"`
}
func (orig OptionsConfiguration) Copy() OptionsConfiguration {
diff --git a/internal/config/config_test.go b/internal/config/config_test.go
index 51a500bb7..6220bce4c 100644
--- a/internal/config/config_test.go
+++ b/internal/config/config_test.go
@@ -53,6 +53,8 @@ func TestDefaultValues(t *testing.T) {
SymlinksEnabled: true,
LimitBandwidthInLan: false,
DatabaseBlockCacheMiB: 0,
+ PingTimeoutS: 30,
+ PingIdleTimeS: 60,
}
cfg := New(device1)
@@ -160,6 +162,8 @@ func TestOverriddenValues(t *testing.T) {
SymlinksEnabled: false,
LimitBandwidthInLan: true,
DatabaseBlockCacheMiB: 42,
+ PingTimeoutS: 60,
+ PingIdleTimeS: 120,
}
cfg, err := Load("testdata/overridenvalues.xml", device1)
diff --git a/internal/config/testdata/overridenvalues.xml b/internal/config/testdata/overridenvalues.xml
index d0b9d9677..8882d1d78 100755
--- a/internal/config/testdata/overridenvalues.xml
+++ b/internal/config/testdata/overridenvalues.xml
@@ -24,5 +24,7 @@
false
true
42
+ 60
+ 120