-
Notifications
You must be signed in to change notification settings - Fork 60
/
index.js
72 lines (56 loc) · 2.02 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
var config = require('./package.json');
var st = require('./lib/service_type');
var Networking = require('./lib/networking');
var networking = new Networking();
/** @member {string} */
module.exports.version = config.version;
module.exports.name = config.name;
/* @borrows Browser as Browser */
var Browser = module.exports.Browser = require('./lib/browser'); //just for convenience
/* @borrows Advertisement as Advertisement */
var Advertisement = module.exports.Advertisement = require('./lib/advertisement'); //just for convenience
/**
* Create a browser instance
* @method
* @param {string} [serviceType] - The Service type to browse for. Defaults to ServiceType.wildcard
* @return {Browser}
*/
module.exports.createBrowser = function browserCreated(serviceType) {
if (typeof serviceType === 'undefined') {
serviceType = st.ServiceType.wildcard;
}
return new Browser(networking, serviceType);
};
module.exports.excludeInterface = function (iface) {
if (networking.started) {
throw new Error('can not exclude interfaces after start');
}
if (iface === '0.0.0.0') {
networking.INADDR_ANY = false;
}
else {
var err = new Error('Not a supported interface');
err.interface = iface;
}
};
/**
* Create a service instance
* @method
* @param {string|ServiceType} serviceType - The service type to register
* @param {number} [port] - The port number for the service
* @param {object} [options] - ...
* @return {Advertisement}
*/
module.exports.createAdvertisement =
function advertisementCreated(serviceType, port, options) {
return new Advertisement(
networking, serviceType, port, options);
};
/** @property {module:ServiceType~ServiceType} */
module.exports.ServiceType = st.ServiceType;
/** @property {module:ServiceType.makeServiceType} */
module.exports.makeServiceType = st.makeServiceType;
/** @function */
module.exports.tcp = st.protocolHelper('tcp');
/** @function */
module.exports.udp = st.protocolHelper('udp');