IP range from $MyINFO
 

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

IP range from $MyINFO

Started by enema, 20 December, 2004, 07:48:11

Previous topic - Next topic

0 Members and 2 Guests are viewing this topic.

enema

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:
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:
function DataArrival(user,data)
	if strsub(data, 1, 7) == "$MyINFO" then
		if strfind(data,"[B]IPrange:61.22, 81.198, 195.95[/B] ") then

blackwings

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.


enema

how about $ConnectToMe then? Can I rip somehow those  IP ranges out from $ConnectToMe??

[NL]Pur

The $MyINFO string doesn't contain any IP

blackwings

QuoteOriginally 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.


enema

**offtopic

which string contains users IP?

**ontopic

blackwings

#6
QuoteOriginally 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.


enema

Ok, heres what I came up with:

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!

blackwings

#8
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


enema

QuoteOriginally 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...

enema

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:

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?

Madman

The Problem is in the
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...

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

enema

#12
still doesnt give any errors and still doesnt work... im starting to feel depresed :(

--- 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???

enema

#13
ok, changed few things, but now I recieve this error: Syntax Error: bad argument #1 to `strfind' (string expected, got nil)

here goes script:

--- 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

Herodes

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"

enema

I start to think, that I dont need this line at all:
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:
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 =(

Herodes

--- 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 ..

enema

#17
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:
if tonumber(sharex) == nil then 
		s,e,num,cur = strfind(sharex, "(%d+)%s+(%S+)") 
		sharex = num * sUnit[cur]
	end

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

How can I solve this and where is the mistake?

enema

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
--- 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

Herodes

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 ...

enema

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!!!!

Herodes


SMF spam blocked by CleanTalk