Coder Social home page Coder Social logo

Not support local hosts file? about domain HOT 14 CLOSED

partim avatar partim commented on August 28, 2024
Not support local hosts file?

from domain.

Comments (14)

partim avatar partim commented on August 28, 2024 1

Quick update: I started the netdb crate and put together a preliminary implementation of get_host_by_name() and its async companion, tentatively named poll_host_by_name(). Needs testing and documenting and examples before it can go onto crates.io even in its really limited state, though.

from domain.

partim avatar partim commented on August 28, 2024

I tend to not want to support this in the domain crate since it is intended for DNS only.

What I would like to do instead is start a new crate that mimics NSS and not only considers /etc/hosts but also /etc/nsswitch.conf and perhaps even allows binding NSS .so libraries. An initial version could only provide name resolution with DNS and the hosts file, to make this functionality available quickly.

How does that sound?

from domain.

Matrix-Zhang avatar Matrix-Zhang commented on August 28, 2024

i think it is not easy to program, because of we don't know the end-user's system environment, there must someone want to use hosts file directly, like me? As a programmer, we should use two crates's functions to resolve the host name? i suggest integrated into domain, just like c api, gethostbyname

from domain.

partim avatar partim commented on August 28, 2024

from domain.

tailhook avatar tailhook commented on August 28, 2024

Binding to .so in async program doesn't make sense. Either use gethostbyname() directly (in a thread) or make normal async resolver with things that's possible to do asynchronously.

from domain.

partim avatar partim commented on August 28, 2024

In pretty much all setups the nsswitch.conf entry for hosts is effectively files dns (safe for alternative resolvers which can be translated into appropriate domain configuration once it supports whatever additional functionality those resolvers provide). It would still be nice if packages could behave correctly in the fraction of cases that differ. For instance, if I removed the files entry from nsswitch.conf (because I have a complex hosts file which I want to disable temporarily), it would be nice it Things Just Worked.

For async use, the .so bindings could be forked into a thread pool.

from domain.

tailhook avatar tailhook commented on August 28, 2024

Well, here is the stock nsswitch.conf from nix:

hosts:     files  dns   myhostname mymachines

mdns and mdns_minimal are also common (as allows service discovery, e.g. to find printers as easy as on other OSs)
systemd is also going to gain popularity just because it's installed everywhere
I'm not sure about ldap

from domain.

partim avatar partim commented on August 28, 2024

Most of this should be supported by the new crate natively, perhaps even ldap if we have an underlying crate for it—a protocol as complex as LDAP would particularly benefit from using a Rust implementation.

from domain.

tailhook avatar tailhook commented on August 28, 2024

Yes. That would be great. But it's a hell of a lot of work :)

from domain.

partim avatar partim commented on August 28, 2024

I’m happy to at least get started. I am somewhat busy with life stuff the next weeks, though, but I’ll start a crate that pulls together the hosts file stuff (a parser for which actually is already present in domain) and the resolver, sometime soon. That will hopefully solve @Matrix-Zhang’s use case and then we can see where we go from there.

from domain.

Matrix-Zhang avatar Matrix-Zhang commented on August 28, 2024

I see, thanks for your hard wrok

from domain.

zonyitoo avatar zonyitoo commented on August 28, 2024

@partim what's the status of netdb crate?

from domain.

partim avatar partim commented on August 28, 2024

I’ve been caught up in moving the last two weeks but things have calmed down now. Hoping to get the remaining stuff done perhaps this weekend already, otherwise early next week.

from domain.

partim avatar partim commented on August 28, 2024

Version 0.1.0 of netdb has just been uploaded to crates.io. It really only is a start just now, but it should allow closing this issue.

from domain.

Related Issues (14)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.