Skip to content

API Proposal Service Discovery

dietrich ayala edited this page Sep 24, 2018 · 6 revisions

Webextensions Service Discovery API Proposal

Background

The Service Discovery API provides a DNS-based API for broadcasting and discovering services on the local network per rfc6763.

The current implementation in mozilla-central was originally landed for FlyWeb and is located at https://dxr.mozilla.org/mozilla-central/source/netwerk/dns/mdns.

Other current uses of MDNs/DNS-SD at Mozilla are in the IoT group in Emerging Technology, where communication between the Gateway and compatible devices happens through local network discovery.

This document is a proposal for offering a similar API for webextensions.

Proposal

This section details a proposed webextensions API for Service Discovery.

This proposal is specifically about discovery and broadcast of services, and does not extend to making or receiving connections. That functionality is done separately through Request, and TCP/UDP Socket APIs.

Permissions

As with most existing webextension APIs, this API will have a new top-level permission, “service-discovery”.

That is, the functions outlined below will not appear in an extension’s browser namespace unless the “service-discovery” permission is included in the extension manifest.

In this way, a user who installs an extension that uses this API can be offered a prompt (either at install time or at use time, see https://github.com/mozilla/addons/issues/51 for that debate) with a message such as:

“This extension may share your IP address with and/or connect to other computers on the local network, do you want to proceed?”

We could consider separate permissions for discovering and broadcasting services. Once the thread model has been defined, we will know more about the risks involved in each, and can determine whether it is necessary at that time.

API methods

The methods provided by this API will be in the browser.serviceDiscovery namespace. Note that, unlike nearly all other existing webextensions interfaces, this is a brand-new interface, so there is no need to includes these methods in the chrome namespace for compatibility.

The methods under browser.serviceDiscovery are:

Method Name Description
announce(options) Announce a service that others on the network can discover. The options object has the following properties: name - the text description of the service; type - the scheme, such as "airplay" or "http" or "ipp"; protocol - the string protocol name, either tcp or udp; port - the port number of the service; attributes - a set of key/value pairs of additional user-defined properties of the service.
discover(options) Discover services that have been announced on the local subnet. The options object has two properties, type and protocol. The type property is a string to specify which types of services the caller wants to know about. The protocol property is to specify which type of protocols the caller wants, and supports only two values, either tcp or udp. Both properties are required.
Clone this wiki locally