Page 1 of 1

Block connections from specified countries or regions

Posted: Fri Jan 13, 2023 5:56 am
by FTP
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":

Code: Select all

local handle = io.popen("curl")
local strResult = handle:read("*a")
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
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: