Signed-off-by: Marcus B Spencer <marcus@marcusspencer.us>
This commit is contained in:
@@ -33,7 +33,7 @@ import (
|
|||||||
|
|
||||||
const (
|
const (
|
||||||
OldestHandledVersion = 10
|
OldestHandledVersion = 10
|
||||||
CurrentVersion = 51
|
CurrentVersion = 52
|
||||||
MaxRescanIntervalS = 365 * 24 * 60 * 60
|
MaxRescanIntervalS = 365 * 24 * 60 * 60
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
@@ -62,7 +62,7 @@ func TestDefaultValues(t *testing.T) {
|
|||||||
LocalAnnMCAddr: "[ff12::8384]:21027",
|
LocalAnnMCAddr: "[ff12::8384]:21027",
|
||||||
MaxSendKbps: 0,
|
MaxSendKbps: 0,
|
||||||
MaxRecvKbps: 0,
|
MaxRecvKbps: 0,
|
||||||
ReconnectIntervalS: 60,
|
ReconnectIntervalS: 20,
|
||||||
RelaysEnabled: true,
|
RelaysEnabled: true,
|
||||||
RelayReconnectIntervalM: 10,
|
RelayReconnectIntervalM: 10,
|
||||||
StartBrowser: true,
|
StartBrowser: true,
|
||||||
|
|||||||
@@ -30,6 +30,7 @@ import (
|
|||||||
// put the newest on top for readability.
|
// put the newest on top for readability.
|
||||||
var (
|
var (
|
||||||
migrations = migrationSet{
|
migrations = migrationSet{
|
||||||
|
{52, migrateToConfigV52},
|
||||||
{51, migrateToConfigV51},
|
{51, migrateToConfigV51},
|
||||||
{50, migrateToConfigV50},
|
{50, migrateToConfigV50},
|
||||||
{37, migrateToConfigV37},
|
{37, migrateToConfigV37},
|
||||||
@@ -101,6 +102,11 @@ func (m migration) apply(cfg *Configuration) {
|
|||||||
cfg.Version = m.targetVersion
|
cfg.Version = m.targetVersion
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func migrateToConfigV52(cfg *Configuration) {
|
||||||
|
oldQuicInterval := max(cfg.Options.ReconnectIntervalS/3, 10)
|
||||||
|
cfg.Options.ReconnectIntervalS = min(cfg.Options.ReconnectIntervalS, oldQuicInterval)
|
||||||
|
}
|
||||||
|
|
||||||
func migrateToConfigV51(cfg *Configuration) {
|
func migrateToConfigV51(cfg *Configuration) {
|
||||||
oldDefault := 2
|
oldDefault := 2
|
||||||
for i, fcfg := range cfg.Folders {
|
for i, fcfg := range cfg.Folders {
|
||||||
|
|||||||
@@ -34,3 +34,25 @@ func TestMigrateCrashReporting(t *testing.T) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestMigrateReconnectInterval(t *testing.T) {
|
||||||
|
cases := []struct {
|
||||||
|
oldInterval int
|
||||||
|
expectedNewInterval int
|
||||||
|
}{
|
||||||
|
{oldInterval: 60, expectedNewInterval: 20},
|
||||||
|
{oldInterval: 120, expectedNewInterval: 40},
|
||||||
|
{oldInterval: 25, expectedNewInterval: 10},
|
||||||
|
{oldInterval: 5, expectedNewInterval: 5},
|
||||||
|
}
|
||||||
|
|
||||||
|
for i, tc := range cases {
|
||||||
|
cfg := Configuration{Version: 51, Options: OptionsConfiguration{ReconnectIntervalS: tc.oldInterval}}
|
||||||
|
migrationsMut.Lock()
|
||||||
|
migrations.apply(&cfg)
|
||||||
|
migrationsMut.Unlock()
|
||||||
|
if cfg.Options.ReconnectIntervalS != tc.expectedNewInterval {
|
||||||
|
t.Errorf("%d: unexpected result, ReconnectIntervalS: %v != %v", i, cfg.Options.ReconnectIntervalS, tc.expectedNewInterval)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@@ -28,7 +28,7 @@ type OptionsConfiguration struct {
|
|||||||
LocalAnnMCAddr string `json:"localAnnounceMCAddr" xml:"localAnnounceMCAddr" default:"[ff12::8384]:21027"`
|
LocalAnnMCAddr string `json:"localAnnounceMCAddr" xml:"localAnnounceMCAddr" default:"[ff12::8384]:21027"`
|
||||||
MaxSendKbps int `json:"maxSendKbps" xml:"maxSendKbps"`
|
MaxSendKbps int `json:"maxSendKbps" xml:"maxSendKbps"`
|
||||||
MaxRecvKbps int `json:"maxRecvKbps" xml:"maxRecvKbps"`
|
MaxRecvKbps int `json:"maxRecvKbps" xml:"maxRecvKbps"`
|
||||||
ReconnectIntervalS int `json:"reconnectionIntervalS" xml:"reconnectionIntervalS" default:"60"`
|
ReconnectIntervalS int `json:"reconnectionIntervalS" xml:"reconnectionIntervalS" default:"20"`
|
||||||
RelaysEnabled bool `json:"relaysEnabled" xml:"relaysEnabled" default:"true"`
|
RelaysEnabled bool `json:"relaysEnabled" xml:"relaysEnabled" default:"true"`
|
||||||
RelayReconnectIntervalM int `json:"relayReconnectIntervalM" xml:"relayReconnectIntervalM" default:"10"`
|
RelayReconnectIntervalM int `json:"relayReconnectIntervalM" xml:"relayReconnectIntervalM" default:"10"`
|
||||||
StartBrowser bool `json:"startBrowser" xml:"startBrowser" default:"true"`
|
StartBrowser bool `json:"startBrowser" xml:"startBrowser" default:"true"`
|
||||||
|
|||||||
+1
-1
@@ -1,4 +1,4 @@
|
|||||||
<configuration version="34">
|
<configuration version="52">
|
||||||
<options>
|
<options>
|
||||||
<listenAddress>tcp://:23000</listenAddress>
|
<listenAddress>tcp://:23000</listenAddress>
|
||||||
<allowDelete>false</allowDelete>
|
<allowDelete>false</allowDelete>
|
||||||
|
|||||||
@@ -99,16 +99,9 @@ func (d *quicDialer) Dial(ctx context.Context, _ protocol.DeviceID, uri *url.URL
|
|||||||
type quicDialerFactory struct{}
|
type quicDialerFactory struct{}
|
||||||
|
|
||||||
func (quicDialerFactory) New(opts config.OptionsConfiguration, tlsCfg *tls.Config, registry *registry.Registry, lanChecker *lanChecker) genericDialer {
|
func (quicDialerFactory) New(opts config.OptionsConfiguration, tlsCfg *tls.Config, registry *registry.Registry, lanChecker *lanChecker) genericDialer {
|
||||||
// So the idea is that we should probably try dialing every 20 seconds.
|
|
||||||
// However it would still be nice if this was adjustable/proportional to ReconnectIntervalS
|
|
||||||
// But prevent something silly like 1/3 = 0 etc.
|
|
||||||
quicInterval := opts.ReconnectIntervalS / 3
|
|
||||||
if quicInterval < 10 {
|
|
||||||
quicInterval = 10
|
|
||||||
}
|
|
||||||
return &quicDialer{
|
return &quicDialer{
|
||||||
commonDialer: commonDialer{
|
commonDialer: commonDialer{
|
||||||
reconnectInterval: time.Duration(quicInterval) * time.Second,
|
reconnectInterval: time.Duration(opts.ReconnectIntervalS) * time.Second,
|
||||||
tlsCfg: tlsCfg,
|
tlsCfg: tlsCfg,
|
||||||
lanChecker: lanChecker,
|
lanChecker: lanChecker,
|
||||||
lanPriority: opts.ConnectionPriorityQUICLAN,
|
lanPriority: opts.ConnectionPriorityQUICLAN,
|
||||||
|
|||||||
Reference in New Issue
Block a user