config options api_host and api_port changed to just api

This commit is contained in:
Lex Berezhny 2019-01-22 15:40:45 -05:00
parent 9ccb3fa2a3
commit 19b0d59159
3 changed files with 14 additions and 14 deletions

View file

@ -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):

View file

@ -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:

View file

@ -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)