1
0
mirror of https://github.com/craigerl/aprsd.git synced 2024-09-27 15:46:53 -04:00

Added a fix for failed logins to APRS-IS

This patch adds a check for a failed login to ARPS due to
LoginError.  This accounts for bad accounts or username/password
failures.  aprsd server will exit immediately upon failed login now.
This commit is contained in:
Hemna 2021-01-12 09:31:04 -05:00
parent 94708024da
commit 3dd23fa2ad
2 changed files with 12 additions and 1 deletions

View File

@ -17,6 +17,8 @@ class Client:
aprs_client = None
config = None
connected = False
def __new__(cls, *args, **kwargs):
"""This magic turns this into a singleton."""
if cls._instance is None:
@ -55,6 +57,10 @@ class Client:
aprs_client.connect()
connected = True
backoff = 1
except LoginError as e:
LOG.error("Failed to login to APRS-IS Server '{}'".format(e))
connected = False
raise e
except Exception as e:
LOG.error("Unable to connect to APRS-IS server. '{}' ".format(e))
time.sleep(backoff)

View File

@ -34,6 +34,7 @@ import time
import aprsd
from aprsd import client, email, messaging, plugin, threads, utils
import aprslib
from aprslib.exceptions import LoginError
import click
import click_completion
import yaml
@ -387,7 +388,11 @@ def server(loglevel, quiet, disable_validation, config_file, flush):
# Create the initial PM singleton and Register plugins
plugin_manager = plugin.PluginManager(config)
plugin_manager.setup_plugins()
client.Client(config)
try:
cl = client.Client(config)
cl.setup_connection()
except LoginError:
sys.exit(-1)
# Now load the msgTrack from disk if any
if flush: