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

[Request] Programmatically determine the local address CIDR #5

Open
b-morgan opened this issue Dec 16, 2020 · 5 comments
Open

[Request] Programmatically determine the local address CIDR #5

b-morgan opened this issue Dec 16, 2020 · 5 comments
Labels
request New feature or request up for grabs Issue/FR will not be worked on, open for a member of the community to take it on

Comments

@b-morgan
Copy link

Is your feature request related to a problem? Please describe.
In an attempt to make this as easy as possible, the plugin should (on OctoPi or Linux) programmatically determine the current local address CIDR.

Describe the solution you'd like
PreFill the Local Network entries with the programmatically determined values. The text
If you have a different local address range than what's listed here, get in touch with whoever administrates your network to find out the local IP range. This will be what you put where it says 'Local Networks' below. might need some different wording.

Describe alternatives you've considered
None

Additional context
On OctoPi (or another Linux distribution) you can use the following command:
ip route | grep -P 'eth0|wlan0' | awk '{print $1}'
or for IPV6:
ip -6 route | grep -P 'eth0|wlan0' | awk '{print $1}'

@cp2004
Copy link
Member

cp2004 commented Dec 16, 2020

There is a way to get this from OctoPrint's API, using the test utilities I believe.

See https://docs.octoprint.org/en/master/api/util.html#post--api-util-test, although I haven't tried it and it sounds specific to the client IP, not a general one. Still, provides the subnet things that might be interesting. I just haven't found time to implement it.

@b-morgan
Copy link
Author

My intention is to idiot proof this process as much as possible. If the local network can be determined automagically, then the user doesn't have to understand the concept or the process for determining it themselves and it removes all those places along the path where they could make a mistake (typo).

From the docs you pointed me to, it sounds like the "Tests whether a provided address (or, if none is provided, the client’s remote address) is a LAN address and if so returns the subnet specifier in CIDR format" is exactly what is needed (and probably better than my complex bash command since it should be OS agnostic.

@cp2004
Copy link
Member

cp2004 commented Dec 16, 2020

Gina added it to 1.5.0 for this use case (since she new I was creating the plugin). I'll see if I can find a bit of time to look at this one over the next couple of weeks, shouldn't take too long.

@draeath
Copy link

draeath commented Dec 31, 2020

Is that reliable in cases a host has "complex" network configuration? For example, multiple interfaces, alias interfaces, bridges, or the like?

@cp2004
Copy link
Member

cp2004 commented Dec 31, 2020

(note that I am by no means an expert and have never touched anything close to a complex network)

The test address API tests the connecting client IP, and returns out 3 things:

  • Is it a LAN address
  • what the client address is
  • what the subnet is

Implementation can be found here:
https://github.com/OctoPrint/OctoPrint/blob/bf8ff6358556aaa073da2d0646f193c3a1fef48f/src/octoprint/server/api/__init__.py#L751-L779
Maybe reading that will give you a clue as to whether it will work? It was created by someone who knows more than me, I just provide a nice looking UI to make it easier to configure 🙂.

I want to say it should do, however without testing it I'm hesitant to do so as I don't know the specifics of your network.

@cp2004 cp2004 added the request New feature or request label Apr 19, 2021
@cp2004 cp2004 added the up for grabs Issue/FR will not be worked on, open for a member of the community to take it on label Oct 29, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
request New feature or request up for grabs Issue/FR will not be worked on, open for a member of the community to take it on
Projects
None yet
Development

No branches or pull requests

3 participants