Skip to content

Commit 23867a2

Browse files
committed
Set default duration to 60 seconds
1 parent 88e3771 commit 23867a2

File tree

3 files changed

+8
-4
lines changed

3 files changed

+8
-4
lines changed

docs/configuration.md

+2-1
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,8 @@
4545
[time.ParseDuration()](https://pkg.go.dev/time#ParseDuration), defaults to `720h` (30 days).
4646
- `network` - configuration options related to the network connection.
4747
- `proxy` - URL of the proxy server.
48-
- `connection_timeout` - connection timeout in seconds, defaults to `0` which will wait indefinitely.
48+
- `connection_timeout` - network connection timeout, the value format must be a valid input for
49+
[time.ParseDuration()](https://pkg.go.dev/time#ParseDuration), defaults to `60s` (60 seconds). `0` means it will wait indefinitely.
4950

5051
### Default directories
5152

internal/cli/configuration/defaults.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ func SetDefaults(settings *Settings) {
7171
// network settings
7272
setKeyTypeSchema("network.proxy", "")
7373
setKeyTypeSchema("network.user_agent_ext", "")
74-
setKeyTypeSchema("network.connection_timeout", 0)
74+
setDefaultValueAndKeyTypeSchema("network.connection_timeout", (time.Second * 60).String())
7575

7676
// locale
7777
setKeyTypeSchema("locale", "")

internal/cli/configuration/network.go

+5-2
Original file line numberDiff line numberDiff line change
@@ -59,9 +59,12 @@ func (settings *Settings) ExtraUserAgent() string {
5959
return settings.GetString("network.user_agent_ext")
6060
}
6161

62+
// ConnectionTimeout returns the netowrk connection timeout
6263
func (settings *Settings) ConnectionTimeout() time.Duration {
63-
timeout := settings.GetInt("network.connection_timeout")
64-
return time.Duration(timeout) * time.Second
64+
if timeout, ok, _ := settings.GetDurationOk("network.connection_timeout"); ok {
65+
return timeout
66+
}
67+
return settings.Defaults.GetDuration("network.connection_timeout")
6568
}
6669

6770
// NetworkProxy returns the proxy configuration (mainly used by HTTP clients)

0 commit comments

Comments
 (0)