1
0
mirror of https://github.com/craigerl/aprsd.git synced 2024-11-17 22:01:49 -05:00

Extend APRS.IS object to change login string

This patch copies the aprslib.inet IS object's _send_login()
method so we can change the login app identification string.
This commit is contained in:
Hemna 2021-01-11 12:43:51 -05:00
parent e1a292d8e0
commit 5de1b3e305

View File

@ -2,7 +2,10 @@ import logging
import select
import time
import aprsd
import aprslib
from aprslib import is_py3
from aprslib.exceptions import LoginError
LOG = logging.getLogger("APRSD")
@ -120,6 +123,53 @@ class Aprsdis(aprslib.IS):
yield line
def _send_login(self):
"""
Sends login string to server
"""
login_str = "user {0} pass {1} vers aprsd {3}{2}\r\n"
login_str = login_str.format(
self.callsign,
self.passwd,
(" filter " + self.filter) if self.filter != "" else "",
aprsd.__version__,
)
self.logger.info("Sending login information")
try:
self._sendall(login_str)
self.sock.settimeout(5)
test = self.sock.recv(len(login_str) + 100)
if is_py3:
test = test.decode("latin-1")
test = test.rstrip()
self.logger.debug("Server: %s", test)
_, _, callsign, status, _ = test.split(" ", 4)
if callsign == "":
raise LoginError("Server responded with empty callsign???")
if callsign != self.callsign:
raise LoginError("Server: %s" % test)
if status != "verified," and self.passwd != "-1":
raise LoginError("Password is incorrect")
if self.passwd == "-1":
self.logger.info("Login successful (receive only)")
else:
self.logger.info("Login successful")
except LoginError as e:
self.logger.error(str(e))
self.close()
raise
except Exception:
self.close()
self.logger.error("Failed to login")
raise LoginError("Failed to login")
def get_client():
cl = Client()