tjfontaine / node-dns

Replacement dns module in pure javascript for node.js
MIT License
585 stars 153 forks source link

Multicast DNS Discovery #18

Open tjfontaine opened 12 years ago

tjfontaine commented 12 years ago

Implement mDNS

bmeck commented 12 years ago

took a quick look at this, the udp/tcp socket factory is causing problems with extensibility, would be much more sane if we could provide a socket/datagram to dump the dns payload onto rather than relying on a factory ( bonus lets you use unix datagram sockets / windows streams for ipc extensions to mDNS etc. )

tjfontaine commented 12 years ago

I had only initially planned on implementing the legacy/one-off api to pass the inclusion test for upstream node.

I'm torn about whether to include a full stack that supports announcing and discovery, or simply provide the infra for one to be built on top of the package. But either way, I think a full mdns stack is more of a specialization of the server than of the client side, so providing an external socket/ipc would be easy in that scenario.

Unless I'm not understanding your point.

bmeck commented 12 years ago

It is less about creating a client vs server and more the lack of extensibility.

For now sockets are decided for you by the factory in https://github.com/tjfontaine/node-dns/blob/master/lib/pending.js#L46compared to node's ability to connect on various other sockets by modifying a HTTP Agent for example ( https://github.com/joyent/node/blob/master/lib/http.js#L1052 ). The fact is with this factory based approach where the types of sockets are hard coded it becomes difficult to work with the socket's themselves such as when you need to enable broadcast on datagrams which need a second function call on them (setBroadcast(true)).

Being able to use a custom factory for sockets instead of this very limited switch statement is more what I would be looking for if I wanted to extend node-dns to include mDNS, otherwise it might be easier to just write my own after looking at how coupled things are.

tjfontaine commented 12 years ago

Ok, so an optional parameter to Request for an external socket factory, or just for a socket in general, would that provide enough plumbing to achieve what you want?

I am mostly worried about the interaction between the queuing and the external factory, but that's a bridge I can cross later

bmeck commented 12 years ago

Yes.