garywill / linux-router

Set Linux as router in one command. Support Internet sharing, redsocks, Wifi hotspot, IPv6. Can also be used for routing VM/containers 🛰️ (也欢迎关注B站 https://space.bilibili.com/2123686105 )
GNU Lesser General Public License v2.1
1.67k stars 148 forks source link

FIX #67: Remove trailing .0 from iw reported frequency #68

Closed Z3hka closed 6 months ago

Z3hka commented 6 months ago

This should fix #67 The sed command removes a dot followed by any number (greater than zero) of zeros followed by the end of the line. This way frequencies now reported with a trailing .0 will also work. Just in case it will also remove .00 and similar, but not ".", ".5" and similar because they may actually have a different meaning and thus should not be rounded away as suggested in #67 with cut but throw an error. The more complete approach would be to use software like bc to do actual non-integer comparison but as long as there are no non-integer-frequencies used i don't think adding an additional dependency is worth it just for the sake of a theoretical future wifi frequency that will require modifications to the script anyway.

garywill commented 6 months ago

Cool~ Thank you @Z3hka for PR~! @kphanipavan @petebueh Let's check this together

garywill commented 6 months ago
grep -E " 24[0-9][0-9](.0+){0,1} MHz

Shouldn't it be \. instead of . ?

And should the same be applied to FREQ_BANK != 2.4 ? (I don't have 5Ghz hardware to test that)


sed 's/\.00*//g'

We should use \b to prevent removing .05

kphanipavan commented 6 months ago

The change which introduced that decimal is shown below Screenshot_20240116_125613

As stated, it is for S1G (Sub 1GHz) frequencies, used with 802.11Ah protocol Screenshot_20240116_125944

The comment in the header file suggests that it is the offset frequency in KHz. image

Found relevant explanation: https://lore.kernel.org/linux-wireless/20200401062150.3324-2-thomas@adapt-ip.com/T/

So, unless 11Ah support is on the roadmap for this script, the decimal and the numbers followed can be ignored.

~Pvn

Z3hka commented 6 months ago

Well, I shouldn't write regexes while tired :D Here are the fixes for the issues you found

petebueh commented 6 months ago

It works for me. I'm using 2.4 GHz