mirror of
https://gitlab2.federez.net/re2o/re2o
synced 2024-11-22 03:13:12 +00:00
Tweak "magic split" comments
This commit is contained in:
parent
118f5af269
commit
cf5756733d
2 changed files with 6 additions and 7 deletions
|
@ -198,11 +198,7 @@ def post_auth(data):
|
||||||
.first()
|
.first()
|
||||||
)
|
)
|
||||||
# Find the port number from freeradius
|
# Find the port number from freeradius
|
||||||
#
|
# See above for details about this "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)
|
|
||||||
port = port.split(".")[0].split("/")[-1][-2:]
|
port = port.split(".")[0].split("/")[-1][-2:]
|
||||||
out = decide_vlan_switch(nas_machine, nas_type, port, mac)
|
out = decide_vlan_switch(nas_machine, nas_type, port, mac)
|
||||||
sw_name, room, reason, vlan_id, decision, attributes = out
|
sw_name, room, reason, vlan_id, decision, attributes = out
|
||||||
|
|
|
@ -150,7 +150,10 @@ def post_auth(request, nas_id, nas_port, user_mac):
|
||||||
if hasattr(nas_interface.machine, "switch"):
|
if hasattr(nas_interface.machine, "switch"):
|
||||||
stack = nas_interface.machine.switch.stack
|
stack = nas_interface.machine.switch.stack
|
||||||
if 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]
|
id_stack_member = nas_port.split("-")[1].split("/")[0]
|
||||||
switch = (
|
switch = (
|
||||||
Switch.objects.filter(stack=stack)
|
Switch.objects.filter(stack=stack)
|
||||||
|
@ -161,7 +164,7 @@ def post_auth(request, nas_id, nas_port, user_mac):
|
||||||
# get the switch port
|
# get the switch port
|
||||||
port = None
|
port = None
|
||||||
if nas_port and nas_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_number = nas_port.split(".")[0].split("/")[-1][-2:]
|
||||||
port = Port.objects.filter(switch=switch, port=port_number).first()
|
port = Port.objects.filter(switch=switch, port=port_number).first()
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue