From 19217562617cb7ca9fbfa1caf57a0ee6d5c0e59d Mon Sep 17 00:00:00 2001 From: drew2a Date: Mon, 18 Oct 2021 16:57:37 +0200 Subject: [PATCH] Split Master Key Settings --- .../tribler_core/components/ipv8/settings.py | 39 +++++++++++++++++++ .../components/masterkey/settings.py | 39 +------------------ .../config/tribler_config_sections.py | 7 ++-- .../tunnel/tests/test_tunnel_settings.py | 2 +- .../modules/watch_folder/settings.py | 9 +++++ 5 files changed, 54 insertions(+), 42 deletions(-) create mode 100644 src/tribler-core/tribler_core/components/ipv8/settings.py create mode 100644 src/tribler-core/tribler_core/modules/watch_folder/settings.py diff --git a/src/tribler-core/tribler_core/components/ipv8/settings.py b/src/tribler-core/tribler_core/components/ipv8/settings.py new file mode 100644 index 00000000000..8b5f3ab83b9 --- /dev/null +++ b/src/tribler-core/tribler_core/components/ipv8/settings.py @@ -0,0 +1,39 @@ +from typing import Optional + +from pydantic import validator + +from tribler_common.network_utils import NetworkUtils +from tribler_core.config.tribler_config_section import TriblerConfigSection + + +# pylint: disable=no-self-argument + + +class BootstrapSettings(TriblerConfigSection): + enabled: bool = True + max_download_rate: int = 1000000 + infohash: str = 'b496932f32daad964e1b63188faabf74d22b45ea' + + +class Ipv8Settings(TriblerConfigSection): + enabled: bool = True + port: int = 7759 + address: str = '0.0.0.0' + bootstrap_override: Optional[str] = None + statistics: bool = False + walk_interval: float = 0.5 + walk_scaling_enabled: bool = True + walk_scaling_upper_limit: float = 3.0 + + @validator('port') + def validate_port(cls, v): + assert 0 <= v <= NetworkUtils.MAX_PORT, 'Port must be in range [0..65535]' + return v + + +class DiscoveryCommunitySettings(TriblerConfigSection): + enabled: bool = True + + +class DHTSettings(TriblerConfigSection): + enabled: bool = True diff --git a/src/tribler-core/tribler_core/components/masterkey/settings.py b/src/tribler-core/tribler_core/components/masterkey/settings.py index 5ee432db9ea..e864000ce6e 100644 --- a/src/tribler-core/tribler_core/components/masterkey/settings.py +++ b/src/tribler-core/tribler_core/components/masterkey/settings.py @@ -1,41 +1,9 @@ -from typing import Optional - -from pydantic import Field, validator - -from tribler_common.network_utils import NetworkUtils +from pydantic import Field from tribler_core.config.tribler_config_section import TriblerConfigSection # pylint: disable=no-self-argument -class BootstrapSettings(TriblerConfigSection): - enabled: bool = True - max_download_rate: int = 1000000 - infohash: str = 'b496932f32daad964e1b63188faabf74d22b45ea' - - -class Ipv8Settings(TriblerConfigSection): - enabled: bool = True - port: int = 7759 - address: str = '0.0.0.0' - bootstrap_override: Optional[str] = None - statistics: bool = False - walk_interval: float = 0.5 - walk_scaling_enabled: bool = True - walk_scaling_upper_limit: float = 3.0 - - @validator('port') - def validate_port(cls, v): - assert 0 <= v <= NetworkUtils.MAX_PORT, 'Port must be in range [0..65535]' - return v - - -class DiscoveryCommunitySettings(TriblerConfigSection): - enabled: bool = True - - -class DHTSettings(TriblerConfigSection): - enabled: bool = True class TrustchainSettings(TriblerConfigSection): @@ -44,8 +12,3 @@ class TrustchainSettings(TriblerConfigSection): testnet_keypair_filename: str = 'ec_trustchain_testnet.pem' alter_keypair_filename: str = 'secondary_key.pem' testnet: bool = Field(default=False, env='TRUSTCHAIN_TESTNET') - - -class WatchFolderSettings(TriblerConfigSection): - enabled: bool = False - directory: str = '' diff --git a/src/tribler-core/tribler_core/config/tribler_config_sections.py b/src/tribler-core/tribler_core/config/tribler_config_sections.py index 294083dbfa3..48f1611a110 100644 --- a/src/tribler-core/tribler_core/config/tribler_config_sections.py +++ b/src/tribler-core/tribler_core/config/tribler_config_sections.py @@ -2,15 +2,16 @@ from tribler_core.components.bandwidth_accounting.settings import BandwidthAccountingSettings from tribler_core.components.gigachannel.community.settings import ChantSettings +from tribler_core.components.ipv8.settings import BootstrapSettings, DHTSettings, DiscoveryCommunitySettings, \ + Ipv8Settings from tribler_core.components.libtorrent.settings import DownloadDefaultsSettings, LibtorrentSettings -from tribler_core.components.masterkey.settings import BootstrapSettings, DHTSettings, DiscoveryCommunitySettings, \ - Ipv8Settings, \ - TrustchainSettings, WatchFolderSettings +from tribler_core.components.masterkey.settings import TrustchainSettings from tribler_core.components.popularity.settings import PopularityCommunitySettings from tribler_core.components.resource_monitor.settings import ResourceMonitorSettings from tribler_core.modules.remote_query_community.settings import RemoteQueryCommunitySettings from tribler_core.modules.torrent_checker.settings import TorrentCheckerSettings from tribler_core.modules.tunnel.community.settings import TunnelCommunitySettings +from tribler_core.modules.watch_folder.settings import WatchFolderSettings from tribler_core.restapi.settings import APISettings from tribler_core.settings import ErrorHandlingSettings, GeneralSettings diff --git a/src/tribler-core/tribler_core/modules/tunnel/tests/test_tunnel_settings.py b/src/tribler-core/tribler_core/modules/tunnel/tests/test_tunnel_settings.py index d002f1bba00..318ba15bbf0 100644 --- a/src/tribler-core/tribler_core/modules/tunnel/tests/test_tunnel_settings.py +++ b/src/tribler-core/tribler_core/modules/tunnel/tests/test_tunnel_settings.py @@ -1,7 +1,7 @@ import pytest from tribler_common.network_utils import NetworkUtils -from tribler_core.components.masterkey.settings import Ipv8Settings +from tribler_core.components.ipv8.settings import Ipv8Settings @pytest.mark.asyncio diff --git a/src/tribler-core/tribler_core/modules/watch_folder/settings.py b/src/tribler-core/tribler_core/modules/watch_folder/settings.py new file mode 100644 index 00000000000..2b875b62121 --- /dev/null +++ b/src/tribler-core/tribler_core/modules/watch_folder/settings.py @@ -0,0 +1,9 @@ +from tribler_core.config.tribler_config_section import TriblerConfigSection + + +# pylint: disable=no-self-argument + + +class WatchFolderSettings(TriblerConfigSection): + enabled: bool = False + directory: str = ''