Comparing version 0.9.7 to 0.9.8
@@ -131,8 +131,4 @@ // Copyright 2012 Iris Couch, all rights reserved. | ||
case 'IN AAAA': | ||
rdata = (record.data || '').split(/:/) | ||
// If we get a raw IPv6 address, patch it | ||
if(rdata.length === 6) { | ||
record.data = record.data.replace('::', ':0:0:0:'); | ||
rdata = (record.data || '').split(/:/) | ||
} | ||
// [hbouvier] More robust parsing of ipV6 address | ||
rdata = ipv6_to_array(record.data || '::') | ||
if(rdata.length !== 8) | ||
@@ -212,2 +208,3 @@ throw new Error('Bad '+record.type+' record data: ' + JSON.stringify(record)) | ||
// [hbouvier] Added default value | ||
var domain = full_domain || ''; | ||
@@ -290,4 +287,4 @@ domain = domain.replace(/\.$/, '') // Strip the trailing dot. | ||
function pair_to_buf(pair) { | ||
// It is possible that the "pair" has less than 4 digits, lets make sure | ||
// that it has. | ||
// [hbouvier] It is possible that the "pair" has less than 4 digits, lets | ||
// make sure that it has. | ||
var pairLength = pair.length; | ||
@@ -302,1 +299,21 @@ if (pairLength < 4) | ||
} | ||
// [hbouvier] More robust parsing of ipV6 address | ||
function ipv6_to_array(string) { | ||
var fullAddress = ['0','0','0','0','0','0','0','0']; | ||
// Remove the contiguous empty strings generated by '::' and keep ony one. | ||
var numbers = string.split(/:/).reduce(function (previous, current) { | ||
if (previous instanceof Array === false) | ||
previous = [previous]; | ||
if (!(current === '' && previous[previous.length -1] === '')) { | ||
previous.push(current) | ||
} | ||
return previous; | ||
}); | ||
// Replace the single empty string, by the number of '0' that | ||
// were "missing" (e.g. shortened address) | ||
var merged = [].concat.apply([], numbers.map(function (num) { | ||
return (num === '') ? fullAddress.slice(numbers.length -1): num; | ||
})); | ||
return merged; | ||
} |
@@ -5,3 +5,3 @@ { "name": "hbo-dnsd" | ||
, "keywords": [ "dns", "bind", "dnsd", "iris" ] | ||
, "version": "0.9.7" | ||
, "version": "0.9.8" | ||
, "author": "Jason Smith <jhs@iriscouch.com> (http://www.iriscouch.com)" | ||
@@ -8,0 +8,0 @@ , "repository": { "type":"git", "url":"https://github.com/hbouvier/dnsd" } |
@@ -84,2 +84,8 @@ // Copyright 2012 Iris Couch, all rights reserved. | ||
var self = this | ||
if(typeof ip === 'function') { | ||
callback = ip | ||
ip = null | ||
} | ||
self.port = port | ||
@@ -86,0 +92,0 @@ self.ip = ip || '0.0.0.0' |
84253
1695