Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Configuration overhaul: version 2 for the configuration toml file (breaking changes) #631

Conversation

josecelano
Copy link
Member

@josecelano josecelano commented Jun 12, 2024

A set of breaking changes in the TOML config file to improve readability and validation.

Subtasks

  • Normalize TrackerMode enum to use the same values as the Tracker.
  • Use lowercase for auth::email_on_signup config option variants.
  • Rename auth::email_on_signup::None variant to auth::email_on_signup::Ingored.
  • Include the log_lovel option in the new section logging and make it mandatory with info default value.
  • Extract password constraints in a new type (section auth).
  • Extract SMPT credentials in a new type (section mail).
  • Include the socket address (IP+PORT) instead of only the port (section net).
  • Use alphabetical order for TOML keys inside the section.

Notes

  • We are normalizing all variants in enums to lowercase in TOML files.
  • The option base_url (section net) already exists in the current version. It's not changed in the new version. It's optional. If it's not present it uses the request headers to get the current host.

Current toml version

log_level = "info"

[website]
name = "Torrust"

[tracker]
api_url = "http://localhost:1212"
mode = "Public"
token = "MyAccessToken"
token_valid_seconds = 7257600
url = "udp://localhost:6969"

[net]
port = 3001

# Uncomment if you want to enable TSL for development
#[net.tsl]
#ssl_cert_path = "./storage/index/lib/tls/localhost.crt"
#ssl_key_path = "./storage/index/lib/tls/localhost.key"

[auth]
email_on_signup = "Optional"
max_password_length = 64
min_password_length = 6
secret_key = "MaxVerstappenWC2021"

[database]
connect_url = "sqlite://data.db?mode=rwc"

[mail]
email_verification_enabled = false
from = "[email protected]"
password = ""
port = 25
reply_to = "[email protected]"
server = ""
username = ""

[image_cache]
capacity = 128000000
entry_size_limit = 4000000
max_request_timeout_ms = 1000
user_quota_bytes = 64000000
user_quota_period_seconds = 3600

[api]
default_torrent_page_size = 10
max_torrent_page_size = 30

[tracker_statistics_importer]
port = 3002
torrent_info_update_interval = 3600

New toml version

[logging]
log_level = "info"

[website]
name = "Torrust"

[tracker]
api_url = "http://localhost:1212"
mode = "public"
token = "MyAccessToken"
token_valid_seconds = 7257600
url = "udp://localhost:6969"

[net]
base_url = "http://localhost"
bind_address = "0.0.0.0:3001"

# Uncomment if you want to enable TSL for development
#[net.tsl]
#ssl_cert_path = "./storage/index/lib/tls/localhost.crt"
#ssl_key_path = "./storage/index/lib/tls/localhost.key"

[auth]
email_on_signup = "Optional"
secret_key = "MaxVerstappenWC2021"

[auth.password_constraints]
max_password_length = 64
min_password_length = 6

[database]
connect_url = "sqlite://data.db?mode=rwc"

[mail]
email_verification_enabled = false
from = "[email protected]"
reply_to = "[email protected]"

[mail.smtp]
port = 25
server = ""

[mail.smtp.credentials]
password = ""
username = ""

[image_cache]
capacity = 128000000
entry_size_limit = 4000000
max_request_timeout_ms = 1000
user_quota_bytes = 64000000
user_quota_period_seconds = 3600

[api]
default_torrent_page_size = 10
max_torrent_page_size = 30

[tracker_statistics_importer]
port = 3002
torrent_info_update_interval = 3600

Normalize TrackerMode enum to use the same values as in the Tracker.

```rust
pub enum TrackerMode {
    /// Will track every new info hash and serve every peer.
    #[serde(rename = "public")]
    Public,

    /// Will only track whitelisted info hashes.
    #[serde(rename = "listed")]
    Listed,

    /// Will only serve authenticated peers
    #[serde(rename = "private")]
    Private,

    /// Will only track whitelisted info hashes and serve authenticated peers
    #[serde(rename = "private_listed")]
    PrivateListed,
}
```

That will enable to use the TrackerMode defined in
https://crates.io/crates/torrust-tracker-primitives for TrackerMode in
the future when a new version of that crate is released.
@josecelano josecelano force-pushed the 591-configuration-overhaul-version-2-for-the-configuration-toml-file-breaking-changes branch from fd0814c to 12010f1 Compare June 12, 2024 16:10
Old:

```toml
log_level = "info"

[website]
name = "Torrust"
```

New:

```toml
[logging]
log_level = "info"

[website]
name = "Torrust"
```

And the value is not Optional anymore. It was a Optional<LogLevel> but
when it was None it defaulted to LogLevel::Info. In practice that means
is mandatory but with the `Info` default value.
@josecelano josecelano force-pushed the 591-configuration-overhaul-version-2-for-the-configuration-toml-file-breaking-changes branch from 49c964b to 50ebb9a Compare June 12, 2024 16:49
…iguration

From:

```toml
[auth]
email_on_signup = "Optional"
max_password_length = 64
min_password_length = 6
secret_key = "MaxVerstappenWC2021"
```

To:

```toml
[auth]
email_on_signup = "Optional"
secret_key = "MaxVerstappenWC2021"

[auth.password_constraints]
max_password_length = 64
min_password_length = 6
```
@josecelano josecelano force-pushed the 591-configuration-overhaul-version-2-for-the-configuration-toml-file-breaking-changes branch from 7124d58 to cd8248a Compare June 12, 2024 17:45
From:

```toml
[mail]
email_verification_enabled = false
from = "[email protected]"
password = ""
port = 25
reply_to = "[email protected]"
server = ""
username = ""
```

To:

```toml
[mail]
email_verification_enabled = false
from = "[email protected]"
reply_to = "[email protected]"

[mail.smtp]
port = 25
server = ""

[mail.smtp.credentials]
password = ""
username = ""
```
not only the port.

Old:

```toml
[net]
port = 3001
```

New:

```toml
[net]
bind_address = "0.0.0.0:3001"
```
@josecelano josecelano self-assigned this Jun 13, 2024
…ly the port

Old:

```toml
[net]
port = 3001
```

New:

```toml
[net]
bind_address = "0.0.0.0:3001"
```
We should produce always the same TOML file from the same configuration
deterministically.
@josecelano josecelano marked this pull request as ready for review June 13, 2024 15:33
@josecelano
Copy link
Member Author

ACK 35a125e

@josecelano josecelano merged commit fb4f199 into torrust:develop Jun 13, 2024
12 of 13 checks passed
josecelano added a commit to torrust/torrust-index-gui that referenced this pull request Jun 13, 2024
d2343f6 feat: [#574] update Index config files (Jose Celano)

Pull request description:

  The Index has introduced some [breaking changes in the TOML config files](torrust/torrust-index#631).

ACKs for top commit:
  josecelano:
    ACK d2343f6

Tree-SHA512: f29fcbb1ef36047e44f27295066c1564e86009b343f76105c561bd68affc2e297b91b244269d9842242e744dff769e6eafa796c922ca114d4e237419335e8dde
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Configuration overhaul: version 2 for the configuration toml file (breaking changes)
1 participant