ISP-Checker
 

News:

29 December 2022 - PtokaX 0.5.3.0 (20th anniversary edition) released...
11 April 2017 - PtokaX 0.5.2.2 released...
8 April 2015 Anti child and anti pedo pr0n scripts are not allowed anymore on this board!
28 September 2015 - PtokaX 0.5.2.1 for Windows 10 IoT released...
3 September 2015 - PtokaX 0.5.2.1 released...
16 August 2015 - PtokaX 0.5.2.0 released...
1 August 2015 - Crowdfunding for ADC protocol support in PtokaX ended. Clearly nobody want ADC support...
30 June 2015 - PtokaX 0.5.1.0 released...
30 April 2015 Crowdfunding for ADC protocol support in PtokaX
26 April 2015 New support hub!
20 February 2015 - PtokaX 0.5.0.3 released...
13 April 2014 - PtokaX 0.5.0.2 released...
23 March 2014 - PtokaX testing version 0.5.0.1 build 454 is available.
04 March 2014 - PtokaX.org sites were temporary down because of DDOS attacks and issues with hosting service provider.

Main Menu

ISP-Checker

Started by nErBoS, 21 April, 2004, 14:50:33

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

nErBoS

Hi,

This is the same ISP-Checker that i have in Brain-Master, hope it helps...

--Made by nErBoS 

sBot = "IP-Checker" 

ipallowed = {      
      "127.0.0.0-127.255.255.255"      
} 	--eg of how to put isps in this table

function NewUserConnected(user, data) 
   if (IspChecker(user.sIP) == 0) then 
      user:SendData(sBot, "Your IP is not allowed in this HUB.") 
      user:Disconnect() 
   end 
end 

OpConnected = NewUserConnected 

function IspChecker(IP) 
   local accept = 0 

   local s,e,ip1,ip2,ip3,ip4 = strfind(IP, "(%d+)%.(%d+)%.(%d+)%.(%d+)") 
   local userIP = Addzero(ip1)..Addzero(ip2)..Addzero(ip3)..Addzero(ip4) 
   userIP = tonumber(userIP) 

   for i=1, getn(ipallowed) do 
      local s,e,a1,a2,a3,a4,b1,b2,b3,b4 = strfind(ipallowed[i], "(%d+)%.(%d+)%.(%d+)%.(%d+)-(%d+)%.(%d+)%.(%d+)%.(%d+)") 
      local aIP = Addzero(a1)..Addzero(a2)..Addzero(a3)..Addzero(a4) 
      aIP = tonumber(aIP) 
      local bIP = Addzero(b1)..Addzero(b2)..Addzero(b3)..Addzero(b4) 
      bIP = tonumber(bIP) 

      if (userIP >= aIP and userIP <= bIP) then 
         accept = 1 
         break 
      end 
   end 
return accept 
end 

function Addzero(number) 
   iAux = tonumber(number) 
   if (iAux < 10) then 
      number = "00"..number 
   elseif (iAux < 100) then 
      number = "0"..number 
   else 
      number = number 
   end 
return number 
end

Best regards, nErBoS
--## nErBoS Spot ##--

kp

function Addzero(number) 

   iAux = tonumber(number) 

   if (iAux < 10) then 

      number = "00"..number 

   elseif (iAux < 100) then 

      number = "0"..number 

   else 

      number = number 

   end 

return number 

end

equals

x = 5
format("%03d",x)

if i got the manual right, or you can translate the IP to a unique number and compare that, or do it like in GeoIP script, too many ways all lead to rome i guess you should be fine.

nErBoS

Hi,

Both ways work :)

Best regards, nErBoS
--## nErBoS Spot ##--

kp

yes i know, it was just a suggestion

nErBoS

Hi,

I know kp, always welcomed, i didn?t got offended :)
But i perfer this way :P

Best regards, nErBoS
--## nErBoS Spot ##--

kp

#5
sure np, mostly people like it when they can reduce many lines to one line, cause it mostly implements a faster handling, not always but mostly,

also check this

func(strnum)
	for _ = (strlen(strnum)+1),3 do
		strnum = "0"..strnum
	end
	return strnum
end

is the board only slow to me?

SMF spam blocked by CleanTalk