Skip to content
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

nut-scanner network scans should provide a "-m auto" option #2244

Closed
aquette opened this issue Dec 22, 2023 · 4 comments · Fixed by #2513
Closed

nut-scanner network scans should provide a "-m auto" option #2244

aquette opened this issue Dec 22, 2023 · 4 comments · Fixed by #2513
Labels
nut-scanner SmartNUT Multi-backend extension of NUT for smart home integrations
Milestone

Comments

@aquette
Copy link
Member

aquette commented Dec 22, 2023

when scanning network devices (SNMP, XML, NUT), nut-scanner should provide a "-m auto" option to automatically provide the local network information.

Example: when your IP is 192.168.1.1 on a class C network, "-m auto" should be equivalent to "-m 192.168.1.1/24"

@jimklimov
Copy link
Member

jimklimov commented Dec 22, 2023

I think this logic could be already done in 42ity fork? port-back is still piecemeal and pending for the bigger features (for diligent separated reviewability and bug dissection).

@aquette
Copy link
Member Author

aquette commented Dec 22, 2023

I told myself the same 42ITy, but not sure. IIRC, it's uses libcidr and I don't want such deps.

For now, in HA SmartNUT add-on, found a clean workaround ;) (bashio returns exactly what is expected)
https://github.com/aquette/addon-smartnut/blob/main/smartnut/rootfs/etc/cont-init.d/smartnut.sh#L89

@jimklimov jimklimov added nut-scanner SmartNUT Multi-backend extension of NUT for smart home integrations labels Jan 20, 2024
@jimklimov
Copy link
Member

BTW, what is wrong with libcidr? :) Not that it's hard to parse a few string patterns and do bit maths ourselves...

@jimklimov
Copy link
Member

FWIW, I've recently had another pass at porting stuff from the FTY fork and checking the remaining differences (by now two big things are packaging recipes and DMF, and also docs/nut-names.txt, see #1316 for the detailed list of that effort).

There were no mentions of libcidr there, and no different code about CIDR handling, so I actually looked deeper and found nutscan-ip.c which does the related magic (including CIDR conversion to a start/end IP address pair) since your and Frederic's time. I guess we dealt with libcidr elsewhere in the 42ITy project, in some other components.

So here your issue is indeed new and pristine after all, with the challenging part being about portably detecting what non-loopback IP address(es) we have at disposal on the current system, with what netmasks, and checking perhaps all of the resulting ranges (if there's more than one).

@jimklimov jimklimov added this to the 2.8.4 milestone Jul 4, 2024
jimklimov added a commit to jimklimov/nut that referenced this issue Jul 4, 2024
…}: report the IP address (range, single, none) in the log [networkupstools#2244]

Signed-off-by: Jim Klimov <[email protected]>
jimklimov added a commit to jimklimov/nut that referenced this issue Jul 4, 2024
jimklimov added a commit to jimklimov/nut that referenced this issue Jul 4, 2024
jimklimov added a commit to jimklimov/nut that referenced this issue Jul 4, 2024
jimklimov added a commit to jimklimov/nut that referenced this issue Jul 4, 2024
… options and others behave differently without them [networkupstools#2244]

Signed-off-by: Jim Klimov <[email protected]>
jimklimov added a commit to jimklimov/nut that referenced this issue Jul 4, 2024
… introduce a way to scan several IP address ranges [networkupstools#2244]

Signed-off-by: Jim Klimov <[email protected]>
jimklimov added a commit to jimklimov/nut that referenced this issue Jul 4, 2024
jimklimov added a commit to jimklimov/nut that referenced this issue Jul 4, 2024
…etworkupstools#2244]

We actually use DEFAULT_NETWORK_TIMEOUT from common.h
same as in clients/upsclient.c

Signed-off-by: Jim Klimov <[email protected]>
jimklimov added a commit to jimklimov/nut that referenced this issue Jul 4, 2024
jimklimov added a commit to jimklimov/nut that referenced this issue Jul 4, 2024
…}: report the IP address (range, single, none) in the log [networkupstools#2244]

Signed-off-by: Jim Klimov <[email protected]>
jimklimov added a commit to jimklimov/nut that referenced this issue Jul 4, 2024
jimklimov added a commit to jimklimov/nut that referenced this issue Jul 4, 2024
jimklimov added a commit to jimklimov/nut that referenced this issue Jul 4, 2024
jimklimov added a commit to jimklimov/nut that referenced this issue Jul 4, 2024
… options and others behave differently without them [networkupstools#2244]

Signed-off-by: Jim Klimov <[email protected]>
jimklimov added a commit to jimklimov/nut that referenced this issue Jul 4, 2024
… introduce a way to scan several IP address ranges [networkupstools#2244]

Signed-off-by: Jim Klimov <[email protected]>
jimklimov added a commit to jimklimov/nut that referenced this issue Jul 4, 2024
jimklimov added a commit to jimklimov/nut that referenced this issue Jul 4, 2024
…etworkupstools#2244]

We actually use DEFAULT_NETWORK_TIMEOUT from common.h
same as in clients/upsclient.c

Signed-off-by: Jim Klimov <[email protected]>
jimklimov added a commit to jimklimov/nut that referenced this issue Jul 4, 2024
jimklimov added a commit to jimklimov/nut that referenced this issue Jul 5, 2024
jimklimov added a commit to jimklimov/nut that referenced this issue Jul 5, 2024
…for debug printouts to be predictable on different platforms [networkupstools#2244]

Signed-off-by: Jim Klimov <[email protected]>
jimklimov added a commit to jimklimov/nut that referenced this issue Jul 8, 2024
jimklimov added a commit to jimklimov/nut that referenced this issue Jul 8, 2024
jimklimov added a commit to jimklimov/nut that referenced this issue Jul 8, 2024
jimklimov added a commit to jimklimov/nut that referenced this issue Jul 8, 2024
…ict, NEWS.adoc: handle_arg_cidr(): add `-m auto*/ADDRLEN` mode [networkupstools#2244]

Signed-off-by: Jim Klimov <[email protected]>
jimklimov added a commit to jimklimov/nut that referenced this issue Jul 8, 2024
… "arg_addr" [networkupstools#2244]

Avoid warning about clash with a global variable.
Fallout of refactoring original code into a method.

Also make it `const` as we do not change the original value anyway.

Signed-off-by: Jim Klimov <[email protected]>
jimklimov added a commit to jimklimov/nut that referenced this issue Jul 8, 2024
… subnet by family before checking for mask length [networkupstools#2244]

Signed-off-by: Jim Klimov <[email protected]>
jimklimov added a commit to jimklimov/nut that referenced this issue Jul 8, 2024
jimklimov added a commit to jimklimov/nut that referenced this issue Jul 8, 2024
jimklimov added a commit to jimklimov/nut that referenced this issue Jul 8, 2024
jimklimov added a commit to jimklimov/nut that referenced this issue Jul 8, 2024
… for ip_ranges[] list and helper metadata, and methods as part of libnutscan [networkupstools#2244, networkupstools#2511]

Not bumping library version, because it was recently bumped as
part of other PRs about this issue. Technically the scope of the
library has been changed by new exported methods and header lines.

Signed-off-by: Jim Klimov <[email protected]>
jimklimov added a commit to jimklimov/nut that referenced this issue Jul 8, 2024
jimklimov added a commit to jimklimov/nut that referenced this issue Jul 8, 2024
jimklimov added a commit to jimklimov/nut that referenced this issue Jul 9, 2024
jimklimov added a commit to jimklimov/nut that referenced this issue Jul 10, 2024
jimklimov added a commit to jimklimov/nut that referenced this issue Jul 15, 2024
jimklimov added a commit to jimklimov/nut that referenced this issue Jul 15, 2024
jimklimov added a commit to jimklimov/nut that referenced this issue Jul 18, 2024
jimklimov added a commit to jimklimov/nut that referenced this issue Jul 18, 2024
jimklimov added a commit to jimklimov/nut that referenced this issue Jul 18, 2024
@jimklimov jimklimov modified the milestones: 2.8.4, 2.8.3 Sep 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
nut-scanner SmartNUT Multi-backend extension of NUT for smart home integrations
Projects
Status: Done
Development

Successfully merging a pull request may close this issue.

2 participants