Add 0.4.14 support.

master
red-001 2018-02-16 22:15:22 +00:00
parent 96f9dbb148
commit 3233c74c53
No known key found for this signature in database
GPG Key ID: 0CBE03CD90F44222
4 changed files with 26 additions and 7 deletions

View File

@ -1,8 +1,8 @@
local api_base = {}
local http_api = ...
local cache_time = tonumber(core.settings:get("block_vps_cache_time")) or 30000 -- ~8 hours
local max_try_count = tonumber(core.settings:get("block_vps_max_try")) or 3 -- how many API do we try to use before aborting
local enabled_sources = string.split(core.settings:get("block_vps_datasources")
local cache_time = tonumber(block_vps.get_setting("block_vps_cache_time")) or 30000 -- ~8 hours
local max_try_count = tonumber(block_vps.get_setting("block_vps_max_try")) or 3 -- how many API do we try to use before aborting
local enabled_sources = string.split(block_vps.get_setting("block_vps_datasources")
or "iphub, iphub_legacy, nastyhosts", ",")
local function gen_stub(name)

View File

@ -3,8 +3,23 @@ local http_api = minetest.request_http_api()
assert(http_api ~= nil, "Add 'block_vps' to secure.http_mods and restart server")
local mod_path = core.get_modpath(core.get_current_modname())
local mod_storage = minetest.get_mod_storage()
local block_type = core.settings:get("block_vps_type") or "activation"
local mod_storage
-- support older minetest versions
if minetest.get_mod_storage then
mod_storage = minetest.get_mod_storage()
end
-- support older minetest versions
function block_vps.get_setting(name)
if core.settings then
return core.settings:get(name)
else
return core.setting_get(name)
end
end
local block_type = block_vps.get_setting("block_vps_type") or "activation"
assert(loadfile(mod_path .. "/api.lua"))(http_api)
dofile(mod_path .. "/iphub.lua")
@ -46,6 +61,10 @@ if block_type == "creation" then
end
end)
elseif block_type == "activation" then
-- support older minetest versions
assert(mod_storage ~= nil, "Your minetest version doesn't support mod storage, " ..
"it is required if 'block_vps_type' is set to 'activation' please change it to any other support setting ('none', 'kick', 'creation')")
core.register_on_joinplayer(function(player)
local name = player:get_player_name()
-- Check if the account has yet to connect from a valid IP

View File

@ -1,5 +1,5 @@
local ip_hub_api = {}
local API_KEY = core.settings:get("iphub_api_key") or 'YOUR_API_KEY_HERE'
local API_KEY = block_vps.get_setting("iphub_api_key") or 'YOUR_API_KEY_HERE'
local function is_base_64(string)
if type(string) == "string" and string ~= "" then

View File

@ -1,6 +1,6 @@
local ip_hub_api = {}
local email = core.settings:get("block_vps_email") or "YOUR_EMAIL@example.com"
local email = block_vps.get_setting("block_vps_email") or "YOUR_EMAIL@example.com"
function ip_hub_api:generate_request(ip)
return { url = "http://legacy.iphub.info/api.php?showtype=4&ip=" .. ip .. "&email=" ..email }