-
Notifications
You must be signed in to change notification settings - Fork 759
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Captive portal: wrong way to get the mac address #1344
Comments
|
Hi Quentin, Nice! I will defer to @AdSchellevis as he needs to inspect this and it means it can only hit 17.1.x as 17.1 is currently building for next week. Can you provide output of "/usr/sbin/arp -an" from the command line for the case where your version works but the current code doesn't? I don't know if the output for arp shifts. Just so we can double-check what's going on. :) Thanks, |
|
Here is what I get : root@router:~ # /usr/sbin/arp -an Thanks, |
|
Ok, I think we should rather change the whole parsing logic for the arp output to make the code less ambiguous. |
|
ok, that's weird.... my previous line seems te be delivering the correct output using the input stated above: `
` Not sure what caused the change to work, but both statements provide the same output.... (first entry v.s. last entry, but only one occurs). |
|
can we simplify this by doing a split(' ') kind of thing? the output is fixed and relying on subelement context seems to be prone to problems later on |
|
.split()[3] should be fine too, as long as you validate the length of the string first.... The current loop always returns output.
|
|
it's simply hard to read / spot errors. :) we could also split by regex "\s+" |
|
That's a matter of taste :) I rather use the normal split. |
|
split() default seems to do exactly this which is perfectly fine... "If sep is not specified or is None, a different splitting algorithm is applied: runs of consecutive whitespace are regarded as a single separator, and the result will contain no empty strings at the start or end if the string has leading or trailing whitespace." returning invalid / non-parsable data without being able to catch it is tricky, may have led into this very ticket. |
|
Hello, I'm coming back to you with this problem. But, as the code was the same, and arp -an had the same output, I didn't understand how it felt un a working state... But I finally have found the real issue ! If I try your script with this interface, the problem occurs: The problem is the "at" in "ath0" ! You should maybe just change 'at' to ' at ' (with space before and after "at"), it works in my case: I don't have this problem anymore just because I'm now using a bridge for my guest network... And of course, "bridge2" doesn't contain 'at' :) Thanks, Quentin Canel |
|
Thanks Quentin, very nice catch! All the more reason to refactor this as proposed to get rid of character-based matching. |
|
refactored using default split() 3151c87, at my end it looks good, feel free to reopen if the issue reappears. |
Hello,
I've made a post in the user forum: https://forum.opnsense.org/index.php?topic=4136.msg15121#msg15121
In this post, I explain a bug with the captive portal.
The arp.py file won't give the mac address, and so will break the captive portal functionality.
Here is the fix: changing this line:
mac = line.split('at')[-1].split('on')[0].strip()
by this one:
mac = line.split('at')[1].split('on')[0].strip()
in arp.py ( https://github.com/opnsense/core/blob/master/src/opnsense/scripts/OPNsense/CaptivePortal/lib/arp.py#L64 ) worked for me.
Thanks,
Quentin
The text was updated successfully, but these errors were encountered: