PeerGuardian Script !!! Help Help
 

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

PeerGuardian Script !!! Help Help

Started by MetalPriest, 27 May, 2004, 13:30:49

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

MetalPriest

Hello !!

Get some error in this script

------------------------------------------------------------------------
--// a peerguardian script ..
--// by Typhoon?/Ratcom_Typhoon?
--// 09-05-2004
--// idea and code from NXS-4 by NightLitch

---- setup

GuardianCheck = 1
notifyOps = 1

---- setup end

BotName = frmHub:GetHubBotName()

GuardianFile = "peerfolder/Guarding.P2P"

Guard = {}

function Main()
       LoadTable(Guard,GuardianFile)  
end


function NewUserConnected(curUser)
   if GuardianCheck==1 then
      local check,comp = BlockGuard(curUser.sIP)
      if notifyOps==1 then
         curUser:Disconnect(BotName, "bye bye")
         SendPmToOps(BotName,"*** "..curUser.sName.." - ( "..curUser.sIP.." ) from Company ( "..comp.." ) tried to login! ***")
      end
   end
end



function BlockGuard(ip)
   local _,_,a,b,c,d = strfind(ip, "(%d*).(%d*).(%d*).(%d*)")
   if ( tonumber(a) and tonumber(b) and tonumber(c) and tonumber(d) ) then
      local uip = ComputeIP(ip)
      if uip then
         for range,comp in Guard do
            local _,_,r1,r2 = strfind(range, "(.*)-(.*)")
            r1 = ComputeIP(r1)
            r2 = ComputeIP(r2)
            if uip>=r1 and uip<=r2 then
               return 1,comp
            end
         end
      end
   end
end

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

function LoadTable(table,file)
   local handle = openfile(file, "r")
   if (handle) then
          local line = read(handle)
          while line do
         s,e,ind,val = strfind( line, "(.*):(.*)")
         table[val]=ind
         line = read(handle)
          end
        closefile(handle)
   end
end
------------------------------------------------------------------------
Syntax error: attempt to concat local `comp' (a nil value)
stack traceback:
   1:  function `NewUserConnected' at line 29 [file `...okaX-0.330 build 15.25\scripts\PeerGuardian.lua']

So if someone can help me !!

MetalPriest




   ?? ?.(*?.?( ?.??.??)?.?*).?? ?
    ???*?.?*???RoboCop???*.??.?*? ?
      ???*?.?Checks you here !!!.??.?*? ?
          (?.?* MetalSweden *?.?) ?.?)
 (?.?* metalsweden.servemp3.com *?.?)
             \'?.(*?.?( ?.? ?.??)?.?*).??

nErBoS

Hi,

Try this one...

--// a peerguardian script .. 
--// by Typhoon?/Ratcom_Typhoon? 
--// 09-05-2004 
--// idea and code from NXS-4 by NightLitch 

---- setup 

GuardianCheck = 1 
notifyOps = 1 

---- setup end 

BotName = frmHub:GetHubBotName() 

GuardianFile = "peerfolder/Guarding.P2P" 

Guard = {} 

function Main() 
LoadTable(Guard,GuardianFile) 
end 


function NewUserConnected(curUser) 
if GuardianCheck==1 then 
local comp = BlockGuard(curUser.sIP) 
if notifyOps==1 then 
curUser:Disconnect(BotName, "bye bye") 
SendPmToOps(BotName,"*** "..curUser.sName.." - ( "..curUser.sIP.." ) from Company ( "..comp.." ) tried to login! ***") 
end 
end 
end 



function BlockGuard(ip) 
local _,_,a,b,c,d = strfind(ip, "(%d*).(%d*).(%d*).(%d*)") 
if ( tonumber(a) and tonumber(b) and tonumber(c) and tonumber(d) ) then 
local uip = ComputeIP(ip) 
if uip then 
for range,comp in Guard do 
local _,_,r1,r2 = strfind(range, "(.*)-(.*)") 
r1 = ComputeIP(r1) 
r2 = ComputeIP(r2) 
if uip>=r1 and uip<=r2 then 
return 1,comp 
end 
end 
end 
end 
end 

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

function LoadTable(table,file) 
local handle = openfile(file, "r") 
if (handle) then 
local line = read(handle) 
while line do 
s,e,ind,val = strfind( line, "(.*):(.*)") 
table[val]=ind 
line = read(handle) 
end 
closefile(handle) 
end 
end

Best regards, nErBoS
--## nErBoS Spot ##--

MetalPriest

Huuuu Nerbos this was fast ...

Thanks !!!

MetalPriest
   ?? ?.(*?.?( ?.??.??)?.?*).?? ?
    ???*?.?*???RoboCop???*.??.?*? ?
      ???*?.?Checks you here !!!.??.?*? ?
          (?.?* MetalSweden *?.?) ?.?)
 (?.?* metalsweden.servemp3.com *?.?)
             \'?.(*?.?( ?.? ?.??)?.?*).??

MetalPriest

Same **** error come up again..

Hmm...

MetalPriest
   ?? ?.(*?.?( ?.??.??)?.?*).?? ?
    ???*?.?*???RoboCop???*.??.?*? ?
      ???*?.?Checks you here !!!.??.?*? ?
          (?.?* MetalSweden *?.?) ?.?)
 (?.?* metalsweden.servemp3.com *?.?)
             \'?.(*?.?( ?.? ?.??)?.?*).??

nErBoS

Hi,

The script is was ok...

--// a peerguardian script .. 
--// by Typhoon?/Ratcom_Typhoon? 
--// 09-05-2004 
--// idea and code from NXS-4 by NightLitch 

---- setup 

GuardianCheck = 1 
notifyOps = 1 

---- setup end 

BotName = frmHub:GetHubBotName() 

GuardianFile = "peerfolder/Guarding.P2P" 

Guard = {} 

function Main() 
	LoadTable(Guard,GuardianFile) 
end 


function NewUserConnected(curUser) 
	if GuardianCheck==1 then 
		local check,comp = BlockGuard(curUser.sIP) 
		if notifyOps==1 then 
			curUser:Disconnect(BotName, "bye bye") 
			SendPmToOps(BotName,"*** "..curUser.sName.." - ( "..curUser.sIP.." ) from Company ( "..comp.." ) tried to login! ***") 
		end 
	end 
end 

function BlockGuard(ip) 
	local _,_,a,b,c,d = strfind(ip, "(%d*).(%d*).(%d*).(%d*)") 
	if ( tonumber(a) and tonumber(b) and tonumber(c) and tonumber(d) ) then 
		local uip = ComputeIP(ip) 
		if uip then 
			for range,comp in Guard do 
				local _,_,r1,r2 = strfind(range, "(.*)-(.*)") 
				r1 = ComputeIP(r1) 
				r2 = ComputeIP(r2) 
				if uip>=r1 and uip<=r2 then 
					return 1,comp 
				end 
			end 
		end 
	end 
end 

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

function LoadTable(table,file) 
	local handle = openfile(file, "r") 
	if (handle) then 
		local line = read(handle) 
		while line do 
			s,e,ind,val = strfind( line, "(.*):(.*)") 
			table[val]=ind 
			line = read(handle) 
		end 
		closefile(handle) 
	end 
end

I belive that the probelm is the table isn't being loaded. Can you show me what you have in "peerfolder/Guarding.P2P" ??

Best regards, nErBoS
--## nErBoS Spot ##--

MetalPriest

ok.. No Problem..

I have only Guardian.p2p file there...

No table file in folder

looks like script can't read it...

Found this script on plops site..

MetalPriest
   ?? ?.(*?.?( ?.??.??)?.?*).?? ?
    ???*?.?*???RoboCop???*.??.?*? ?
      ???*?.?Checks you here !!!.??.?*? ?
          (?.?* MetalSweden *?.?) ?.?)
 (?.?* metalsweden.servemp3.com *?.?)
             \'?.(*?.?( ?.? ?.??)?.?*).??

nErBoS

Hi,

The script is given erro because the table is empty, should have something i think.

Best regards, nErBoS
--## nErBoS Spot ##--

MetalPriest

#7
Thanks Nerbos

Have play with it and check some things..

My code goes here..
--------------------------------------------------------------------
BotName = frmHub:GetHubBotName()
----------------------------------------------------------------------------------------------
GuardianFile = "Guard/Guarding.P2P"
Guard = {}
Guardian = 1
----------------------------------------------------------------------------------------------
--//Code
----------------------------------------------------------------------------------------------
function Main()
LoadGuard(Guard,GuardianFile)
frmHub:RegBot(BotName)
end
----------------------------------------------------------------------------------------------
function NewUserConnected(User)
if GuardianCheck==1 then
      local check,comp = BlockGuard(User.sIP)
      if check==1 then
         SendPmToOps(nBotName,"*** "..User.sName.." - ( "..User.sIP.." ) from Company ( "..comp.." ) tried to login! ***")
         check = 0
      end
   end
 end
----------------------------------------------------------------------------------------------
function BlockGuard(ip)
   local _,_,a,b,c,d = strfind(ip, "(%d*).(%d*).(%d*).(%d*)")
   if ( tonumber(a) and tonumber(b) and tonumber(c) and tonumber(d) ) then
      local uip = ComputeIP(ip)
      if uip then
         for range,comp in Guard do
            local _,_,r1,r2 = strfind(range, "(.*)-(.*)")
            r1 = ComputeIP(r1)
            r2 = ComputeIP(r2)
            if uip>=r1 and uip<=r2 then
               return 1,comp
            end
         end
      end
   end
end
----------------------------------------------------------------------------------------------
function ComputeIP(curIP)
   local _,_,a,b,c,d = strfind(curIP, "(%d+).(%d+).(%d+).(%d+)")
   return a*16777216 + b*65536 + c*256 + d
end
----------------------------------------------------------------------------------------------
function LoadGuard(table,file)
   local handle = openfile(file, "r")
   if (handle) then
          local line = read(handle)
          while line do
         s,e,ind,val = strfind( line, "(.*):(.*)")
         table[val]=ind
         line = read(handle)
          end
        closefile(handle)
   end
end
----------------------------------------------------------------------------------------------
This work !!!!
MetalPriest
   ?? ?.(*?.?( ?.??.??)?.?*).?? ?
    ???*?.?*???RoboCop???*.??.?*? ?
      ???*?.?Checks you here !!!.??.?*? ?
          (?.?* MetalSweden *?.?) ?.?)
 (?.?* metalsweden.servemp3.com *?.?)
             \'?.(*?.?( ?.? ?.??)?.?*).??

SMF spam blocked by CleanTalk