drTr0jan commented on issue #1740: URL: https://github.com/apache/logging-log4j2/issues/1740#issuecomment-5632595607
@ppkarwasz, Piotr, thanks for the fast answer. > On Linux [InetAddress.getLocalHost()](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/net/InetAddress.html#getLocalHost()) does this: > impl.getLocalHostName() calls gethostname(): that is all it does, so you get the kernel's UTS nodename, traditionally unqualified. Hm... But on Darwin and FreeBSD `gethostname(3)` returns **qualified** hostname. > On Linux [InetAddress.getLocalHost()](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/net/InetAddress.html#getLocalHost()) does this: > ... > That name goes to lookupAllHostAddr(), which calls [getaddrinfo()](https://man7.org/linux/man-pages/man3/getaddrinfo.3.html) with the AI_CANONNAME hint, so the C library does resolve a canonical name. Am I to understand, `InetAddress.getLocalHost()` after `impl.getLocalHostName()` does next..? 1. `InetAddress.getLocalHost()` calls `getAllByName0()` for reverse lookup the name (`local`). 2. `InetAddress.getAllByName0()` calls `NameServiceAddresses.get()` for reverse lookup the name (`host`). 3. `NameServiceAddresses.get()` calls `getAddressesFromNameService()' for get address for the name (`host`) from a NS. 4. `InetAddress.getAddressesFromNameService()` calls `lookupByName()` for lookup by the name (`host`). 5. `PlatformResolver.lookupByName()` calls `lookupAllHostAddr()`, which calls [getaddrinfo()](https://man7.org/linux/man-pages/man3/getaddrinfo.3.html) with the AI_CANONNAME hint, so the C library does resolve a canonical name. Is it correct? -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
