|
|
|
@ -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){ |
|
|
|
|