Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

added kludgy avahi detection

  • Loading branch information...
commit 81bf5ab12ae6d7178a91b35fb8203464eb8044bd 1 parent fa56ea6
@agnat authored
Showing with 30 additions and 0 deletions.
  1. +30 −0 lib/avahi.js
View
30 lib/avahi.js
@@ -0,0 +1,30 @@
+var dns_sd = require('./dns_sd');
+var util = require('util');
+
+function hasInterfaceIndexLocalOnly() {
+ try {
+ var sr = new dns_sd.DNSServiceRef()
+ , flags = dns_sd.kDNSServiceInterfaceIndexLocalOnly
+ , iface = 0
+ , name = null
+ , type = '_http._tcp'
+ , domain = null
+ , host = null
+ , port = 4321
+ , txtRec = null
+ , cb = null
+ , ctx = null
+ ;
+ dns_sd.DNSServiceRegister( sr, flags, iface, name, type, domain,
+ host, port, txtRec, cb, ctx);
+ } catch (ex) {
+ if (ex.errorCode === dns_sd.kDNSServiceErr_Unsupported) {
+ return false;
+ }
+ console.warn('Unexpected result while probing for avahi:', ex);
+ console.log(util.inspect(ex));
+ }
+ return true;
+}
+
+module.exports = ! hasInterfaceIndexLocalOnly();
Please sign in to comment.
Something went wrong with that request. Please try again.