Skip to content

Commit

Permalink
Merge pull request #16 from qstokkink/fix_port_reserve
Browse files Browse the repository at this point in the history
Reclaim port on start
  • Loading branch information
qstokkink committed Apr 18, 2024
2 parents 65305f1 + d18c8a4 commit b753d3a
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
5 changes: 5 additions & 0 deletions src/tribler/core/start_core.py
Expand Up @@ -35,6 +35,11 @@ def run_core(api_port: int, api_key: str | None, state_dir: Path) -> None:

config = TriblerConfigManager(state_dir / "configuration.json")
config.set("state_dir", str(state_dir))

if config.get("api/refresh_port_on_start"):
config.set("api/http_port", 0)
config.set("api/https_port", 0)

if api_key is None:
config.set("api/key", api_key)
config.write()
Expand Down
4 changes: 3 additions & 1 deletion src/tribler/tribler_config.py
Expand Up @@ -24,6 +24,7 @@ class ApiConfig(TypedDict):
https_enabled: bool
https_host: str
https_port: int
refresh_port_on_start: bool


class ContentDiscoveryCommunityConfig(TypedDict):
Expand Down Expand Up @@ -164,7 +165,8 @@ class TriblerConfig(TypedDict):
"https_enabled": False,
"https_host": "127.0.0.1",
"https_port": 0,
"https_certfile": "https_certfile"
"https_certfile": "https_certfile",
"refresh_port_on_start": True
},

"ipv8": ipv8_default_config,
Expand Down

0 comments on commit b753d3a

Please sign in to comment.