Download Blocker
 

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

Download Blocker

Started by NemeziS, 06 June, 2005, 15:56:27

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

NemeziS

Hi,

I'm writing a script in Lua4 that allows to download for selected ips:

This is the content of my Ranges.txt file:
127.0.0.1|127.0.0.1
10.0.0.0|10.255.255.255
81.211.62.0|81.211.62.255
172.16.0.0|172.31.255.255
192.168.0.0|192.168.255.255
194.154.83.0|194.154.83.255
213.33.170.0|213.33.170.255
213.85.12.0|213.85.12.255
213.85.47.0|213.85.47.255

And here is the script:

--//Some code grabbed from RangeBlaster by Phatty

Ranges = {}

BlockTriggs = {
	["$Rev"] = 1,
	["$Con"] = 2,
}

function Main()
	frmHub:EnableFullData(1)
	LoadIps()
end

function LoadIps()
	local tmp = 0
	local handle = openfile("txt/Ranges.txt","r")
	line = read(handle)
	while line do
		tmp = tmp + 1
		local s,e,ipr1,ipr2 = strfind(line,"(%S+)|(%S+)")
		if ipr2 == nil then
		end
		Ranges[ipr1] = ipr2
	line = read(handle)
	end
end

function Allowed(userip)
	local s,e,range1,range2,range3,range4 = strfind(userip,"(%d+).(%d+).(%d+).(%d+)")
	for i,p in Ranges do
		local s,e,ipa1,ipb1,ipc1,ipd1 = strfind(i, "(%d*).(%d*).(%d*).(%d*)")
		local s,e,ipa2,ipb2,ipc2,ipd2 = strfind(p, "(%d*).(%d*).(%d*).(%d*)")
		if range1 == ipa1 then
			if range1 < ipa1 or range1 > ipa2 then
			else
				if range2 < ipb1 or range2 > ipb2 then
				else
					if range3 < ipc1 or range3 > ipc2 then
					else
						if range4 < ipd1 or range4 > ipd2 then
						else
							collectgarbage()
							flush()
							return 1
						end
					end
				end
			end
		end
	end
end

function DataArrival(user,data)
	if strsub(data,1,1) == "$" then
		local str1 = strsub(data,1,4)
		if BlockTriggs[str1] then
			if BlockTriggs[str1] == 1 then
				local _,_,conNick = strfind(data,"(%S+)|$")
				local usr = GetItemByName(conNick)
				if (Allowed(usr.sIP) == nil) then
					return 1
				end
			elseif BlockTriggs[str1] == 2 then
				local _,_,conNick = strfind(strsub(data,14,strlen(data)),"^(%S+)")
				local usr = GetItemByName(conNick)
				if (Allowed(usr.sIP) == nil) then
					return 1
				end
			end
		end
	end
end

I don't know why, but PtokaX 0.330 15.18 debug gives me an error:

Syntax error: attempt to index local `usr' (a nil value)
stack traceback:
   1:  function `DataArrival' at line 77 [file `...iles\UltraFIRE server\scripts\downl_blocker.lua']

HELP ME PLZ!!!  I DON'T UNDERSTAND AN ERROR. X(
--LUA forever! =)

NemeziS

Please help!  :(

Respectfully,
NemeziS
--LUA forever! =)

TTB

try changing
local usr = GetItemByName(conNick)
into
local user = GetItemByName(conNick)

I exually don't know, but try it :)
TTB

(? ?.??.-> Admin @ Surfnet hubs <-.??.???)

NemeziS

#3
It didn't help. Now the script laggggs a lot! It allows to download some times for users who are not in Ranges.txt. Could someone try to write this script himself? Plizzzzzzzzz  :)

It's very important.

Respectfully,
NemeziS
--LUA forever! =)

SMF spam blocked by CleanTalk