mirror of
https://gitlab.com/MrFry/mrfrys-node-server
synced 2025-04-01 20:24:18 +02:00
Added old.js, logging imporvements, manual refractor
This commit is contained in:
parent
5c8707f220
commit
b4b0a8322c
4 changed files with 81 additions and 196 deletions
|
@ -62,15 +62,12 @@ function LogReq (req, toFile, sc) {
|
|||
try {
|
||||
let ip = req.headers['cf-connecting-ip'] || req.connection.remoteAddress
|
||||
|
||||
let rColor = GetRandomColor(ip)
|
||||
|
||||
let logEntry = C(rColor) + ip + C()
|
||||
let color = 'green'
|
||||
let logEntry = C(GetRandomColor(ip)) + ip + C()
|
||||
if (req.url.includes('lred')) {
|
||||
color = 'red'
|
||||
logEntry += C('red')
|
||||
}
|
||||
|
||||
logEntry += C(color) + DELIM + req.hostname + DELIM + req.headers['user-agent'] + DELIM + req.method + DELIM
|
||||
logEntry += DELIM + req.hostname + DELIM + req.headers['user-agent'] + DELIM + req.method + DELIM
|
||||
|
||||
logEntry += req.url
|
||||
|
||||
|
@ -99,6 +96,8 @@ function GetRandomColor (ip) {
|
|||
let res = ip.split('').reduce((res, x) => {
|
||||
if (!isNaN(x)) {
|
||||
return res + parseInt(x)
|
||||
} else {
|
||||
return res
|
||||
}
|
||||
}, 0)
|
||||
return colors[res % colors.length]
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue