Get x-forwarded-for IP address from cloudflare when it exists

This commit is contained in:
calzoneman 2013-06-26 10:57:56 -04:00
parent a89f5138d3
commit c00b95feae
2 changed files with 7 additions and 3 deletions

View File

@ -2,7 +2,7 @@
"author": "Calvin Montgomery",
"name": "CyTube",
"description": "Online media synchronizer and chat",
"version": "2.0.0",
"version": "2.0.1",
"repository": {
"url": "http://github.com/calzoneman/sync"
},

View File

@ -9,7 +9,7 @@ The above copyright notice and this permission notice shall be included in all c
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
const VERSION = "2.0.0";
const VERSION = "2.0.1";
var fs = require("fs");
var Logger = require("./logger.js");
@ -127,8 +127,12 @@ fs.exists("chanlogs", function(exists) {
}
});
function getSocketIP(socket) {
return socket.handshake.headers["x-forwarded-for"] || socket.handshake.address.address;
}
exports.io.sockets.on("connection", function(socket) {
var ip = socket.handshake.address.address;
var ip = getSocketIP(socket);
if(Database.checkGlobalBan(ip)) {
Logger.syslog.log("Disconnecting " + ip + " - bant");
socket.emit("kick", {