-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathchecker.lua
95 lines (86 loc) · 2.78 KB
/
checker.lua
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
-- Default proxy and vpn checker websites
-- The best checker should be the first registered!
-- Iphub.info
local iphub_key = minetest.settings:get("iphub_key")
if iphub_key then
local check = {}
function check.getreq(ip)
local req = {
["url"] = "http://v2.api.iphub.info/ip/"..ip,
["extra_headers"] = {"X-Key: "..iphub_key}
}
local callback = function(result)
if result.code == 429 then -- Iphub request limit reached!
check.active = false
return nil, "IPhub Limit reached!"
end
local data = minetest.parse_json(result.data)
if result.completed and result.succeeded and data and data.block then -- Correct request
if data.block == 1 then
return false
else return true
end
else return nil, "Incorrect iphub request!"
end
end
return req, callback
end
vps_blocker.register_checker(check)
end
-- Getipintel.net
local contact = minetest.settings:get("getipintel_contact")
if contact then
local check = {}
function check.getreq(ip)
local req = {
["url"] = "https://check.getipintel.net/check.php?contact="..contact.."&ip="..ip
}
local callback = function(result)
if result.code == 429 then -- Iphub request limit reached!
check.active = false
return nil, "Getipintel Limit reached!"
end
local data = tonumber(result.data)
if result.completed and result.succeeded and result.code == 200 and data then -- Correct request
if data > 0.99 then
return false
else return true
end
else return nil, "Incorrect getipintel request!"
end
end
return req, callback
end
vps_blocker.register_checker(check)
end
-- Proxycheck.io
do
local proxycheck_key = minetest.settings:get("proxycheck_key")
local check = {}
function check.getreq(ip)
local req = {
["url"] = "http://proxycheck.io/v2/"..ip.."?vpn=1"
}
if proxycheck_key then
req.url = req.url.."&key="..proxycheck_key
end
local callback = function(result)
local data = minetest.parse_json(result.data)
if result.completed and result.succeeded and data then -- Correct request
if data.status == "ok" or data.status == "warning" and data[ip] and data[ip].proxy then
if data[ip].proxy == "yes" then
return false
else return true
end
elseif data.status == "denied" and string.find(data.message, "exhausted") then
check.active = false
return nil, "Proxycheck Limit reached!"
else return nil, (data.status or "error") .. ": "..(data.message or "Bad request-result!")
end
else return nil, "Incorrect iphub request!"
end
end
return req, callback
end
vps_blocker.register_checker(check)
end