_startResolving: function () { this._resolving = true; publicAddress((function (err, data) { this._resolving = false; // if the resolving failed, skip it this._resolved = data || {}; // emit all queued callbacks this._callbacks.forEach((function (callback) { callback(null, this._resolved); }).bind(this)); }).bind(this)); }
var config = require("./config"); var url = require("url"); var request = require("request"); var cluster = require('cluster'); var throttle = require("tokenthrottle")({rate: config.max_requests_per_second}); http.globalAgent.maxSockets = Infinity; https.globalAgent.maxSockets = Infinity; var publicAddressFinder = require("public-address"); var publicIP; // Get our public IP address publicAddressFinder(function (err, data) { if (!err && data) { publicIP = data.address; } }); function addCORSHeaders(req, res) { if (req.method.toUpperCase() === "OPTIONS") { if (req.headers["access-control-request-headers"]) { res.setHeader("Access-Control-Allow-Headers", req.headers["access-control-request-headers"]); } if (req.headers["access-control-request-method"]) { res.setHeader("Access-Control-Allow-Methods", req.headers["access-control-request-method"]); } } if (req.headers["origin"]) {