Hi!
Anyone can help me with this?
I need an IP Bot with these ip?s. Is it possible?
Thank you!
195.245.234.0/24
193.221.96.0/20
195.138.0.0/19
194.145.121.0/24
81.84.0.0/16
83.132.0.0/16
85.138.0.0/15
212.113.160.0/19
213.22.0.0/16
193.53.22.0/24
193.194.155.0/24
213.129.128.0/19
193.236.127.0/24
146.193.0.0/19
146.193.32.0/19
146.193.64.0/18
146.193.128.0/17
192.12.232.0/24
192.35.246.0/24
192.135.129.0/24
192.136.49.0/24
194.117.24.0/21
194.117.32.0/22
213.63.0.0/17
213.63.128.0/17
213.141.0.0/19
194.153.132.0/24
195.85.221.0/24
83.223.160.0/19
213.190.192.0/19
213.138.224.0/19
62.229.64.0/19
194.235.128.0/21
194.235.136.0/22
195.61.64.0/19
193.41.114.0/23
212.48.64.0/19
212.54.128.0/19
212.54.144.0/20
194.145.59.0/24
194.145.60.0/24
194.145.61.0/24
194.145.62.0/24
192.67.76.0/24
192.104.37.0/24
195.95.236.0/23
195.245.128.0/18
213.58.0.0/16
80.172.0.0/16
80.172.224.0/24
194.8.30.0/24
194.130.254.0/23
195.22.0.0/19
62.48.128.0/17
83.240.128.0/17
158.162.120.0/21
192.188.10.0/24
193.176.0.0/24
193.236.120.0/24
193.236.121.0/24
193.236.122.0/24
193.236.123.0/24
195.35.66.0/24
139.83.0.0/16
158.162.0.0/18
158.162.64.0/19
158.162.96.0/20
158.162.112.0/21
158.162.128.0/18
158.162.192.0/18
192.88.99.0/24
193.136.0.0/15
194.117.0.0/20
194.117.16.0/21
194.117.40.0/22
194.210.0.0/16
82.140.192.0/20
193.126.0.0/16
193.192.1.0/24
193.192.2.0/24
193.192.3.0/24
81.193.0.0/16
82.154.0.0/15
85.240.0.0/13
192.92.150.0/24
194.65.0.0/16
212.55.128.0/18
213.13.0.0/16
192.188.10.0/24
192.199.16.0/20
193.236.120.0/24
193.236.123.0/24
194.79.64.0/19
194.117.36.0/22
195.23.0.0/16
195.225.220.0/22
212.0.160.0/21
213.205.64.0/19
194.38.128.0/19
213.146.192.0/19
193.219.96.0/21
81.20.240.0/20
195.8.0.0/19
217.168.112.0/20
83.174.0.0/18
212.18.160.0/19
213.30.0.0/17
212.16.128.0/19
212.251.128.0/17
212.13.32.0/19
84.90.0.0/15
213.228.128.0/18
217.129.0.0/16
212.113.128.0/19
80.90.192.0/19
195.245.197.0/24
217.23.0.0/20
80.79.0.0/20
SA 193.111.42.0/24
193.192.4.0/22
193.192.8.0/22
81.92.192.0/19
82.102.0.0/18
195.234.134.0/24
62.169.64.0/19
192.35.96.0/26
195.35.96.0/24
195.60.162.0/23
217.70.72.0/21
80.251.161.128/28
217.112.192.0/22
217.112.196.0/24
62.249.8.176/28
80.251.160.0/20
80.91.80.0/22
83.144.128.0/18
193.17.0.0/24
85.88.128.0/19
there are ip bots about in the forum. do you want to alow or disalow these ip's you have listed? you can add them to scripts that exist already
QuoteOriginally posted by SilvaO
Hi!
Anyone can help me with this?
I need an IP Bot with these ip?s. Is it possible?
Thank you!
195.245.234.0/24
193.221.96.0/20
195.138.0.0/19
194.145.121.0/24
81.84.0.0/16
83.132.0.0/16
85.138.0.0/15
212.113.160.0/19
213.22.0.0/16
193.53.22.0/24
193.194.155.0/24
213.129.128.0/19
193.236.127.0/24
146.193.0.0/19
146.193.32.0/19
146.193.64.0/18
146.193.128.0/17
192.12.232.0/24
192.35.246.0/24
192.135.129.0/24
192.136.49.0/24
194.117.24.0/21
194.117.32.0/22
213.63.0.0/17
213.63.128.0/17
213.141.0.0/19
194.153.132.0/24
195.85.221.0/24
83.223.160.0/19
213.190.192.0/19
213.138.224.0/19
62.229.64.0/19
194.235.128.0/21
194.235.136.0/22
195.61.64.0/19
193.41.114.0/23
212.48.64.0/19
212.54.128.0/19
212.54.144.0/20
194.145.59.0/24
194.145.60.0/24
194.145.61.0/24
194.145.62.0/24
192.67.76.0/24
192.104.37.0/24
195.95.236.0/23
195.245.128.0/18
213.58.0.0/16
80.172.0.0/16
80.172.224.0/24
194.8.30.0/24
194.130.254.0/23
195.22.0.0/19
62.48.128.0/17
83.240.128.0/17
158.162.120.0/21
192.188.10.0/24
193.176.0.0/24
193.236.120.0/24
193.236.121.0/24
193.236.122.0/24
193.236.123.0/24
195.35.66.0/24
139.83.0.0/16
158.162.0.0/18
158.162.64.0/19
158.162.96.0/20
158.162.112.0/21
158.162.128.0/18
158.162.192.0/18
192.88.99.0/24
193.136.0.0/15
194.117.0.0/20
194.117.16.0/21
194.117.40.0/22
194.210.0.0/16
82.140.192.0/20
193.126.0.0/16
193.192.1.0/24
193.192.2.0/24
193.192.3.0/24
81.193.0.0/16
82.154.0.0/15
85.240.0.0/13
192.92.150.0/24
194.65.0.0/16
212.55.128.0/18
213.13.0.0/16
192.188.10.0/24
192.199.16.0/20
193.236.120.0/24
193.236.123.0/24
194.79.64.0/19
194.117.36.0/22
195.23.0.0/16
195.225.220.0/22
212.0.160.0/21
213.205.64.0/19
194.38.128.0/19
213.146.192.0/19
193.219.96.0/21
81.20.240.0/20
195.8.0.0/19
217.168.112.0/20
83.174.0.0/18
212.18.160.0/19
213.30.0.0/17
212.16.128.0/19
212.251.128.0/17
212.13.32.0/19
84.90.0.0/15
213.228.128.0/18
217.129.0.0/16
212.113.128.0/19
80.90.192.0/19
195.245.197.0/24
217.23.0.0/20
80.79.0.0/20
SA 193.111.42.0/24
193.192.4.0/22
193.192.8.0/22
81.92.192.0/19
82.102.0.0/18
195.234.134.0/24
62.169.64.0/19
192.35.96.0/26
195.35.96.0/24
195.60.162.0/23
217.70.72.0/21
80.251.161.128/28
217.112.192.0/22
217.112.196.0/24
62.249.8.176/28
80.251.160.0/20
80.91.80.0/22
83.144.128.0/18
193.17.0.0/24
85.88.128.0/19
I don't understand your request
Its something with those IP's that isnt correct ...
And that could be the reason for hes ask / else he did a mistake
Ips always comes in series XXX.XXX.XXX.XXX - No /XX after
---#ipbot v1.0
---# pt rages
---# imune nick excepcoes
--- bot name
sBot = ""
--- imune nick
excepcoes = {
[""] = 1,
}
--## Config ##--
-- put the rages in there
arrIP = {
["192.168.0.1"] = "192.168.255.255", -- REDE LOCAL
["127.0.0.1"] = "127.0.0.1", -- LOCAL HOST
["81.84.0.0"] = "81.84.255.255", -- TVCABO
["83.132.0.0"] = "83.132.255.255", -- TVCABO
["85.138.0.0"] = "85.139.255.255", -- TVCABO
["212.113.160.0"] = "212.113.191.255", -- TVCABO
["213.22.0.0"] = "213.22.255.255", -- TVCABO
["195.245.234.0"] = "195.245.234.255", -- BPN
["193.221.96.0"] = "193.221.111.255", -- ITM-PORTUGAL
["195.138.0.0"] = "195.138.31.255", -- SIBS
["194.145.121.0"] = "194.145.121.255", -- ESDI
["193.53.22.0"] = "193.53.22.255", -- SERVIBANCA
["193.194.155.0"] = "193.194.155.255", -- SHOPPING DIRECT
["213.129.128.0"] = "213.129.159.255", -- netway
["193.236.127.0"] = "193.236.127.255", -- Sistema de Mail para Todos do MCT
["146.193.0.0"] = "146.193.31.255", -- INESC
["146.193.32.0"] = "146.193.63.255", -- INESC
["146.193.64.0"] = "146.193.127.255", -- INESC
["146.193.128.0"] = "146.193.255.255", -- INESC
["192.12.232.0"] = "192.12.232.255", -- INESC
["192.35.246.0"] = "192.35.246.255", -- INESC
["192.135.129.0"] = "192.135.129.255", -- INESC
["192.136.49.0"] = "192.136.49.255", -- INESC
["194.117.24.0"] = "194.117.31.255", -- INESC
["194.117.32.0"] = "194.117.35.255", -- INESC
["213.63.0.0"] = "213.63.127.255", -- Jazztel Portugal
["213.63.128.0"] = "213.63.255.255", -- Jazztel Portugal
["213.141.0.0"] = "213.141.31.255", -- Jazztel Portugal
["194.153.132.0"] = "194.153.132.255", -- BPI, SA
["195.85.221.0"] = "195.85.221.255", -- BPI, SA
["83.223.160.0"] = "83.223.191.255", -- CABOTVM.PT
["213.190.192.0"] = "213.190.223.255", -- CABOTVM.PT
["213.138.224.0"] = "213.138.255.255", -- CABOTVM.PT
["62.229.64.0"] = "62.229.95.255", -- GLOBAL-ONE-PORTUGAL
["194.235.128.0"] = "194.235.135.255", -- GLOBAL-ONE-PORTUGAL
["194.235.136.0"] = "194.235.139.255", -- GLOBAL-ONE-PORTUGAL
["195.61.64.0"] = "195.61.95.255", -- GLOBAL-ONE-PORTUGAL
["193.41.114.0"] = "193.41.115.255", -- YASP
["212.48.64.0"] = "212.48.95.255", -- HLC
["212.54.128.0"] = "212.54.159.255", -- ITNET-Network
["212.54.144.0"] = "212.54.159.255", -- ITNET-Network
["194.145.59.0"] = "194.145.59.255", -- Siemens
["194.145.60.0"] = "194.145.60.255", -- Siemens
["194.145.61.0"] = "194.145.61.255", -- Siemens
["194.145.62.0"] = "194.145.62.255", -- Siemens
["192.67.76.0"] = "192.67.76.255", -- Centro de Calculo da Faculdade de Ciencias de Lisboa
["192.104.37.0"] = "192.104.37.255", -- Edinet
["195.95.236.0"] = "195.95.237.255", -- Edinet
["195.245.128.0"] = "195.245.191.255", -- Edinet
["213.58.0.0"] = "213.58.255.255", -- Edinet
["217.70.64.0"] = "217.70.71.255", -- Edinet
["217.70.72.0"] = "217.70.79.255", -- Edinet
["80.172.0.0"] = "80.172.255.255", -- VIA NET.WORKS Portugal
["194.8.30.0"] = "194.8.30.255", -- VIA NET.WORKS Portugal
["194.130.254.0"] = "194.130.255.255", -- VIA NET.WORKS Portugal
["195.22.0.0"] = "195.22.31.255", -- VIA NET.WORKS Portugal
["62.48.128.0"] = "62.48.255.255", -- PT Prime
["83.240.128.0"] = "83.240.255.255", -- PT Prime
["158.162.120.0"] = "158.162.127.255", -- PT Prime
["193.176.0.0"] = "193.176.0.255", -- PT Prime
["195.35.66.0"] = "195.35.66.255", -- PT Prime
["139.83.0.0"] = "139.83.255.255", -- RCCN-NET
["158.162.0.0"] = "158.162.63.255", -- RCCN-NET
["158.162.64.0"] = "158.162.95.255", -- RCCN-NET
["158.162.96.0"] = "158.162.111.255", -- RCCN-NET
["158.162.112.0"] = "158.162.119.255", -- RCCN-NET
["158.162.128.0"] = "158.162.191.255", -- RCCN-NET
["158.162.192.0"] = "158.162.255.255", -- RCCN-NET
["192.88.99.0"] = "192.88.99.255", -- RCCN-NET
["193.136.0.0"] = "193.137.255.255", -- RCCN-NET
["194.117.0.0"] = "194.117.15.255", -- RCCN-NET
["194.117.16.0"] = "194.117.23.255", -- RCCN-NET
["194.117.40.0"] = "194.117.43.255", -- RCCN-NET
["194.210.0.0"] = "194.210.255.255", -- RCCN-NET
["82.140.192.0"] = "82.140.207.255", -- KPNQwest
["193.126.0.0"] = "193.126.255.255", -- KPNQwest
["193.192.1.0"] = "193.192.1.255", -- KPNQwest
["193.192.2.0"] = "193.192.2.255", -- KPNQwest
["193.192.3.0"] = "193.192.3.255", -- KPNQwest
["81.193.0.0"] = "81.193.255.255", -- Telepac
["82.154.0.0"] = "82.155.255.255", -- Telepac
["85.240.0.0"] = "85.247.255.255", -- Telepac
["192.92.150.0"] = "192.92.150.255", -- Telepac
["194.65.0.0"] = "194.65.255.255", -- Telepac
["212.55.128.0"] = "212.55.191.255", -- Telepac
["213.13.0.0"] = "213.13.255.255", -- Telepac
["192.188.10.0"] = "192.188.10.255", -- Novis
["192.199.16.0"] = "192.199.31.255", -- Novis
["193.236.120.0"] = "193.236.120.255", -- Novis
["193.236.121.0"] = "193.236.121.255", -- Novis
["193.236.122.0"] = "193.236.122.255", -- Novis
["193.236.123.0"] = "193.236.123.255", -- Novis
["194.79.64.0"] = "194.79.95.255", -- Novis
["194.117.36.0"] = "194.117.39.255", -- Novis
["195.23.0.0"] = "195.23.255.255", -- Novis
["195.225.220.0"] = "195.225.223.255", -- Novis
["212.0.160.0"] = "212.0.167.255", -- Novis
["213.205.64.0"] = "213.205.95.255", -- Novis
["194.38.128.0"] = "194.38.159.255", -- COMNEXO, SA
["213.146.192.0"] = "213.146.223.255", -- COMNEXO, SA
["193.219.96.0"] = "193.219.103.255", -- IP Global
["81.20.240.0"] = "81.20.255.255", -- CPRM
["195.8.0.0"] = "195.8.31.255", -- CPRM
["217.168.112.0"] = "217.168.127.255", -- CPRM
["83.174.0.0"] = "83.174.63.255", -- Vodafone
["212.18.160.0"] = "212.18.191.255", -- Vodafone
["213.30.0.0"] = "213.30.127.255", -- Vodafone
["212.16.128.0"] = "212.16.159.255", -- Teleweb
["212.251.128.0"] = "212.251.255.255", -- Teleweb
["212.13.32.0"] = "212.13.63.255", -- NorteNet
["84.90.0.0"] = "84.91.255.255", -- Cabovisao,SA
["213.228.128.0"] = "213.228.191.255", -- Cabovisao,SA
["217.129.0.0"] = "217.129.255.255", -- Cabovisao,SA
["212.113.128.0"] = "212.113.159.255", -- MaxitelCom, SA
["80.90.192.0"] = "80.90.223.255", -- Oni Way
["195.245.197.0"] = "195.245.197.255", -- Inst Informatica e Estat da Solidariedade
["217.23.0.0"] = "217.23.15.255", -- Cofina.com
["80.79.0.0"] = "80.79.15.255", -- Guiao, S.A.
["193.111.42.0"] = "193.111.42.255", -- Finibanco, SA
["193.192.4.0"] = "193.192.7.255", -- INE
["193.192.8.0"] = "193.192.11.255", -- INE
["81.92.192.0"] = "81.92.223.255", -- NFSi-Solucoes Internet Lda.
["82.102.0.0"] = "82.102.63.255", -- NFSi-Solucoes Internet Lda.
["195.234.134.0"] = "195.234.134.255", -- CAIXANET
["62.169.64.0"] = "62.169.95.255", --Optimus
["192.35.96.0"] = "192.35.96.63", -- BanifServ
["195.35.96.0"] = "195.35.96.255", -- BanifServ
["195.60.162.0"] = "195.60.163.255", -- Instituto Superior de Linguas e Administra??o
["217.70.72.0"] = "217.70.79.255", -- Bragatel
["80.251.161.128"] = "80.251.161.143", -- PHC
["217.112.192.0"] = "217.112.195.255", -- WTS
["217.112.196.0"] = "217.112.196.255", -- WTS
["62.249.8.176"] = "62.249.8.191", -- DATABOX-PT
["80.251.160.0"] = "80.251.175.255", -- COLT
["80.91.80.0"] = "80.91.83.255", -- LNCES
["83.144.128.0"] = "83.144.191.255", -- Pluricanal, SA
["193.17.0.0"] = "193.17.0.255", -- Imprensa Nacional
}
--## Fim da tabela de ranges autorizadas pelo Hub ##--
function Main()
frmHub:RegBot(sBot)
end
function NewUserConnected(user)
if (excepcoes[user.sName] == nil) and (isGoodIP(user.sIP) == nil) then
user:SendData(sBot, "Your IP is not allowed in this HUB. O teu ip n?o ? permitido neste Hub. [ Caso estejas em portugal, envia um email vai ao syte [URL]http://gigashare.rd5.net/[/URL] e explica a situa??o")
user:SendData("$ForceMove lusoleader.no-ip.org")
user:Disconnect()
end
end
OpConnected = NewUserConnected
function isGoodIP(sIP)
sIP = ipToNumber(sIP)
local iFirst,iLast
for iFirst, iLast in arrIP do
if (sIP >= ipToNumber(iFirst) and sIP <= ipToNumber(iLast)) then
return 1
end
end
return nil
end
function ipToNumber(sIP)
iAux = ""
string.gsub(sIP,"(%d+)", function(w)
w = tonumber(w)
if (w < 10) then
iAux = iAux.."00"..w
elseif (w < 100) then
iAux = iAux.."0"..w
else
iAux = iAux..w
end
end)
return tonumber(iAux)
end
QuoteOriginally posted by uffetjur
Its something with those IP's that isnt correct ...
And that could be the reason for hes ask / else he did a mistake
Ips always comes in series XXX.XXX.XXX.XXX - No /XX after
His IP Ranges is CIDR ranges
I have only come over one script for that, and that will not work with above ranges.
BUT
just keep the faith up, I Am exploring and testing the CIDR ranges. I Am trying to find a suitable way to calculate the range for now...
Just wait, in time I will release my new IP-Checker
Supporting:
x.x.x.x-x.x.x.x - Standard Range
x.x.x.x/x - CIDR Range
x.x.x.x:x - Simple style ( my short style of Standard ex. 127.0.0.1:255 range is from: 127.0.0.1-127.0.0.255
x.x.x.* - C Range
x.x.* - B - Range
x.* - A Range
that is the ones that will be supported...
later all
lookin forward to that 1 NL ^^ but take your time ;)
QuoteOriginally posted by NightLitch
just keep the faith up, I Am exploring and testing the CIDR ranges. I Am trying to find a suitable way to calculate the range for now...
I really don't dare to give you advice, but you should do the following:
tCIDR={["26"]=64}
(Btw as I can recall, formula is 2^(32-CIDRvalue), so a 26 CIDR results in 2^6=64 IPs.)
Anyhow it is, IPs can be calculated from the standard subnet too, I have to find a formula for these... found this (http://www.linuxsa.org.au/pipermail/linuxsa/2002-July/042639.html).
hello,
can anyw give me a litle help ?
I nead a ipbot script to use x.x.x.x/x - CIDR Range
can anywone modify this one ?
sBot = ""
excepcoes = {
[""] = 1,
}
--## Configura??o ##--
-- Insira aqui as ranges que pretende autorizar no hub
arrIP = {
["192.168.0.1"] = "192.168.255.255", -- A RANGE
["127.0.0.2"] = "127.0.0.2", -- AN IP
}
--## Fim da tabela de ranges autorizadas pelo Hub ##--
function Main()
frmHub:RegBot(sBot)
end
function NewUserConnected(user)
if (excepcoes[user.sName] == nil) and (isGoodIP(user.sIP) == nil) then
user:SendData(sBot, "Your IP is not allowed in this HUB. O teu ip n?o ? permitido neste Hub. Caso estejas em portugal, envia um email para [EMAIL]rui-mag@netcabo.pt[/EMAIL] ou vai ao syte [URL]http://gigashare.kazorum.com[/URL] e explica a situa??o")
user:SendData("$ForceMove portugal-music.sytes.net:6969")
user:Disconnect()
end
end
OpConnected = NewUserConnected
function isGoodIP(sIP)
sIP = ipToNumber(sIP)
local iFirst,iLast
for iFirst, iLast in arrIP do
if (sIP >= ipToNumber(iFirst) and sIP <= ipToNumber(iLast)) then
return 1
end
end
return nil
end
function ipToNumber(sIP)
iAux = ""
string.gsub(sIP,"(%d+)", function(w)
w = tonumber(w)
if (w < 10) then
iAux = iAux.."00"..w
elseif (w < 100) then
iAux = iAux.."0"..w
else
iAux = iAux..w
end
end)
return tonumber(iAux)
end
QuoteOriginally posted by uffetjur
Its something with those IP's that isnt correct ...
And that could be the reason for hes ask / else he did a mistake
Ips always comes in series XXX.XXX.XXX.XXX - No /XX after
Know i'm a little late.
Well he did not mistake, he wants to ban alle thease ranges. And the /xx i quite normal. And called classless inter domain Routing. also known as supernetting.
xxx.xxx.xxx.xxx/n
where n is the number of (leftmost) '1' bits in the mask.
And the range size can be counted with the formula:
127.0.0.0/x 's range size:
2^(32-x) IPs
127.0.0.0/26=2^6=64 IPs (class C range)
QuoteOriginally posted by bastya_elvtars
And the range size can be counted with the formula:
127.0.0.0/x 's range size:
2^(32-x) IPs
127.0.0.0/26=2^6=64 IPs (class C range)
He's gonna need more then that..
But google is a friend.
take a look here
http://jodies.de/ipcalc (http://jodies.de/ipcalc)
This should explain how to do it,
well one could workaround the lak of binaryfunctions
in LUA i suppose, but if then one would end up, calculating
much more than one needs to.
So I think sticking to x.x.x.x-x.x.x.x in LUA is the best way, other than that, I think one can also implement c into LUA, then the scene would look different, but not sure
QuoteOriginally posted by Mogli
take a look here
http://jodies.de/ipcalc (http://jodies.de/ipcalc)
This should explain how to do it,
well one could workaround the lak of binaryfunctions
in LUA i suppose, but if then one would end up, calculating
much more than one needs to.
So I think sticking to x.x.x.x-x.x.x.x in LUA is the best way, other than that, I think one can also implement c into LUA, then the scene would look different, but not sure
Lak of binary functions? Wich functions do you need for this wich can not be found in the PxBITWISE lua extension? The bitwise functions is there so you actually can do "calculations" with less cpu instructions.
[irony]And sticking to x.x.x.x-x.x.x.x will be good because parseing, compareing strings and such takes less instructions[/irony] <- Sorry but i don't think so
well for one reason ip-ip is faster cause you may use binary search, there are patriciaTrees but i assume that
they become quite big with many ranges, and the lookup will slow down, so if you bluebear, want to do a speed test with all the IP bots alive you also get to the point that its the fastest. Guess Vidfamne would agree here.
Well okey with binary functions its simple, just follow the exsample of the site ;)
btw could you post that binary module, so I can play around a bit with it, since there are quite many functions that come in handy when beeing able to calc in binary.
It's here (http://www.thewildplace.dk/site/download.php?view.12).
Working with ips in strings will never be faster then converting them to integral values and work with them.
And the bitwise lib is released. I announced it in
LUA & PtokaX-Scripting-Interface (http://board.univ-angers.fr/board.php?boardid=5&sid=621306731bb995624a76b34bcfacf21e).
It provedes Xor, Or, And, LeftShift and RightShift.
Bottom line is if you have a ip in dotted notation (a string like 192.168.1.1) it would be upto 120 bits long.
If you converted it into a integral value wich only would be 32 bits for ip v4. So it do not take a genius to see that this way is much faster, particularly when most cpu's out there are 32 bit processors.
QuoteOriginally posted by bluebear
Working with ips in strings will never be faster then converting them to integral values and work with them.
And the bitwise lib is released. I announced it in
LUA & PtokaX-Scripting-Interface (http://board.univ-angers.fr/board.php?boardid=5&sid=621306731bb995624a76b34bcfacf21e).
It provedes Xor, Or, And, LeftShift and RightShift.
Bottom line is if you have a ip in dotted notation (a string like 192.168.1.1) it would be upto 120 bits long.
If you converted it into a integral value wich only would be 32 bits for ip v4. So it do not take a genius to see that this way is much faster, particularly when most cpu's out there are 32 bit processors.
he could have used the search option and would have found a topic about this proving that the string way is the slowest.
plop
About to use string or not.
I think that it doesn't really matter if you would
sort a IPRange by converting them to sortable strings
e.g. 001.005.004.567 and sort them or
if you compute them into a integer value,
since it is the lookupmethod that is so much faster
with binarysearch, of course best is to use both.
working fine bluebear, although I had work around
the MSB making all numbers Negative, but I suppose
if I'd rewrite the decompute to bitwise, (maybe I'll do that later ), I could do without that too.
if someones interested how I did it
libinit = loadlib("pxbitwise.dll", "_libinit")
libinit()
function Main()
SendToAll( BitWise.Version() )
tlook = {}
tlook[0] = 0
i2 = 0
for i = 31,0,-1 do
i2 = i2 + 1
tlook[i2] = tlook[i2-1] + 2^i
--SendToAll( i2, tlook[i2] )
end
siP = "129.168.0.64"
iNet = 26
SendToAll( "IP", siP.." / "..iNet )
local iIP = computeIP( siP )
local NetMask = tlook[iNet]
SendToAll( "Netmask",decomputeIP( NetMask ) )
local Wildcard = BitWise.Xor(NetMask, tlook[32])
SendToAll( "Wildcrad",decomputeIP( Wildcard ) )
local Network = BitWise.And( iIP, NetMask)
if Network < 0 then
--SendToAll( BitWise.lShift32( 1, 31 ) )
Network = BitWise.Xor( Network, -2147483648 ) + 2^31
end
SendToAll( "Network", decomputeIP( Network ).." / "..iNet )
local Broadcast = Network + Wildcard
SendToAll( "Boeadcast", decomputeIP( Broadcast ) )
local Min = Network+1
local Max = Broadcast - 1
SendToAll( "Min", decomputeIP( Min ) )
SendToAll( "Max", decomputeIP( Max ) )
end
--// Compute IP
function computeIP( sIP )
local _,_,a,b,c,d = string.find( sIP, "^(%d+)%.(%d+)%.(%d+)%.(%d+)$")
return a*256^3 + b*256^2 + c*256 + d
end
--// IPBot:DeCompute IP
function decomputeIP( iIP )
local temp1 = math.mod( iIP, 16777216 )
local temp2 = math.mod( temp1, 65536 )
return ( math.floor( iIP/16777216).."."..math.floor(temp1/65536).."."..math.floor(temp2/256).."."..math.floor( math.mod(temp2,256)))
end
Here is how I usually do it... some ideas from Herodes:
function CalcIP(ip)
local err
local c,decip=1,0
for bit in string.gfind(ip,"(%d+)") do
if not tonumber(bit) or tonumber(bit) > 255 then
err=true
break
else
decip=decip+(tonumber(bit)*c)
c=c*256
end
end
if not err then
return decip
end
end
function ReCalcIP(ip)
local tmp
pt1=math.floor((ip)/16777216)
tmp=math.mod((ip),16777216)
pt2=math.floor((tmp)/65536)
tmp=math.mod(tmp,65536)
pt3=math.floor((tmp)/256)
pt4=math.mod(tmp,256)
return (pt4.."."..pt3.."."..pt2.."."..pt1)
end
BTW nice to see that somebody is actually using math.mod :)
This is little over my head, but I can only say that GeoIP-
script working with mumbers, in the binary search-function.
Not strings.
Please inform me if it matters, or am I wrong?
QuoteOriginally posted by VidFamne
This is little over my head, but I can only say that GeoIP-
script working with mumbers, in the binary search-function.
Not strings.
Please inform me if it matters, or am I wrong?
The research will only start tomorrow, first I will create my own concept then do comparisons.
VidFamne that was what I wanted to say that the binary search is so much faster,
that is actually would not matter how to sort the IP's by
string or number you would still be faster than a linear search.
But as said best is using both, also the IP-Bots I use
convert ip'S to numbers, but the code from the last post
is just to convert CIDR Ranges into normal ranges.
If you're still concerned with CIDRs, give those a shot..
--// ----------------------------------------------------------
--// IP to Decimal computing
IP_toDECIMAL = function(sIP)
if sIP then
if IP_isIP(sIP) then
local _,_,a,b,c,d = string.find(sIP, "^(%d+)%.(%d+)%.(%d+)%.(%d+)$")
return a*16777216 + b*65536 + c*256 + d
end
end
end
--// ----------------------------------------------------------
--// Decimal to IP computing
IP_fromDECIMAL = function(iIP)
if iIP then
local temp1 = math.mod(iIP, 16777216)
local temp2 = math.mod(temp1, 65536)
return (math.floor(iIP/16777216).."."..math.floor(temp1/65536).."."..math.floor(temp2/256).."."..math.floor( math.mod(temp2,256)))
end
end
--// ----------------------------------------------------------
--// Is a string an IP address?, by GeceBekcisi
IP_isIP = function(sIP)
if sIP then
local _,_,a,b,c,d = string.find(sIP, "^(%d+)%.(%d+)%.(%d+)%.(%d+)$")
if a and b and c and d then
if 256 > tonumber(a) and 256 > tonumber(b) and 256 > tonumber(c) and 256 > tonumber(d) then
return 1
end
end
end
end
--// ----------------------------------------------------------
--// General IP Correction (like 127.0.0.01 to 127.0.0.1), by GeceBekcisi
IP_Correction = function(sIP)
if sIP then
local _,_,a,b,c,d = string.find(sIP, "^(%d+)%.(%d+)%.(%d+)%.(%d+)$")
if a and b and c and d then
if a ~= tonumber(a) or b ~= tonumber(b) or c ~= tonumber(c) or d ~= tonumber(d) then
sIP = tonumber(a).."."..tonumber(b).."."..tonumber(c).."."..tonumber(d)
end
return sIP
end
end
end
--// ----------------------------------------------------------
--// Is a string a CIDR (Classless Internet Domain Routing)?, by GeceBekcisi
CIDR_isCIDR = function(sCIDR)
if sCIDR then
local _,_,a,b,c,d,CIDRPrefix = string.find(sCIDR, "^(%d+)%.(%d+)%.(%d+)%.(%d+)/(%d+)$")
if a and b and c and d and CIDRPrefix then
if 32 > tonumber(CIDRPrefix) and tonumber(CIDRPrefix) > 0 then
return 1
end
end
end
end
--// ----------------------------------------------------------
--// General CIDR Correction (like 127.000.0.01/0021 to 127.0.0.1/21), by GeceBekcisi
CIDR_Correction = function(sCIDR)
if sCIDR then
local _,_,a,b,c,d,CIDRPrefix = string.find(sCIDR, "^(%d+)%.(%d+)%.(%d+)%.(%d+)/(%d+)$")
if a and b and c and d and CIDRPrefix then
local sCorrCIDR = sCIDR
if a ~= tonumber(a) or b ~= tonumber(b) or c ~= tonumber(c) or d ~= tonumber(d) or CIDRPrefix ~= tonumber(CIDRPrefix) then
sCorrCIDR = tonumber(a).."."..tonumber(b).."."..tonumber(c).."."..tonumber(d).."/"..tonumber(CIDRPrefix)
end
return sCorrCIDR
end
end
end
--// ----------------------------------------------------------
--// CIDR (Classless Internet Domain Routing) to IP Range computing, by GeceBekcisi
CIDR_toRANGE = function(sCIDR)
if sCIDR then
local _,_,a,b,c,d,CIDRPrefix = string.find(sCIDR, "^(%d+)%.(%d+)%.(%d+)%.(%d+)/(%d+)$")
if a and b and c and d and CIDRPrefix then
CIDRPrefix = tonumber(CIDRPrefix)
if CIDRPrefix ~= 0 or CIDRPrefix ~= 32 then
local PoolSize = 2^(8-(math.mod(CIDRPrefix,8)))
if math.floor(CIDRPrefix/8) == 3 then
return IP_Correction(IP_fromDECIMAL(IP_toDECIMAL(a.."."..b.."."..c..".0")+(math.floor(d/PoolSize)*PoolSize))),IP_Correction(IP_fromDECIMAL(IP_toDECIMAL(a.."."..b.."."..c..".0")+(math.floor(d/PoolSize)*PoolSize)+PoolSize-1))
elseif math.floor(CIDRPrefix/8) == 2 then
local _,_,g,h,i,j = string.find(IP_fromDECIMAL(IP_toDECIMAL(a.."."..b..".0.0")+(math.floor(c/PoolSize)*PoolSize)), "^(%d+)%.(%d+)%.(%d+)%.(%d+)$")
local _,_,k,l,m,n = string.find(IP_fromDECIMAL(IP_toDECIMAL(a.."."..b..".0.0")+(math.floor(c/PoolSize)*PoolSize)+PoolSize-1), "^(%d+)%.(%d+)%.(%d+)%.(%d+)$")
return IP_Correction(g.."."..h.."."..j..".0"),IP_Correction(k.."."..l.."."..n..".255")
elseif math.floor(CIDRPrefix/8) == 1 then
local _,_,g,h,i,j = string.find(IP_fromDECIMAL(IP_toDECIMAL(a..".0.0.0")+(math.floor(b/PoolSize)*PoolSize)), "^(%d+)%.(%d+)%.(%d+)%.(%d+)$")
local _,_,k,l,m,n = string.find(IP_fromDECIMAL(IP_toDECIMAL(a..".0.0.0")+(math.floor(b/PoolSize)*PoolSize)+PoolSize-1), "^(%d+)%.(%d+)%.(%d+)%.(%d+)$")
return IP_Correction(g.."."..j..".0.0"),IP_Correction(k.."."..n..".255.255")
elseif math.floor(CIDRPrefix/8) == 0 then
local _,_,g,h,i,j = string.find(IP_fromDECIMAL(IP_toDECIMAL("0.0.0.0")+(math.floor(a/PoolSize)*PoolSize)), "^(%d+)%.(%d+)%.(%d+)%.(%d+)$")
local _,_,k,l,m,n = string.find(IP_fromDECIMAL(IP_toDECIMAL("0.0.0.0")+(math.floor(a/PoolSize)*PoolSize)+PoolSize-1), "^(%d+)%.(%d+)%.(%d+)%.(%d+)$")
return IP_Correction(j..".0.0.0"),IP_Correction(n..".255.255.255")
end
end
end
end
end
--// ----------------------------------------------------------
--// CIDR (Classless Internet Domain Routing) to IP Range computing, by GeceBekcisi
CIDR_fromRANGE = function(sIP1,sIP2)
if sIP1 and sIP2 then
sIP1 = IP_Correction(sIP1)
sIP2 = IP_Correction(sIP2)
for i=0,32 do
if 2^i > (IP_toDECIMAL(sIP2)-IP_toDECIMAL(sIP1)) then
local sCIDR = sIP1.."/"..(32-i)
local TempIP1,TempIP2 = CIDR_toRANGE(sCIDR)
if IP_toDECIMAL(TempIP1) <= IP_toDECIMAL(sIP1) and IP_toDECIMAL(TempIP2) >= IP_toDECIMAL(sIP2) then
return sCIDR
end
end
end
end
end
--// ----------------------------------------------------------
Hi,
This on converts CIDR to Range IP, decimal and binary. Sort table by Isp.
Use on CIDR file:
xxx.xxx.xxx.xxx/xx # Isp
--### Variables ----------------------------------------------------------------------------------------------------
fFinal="IPs.txt" -- Final file with Range IP
fDecimal = "IPsDec.txt" -- Final file with decimal IP
fBinario = "IPsBin.txt" -- Final file with binary IP
file="ipranges.txt" -- File with CIDR ranges
--[[
Must be:
xxx.xxx.xxx.xxx/xx # ISP
Please, don't forget your ISP. Table will be sort by ISP
]]--
tRanges={}
tRangesDEC={}
tRangesBIN={}
--### Functions ------------------------------------------------------------------------------------------------------
function IpToDec(op1, op2, op3, op4, CIDR)
decstart = op1 * (256^3) + op2 * (256^2) + op3 * 256 + op4
decend = decstart + (2^(32 - CIDR)) - 1
end
function DecToIp(decend)
ipad1 = math.floor(decend / (256^3))
ipad2 = math.floor((decend - (ipad1 * (256^3)))/(256^2))
ipad3 = math.floor((decend - (ipad1*(256^3) + ipad2*(256^2)))/256)
ipad4 = math.floor((decend - (ipad1*(256^3) + ipad2*(256^2) + ipad3 * 256)))
end
function DecToBin(decstart)
d = decstart
local bin_s = ""
while (d > 1) do
a = math.floor(d/2)
b = (d/2)-a
if ( b > 0) then
bin_s = "1"..bin_s
else
bin_s = "0"..bin_s
end
d = a
end
bin_s = "1"..bin_s
return bin_s
end
function SaveToFile(file, tablename, tablename1)
local handle = io.open(file,"w+")
handle:write(tablename1.." = {\n")
for Isps in tablename do
local Isps1 = (type(Isps) == "string") and string.format("%q",Isps) or tostring(Isps);
handle:write("\t["..Isps1.."] = {\n")
for First, Last in tablename[Isps] do
handle:write("\t\t["..First.."] = "..Last..",\n")
end
handle:write("\t},\n")
end
handle:write("}")
handle:flush()
handle:close()
end
--### Read you IP-CIDR file ---------------------------------------------------------------------------------
for line in io.lines(file) do
_,_,op1,op2,op3,op4,CIDR,Isp=string.find(line,"(%d+).(%d+).(%d+).(%d+)/(%d+)%s+#%s+(.+)")
IpToDec(op1, op2, op3, op4, CIDR)
DecToIp(decend)
bins = DecToBin(decstart)
binf = DecToBin(decend)
if tRanges[Isp] == nil then
tRanges[Isp] = {}
tRanges[Isp][op1.."."..op2.."."..op3.."."..op4] = ipad1.."."..ipad2.."."..ipad3.."."..ipad4
else
tRanges[Isp][op1.."."..op2.."."..op3.."."..op4] = ipad1.."."..ipad2.."."..ipad3.."."..ipad4
end
if tRangesDEC[Isp] == nil then
tRangesDEC[Isp] = {}
tRangesDEC[Isp][decstart] = decend
else
tRangesDEC[Isp][decstart] = decend
end
if tRangesBIN[Isp] == nil then
tRangesBIN[Isp] = {}
tRangesBIN[Isp][bins] = binf
else
tRangesBIN[Isp][bins] = binf
end
end
--### Save Files -------------------------------------------------------------------------------------------
if loadfile(fFinal) then dofile(fFinal) end
SaveToFile(fFinal , tRanges , "tRanges")
if loadfile(fDecimal) then dofile(fDecimal) end
SaveToFile(fDecimal, tRangesDEC, "tRangesDEC")
if loadfile(fBinario) then dofile(fBinario) end
SaveToFile(fBinario, tRangesBIN, "tRangesBIN")
Regards,
zero-cool you'd check this thread (http://forum.ptokax.org/index.php?topic=5972.0) since your code has the same issue
Quote from: GeceBekcisi on 09 June, 2006, 12:13:21
zero-cool you'd check this thread (http://forum.ptokax.org/index.php?topic=5972.0) since your code has the same issue
Thanks ! ;) ;)
GeceBekcisi your script doesn't have rightclick suport ? :(
Well, it's not an end-user code, it's a part of one of my bot's and posted here for development purposes.