mirror of https://github.com/calzoneman/sync.git
Strip URL query before logging
This commit is contained in:
parent
9194c341af
commit
36d3232d9f
12
server.js
12
server.js
|
@ -77,9 +77,15 @@ var Server = {
|
||||||
if(status === undefined)
|
if(status === undefined)
|
||||||
status = 200;
|
status = 200;
|
||||||
var ip = req.connection.remoteAddress;
|
var ip = req.connection.remoteAddress;
|
||||||
var ip2 = req.header("x-forwarded-for");
|
var ip2 = false;
|
||||||
var ipstr = ip === ip2 ? ip : ip + " (X-Forwarded-For " + ip2 + ")";
|
if(this.cfg["trust-x-forward"])
|
||||||
this.httpaccess.log([ipstr, req.method, req.url, status, req.headers["user-agent"]].join(" "));
|
ip2 = req.header("x-forwarded-for") || req.header("cf-connecting-ip");
|
||||||
|
var ipstr = !ip2 ? ip : ip + " (X-Forwarded-For " + ip2 + ")";
|
||||||
|
var url = req.url;
|
||||||
|
// Remove query
|
||||||
|
if(url.indexOf("?") != -1)
|
||||||
|
url = url.substring(0, url.lastIndexOf("?"));
|
||||||
|
this.httpaccess.log([ipstr, req.method, url, status, req.headers["user-agent"]].join(" "));
|
||||||
},
|
},
|
||||||
init: function () {
|
init: function () {
|
||||||
this.httpaccess = new Logger.Logger("httpaccess.log");
|
this.httpaccess = new Logger.Logger("httpaccess.log");
|
||||||
|
|
Loading…
Reference in New Issue