PtokaX forum

Archive => Archived 5.0 boards => Finished Scripts => Topic started by: Snowman on 04 May, 2005, 16:39:04

Title: IPGuard?
Post by: Snowman on 04 May, 2005, 16:39:04
FINALLY!!! :))

Here is the new and reborn IPGuard? Stand-alone from my good old Mean-Machine?

Changelog:

- Changed > Rewritten for Lua v5.
- Changed > Rewritten the filters to be accurate. (It actually blocked some IP's that shouldn't be blocked before).
- Changed > Moved the "Guarding.P2P" file to a subfolder called "IPGuard?".
- Added > It's now possible to change the botname.
- Added > It's now possible to set if reports should be sent to the Ops.
- Added > a settings file in the subfolder "IPGuard?"


You can get it at the link below ;)


Snowman
Title:
Post by: night_hawk on 04 May, 2005, 17:47:40
i am getting this message

Syntax IPGuard?.lua:7: bad argument #1 to `lines' (No such file or directory
)
Syntax IPGuard?.lua:48: bad argument #1 to `lines' (No such file or directory
)


just to let you know cuase it is not working
Title:
Post by: bastya_elvtars on 04 May, 2005, 17:58:25
Hehe thats due to the ? fucking things up, due to Windows filesystem character encoding problems. Now why did you compile the bot? You will have to re-release it with correct settings, or decompiled. :P
Title:
Post by: OpticaL on 04 May, 2005, 18:47:08
Remove it IPGuard isn't a registered name anyway =)
Title:
Post by: night_hawk on 04 May, 2005, 19:29:41
i will wait for snowman to look at it..
Title:
Post by: Snowman on 05 May, 2005, 10:53:14
Hi to all of you.

The ? is NOT the problem.
Note that the Guarding.P2P AND the settings.dat MUST reside in the subfolder IPGuard? or it WILL fail with the error you have seen.

It works great here :)


Snowman
Title:
Post by: bastya_elvtars on 05 May, 2005, 11:20:43
QuoteOriginally posted by Snowman
The ? is NOT the problem.

Such characters are still dangerous to use in folder names, especially when users have no opportunity to change it if they have problems.
Title:
Post by: Typhoon on 05 May, 2005, 12:32:09
here's another version.. tested quickly and worked...

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

---- setup
tSetting = {
GuardianCheck = 1,
notifyOps = 1,
BotName = frmHub:GetHubBotName(),
GuardianFile = "peerguard/Guarding.P2P",}

---- setup end

Guard = {}

function Main()
       LoadTable(Guard,tSetting.GuardianFile)
end


function NewUserConnected(curUser)
if tSetting.GuardianCheck==1 then
local check,comp = BlockGuard(curUser.sIP)
if check == "fail" then
if comp ~= nil then com = comp else com = "Unknown" end
if tSetting.notifyOps==1 then
curUser:SendData(tSetting.BotName, "Your Ip is not allowed in here,bye bye")
curUser:Disconnect()
SendPmToOps(tSetting.BotName,"*** "..curUser.sName.." - ( "..curUser.sIP.." ) from Company \" "..com.." \" tried to login! ***")
end
end
end
end



function BlockGuard(ip)
local _,_,a,b,c,d = string.find(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 pairs(Guard) do
local _,_,r1,r2 = string.find(range, "(.*)-(.*)")
r1 = ComputeIP(r1)
r2 = ComputeIP(r2)
if uip>=r1 and uip<=r2 then
return "fail",comp
end
end
end
end
end

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

function LoadTable(table,file)
local f = io.open(file)
if f then
for line in f:lines() do
local s,e,ind,val = string.find( line, "(.*):(.*)")
table[val]=ind
    end
f:flush()
  f:close()
end
end

just make a folder called "peerguard" and place the Guarding.p2p file inside it

feel free to extend improve old convert from lua 4 could be improved much more i guess

Typhoon?
Title:
Post by: Snowman on 09 May, 2005, 07:15:50
As almost everyone uses Windows XP with Unicode support these days then this AND a lot of other special characters can be used freely.

But if someone still have problems with it then please drop a note...


Snowman
Title:
Post by: bastya_elvtars on 09 May, 2005, 08:12:09
QuoteOriginally posted by Snowman
As almost everyone uses Windows XP with Unicode support these days then this AND a lot of other special characters can be used freely.

Better not discuss this 'feature' here, but search me on MSN and I will tell you about this second-to-none Unicode support. My idea was just part of the 'play safe policy'.
Title:
Post by: sander815 on 06 June, 2005, 15:24:44
please change this to not use the "'tm" marking, i cannot use it on my win2000
Title: UPDATE!!!
Post by: Snowman on 06 June, 2005, 19:49:18
v3.0.65 released.

- Changed > Removed the Trademark logo due to Win2K incompability.


Snowman
Title:
Post by: sander815 on 06 June, 2005, 21:11:51
can you release it as not compiled maybe?
i want to be able to change its nick etc
Title:
Post by: Snowman on 06 June, 2005, 21:16:53
sander815:

It IS possible to edit the name... Read the readme...


Snowman