daemon/config: Validate() also validate default MTU

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
This commit is contained in:
Sebastiaan van Stijn 2022-06-06 16:53:25 +02:00
parent fce7ebdaa5
commit f8231c62f4
No known key found for this signature in database
GPG Key ID: 76698F39D527CE8C
2 changed files with 20 additions and 0 deletions

View File

@ -597,6 +597,9 @@ func Validate(config *Config) error {
}
// TODO(thaJeztah) Validations below should not accept "0" to be valid; see Validate() for a more in-depth description of this problem
if config.Mtu < 0 {
return fmt.Errorf("invalid default MTU: %d", config.Mtu)
}
if config.MaxConcurrentDownloads < 0 {
return fmt.Errorf("invalid max concurrent downloads: %d", config.MaxConcurrentDownloads)
}

View File

@ -280,6 +280,15 @@ func TestValidateConfigurationErrors(t *testing.T) {
},
expectedErr: "123456 is not a valid domain",
},
{
name: "negative MTU",
config: &Config{
CommonConfig: CommonConfig{
Mtu: -10,
},
},
expectedErr: "invalid default MTU: -10",
},
{
name: "negative max-concurrent-downloads",
config: &Config{
@ -397,6 +406,14 @@ func TestValidateConfiguration(t *testing.T) {
},
},
},
{
name: "with mtu",
config: &Config{
CommonConfig: CommonConfig{
Mtu: 1234,
},
},
},
{
name: "with max-concurrent-downloads",
config: &Config{