Skip to content

Commit 9de3b93

Browse files
committed
Add IPv6 support to DNSBL lookups
1 parent bc9c05a commit 9de3b93

3 files changed

Lines changed: 11 additions & 4 deletions

File tree

lib/dnsbl.js

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,14 @@ var vasync = require('vasync');
2929
}
3030
*/
3131

32+
function to_revip(ip) {
33+
if (ip.kind() === 'ipv6') {
34+
return ip.toFixedLengthString().split(':').join('').split('').reverse().join('.');
35+
} else {
36+
return ip.toString().split('.').reverse().join('.');
37+
}
38+
}
39+
3240
function DNSBLQuery(options, cb) {
3341
if (!(this instanceof DNSBLQuery))
3442
return new DNSBLQuery(options, cb);
@@ -45,8 +53,7 @@ function DNSBLQuery(options, cb) {
4553

4654
var q = this.dnsbl_parallel = vasync.queue(dnsblQuery, options.parallel || 4);
4755

48-
// TODO IPv6
49-
var revip = options.ip.split('.').reverse().join('.');
56+
var revip = to_revip(options.ip);
5057

5158
var servers = Object.keys(options.servers);
5259

lib/dnsfilter.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ DNSFilter.prototype._transform = function dnsfltrTransform(client, enc, cb) {
7777
},
7878
function dnsblQuery(next) {
7979
DNSBLQuery({
80-
ip: client.remoteParsedAddressString,
80+
ip: client.remoteParsedAddress,
8181
servers: self.dnsfltr_config.servers,
8282
}, next);
8383
},

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
},
2525
"dependencies": {
2626
"bunyan": "^1.8.0",
27-
"ipaddr.js": "^1.2.0",
27+
"ipaddr.js": "^1.9.0",
2828
"lstream": "0.0.4",
2929
"socket.io": "^1.3.5",
3030
"vasync": "^1.6.3",

0 commit comments

Comments
 (0)