Traffic blocking if special reasons
 

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

Traffic blocking if special reasons

Started by ConejoDelMal, 28 April, 2005, 13:52:18

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

ConejoDelMal

hi, i need some help...
i have this script:
sBot = "-=Brainu=-" 

sOpChatName = "-=OpChat=-"


--## Configuration ##-- 

-- Put in this table the Prefixes you want the users to have
 
sPrefix = { "[CV]" , "(CV)" ,}

-- Put in this table the IP-Range or IP you want to be checked for

arrIP = { 
   ["10.6.0.0"] = "10.6.0.30",
   ["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
} 

--## END ##-- 

function Main() 
   frmHub:RegBot(sBot) 
end 

function NewUserConnected(user) 
   if (CheckUserPrefix(user) == nil) and not (isGoodIP(user.sIP) == nil) then 
      user:SendPM(sBot, "Inclui o prefixo [CV] ou (CV) no teu nick, isto porque o Sapo Adsl conta como internacional o trafego de ti")
      user:SendPM(sBot, "Se precisares de ajuda, ou tiveres d?vidas contacta um Operador")
      SendPmToOps(sOpChatName, "O utilizador "..user.sName.." foi requisitado para usar o prefixo [CV]")
   end 
end 

OpConnected = NewUserConnected 

function CheckUserPrefix(user)
	for key,pre in sPrefix do 
	if string.find(string.lower(user.sName), string.lower(pre),1,1) then 
	return 1 
	end 
end 


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 
end

and i want that the users with an ip belonging to that range, and if they dont use the tag [CV] or (CV) get blocked uploads and downloads.... I've been trying, but without success
thx
Rede-DC Comunidade Portuguesa de DC

jiten

Here you go (not tested):
-- modded by jiten

sBot = "-=Brainu=-" 

sOpChatName = "-=OpChat=-"


--## Configuration ##-- 

-- Put in this table the Prefixes you want the users to have
 
sPrefix = { "[CV]" , "(CV)" ,}

-- Put in this table the IP-Range or IP you want to be checked for

arrIP = { 
   ["10.6.0.0"] = "10.6.0.30",
   ["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
}
--## END ##-- 

function Main()
	frmHub:RegBot(sBot) 
end 

function NewUserConnected(user) 
	if (CheckUserPrefix(user) == nil) and not (isGoodIP(user.sIP) == nil) then 
		user:SendPM(sBot, "Inclui o prefixo [CV] ou (CV) no teu nick, isto porque o Sapo Adsl conta como internacional o trafego de ti")
		user:SendPM(sBot, "Se precisares de ajuda, ou tiveres d?vidas contacta um Operador")
		SendPmToOps(sOpChatName, "O utilizador "..user.sName.." foi requisitado para usar o prefixo [CV]")
	end 
end 

OpConnected = NewUserConnected 

function ConnectToMeArrival(user,data)
	if (CheckUserPrefix(user) == nil) and not (isGoodIP(user.sIP) == nil) then 
		user:SendData(sBot, "N?o podes fazer downloads/uploads at? mudares o teu prefixo para [CV] ou (CV)")
		return 1
	end
end

RevConnectToMeArrival = ConnectToMeArrival

function CheckUserPrefix(user)
	for key,pre in sPrefix do 
		if string.find(string.lower(user.sName), string.lower(pre),1,1) then 
			return 1 
		end 
	end 
end

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

Best regards,

jiten

ConejoDelMal

#2
lol....thx a lot jiten, i was already making it complicated, trying to add users to tables..  :D

*edited*
working great, once again, thx a lot!! u rule : :P
Rede-DC Comunidade Portuguesa de DC

jiten


ConejoDelMal

#4
can somebody now help me to make it work in lua 4?
i modded another script, mixtured with this one, but its not blocking the uploads, just the downloads
sBot = "-=Brainu=-" 

sOpChatName = "-=OpChat=-"




--## Configuration ##-- 

-- Put in this table the Prefixes you want the users to have
 
sPrefix = { "[CV]" , "(CV)" ,}

-- Put in this table the IP-Range or IP you want to be checked for

IPS = { 
"CV-84.90.0.0-84.91.255.255",      --  Cabovisao,SA
"CV-213.228.128.0-213.228.191.255",   --  Cabovisao,SA
"CV-217.129.0.0-217.129.255.255",      --  Cabovisao,SA
}

--## END ##-- 

function Main() 
   frmHub:RegBot(sBot) 
   frmHub:EnableFullData(1)
end 

function CheckIP(sIP) 
	local s,e 
	ip = ComputeIP(sIP) 
	for i=1, getn(IPS) do 
	_,_,s,e = strfind(IPS[i], "%S+-(%S+)-(%S+)") 
	s = ComputeIP(s) 
	e = ComputeIP(e) 
	if ip>=s and ip<=e then 
	return i 
	end 
end 
return nil 
end 

function ComputeIP(sIP) 
	local a,b,c,d 
	_,_,a,b,c,d = strfind(sIP, "(%d+).(%d+).(%d+).(%d+)") 
	return a*16777216 + b*65536 + c*256 + d 
end 


function NewUserConnected(user) 
   local i = CheckIP(user.sIP) 
   if not i == nil then 
     if (CheckUserPrefix(user) == nil) then 
      user:SendPM(sBot, " ")
      user:SendPM(sBot, "Inclui o prefixo [CV] ou (CV) no teu nick, ex: [PT][CV]nick, isto porque o Sapo Adsl conta como internacional o tr?fego de ti")
      user:SendPM(sBot, "Por motivos de seguran?a o teu tr?fego est? bloqueado at? fazeres a altera??o. Se precisares de ajuda, ou tiveres d?vidas contacta um Operador")
     end 
   end
end 

OpConnected = NewUserConnected 

function DataArrival(user, data)
	local i = CheckIP(user.sIP) 
	if (CheckUserPrefix(user) == nil) and not i == nil then

		if (strsub(data,1,15) == "$RevConnectToMe") then
		local s,e,to,from = strfind(data, "$RevConnectToMe%s+(%S+)%s+(%S+)")
			if (CheckUserPrefix(user) == nil) and not i == nil then
			user:SendData(sBot, "N?o podes fazer downloads/uploads at? incluires o prefixo [CV] ou (CV) no teu nick")
			return 1
			end
		end
		if (strsub(data,1,12) == "$ConnectToMe") then
		local s,e,from,toip = strfind(data, "$ConnectToMe%s+(%S+)%s+(%d+%.%d+%.%d+%.%d+):")
			if (CheckUserPrefix(user) == nil) and not i == nil then
			user:SendData(sBot, "N?o podes fazer downloads/uploads at? incluires o prefixo [CV] ou (CV) no teu nick")
			return 1
			end
		end
	end
end


function CheckUserPrefix(user)
	for key,pre in sPrefix do 
	if strfind(strlower(user.sName), strlower(pre),1,1) then 
	return 1 
	end 
end
end

*edited*
well...nevermind, not being able to download makes them to change the prefix instantly....though they need to be blocked, lazy people...  :D
Rede-DC Comunidade Portuguesa de DC

SMF spam blocked by CleanTalk