Fix: refresh message authentication when serialising

This commit is contained in:
Istvan Ruzman
2020-08-12 10:22:01 +02:00
parent d7ff0be1aa
commit 93193ee18d

View File

@@ -183,6 +183,8 @@ class Packet(OrderedDict):
def serialize(self) -> bytes:
"""Serialize the Packet to the RADIUS Line Format"""
if self.host.message_authenticator:
self.add_message_authenticator()
# TODO: This is not an abstract method
raise NotImplementedError
@@ -298,17 +300,12 @@ class AcctPacket(Packet): # pylint: disable=abstract-method
def increase_acct_delay_time(self, delay_time: float):
"""Increase the Accounting Delay Time
This method automatically adjust the Authenticator
and the Message-Authenticator (if present)
No check for the Accounting Codes are made, an
Accounting-Respones should not contain the
Acct-Delay-Time Attribute.
"""
try:
self["Acct-Delay-Time"] += int(delay_time)
if self.host.message_authenticator:
self.refresh_message_authenticator()
except KeyError:
pass