Browse Source

Tweak "magic split" comments

radius_api
Jean-Romain Garnier 5 years ago
parent
commit
cf5756733d
  1. 6
      freeradius_utils/auth.py
  2. 7
      radius/api/views.py

6
freeradius_utils/auth.py

@ -198,11 +198,7 @@ def post_auth(data):
.first()
)
# 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)
# See above for details about this "magic split"
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

7
radius/api/views.py

@ -150,7 +150,10 @@ def post_auth(request, nas_id, nas_port, user_mac):
if hasattr(nas_interface.machine, "switch"):
stack = nas_interface.machine.switch.stack
if stack:
# magic split
# 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 = nas_port.split("-")[1].split("/")[0]
switch = (
Switch.objects.filter(stack=stack)
@ -161,7 +164,7 @@ def post_auth(request, nas_id, nas_port, user_mac):
# get the switch port
port = None
if nas_port and nas_port != "None":
# magic split
# magic split (see above)
port_number = nas_port.split(".")[0].split("/")[-1][-2:]
port = Port.objects.filter(switch=switch, port=port_number).first()

Loading…
Cancel
Save