Browse Source

Added IPv6 support.

pull/52/head
Artūrs Vaļenieks 9 years ago
parent
commit
95312af31a
1 changed files with 12 additions and 1 deletions
  1. +12
    -1
      lib/client.js

+ 12
- 1
lib/client.js View File

@ -3,6 +3,7 @@ var https = require("https");
var json = require("./json");
var url = require("url");
var util = require("util");
var os = require('os');
/*section: client
*comment: |
@ -66,11 +67,21 @@ client.prototype.request = function(method, path, params, callback){
"query": query,
});
function is_ipv4_loop_back(interface0) {
// 169.254.xx.xx - loop back address for IPv4
// if it exists all requests are redirected to localhost
return interface0.address.indexOf('169.254.') === 0;
}
var isIPv6 = os.networkInterfaces().en0.find(is_ipv4_loop_back);
var family = isIPv6 ? 6 : 4;
var http_options = {
hostname: this.api_host,
port: 443,
method: method.toUpperCase(),
path: path
path: path,
family: family
};
if(this.proxy_agent){


Loading…
Cancel
Save