Page 1 of 1

Import IP access rules from a text file

Posted: Fri Jul 03, 2015 10:13 am
by FTP
For importing IP access rules from a text file, you just need to use the following Lua script:

Code: Select all

local domain = "YourDomainName"
local ipmasks = c_GetIPMaskList(domain)

local domain_ipmasks = {}

if type(ipmasks) == "table" then
   for _,ipmask in pairs(ipmasks) do
      local temp = {}
      table.insert(temp, ipmask.ip)
      table.insert(temp, ipmask.refuse)
      table.insert(domain_ipmasks, temp)
   end
end

local fp = assert(io.open("c:/bannedIPs.txt", "rb"))
local content = fp:read("*all")
fp:close()

local arrayIP = Split(content, "\n")
for _, ip in ipairs(arrayIP) do
	local strIP = ip
	if string.sub(ip,-1) == "\r" then
	    strIP = string.sub(ip, 0, string.len(ip)-1)
	end
	table.insert(domain_ipmasks, {strIP, true})
end

c_SetIPMaskList(domain, domain_ipmasks)
And the content of IP access rules file will look like this:

Code: Select all

41.79.56.0/22
41.79.112.0/22
41.79.132.0/22
41.79.188.0/22
41.85.192.0/19
41.190.32.0/19
41.191.232.0/21
41.220.16.0/20
41.221.144.0/20
77.246.48.0/20
154.73.80.0/22
194.133.122.0/24
BTW, please do not add any "allowed" IP access rules if you already have "denied" rules.

Re: Import IP access rules from a text file

Posted: Thu Nov 10, 2022 5:59 pm
by davidroork
Do I have to purchase the Corporate Edition to be able to set this event LUA script or am I doing something wrong?
I keep getting an error saying this is not available in free/standard/secure versions.

Re: Import IP access rules from a text file

Posted: Fri Nov 11, 2022 12:13 am
by FTP
Yes, the event feature is only supported in the Corporate edition.