diff --git a/freeradius_utils/auth.py b/freeradius_utils/auth.py index d41e9a5a..d1876edd 100644 --- a/freeradius_utils/auth.py +++ b/freeradius_utils/auth.py @@ -185,6 +185,11 @@ def post_auth(data): instance_stack = nas_machine.switch.stack if instance_stack: # If it is a stack, we select the correct switch in the stack + # + # For Juniper, the result looks something like this: NAS-Port-Id = "ge-0/0/6.0"" + # For other brands (e.g. HP or Mikrotik), the result usually looks like: NAS-Port-Id = "6.0" + # This "magic split" handles both cases + # Cisco can rot in Hell for all I care, so their format is not supported (it looks like NAS-Port-ID = atm 31/31/7:255.65535 guangzhou001/0/31/63/31/127) id_stack_member = port.split("-")[1].split("/")[0] nas_machine = ( Switch.objects.filter(stack=instance_stack) @@ -192,8 +197,12 @@ def post_auth(data): .prefetch_related("interface_set__domain__extension") .first() ) - # Find the port number from freeradius, works both with HP, Cisco - # and juniper output + # Find the port number from freeradius + # + # For Juniper, the result looks something like this: NAS-Port-Id = "ge-0/0/6.0"" + # For other brands (e.g. HP or Mikrotik), the result usually looks like: NAS-Port-Id = "6.0" + # This "magic split" handles both cases + # Cisco can rot in Hell for all I care, so their format is not supported (it looks like NAS-Port-ID = atm 31/31/7:255.65535 guangzhou001/0/31/63/31/127) port = port.split(".")[0].split("/")[-1][-2:] out = decide_vlan_switch(nas_machine, nas_type, port, mac) sw_name, room, reason, vlan_id, decision, attributes = out