-
Notifications
You must be signed in to change notification settings - Fork 32
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
DNS-SD API #7
Comments
Feedback from @mafintosh
|
Chrome OS apps seem to have mdns API |
@autonome It looks like this is what IPFS is currently using for mdns: And my guess is this is what Dat uses Would be worth taking a look what the API is to try and match that |
Noting that the libp2p-mdns module just uses the multicast-dns module under
the hood as well
…On Wed, May 23, 2018, 23:33 Irakli Gozalishvili ***@***.***> wrote:
@autonome <https://github.com/autonome> It looks like this is what IPFS
is currently using for mdns:
https://github.com/libp2p/js-libp2p-mdns
And my guess is this is what Dat uses
https://github.com/mafintosh/multicast-dns
Would be worth taking a look what the API is to try and match that
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#7 (comment)>, or mute
the thread
<https://github.com/notifications/unsubscribe-auth/AAW_VeleptQn7PKL2_F5F91NH386iVXgks5t1eOdgaJpZM4UCBW1>
.
|
Hello. I helped to develop the mDNS implementation for FlyWeb. I'd like to know more about this project. Is there a channel on IRC/Slack? |
Hey @justindarc! #dweb on Mozilla Slack and IRC.
…On Thu, May 24, 2018 at 8:23 AM justindarc ***@***.***> wrote:
Hello. I helped to develop the mDNS implementation for FlyWeb. I'd like to
know more about this project. Is there a channel on IRC/Slack?
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#7 (comment)>, or mute
the thread
<https://github.com/notifications/unsubscribe-auth/AADDtxqgAEKefjdQKFsc2Xh5eOFj9CXEks5t1tB9gaJpZM4UCBW1>
.
|
@autonome has landed simple discovery API and I made an example add-on https://github.com/mozilla/libdweb/tree/master/demo/mdns. There is also gif in readme now showing it in action. |
It's discovery only, and once upon a day had implementations (Opera!), but perhaps there's some value to mentioning that there was as Discovery API specification that web pages could use to find mdns services. |
MDNS is great for discovery, but won't this require the ability to listen on ports from a WebExtension to be useful? |
That's why we also expose UDP / TCP socket APIs. |
Code that crashes the Nightly: const {
classes: Cc,
interfaces: Ci,
utils: Cu,
results: Cr,
manager: Cm
} = Components
Cu.import("resource://gre/modules/XPCOMUtils.jsm");
const DNS_SD_CID = "@mozilla.org/toolkit/components/mdnsresponder/dns-sd;1"
const sd = Cc[DNS_SD_CID].getService(Ci.nsIDNSServiceDiscovery)
let serviceType = '_http._tcp';
let registrationListener = {
onServiceRegistered: function(serviceInfo) {
console.log('svcRegistered', serviceInfo);
},
onServiceUnregistered: function(serviceInfo) {
console.log('svcUnregistered', serviceInfo);
},
onRegistrationFailed: function(serviceInfo, errorCode) {
console.log('regFailed', serviceInfo, errorCode);
},
onUnregistrationFailed: function(serviceInfo, errorCode) {
console.log('unregFailed', serviceInfo, errorCode);
}
};
let serviceInfo = {
port: 80,
serviceType: '_http._tcp'
};
sd.registerService(serviceInfo, registrationListener); |
@autonome Following does not seems to crash: Cu.import("resource://gre/modules/XPCOMUtils.jsm");
class DNSServiceInfo {
constructor(host="", port=0, serviceName="", serviceType="", domainName="", attributes=versionAttr) {
this.host = host
this.port = port
this.address = host
this.serviceName = serviceName
this.serviceType = serviceType
this.domainName = domainName
this.attributes = attributes
}
}
DNSServiceInfo.prototype.QueryInterface = ChromeUtils.generateQI([Ci.nsIDNSServiceInfo])
class DNSRegistrationListener {
onServiceRegistered(serviceInfo) {
console.log('onServiceRegistered', serviceInfo);
}
onServiceUnregistered(serviceInfo) {
console.log('onServiceUnregistered', serviceInfo);
}
onRegistrationFailed(serviceInfo, errorCode) {
console.log('onRegistrationFailed', serviceInfo, errorCode);
}
onUnregistrationFailed(serviceInfo, errorCode) {
console.log('onUnregistrationFailed', serviceInfo, errorCode);
}
}
const SERVICE_TYPE = "_presentation-ctrl._tcp"
const LATEST_VERSION = 1
const versionAttr = Cc["@mozilla.org/hash-property-bag;1"]
.createInstance(Ci.nsIWritablePropertyBag2)
versionAttr.setPropertyAsUint32("version", LATEST_VERSION)
const mDNS = Cc["@mozilla.org/toolkit/components/mdnsresponder/dns-sd;1"]
.getService(Ci.nsIDNSServiceDiscovery)
const service = new DNSServiceInfo("device.local", 12345, "service.name", SERVICE_TYPE)
const listener = new DNSRegistrationListener()
mDNS.registerService(service, listener) I suspect that C++ implementation attempts to cast serviceInfo as |
Posting some discussion from IRC where @justindarc provides some insight on why the gecko implementation is they way it is that i think might be relevant to wider audience:
|
There was some more discussion on the IRC specifically I was trying to figure out why differences between nsIDNSServiceDiscovery and dns-discovery / libp2p-mdns both IPFS and Dat seem to differ from implementation in gecko in a same way. Specifically gecko implements DNS-SD according to https://tools.ietf.org/html/rfc6763 which requires Issue
Questions
@mafintosh @lidel @olizilla I could use your input here. |
@Gozala did some digging and on the IPFS side it seems both go and js implementations of mDNS discovery will be changed to use the new suffix: |
mDNS -> ServiceDiscoveryAfter more chatter (following #7 (comment)) on IRC it became clear that they way IPFS and Dat use mDNS for discovery is remarkably similar to DNS-Based Service Discovery (as per rfc6763) except some incompatibilities described in the previous comment. As per @lidel's comment above it seems that IPFS is going to resolve incompatibility and as I understand @mafintosh also agreed to do that on Dat side, which is needless to say I'm super excited about! In the light of this I renamed mDNS API to ServiceDiscovery and landed implementation that allows discovery of services and announcement. Readme contains some examples. I would like make few notes and request feedback on the API itself as I'm having some reservations:
|
@justindarc BTW I have also wondered if there was a reason to resolve hostname like this: https://github.com/mozilla/gecko-dev/blob/86897859913403b68829dbf9a154f5a87c4b0638/netwerk/dns/mdns/libmdns/fallback/MulticastDNS.jsm#L732-L744 instead of say: Cc['@mozilla.org/network/dns-service;1']
.getService(Ci.nsIDNSService)
.myHostName |
@Gozala sorry for the late response. Here's my responses to the questions you tagged me in:
|
mdns used for local peer discovery and is critical for enabling dweb protocols on the local network. There is an mdns artifacts from Project Flyweb that likely could be utilized to expose WebExtensions API.
The text was updated successfully, but these errors were encountered: