3
|
1 local Luan = require "luan:Luan.luan"
|
|
2 local error = Luan.error
|
|
3 local String = require "luan:String.luan"
|
|
4 local trim = String.trim or error()
|
|
5 local regex = String.regex or error()
|
|
6 local contains = String.contains or error()
|
90
|
7 local Table = require "luan:Table.luan"
|
|
8 local concat = Table.concat or error()
|
3
|
9 local Http = require "luan:http/Http.luan"
|
|
10 local Logging = require "luan:logging/Logging.luan"
|
|
11 local logger = Logging.logger "error_log.js"
|
|
12
|
|
13
|
90
|
14 local bad_agents = {
|
|
15 [[Version/14\.]]
|
|
16 }
|
|
17 local bad_agents_ptn = regex(concat(bad_agents,"|"))
|
|
18
|
3
|
19 local function priority(err)
|
90
|
20 local agent = Http.request.headers["user-agent"]
|
|
21 if agent~=nil and bad_agents_ptn.matches(agent) then return "info" end
|
3
|
22 return "error"
|
|
23 end
|
|
24
|
|
25 return function()
|
|
26 local err = Http.request.parameters.err
|
|
27 if err == nil then
|
|
28 return -- stupid bots
|
|
29 end
|
|
30 local call = priority(err)
|
|
31 logger[call](trim(err).."\n"..trim(Http.request.raw_head).."\n")
|
|
32 end
|