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

Getting loopback IP address from GetLocalAddressList. #494

Open
coffeegreg opened this issue Jul 21, 2023 · 4 comments
Open

Getting loopback IP address from GetLocalAddressList. #494

coffeegreg opened this issue Jul 21, 2023 · 4 comments
Assignees
Labels
Element: Socket Stacks Issues related to OS socket APIs, TIdStack and TIdSocketList descedants, etc Status: Review Needed Issue needs further review to decide next status Type: Enhancement Issue is proposing a new feature/enhancement

Comments

@coffeegreg
Copy link
Contributor

Does anyone know why the loopback IP address (127.0.0.1) is intentionally filtered out in the procedures:

  1. TIdStackUnix.GetLocalAddressList
    if (LAddrInfo^.ifa_addr <> nil) and ((LAddrInfo^.ifa_flags and IFF_LOOPBACK) = 0) then
  2. TIdStackWindows.GetLocalAddressList in GetLocalAddressesByAdaptersAddresses
    if (Adapter.IfType <> IF_TYPE_SOFTWARE_LOOPBACK) and ((Adapter.Flags and IP_ADAPTER_RECEIVE_ONLY) = 0) then
    ?
    Without these conditions, it correctly fetches all IP addresses, including the loopback IP address. Tested on Windows, Linux and macOS.
@coffeegreg coffeegreg added Status: Reported Issue has been reported for review Type: Question Issue is asking a question, or requesting support/clarity labels Jul 21, 2023
@rlebeau
Copy link
Member

rlebeau commented Jul 24, 2023

Is there a particular reason why the loopback IP should be included?

@rlebeau rlebeau added Element: Socket Stacks Issues related to OS socket APIs, TIdStack and TIdSocketList descedants, etc Status: More Info Needed Issue needs further information to continue progress and removed Status: Reported Issue has been reported for review labels Jul 24, 2023
@coffeegreg
Copy link
Contributor Author

It is just a question...
Sometimes it is necessary to run services listening on loopback interface addresses such as 127.0.0.1, although there may be more interfaces and loopback IP addresses. Mainly for diagnostics and troubleshooting, but also for interconnecting local services that listening on loopback interfaces only. Before trying to run a service on a given interface, it would be good to check if it exists. I can imagine a machine with multiple loopback interfaces and/or multiple IP addresses on them, or even in extreme cases no loopback interface at all. This is where the GetLocalAddressList procedure could come in handy if it didn't filter out IP addresses from the loopback interfaces.
As I mentioned, this is just a question to find out more about possible issues that may have caused the intentional loopback IP address filtering out in the GetLocalAddressList routine.

@rlebeau
Copy link
Member

rlebeau commented Jul 25, 2023

There is not a technical reason why loopback addresses are being filtered out, other than it's not common to have a server listening on loopbacks. I suppose I could add an input flag to GetLocalAddressList() to let the caller specify whether loopbacks should be included in the output or not.

@coffeegreg
Copy link
Contributor Author

Good idea.

@rlebeau rlebeau added Type: Enhancement Issue is proposing a new feature/enhancement Status: Review Needed Issue needs further review to decide next status and removed Type: Question Issue is asking a question, or requesting support/clarity Status: More Info Needed Issue needs further information to continue progress labels Jul 25, 2023
@rlebeau rlebeau added this to the Indy 11 - Maintenance Release milestone Jul 25, 2023
@rlebeau rlebeau self-assigned this Jul 25, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Element: Socket Stacks Issues related to OS socket APIs, TIdStack and TIdSocketList descedants, etc Status: Review Needed Issue needs further review to decide next status Type: Enhancement Issue is proposing a new feature/enhancement
Projects
None yet
Development

No branches or pull requests

2 participants