When defining a client host 0.0.0.0 for a CoA radius Server, then a KeyError will occur when handling a CoA packet.
File ".../pyrad/server.py", line 250, in _HandleCoaPacket
pkt.secret = self.hosts[pkt.source[0]].secret
~~~~~~~~~~^^^^^^^^^^^^^^^
KeyError: '172.16.0.100'
The reason seems to be that _AddSecret(...) was added at some point to support using 0.0.0.0 as a host, but the pkt.secret = ... assignment that it ought to replace was not removed.
Work-around while this fix is not available in the released pyrad packge
For now, I fixed the issue by overriding _AddSecret(...) to dynamically add a host when 0.0.0.0 was matched.
def _AddSecret(self, pkt):
if pkt.source[0] in self.hosts:
pkt.secret = self.hosts[pkt.source[0]].secret
elif '0.0.0.0' in self.hosts:
pkt.secret = self.hosts['0.0.0.0'].secret
# The fix: dynamically add the actual host to the server's hosts list.
self.hosts[pkt.source[0]] = self.hosts['0.0.0.0']
else:
raise server.ServerPacketError('Received packet from unknown host')
The PR got merged, and will be part of the next release.
Since no release is done yet with the fix in it, I will keep this issue open until the release is done.
Till then, the work-around will have to be used.
When defining a client host
0.0.0.0
for a CoA radius Server, then a KeyError will occur when handling a CoA packet.The reason seems to be that
_AddSecret(...)
was added at some point to support using0.0.0.0
as a host, but thepkt.secret = ...
assignment that it ought to replace was not removed.I provided a fix in PR: https://github.com/pyradius/pyrad/pull/196
Work-around while this fix is not available in the released pyrad packge
For now, I fixed the issue by overriding
_AddSecret(...)
to dynamically add a host when0.0.0.0
was matched.