Ive tried to use the long awaited multiple IP account protection in 3.1 without success. The IP's are added to the
IP_check table fine but it didn't worked.
After several bans of my own account I've gone to debug the source and found that its not working
because of buggy code. Login is working only if you go from the first IP in the table for every user.
Here is a solution
Check_IP = function(user,data)
local Name = user.sName
local Found = false
for i,v in pairs(IP_Check[Name]) do
if i == user.sIP or WSA.GetHostByName(i) == user.sIP then
user:SendData(Cfg.Bot_Name,"IP check passed ! - "..user.sIP)
Found = true
break
end
end
if (not Found) then
IP_Check_Failed_Message(user)
user:SendData(Cfg.Bot_Name," - "..user.sIP)
user:SendData(Cfg.Bot_Name,IP_Check[Name])
TempBan(user.sIP,0,"IP check failed",Cfg.Bot_Name,0)
NickTempBan(user.sName,0,"IP check failed",Cfg.Bot_Name)
SendToOps(Cfg.Bot_Name,Cvrt.P2[user.iProfile].." ".. user.sName.." from "..user.sIP.." has been Disconnected and TempBanned because IP check failed.")
end
Clear()
end
Its working ok on my hub for a week
I pmed this to Time a week ago or so but he isn't reacted so I placed it here too...
Can you post how the table/array looks like?
Not fully tested tho but should work, let me know if problems (added dns name to protection) ::)
Check_IP = function(user,data) -- fix originally made by eMTee from http://forum.ptokax.org
local pass,who = false,user.sName
for i,key in pairs(IP_Check[who]) do
if i == user.sIP or WSA.GetHostByName(i) == user.sIP or i == WSA.GetHostByAddr(user.sIP) then
user:SendData(Cfg.Bot_Name,"IP check passed !")
pass = true
return 1
end
end
if not pass then
IP_Check_Failed_Message(user)
user:SendData(Cfg.Bot_Name,IP_Check[Name])
TempBan(user.sIP,0,"IP check failed",Cfg.Bot_Name,0)
NickTempBan(user.sName,0,"IP check failed",Cfg.Bot_Name)
SendToOps(Cfg.Bot_Name,Cvrt.P2[user.iProfile].." ".. user.sName.." from "..user.sIP.." has been Disconnected and TempBanned because IP check failed.")
end
Clear()
end
Nice because this way it eliminates that lots of unneccesary host resolves in the loop.
Seems it works as it should. 8)
Quote from: eMTee on 08 March, 2007, 16:14:30
Nice because this way it eliminates that lots of unneccesary host resolves in the loop.
Seems it works as it should. 8)
Your way was the working one.. mine didnt like hub address as protection :P
Post updated with correct version
OK I updated... its working, the only one problem is if you have eg 6 ips / dns's for a name and you log in from the ip what is in 6th index of the table those 5 reverse dns resolves can take even 15 secs at login...
I can't see why do you need that though ( i == WSA.GetHostByAddr(user.sIP) ) it works fine without it... many of my ops has their own hub address or dynamic dns set and they can connect from there with their dns address added to the table...
Quote from: eMTee on 09 March, 2007, 13:38:08
I can't see why do you need that though ( i == WSA.GetHostByAddr(user.sIP) ) it works fine without it... many of my ops has their own hub address or dynamic dns set and they can connect from there with their dns address added to the table...
That part is from lv 3.2 that has dns name stuffs added (ban/get dns name)
[19:51:58] <?Debug?LV?3.2> <C??o?y??> !getdnsname (adsl)Guq
[19:51:58] <?Leviathan_3.2?> *** (adsl)Guq's dns name is dsl-sjkgw4-fef4f800-192.dhcp.inet.fi (84.248.244.192)
Nice function, now I can see why ;)
The long login time is the only problem but this way you can do nothing with it... so if someone want to login protected from 8 places then pay the price : WAIT ;D