Get x-forwarded-for IP address from cloudflare when it exists
This commit is contained in:
parent
a89f5138d3
commit
c00b95feae
|
@ -2,7 +2,7 @@
|
||||||
"author": "Calvin Montgomery",
|
"author": "Calvin Montgomery",
|
||||||
"name": "CyTube",
|
"name": "CyTube",
|
||||||
"description": "Online media synchronizer and chat",
|
"description": "Online media synchronizer and chat",
|
||||||
"version": "2.0.0",
|
"version": "2.0.1",
|
||||||
"repository": {
|
"repository": {
|
||||||
"url": "http://github.com/calzoneman/sync"
|
"url": "http://github.com/calzoneman/sync"
|
||||||
},
|
},
|
||||||
|
|
|
@ -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.
|
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 fs = require("fs");
|
||||||
var Logger = require("./logger.js");
|
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) {
|
exports.io.sockets.on("connection", function(socket) {
|
||||||
var ip = socket.handshake.address.address;
|
var ip = getSocketIP(socket);
|
||||||
if(Database.checkGlobalBan(ip)) {
|
if(Database.checkGlobalBan(ip)) {
|
||||||
Logger.syslog.log("Disconnecting " + ip + " - bant");
|
Logger.syslog.log("Disconnecting " + ip + " - bant");
|
||||||
socket.emit("kick", {
|
socket.emit("kick", {
|
||||||
|
|
Loading…
Reference in a new issue