diff --git a/aprsd/client.py b/aprsd/client.py index 8ca5dd3..1af14b2 100644 --- a/aprsd/client.py +++ b/aprsd/client.py @@ -24,7 +24,7 @@ TRANSPORT_SERIALKISS = "serialkiss" factory = None -class Client: +class Client(metaclass=trace.TraceWrapperMetaclass): """Singleton client class that constructs the aprslib connection.""" _instance = None @@ -86,7 +86,7 @@ class Client: pass -class APRSISClient(Client): +class APRSISClient(Client, metaclass=trace.TraceWrapperMetaclass): _client = None @@ -135,7 +135,6 @@ class APRSISClient(Client): """APRS lib already decodes this.""" return core.Packet.factory(args[0]) - @trace.trace def setup_connection(self): user = CONF.aprs_network.login password = CONF.aprs_network.password @@ -172,7 +171,7 @@ class APRSISClient(Client): return aprs_client -class KISSClient(Client): +class KISSClient(Client, metaclass=trace.TraceWrapperMetaclass): _client = None @@ -241,7 +240,6 @@ class KISSClient(Client): else: return packet - @trace.trace def setup_connection(self): self._client = kiss.KISS3Client() return self._client diff --git a/aprsd/cmds/webchat.py b/aprsd/cmds/webchat.py index c422d44..3c20f39 100644 --- a/aprsd/cmds/webchat.py +++ b/aprsd/cmds/webchat.py @@ -427,8 +427,8 @@ def init_flask(loglevel, quiet): "--port", "port", show_default=True, - default=80, - help="Port to listen to web requests", + default=None, + help="Port to listen to web requests. This overrides the config.webchat.web_port setting.", ) @click.pass_context @cli_helper.process_standard_options @@ -450,6 +450,8 @@ def webchat(ctx, flush, port): CONF.log_opt_values(LOG, logging.DEBUG) user = CONF.admin.user users[user] = generate_password_hash(CONF.admin.password) + if not port: + port = CONF.webchat.web_port # Initialize the client factory and create # The correct client object ready for use @@ -488,7 +490,7 @@ def webchat(ctx, flush, port): # This is broken for now after removing cryptography # and pyopenssl # ssl_context="adhoc", - host=CONF.admin.web_ip, + host=CONF.webchat.web_ip, port=port, allow_unsafe_werkzeug=True, ) diff --git a/aprsd/conf/common.py b/aprsd/conf/common.py index d466259..74b1abc 100644 --- a/aprsd/conf/common.py +++ b/aprsd/conf/common.py @@ -19,6 +19,10 @@ rpc_group = cfg.OptGroup( name="rpc_settings", title="RPC Settings for admin <--> web", ) +webchat_group = cfg.OptGroup( + name="webchat", + title="Settings specific to the webchat command", +) aprsd_opts = [ @@ -163,6 +167,29 @@ enabled_plugins_opts = [ ), ] +webchat_opts = [ + cfg.IPOpt( + "web_ip", + default="0.0.0.0", + help="The ip address to listen on", + ), + cfg.PortOpt( + "web_port", + default=8001, + help="The port to listen on", + ), + cfg.StrOpt( + "latitude", + default=None, + help="Latitude for the GPS Beacon button. If not set, the button will not be enabled.", + ), + cfg.StrOpt( + "longitude", + default=None, + help="Longitude for the GPS Beacon button. If not set, the button will not be enabled.", + ), +] + def register_opts(config): config.register_opts(aprsd_opts) @@ -173,6 +200,8 @@ def register_opts(config): config.register_opts(watch_list_opts, group=watch_list_group) config.register_group(rpc_group) config.register_opts(rpc_opts, group=rpc_group) + config.register_group(webchat_group) + config.register_opts(webchat_opts, group=webchat_group) def list_opts(): @@ -181,4 +210,5 @@ def list_opts(): admin_group.name: admin_opts, watch_list_group.name: watch_list_opts, rpc_group.name: rpc_opts, + webchat_group.name: webchat_opts, }