Permalink
Browse files

[iface] use new network interface handling in browser and advertisement

  • Loading branch information...
1 parent 36f4130 commit 91f8f6ff3d6a07a9b172b43aa6d45696b540c119 @agnat committed Dec 18, 2012
Showing with 15 additions and 2 deletions.
  1. +2 −1 lib/advertisement.js
  2. +6 −1 lib/browser.js
  3. +7 −0 lib/resolver_sequence_tasks.js
View
@@ -1,4 +1,5 @@
var dns_sd = require('./dns_sd')
+ , nif = require('./network_interface')
, util = require('util')
;
@@ -21,7 +22,7 @@ function Advertisement(serviceType, port, options, callback) {
serviceType = makeServiceType(serviceType);
var flags = options.flags || 0
- , ifaceIdx = options.interfaceIndex || 0
+ , ifaceIdx = nif.interfaceIndex(options)
, name = options.name || null
, domain = options.domain || null
, host = options.host || null
View
@@ -1,4 +1,5 @@
var dns_sd = require('./dns_sd')
+ , nif = require('./network_interface')
, util = require('util')
, rst = require('./resolver_sequence_tasks')
, st = require('./service_type')
@@ -11,7 +12,7 @@ var Browser = exports.Browser = function Browser(serviceType, options) {
options = options || {};
var flags = options.flags || 0
- , ifaceIdx = options.interfaceIndex || 0
+ , ifaceIdx = nif.interfaceIndex(options)
, domain = options.domain || null
, context = options.context || null
, requested_type = st.makeServiceType( serviceType );
@@ -91,6 +92,10 @@ Browser.defaultResolverSequence = [
, rst.makeAddressesUnique()
];
+if (typeof dns_sd.if_indextoname !== 'undefined') {
+ Browser.defaultResolverSequence.push(rst.networkInterfaceName());
+}
+
exports.browseThemAll = function browseThemAll(options) {
options = options || {}
options.resolverSequence = options.resolverSequence || [];
@@ -174,6 +174,13 @@ exports.logService = function logService() {
}
}
+exports.networkInterfaceName = function networkInterfaceName() {
+ return function networkInterfaceName(service, next) {
+ service.networkInterface = dns_sd.if_indextoname(service.interfaceIndex);
+ next();
+ }
+}
+
function errnoException(errorno, syscall) {
// TODO make this more compatible with ErrnoException from src/node.cc
// Once all of Node is using this function the ErrnoException from

0 comments on commit 91f8f6f

Please sign in to comment.