RPC Server logs the client IP on failed auth

this patch adds an error log for the client IP of who connects
to the rpc server without proper auth key.
This commit is contained in:
Hemna 2023-08-23 13:48:09 -04:00
parent 859f904602
commit 9582812041
1 changed files with 5 additions and 0 deletions

View File

@ -16,8 +16,13 @@ LOG = logging.getLogger("APRSD")
def magic_word_authenticator(sock):
client_ip = sock.getpeername()[0]
magic = sock.recv(len(CONF.rpc_settings.magic_word)).decode()
if magic != CONF.rpc_settings.magic_word:
LOG.error(
f"wrong magic word passed from {client_ip} "
"'{magic}' != '{CONF.rpc_settings.magic_word}'",
)
raise AuthenticationError(
f"wrong magic word passed in '{magic}'"
f" != '{CONF.rpc_settings.magic_word}'",