Block connections from specified countries or regions
Posted: Fri Jan 13, 2023 5:56 am
If you want to block connections from specified countries or regions, you can insert the following script into the event "Event Manager > FTP/HTTP/SSH Events > BeforeUserLoggedIn":
Just replace the string "Country1, Country2, Country3" into the real country/region names you want to block.
And you can find all the country/region names from this web page: https://www.iplocate.com/en/resources/countries
Code: Select all
local handle = io.popen("curl http://ip-api.com/line/%IP")
local strResult = handle:read("*a")
handle:close()
if strResult ~= nil and strResult ~= "" then
local arrResult = Split(strResult, "\n")
if table.maxn(arrResult) > 1 and arrResult[1] == "success" then
local country = arrResult[2]
local bannedCountries = "Country1, Country2, Country3"
if string.find(bannedCountries, country) then
bCancelEvent = true
return
end
end
end
And you can find all the country/region names from this web page: https://www.iplocate.com/en/resources/countries