0
|
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()
|
|
7 local Table = require "luan:Table.luan"
|
|
8 local concat = Table.concat or error()
|
|
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
|
|
14 local bad_agents = {
|
|
15 [[Googlebot]]
|
|
16 [[GSA/]]
|
|
17 [[Mobile/15E148 Instagram]]
|
|
18 [[Firefox/]]
|
|
19 [[VivoBrowser/]]
|
|
20 [[Chrome/(4\d|5\d|70|83|86|87|94)\.]]
|
|
21 [[musical_ly_2\d\.]]
|
|
22 }
|
|
23 local bad_agents_ptn = regex(concat(bad_agents,"|"))
|
|
24
|
|
25 local bad_contents = {
|
|
26 [[\Qchrome-extension://\E]]
|
|
27 [[\Q@webkit-masked-url://hidden/\E]]
|
|
28 [[\Qanalytics.tiktok.com\E]]
|
|
29 [[\QStrict mode does not allow function declarations in a lexically nested statement.\E]]
|
|
30 [[\QFailed to set the 'currentTime' property on 'HTMLMediaElement': The provided double value is non-finite.\E]]
|
|
31 [[\QThe element has no supported sources.\E]]
|
|
32 [[\QThe play() request was interrupted by a call to pause().\E]]
|
|
33 [[\QReferenceError: Can't find variable: _AutofillCallbackHandler\E]]
|
|
34 [[\QUtilityScript\E]]
|
|
35 [[\QscrollReadRandom\E]]
|
|
36 [[\QdoGameClick\E]]
|
|
37 [[\Qurl = undefined\E]]
|
|
38 [[\QFailed to set remote answer sdp: The order of m-lines in answer doesn't match order in offer. Rejecting answer.\E]]
|
|
39 }
|
|
40 local bad_contents_ptn = regex(concat(bad_contents,"|"))
|
|
41
|
|
42 local function priority(err)
|
|
43 local agent = Http.request.headers["user-agent"]
|
|
44 if agent~=nil and bad_agents_ptn.matches(agent) then return "info" end
|
|
45 if bad_contents_ptn.matches(err) then return "info" end
|
|
46 local x_requested_with = Http.request.headers["X-Requested-With"]
|
|
47 if x_requested_with ~= nil then
|
|
48 return "info"
|
|
49 end
|
|
50 return "error"
|
|
51 end
|
|
52
|
|
53 return function()
|
|
54 local err = Http.request.parameters.err
|
|
55 if err == nil then
|
|
56 return -- stupid bots
|
|
57 end
|
|
58 local call = priority(err)
|
|
59 logger[call](trim(err).."\n"..trim(Http.request.raw_head).."\n")
|
|
60 end
|