Skip to content

Config overhaul: version 2 for the configuration toml file (breaking changes) #878

@josecelano

Description

@josecelano

Parent issue: #401

Discussed in #853

Originally posted by josecelano May 9, 2024
Relates to:

The final configuration overhaul step would be defining a new config file structure.

An extra validation could be needed like the one described here. For example, if you enable TSL for the tracker API you must provide both the certificate path and the certificate key path:

[http_api]
bind_address = "127.0.0.1:1212"
enabled = true
ssl_cert_path = ""
ssl_enabled = false
ssl_key_path = ""

I think that type of validation could be implemented after parsing the injected configuration or maybe just by reorganising the toml file structure. For example:

No API enabled:

# No section [http_api]

API enabled but no TSL enabled:

[http_api]
bind_address = "127.0.0.1:1212"

API enabled with TSL enabled:

[http_api]
bind_address = "127.0.0.1:1212"

[http_api.tsl_config]
ssl_cert_path = "./storage/tracker/lib/tls/localhost.crt"
ssl_key_path = "./storage/tracker/lib/tls/localhost.key"

We would not need the enabled field. If the section is present the feature is enabled. If it's not it means that feature is disabled.

These breaking changes will be added in a new v2 configuration in a new PR.

I would like to discuss the final version 2 for the config file before implementing it.

Current Configuration

log_level = "info"
mode = "public"
db_driver = "Sqlite3"
db_path = "./storage/tracker/lib/database/sqlite3.db"
announce_interval = 120
min_announce_interval = 120
on_reverse_proxy = false
external_ip = "0.0.0.0"
tracker_usage_statistics = true
persistent_torrent_completed_stat = false
max_peer_timeout = 900
inactive_peer_cleanup_interval = 600
remove_peerless_torrents = true

[[udp_trackers]]
enabled = false
bind_address = "0.0.0.0:6969"

[[http_trackers]]
enabled = false
bind_address = "0.0.0.0:7070"
ssl_enabled = false
ssl_cert_path = ""
ssl_key_path = ""

[http_api]
enabled = true
bind_address = "127.0.0.1:1212"
ssl_enabled = false
ssl_cert_path = ""
ssl_key_path = ""

[http_api.access_tokens]
admin = "MyAccessToken"

[health_check_api]
bind_address = "127.0.0.1:1313"

New Configuration

Example with 2 HTTP trackers. The first one without TSL configuration.

[logging]
log_level = "info"

[core]
mode = "public"
tracker_usage_statistics = true
inactive_peer_cleanup_interval = 600

  [core.tracker_policy]
  max_peer_timeout = 900
  persistent_torrent_completed_stat = false
  remove_peerless_torrents = true

  [core.announce_policy]
  interval = 120
  interval_min = 120

  [core.database]
  driver = "Sqlite3"
  path = "./storage/tracker/lib/database/sqlite3.db"

  [core.net]
  external_ip = "0.0.0.0"
  on_reverse_proxy = false

[[udp_trackers]]
bind_address = "0.0.0.0:6969"

[[http_trackers]]
bind_address = "0.0.0.0:7070"

[[http_trackers]]
bind_address = "0.0.0.0:7071"

  [http_trackers.tsl_config]
  ssl_cert_path = "./storage/tracker/lib/tls/localhost.crt"
  ssl_key_path = "./storage/tracker/lib/tls/localhost.key"

[http_api]
bind_address = "127.0.0.1:1212"

  [http_api.tsl_config]
  ssl_cert_path = "./storage/http_api/lib/tls/localhost.crt"
  ssl_key_path = "./storage/http_api/lib/tls/localhost.key"

  [http_api.access_tokens]
  admin = "MyAccessToken"

[health_check_api]
bind_address = "127.0.0.1:1313"

Env vars also change:

TORRUST_TRACKER_CONFIG_OVERRIDE_DB_DRIVER -> TORRUST_TRACKER_CONFIG_OVERRIDE_CORE__DATABASE__DRIVER

The new configuration in JSON:

{
  "logging": {
    "log_level": "info"
  },
  "core": {
    "mode": "public",
    "tracker_usage_statistics": true,
    "inactive_peer_cleanup_interval": 600,
    "tracker_policy": {
      "max_peer_timeout": 900,
      "persistent_torrent_completed_stat": false,
      "remove_peerless_torrents": true
    },
    "announce_policy": {
      "interval": 120,
      "interval_min": 120
    },
    "database": {
      "driver": "Sqlite3",
      "path": "./storage/tracker/lib/database/sqlite3.db"
    },
    "net": {
      "external_ip": "0.0.0.0",
      "on_reverse_proxy": false
    }
  },
  "udp_trackers": [
    {
      "bind_address": "0.0.0.0:6969"
    }
  ],
  "http_trackers": [
    {
      "bind_address": "0.0.0.0:7070"
    },
    {
      "bind_address": "0.0.0.0:7071",
      "tsl_config": {
        "ssl_cert_path": "./storage/tracker/lib/tls/localhost.crt",
        "ssl_key_path": "./storage/tracker/lib/tls/localhost.key"
      }
    }
  ],
  "http_api": {
    "bind_address": "127.0.0.1:1212",
    "tsl_config": {
      "ssl_cert_path": "./storage/http_api/lib/tls/localhost.crt",
      "ssl_key_path": "./storage/http_api/lib/tls/localhost.key"
    },
    "access_tokens": {
      "admin": "MyAccessToken"
    }
  },
  "health_check_api": {
    "bind_address": "127.0.0.1:1313"
  }
}

Metadata

Metadata

Assignees

Type

No type

Projects

Status

Done

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions