Author Topic: IP range from $MyINFO  (Read 5633 times)

0 Members and 1 Guest are viewing this topic.

Offline enema

  • Lord
  • ***
  • Posts: 276
  • Karma: +1/-0
IP range from $MyINFO
« on: 20 December, 2004, 07:48:11 »
Hello!

How can I get (and is it possible?) IP range from $MyInfo? How will it look in script?

For example, If I want to get users mode from his $MyInfo, it would look like this:
Code: [Select]
function DataArrival(user,data)
if strsub(data, 1, 7) == "$MyINFO" then
if strfind(data,"M:P") then

I need it to look somehow like this:
Code: [Select]
function DataArrival(user,data)
if strsub(data, 1, 7) == "$MyINFO" then
if strfind(data,"[B]IPrange:61.22, 81.198, 195.95[/B] ") then
8)  mitava.no-ip.org   8)

PtokaX forum

IP range from $MyINFO
« on: 20 December, 2004, 07:48:11 »

Offline blackwings

  • Scripter
  • King
  • ******
  • Posts: 986
  • Karma: +12/-8
(No subject)
« Reply #1 on: 20 December, 2004, 09:27:41 »
that isn't possible I think. I think you need to check what I a User has and compair in with a range in a table.


Offline enema

  • Lord
  • ***
  • Posts: 276
  • Karma: +1/-0
(No subject)
« Reply #2 on: 20 December, 2004, 09:41:43 »
how about $ConnectToMe then? Can I rip somehow those  IP ranges out from $ConnectToMe??
8)  mitava.no-ip.org   8)

[NL]Pur

  • Guest
(No subject)
« Reply #3 on: 20 December, 2004, 09:52:05 »
The $MyINFO string doesn't contain any IP

Offline blackwings

  • Scripter
  • King
  • ******
  • Posts: 986
  • Karma: +12/-8
(No subject)
« Reply #4 on: 20 December, 2004, 10:24:40 »
Quote
Originally posted by [NL]Pur
The $MyINFO string doesn't contain any IP
ya, that was what I thought too, so enema, you need a script that check like user.sIP and compairs it with a ip range in a table. Take a existing IP blocker and modify it to your need.


Offline enema

  • Lord
  • ***
  • Posts: 276
  • Karma: +1/-0
(No subject)
« Reply #5 on: 20 December, 2004, 10:57:46 »
**offtopic

which string contains users IP?

**ontopic
8)  mitava.no-ip.org   8)

Offline blackwings

  • Scripter
  • King
  • ******
  • Posts: 986
  • Karma: +12/-8
(No subject)
« Reply #6 on: 20 December, 2004, 11:00:11 »
Quote
Originally posted by enema
**offtopic

which string contains users IP?

**ontopic
you can see users IP with "user.sIP", which isn't a string, more like a variable.
« Last Edit: 20 December, 2004, 11:02:11 by blackwings »


Offline enema

  • Lord
  • ***
  • Posts: 276
  • Karma: +1/-0
(No subject)
« Reply #7 on: 20 December, 2004, 11:08:59 »
Ok, heres what I came up with:

Code: [Select]
RC_MinShare = "10 GB"
-------------------------------------------------
sUnit = {}
sUnit["KB"]= 1024
sUnit["MB"]= 1048576
sUnit["GB"]= 1073741824
sUnit["TB"]= 1099511627776

tRanges = {
["81.198.(%d*).(%d*)"]=1
}

function Main()
   if tonumber(RC_MinShare) == nil then s,e,num,cur = strfind(RC_MinShare, "(%d+)%s+(%S+)") RC_MinShare = num * sUnit[cur] end
end

function DataArrival(user,data)
if tRanges[user.sIP] == tRanges[user.sIP] + 1 then
local _,_,share = strfind(data, "(%d+)%$%|$")
if tonumber(share) < tonumber(RC_MinShare / 5) then
user:SendData(" You do not meet the minimum share for passive users. You are being disconnected.")
user:Disconnect()
return 1
end
end
end

As you can see, It is totally in mess.. gives me this error: Syntax Error: attempt to perform arithmetic on a nil value

Im stuck... HELP!
8)  mitava.no-ip.org   8)

Offline blackwings

  • Scripter
  • King
  • ******
  • Posts: 986
  • Karma: +12/-8
(No subject)
« Reply #8 on: 20 December, 2004, 11:24:19 »
no line number in the error message :P Anyway I think its the line in Main() it complains about.
I 'm a newbie in lua, so I can't really tell you how to fix it :P
« Last Edit: 20 December, 2004, 11:24:34 by blackwings »


Offline enema

  • Lord
  • ***
  • Posts: 276
  • Karma: +1/-0
(No subject)
« Reply #9 on: 20 December, 2004, 11:47:17 »
Quote
Originally posted by blackwings
no line number in the error message :P Anyway I think its the line in Main() it complains about.
I 'm a newbie in lua, so I can't really tell you how to fix it :P

hmm... the Main() line should be ok... I took it from difrient script where it worked fine...
8)  mitava.no-ip.org   8)

Offline enema

  • Lord
  • ***
  • Posts: 276
  • Karma: +1/-0
(No subject)
« Reply #10 on: 22 December, 2004, 18:52:45 »
cmon guys, please help me! Im stuck!  PX says: No syntax errors in script file.... BUT IT DOESNT WORK! :'(

This is how far I am:

Code: [Select]
RC_MinShare = "10 GB"
-------------------------------------------------
sUnit = {}
sUnit["KB"]= 1024
sUnit["MB"]= 1048576
sUnit["GB"]= 1073741824
sUnit["TB"]= 1099511627776

tRanges = {
["62.84.(%d*).(%d*)"] = 1
}

bot = "share_man"

function Main()
   if tonumber(RC_MinShare) == nil then s,e,num,cur = strfind(RC_MinShare, "(%d+)%s+(%S+)") RC_MinShare = num * sUnit[cur] end
end

function DataArrival(user,data)
if tRanges[user.sIP] then
local _,_,share = strfind(data, "(%d+)%$%|$")
if tonumber(share) < tonumber(RC_MinShare / 2) then
user:SendData(bot, "You do not meet the minimum share for passive users. You are being disconnected.")
user:Disconnect()
return 1
end
end
end

Can u find my mistake?
8)  mitava.no-ip.org   8)

Offline Madman

  • Scripter
  • Emperor
  • ******
  • Posts: 1 316
  • Karma: +75/-1
(No subject)
« Reply #11 on: 22 December, 2004, 20:18:04 »
The Problem is in the
Code: [Select]
tRanges = {
["62.84.(%d*).(%d*)"] = 1,
["192.168.0.2"] = 1,
}

I added My Lan IP and that works...
So, the problem is this (%d*).(%d*)
but i dont know how to fix that...
I'm not that good...
I added some lines, beacuse i got syntax error without them...

Code: [Select]
RC_MinShare = "10 GB"
-------------------------------------------------
sUnit = {}
sUnit["KB"]= 1024
sUnit["MB"]= 1048576
sUnit["GB"]= 1073741824
sUnit["TB"]= 1099511627776

tRanges = {
["62.84.(%d*).(%d*)"] = 1,
["192.168.0.2"] = 1,
}

bot = "share_man"

function Main()
if tonumber(RC_MinShare) == nil then s,e,num,cur = strfind(RC_MinShare, "(%d+)%s+(%S+)") RC_MinShare = num * sUnit[cur] end
end

function DataArrival(user,data)
if tRanges[user.sIP]==1 then
if strsub(data, 1, 7) == "$MyINFO" then
if strfind(data,"M:P") then
local _,_,share = strfind(data, "(%d+)%$%|$")
if tonumber(share) < tonumber(RC_MinShare) then
user:SendData(bot, "You do not meet the minimum share for passive users. You are being disconnected.")
user:Disconnect()
return 1
end
end
end
end
end
We suffer in silence, we lurk in the shadows, we kill in the night
Site currently down, ETA of returning online is 2099 ;p

Offline enema

  • Lord
  • ***
  • Posts: 276
  • Karma: +1/-0
(No subject)
« Reply #12 on: 23 December, 2004, 09:43:09 »
still doesnt give any errors and still doesnt work... im starting to feel depresed :(

Code: [Select]
--- Script Base is taken from NightLitch share bot and Ipbot lua script by aMutex
-------------------------------------------------
Scripted_share = "10 GB"
-------------------------------------------------
sUnit = {}
sUnit["KB"]= 1024
sUnit["MB"]= 1048576
sUnit["GB"]= 1073741824
sUnit["TB"]= 1099511627776

bot = "share_man"



oAllow={}
function splittip(IP)
r,g,a,b,c,d = strfind(IP, "(%d*).(%d*).(%d*).(%d*)")
d=a.."."..b.."."..c.."."..d
c=a.."."..b.."."..c..".*"
b=a.."."..b..".*"
a=a..".*"
return a,b,c,d
end

function Main()
oAllow["127.*"]=1
oAllow["81.198.*"]=1
oAllow["62.84.16.*"]=1

if tonumber(Scripted_share) == nil then s,e,num,cur = strfind(Scripted_share, "(%d+)%s+(%S+)") Scripted_share = num * sUnit[cur]
end
end

function NewUserConnected(curUser)
theIP=curUser.sIP
local a,b,c,d=splittip(theIP)
if ((oAllow[a]==1)or(oAllow[b]==1)or(oAllow[c]==1)or(oAllow[d]==1)) then

local _,_,share = strfind(data, "(%d+)%$%|$")
if tonumber(share) < tonumber(Scripted_share / 2) then
user:SendData(bot, "You do not meet the minimum share for your IP range.")
user:Disconnect()
return 1
end
end
end
 
whats wrong with it???
« Last Edit: 23 December, 2004, 09:44:52 by enema »
8)  mitava.no-ip.org   8)

Offline enema

  • Lord
  • ***
  • Posts: 276
  • Karma: +1/-0
(No subject)
« Reply #13 on: 26 December, 2004, 14:40:36 »
ok, changed few things, but now I recieve this error: Syntax Error: bad argument #1 to `strfind' (string expected, got nil)

here goes script:

Code: [Select]
--- Script Base is taken from NightLitch share bot and Ipbot lua script by aMutex
-------------------------------------------------
sharex = "5 GB"
-------------------------------------------------
sUnit = {}
sUnit["KB"]= 1024
sUnit["MB"]= 1048576
sUnit["GB"]= 1073741824
sUnit["TB"]= 1099511627776

bot = "shareman"

oAllow={}
function splittip(IP)
r,g,a,b,c,d = strfind(IP, "(%d*).(%d*).(%d*).(%d*)")
d=a.."."..b.."."..c.."."..d
c=a.."."..b.."."..c..".*"
b=a.."."..b..".*"
a=a..".*"
return a,b,c,d
end

function Main()
oAllow["127.*"]=1
oAllow["81.198.*"]=1
oAllow["62.84.16.*"]=1

if tonumber(sharex) == nil then s,e,num,cur = strfind(sharex, "(%d+)%s+(%S+)") sharex = num * sUnit[cur]
end
end

function NewUserConnected(curUser)
theIP=curUser.sIP
local a,b,c,d=splittip(theIP)
if ((oAllow[a]==1)or(oAllow==1)or(oAllow[c]==1)or(oAllow[d]==1)) then

local _,_,share = strfind(data, "(%d+)%$%|$")
if tonumber(share) < tonumber(sharex * 2) then
user:SendData(bot, "You do not meet the minimum share for your IP range.")
user:Disconnect()
return 1
end
end
end

Plz help me! I know you guys can!  this one is very important to me!

To Moderators:  It would be nice, If you could change the name of this thread from "IP range from $Myinfo" to "Certain IP ranges has difrient min share" since we're not talking about any $MyInfos anymore
« Last Edit: 26 December, 2004, 14:45:06 by enema »
8)  mitava.no-ip.org   8)

Herodes

  • Guest
(No subject)
« Reply #14 on: 26 December, 2004, 17:34:01 »
Code: [Select]
function NewUserConnected(curUser)
theIP=curUser.sIP
local a,b,c,d=splittip(theIP)
if ((oAllow[a]==1)or(oAllow==1)or(oAllow[c]==1)or(oAllow[d]==1)) then

local _,_,share = strfind([b]data[/b], "(%d+)%$%|$")
if tonumber(share) < tonumber(sharex * 2) then
the "data" of the strfind is not defined or provided anywhere ...
maybe try it with "user.sMyInfoString"

Offline enema

  • Lord
  • ***
  • Posts: 276
  • Karma: +1/-0
(No subject)
« Reply #15 on: 26 December, 2004, 18:41:24 »
I start to think, that I dont need this line at all:
Code: [Select]
local _,_,share = strfind(data, "(%d+)%$%|$")Correct me if im wrong!!!

If I remove it I recieve this error - Syntax Error: attempt to compare nil with number

I recieve it very offten, when I try to build this script and in situations, where I think it should work but it doesnt...
I think problem is in this line:
Code: [Select]
if tonumber(sharex) == nil then s,e,num,cur = strfind(sharex, "(%d+)%s+(%S+)") sharex = num * sUnit[cur]
If so, im unable to find solution =(
8)  mitava.no-ip.org   8)

Herodes

  • Guest
(No subject)
« Reply #16 on: 26 December, 2004, 22:14:47 »
Code: [Select]
--- Script Base is taken from NightLitch share bot and Ipbot lua script by aMutex
-------------------------------------------------
sharex = "5 GB"
-------------------------------------------------
sUnit = {
["KB"]= 1024,
["MB"]= 1024^2,
["GB"]= 1024^3,
["TB"]= 1024^4,
}

bot = "shareman"

oAllow={}

function splittip(IP)
r,g,a,b,c,d = strfind(IP, "(%d*).(%d*).(%d*).(%d*)")
d=a.."."..b.."."..c.."."..d
c=a.."."..b.."."..c..".*"
b=a.."."..b..".*"
a=a..".*"
return a,b,c,d
end

function Main()
oAllow["127.*"]=1
oAllow["81.198.*"]=1
oAllow["62.84.16.*"]=1
if tonumber(sharex) == nil then
s,e,num,cur = strfind(sharex, "(%d+)%s+(%S+)")
sharex = num * sUnit[cur]
end
end

function NewUserConnected(curUser)
--- theIP=curUser.sIP --- removed this variable It is totally uneccessary.
local a,b,c,d=splittip(curUser.sIP)
if ( (oAllow[a]==1) or (oAllow==1) or (oAllow[c]==1) or (oAllow[d]==1) ) then
local _,_,share = strfind(curUser.sMyInfoString, "(%d+)%$%|$")      --- changed "data" with curUser.sMyInfoString ...
if tonumber(share) < (sharex * 2) then --- removed the "tonumber(sharex * 2)" on this line .. it is a number already ;)
user:SendData(bot, "You do not meet the minimum share for your IP range.")
user:Disconnect()
return 1
end
end
end
try this .. watch the comments and compare to what u have ..

Offline enema

  • Lord
  • ***
  • Posts: 276
  • Karma: +1/-0
(No subject)
« Reply #17 on: 27 December, 2004, 08:46:09 »
same problem:

Syntax Error: attempt to compare nil with number

I recieve it when user with "62.84.16" IP range connects.

I guess, the problem is here:
Code: [Select]
if tonumber(sharex) == nil then
s,e,num,cur = strfind(sharex, "(%d+)%s+(%S+)")
sharex = num * sUnit[cur]
end

and here:
Code: [Select]
local _,_,share = strfind(user.sMyInfoString, "(%d+)%$%|$")
if tonumber(share) < (sharex * 2) then

How can I solve this and where is the mistake?
« Last Edit: 28 December, 2004, 09:43:51 by enema »
8)  mitava.no-ip.org   8)

Offline enema

  • Lord
  • ***
  • Posts: 276
  • Karma: +1/-0
(No subject)
« Reply #18 on: 29 December, 2004, 08:54:33 »
A little bit more simplified version... Still doesnt work... All functions are taken from scripts, that work. That means I have made a mistake somewhere while putting them together

gives me this Syntax Error: attempt to compare string with number
Code: [Select]
--- Script Base is taken from Ipbot lua script by aMutex

Bot = "shareman"

oAllow={}

function splittip(IP)
r,g,a,b,c,d = strfind(IP, "(%d*).(%d*).(%d*).(%d*)")
d=a.."."..b.."."..c.."."..d
c=a.."."..b.."."..c..".*"
b=a.."."..b..".*"
a=a..".*"
return a,b,c,d
end

function Main()
frmHub:RegBot(Bot)
oAllow["127.*"]=1
oAllow["130.239.103.*"]=1
oAllow["212.217.193.*"]=1
end

function NewUserConnected(curUser)
local s,e,share = strfind(curUser.sMyInfoString, "%$%s*(%d+)%$")
share = format("%0.2f", tonumber(share)/(1024*1024*1024))
local a,b,c,d=splittip(curUser.sIP)
if ((oAllow[a]==1)or(oAllow[b]==1)or(oAllow[c]==1)or(oAllow[d]==1)) then
else
if (share < 10) then
curUser:SendData(Bot, "You do not meet the minimum share for your IP range.")
curUser:Disconnect()
return 1
end
end
end
8)  mitava.no-ip.org   8)

Herodes

  • Guest
(No subject)
« Reply #19 on: 29 December, 2004, 15:30:18 »
Code: [Select]
function NewUserConnected(curUser)
local s,e,share = strfind(curUser.sMyInfoString, "%$%s*(%d+)%$")
share = format("%0.2f", tonumber(share)/(1024*1024*1024)) --- this outputs a string
local a,b,c,d=splittip(curUser.sIP)
if ((oAllow[a]==1)or(oAllow[b]==1)or(oAllow[c]==1)or(oAllow[d]==1)) then
else
--- if (share < 10) then --- then you this ... :)
if (tonumber(share) > 10) then-- it is better to do smth like this  
curUser:SendData(Bot, "You do not meet the minimum share for your IP range.")
curUser:Disconnect()
return 1
end
end
end
watch the comments ...

Offline enema

  • Lord
  • ***
  • Posts: 276
  • Karma: +1/-0
(No subject)
« Reply #20 on: 29 December, 2004, 16:32:13 »
YES IT FINNALY WORKS!!!!! Thank you Herodes, you rock!!!

I will put this one in finished scripts section... I guess it is quite usefull!!!!

And thank you again!!!!
8)  mitava.no-ip.org   8)

Herodes

  • Guest
(No subject)
« Reply #21 on: 30 December, 2004, 01:30:30 »
you r welcome

PtokaX forum

(No subject)
« Reply #21 on: 30 December, 2004, 01:30:30 »