fs = require('fs'),
dns = require('dns'),
url = require('url'),
- _ = require('underscore'),
+ _ = require('lodash'),
Client = require('./client.js').Client,
HttpHandler = require('./httphandler.js').HttpHandler,
- rehash = require('./rehash.js');
+ rehash = require('./rehash.js'),
+ range_check = require('range_check');
// Start socket.io listening on this weblistener
this.ws = ws.listen(hs, _.extend({ssl: true}, ws_opts));
- hs.listen(web_config.port, web_config.address);
+ hs.listen(web_config.port, web_config.address, function () {
+ that.emit('listening');
+ });
console.log('Listening on ' + web_config.address + ':' + web_config.port.toString() + ' with SSL');
} else {
// Start socket.io listening on this weblistener
this.ws = ws.listen(hs, _.extend({ssl: false}, ws_opts));
- hs.listen(web_config.port, web_config.address);
+ hs.listen(web_config.port, web_config.address, function () {
+ that.emit('listening');
+ });
console.log('Listening on ' + web_config.address + ':' + web_config.port.toString() + ' without SSL');
}
var address = handshakeData.address.address;
// If a forwarded-for header is found, switch the source address
- if (handshakeData.headers['x-forwarded-for']) {
+ if (handshakeData.headers[global.config.http_proxy_ip_header || 'x-forwarded-for']) {
// Check we're connecting from a whitelisted proxy
- if (!global.config.http_proxies || global.config.http_proxies.indexOf(address) < 0) {
+ if (!global.config.http_proxies || !range_check.in_range(address, global.config.http_proxies)) {
console.log('Unlisted proxy:', address);
callback(null, false);
return;