Skip to content

Commit

Permalink
Fix scan_airtunes for OSX ML 10.8+
Browse files Browse the repository at this point in the history
  • Loading branch information
taiyangc committed Jan 4, 2013
1 parent c438fea commit 33cd643
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions examples/scan_airtunes.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,13 @@ if(os.platform() !== 'darwin') {
process.exit(1);
}

exec('mDNS -B _raop._tcp', {
// Mountain Lion 12.0.0 replaces mDNS with dns-sd
if(os.release() < '12')
var mdns = 'mDNS';
else
var mdns = 'dns-sd';

exec(mdns + ' -B _raop._tcp', {
timeout: 300
}, function(error, stdout) {
var devices = [];
Expand All @@ -23,10 +29,10 @@ exec('mDNS -B _raop._tcp', {
});

devices.forEach(function(dev) {
exec('mDNS -L "' + dev.mac + '@' + dev.name + '" _raop._tcp local', {
exec(mdns + ' -L "' + dev.mac + '@' + dev.name + '" _raop._tcp local', {
timeout: 300
}, function(error, stdout) {
var res = /Service can be reached at\s+(\S*)\s+:(\d+)/.exec(stdout);
var res = /can be reached at\s+(\S*)\s*:(\d+)/.exec(stdout);
if(!res)
console.log(dev.name + ' no match');
else
Expand Down

0 comments on commit 33cd643

Please sign in to comment.