diff --git a/lbrynet/conf.py b/lbrynet/conf.py index 7a2293744..8e2bf401c 100644 --- a/lbrynet/conf.py +++ b/lbrynet/conf.py @@ -370,19 +370,19 @@ class BaseConfig: class CLIConfig(BaseConfig): - # Changing this value is not-advised as it could potentially - # expose the lbrynet daemon to the outside world which would - # give an attacker access to your wallet and you could lose - # all of your credits. - api_host = String( - 'Host name for lbrynet daemon API.', 'localhost', - previous_names=['API_INTERFACE'] - ) - api_port = Integer('Port for lbrynet daemon API.', 5279) + api = String('Host name and port for lbrynet daemon API.', 'localhost:5279') @property def api_connection_url(self) -> str: - return f"http://{self.api_host}:{self.api_port}/lbryapi" + return f"http://{self.api}/lbryapi" + + @property + def api_host(self): + return self.api.split(':')[0] + + @property + def api_port(self): + return int(self.api.split(':')[1]) class Config(CLIConfig): diff --git a/lbrynet/extras/daemon/Daemon.py b/lbrynet/extras/daemon/Daemon.py index 1cbd6b2e3..28309076b 100644 --- a/lbrynet/extras/daemon/Daemon.py +++ b/lbrynet/extras/daemon/Daemon.py @@ -472,8 +472,8 @@ class Daemon(metaclass=JSONRPCServerType): await self.setup() await self.analytics_manager.send_server_startup_success() except OSError: - log.error('lbrynet API failed to bind TCP %s:%i for listening. Daemon is already running or this port is ' - 'already in use by another application.', self.conf.api_host, self.conf.api_port) + log.error('lbrynet API failed to bind TCP %s for listening. Daemon is already running or this port is ' + 'already in use by another application.', self.conf.api) except defer.CancelledError: log.info("shutting down before finished starting") except Exception as err: diff --git a/tests/integration/cli/test_cli.py b/tests/integration/cli/test_cli.py index dc30fb7a2..b85f9151b 100644 --- a/tests/integration/cli/test_cli.py +++ b/tests/integration/cli/test_cli.py @@ -39,7 +39,7 @@ class CLIIntegrationTest(AsyncioTestCase): conf = Config() conf.data_dir = '/tmp' conf.share_usage_data = False - conf.api_port = 5299 + conf.api = 'localhost:5299' conf.components_to_skip = skip Daemon.component_attributes = {} self.daemon = Daemon(conf) @@ -51,6 +51,6 @@ class CLIIntegrationTest(AsyncioTestCase): def test_cli_status_command_with_auth(self): actual_output = StringIO() with contextlib.redirect_stdout(actual_output): - cli.main(["--api-port", "5299", "status"]) + cli.main(["--api", "localhost:5299", "status"]) actual_output = actual_output.getvalue() self.assertIn("connection_status", actual_output)