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

Favor dns_sd DNSServiceGetAddrInfo on linux as well #250

Open
tadam313 opened this issue Apr 12, 2021 · 2 comments
Open

Favor dns_sd DNSServiceGetAddrInfo on linux as well #250

tadam313 opened this issue Apr 12, 2021 · 2 comments

Comments

@tadam313
Copy link

I'm wondering whether we should prefer to use the dns_sd DNSServiceGetAddrInfo function (HAVE_DNSSERVICEGETADDRINFO flag) over the node implementation (cares_wrap) on linux-ish systems as well if available. I know that "avahi compat" library does not have this function, however, we can still compile Apple's mDNSResponder Posix version on certain linux distros which does have it. I have a use-case on Synology DSM (which is recognized as "Linux" by node gyp) where I had to use Apple's library (avahi is not available) and need to force using DNSServiceGetAddrInfo (by manually defining HAVE_DNSSERVICEGETADDRINFO in binding.gyp). Unfortunately, the node implementation did not work, I was constantly getting errors like { code: -3008, errno: -3008, syscall: 'getaddrinfo' }. However dns_sd implementation works perfectly fine.

This makes me wondering should we define HAVE_DNSSERVICEGETADDRINFO based on capability on Linux? For now, it's completely missing and assumed that linux systems use avahi library every time. For example, we could use nm to check whether DNSServiceGetAddrInfo is available in libdns_sd.so or not? WDYT?

The alternative would be to target Synology DSM OS exclusively with some condition and define this flag there, but not sure at the time how could we do it.

@agnat
Copy link
Owner

agnat commented Dec 31, 2022

Hi @tadam313,

apologies for being unresponsive. Must have slipped through...

Yes, I like it. Detecting the actual dns_sd implementation would be great and I'm sure I've tried. However, IIRC a symbol based approach (configure, nm, dlopen, etc) does not work. Unfortunately avahi actually has that symbol but the function reports an error and terminates the process (again IIRC).

Now that it's on my radar let me think about it some more. If auto detection at runtime becomes too awkward at least there should be a way to select the implementation without modifying files... preferably at runtime, without recompiling. Maybe an environment variable? WDYT?

@tadam313
Copy link
Author

tadam313 commented Feb 8, 2023

yeah I think we'd need to do the runtime auto detection in C++ code maybe using externals and weak references, but not sure at this point 🤔 By any means feel free to give it a shot it would be interesting to do some digging in this area 🙂
On the other hand the easiest would be to use an env var for sure and define a condition in binding.gyp for that env var. The only downside of that it would be easy to miss as it would be buried deep and not visible on the interface, but at least there is a solution without modifying the source

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants