PtokaX forum

Lua 5.3/5.2/5.1 Scripts (for PtokaX 0.4.0.0 and newer) => Conversion Requests => Topic started by: ArtificialInsanety on 09 February, 2009, 21:15:43

Title: Connection Deny
Post by: ArtificialInsanety on 09 February, 2009, 21:15:43
Hi , I need a script convertion and I need it to block client if connection type isn't in the list. ty
-- ConDeny
-- Made by Madman
-- Request by Helios

Bot = "ConDeny"
Action = 1 -- 1 = disconnect, 2 = timeban, 3 = redirect
TimeBanTime = 5 -- Minutes to timeban
RedirAddres = "myotherhub.org" -- addy to redirect to
Msg = "Your connection type is not allowed in this hub" -- msg to send
Owner = "Madman"
informOwn = 1 -- if 1, pm owner about connetion not in table

-- 1 = Allow, 0 = Deny
Connection = {
["28.8Kbps"] = 1,
["33.6Kbps"] = 1,
["56Kbps"] = 1,
["ISDN"] = 1,
["Satellite"] = 1,
["Cable"] = 1,
["DSL"] = 1,
["LAN(T1)"] = 1,
["LAN(T3)"] = 1,
}

function NewUserConnected(curUser)
if Connection[curUser.sConnection] == 0 then
if Action == 1 then
curUser:SendData(Bot,Msg)
curUser:Disconnect()
elseif Action == 2 then
curUser:SendData(Bot,Msg)
curUser:TimeBan(TimeBanTime)
elseif Action == 3 then
curUser:Redirect(RedirAddress,Msg)
end
elseif Connection[curUser.sConnection] == nil then
if informOwn == 1 then
SendPmToNick(Owner,frmHub:GetHubBotName(), curUser.sName.. " logged in with an connetion that aren't in the Connnetion table. His/Hers connetion is -->" ..curUser.sConnection.. "<--")
end
end
end
Title: Re: Connection Deny
Post by: Madman on 10 February, 2009, 18:54:23

-- ConDeny 2.0
-- Made by Madman
-- Request by Helios
-- Converted to API 2 by Madman
-- Requested by ArtificialInsanety

Bot = "ConDeny"
Action = 1 -- 1 = disconnect, 2 = timeban, 3 = redirect
TimeBanTime = 5 -- Minutes to timeban
RedirAddres = "myotherhub.org" -- addy to redirect to
Msg = "Your connection type is not allowed in this hub" -- msg to send
Owner = "Madman"
informOwn = true -- if true, pm owner about connetion not in table

-- true = Deny, false = Allow
Connection = {
["28.8Kbps"] = false,
["33.6Kbps"] = false,
["56Kbps"] = false,
["ISDN"] = false,
["Satellite"] = false,
["Cable"] = false,
["DSL"] = false,
["LAN(T1)"] = false,
["LAN(T3)"] = false,
}

function UserConnected(user)
Core.GetUser(user,4)
if Connection[user.sConnection] then
if Action == 1 then
Core.SendToUser(user,"<" ..Bot.. "> " ..Msg)
Core.Disconnect(user)
elseif Action == 2 then
BanMan.TempBan(user,TimeBanTimer,Msg,Bot,false)
elseif Action == 3 then
Core.Redirect(user,RedirAddress,Msg)
end
elseif (Connection[user.sConnection] == nil) and informOwn then
Core.SendPmToNick(Owner,SetMan.GetString(21),user.sNick.. " logged in with an connection that aren't in the Connection table. His/Hers connection is -->" ..user.sConnection .. "<--")
end
end


I only converted it...
What do you mean by block?
Title: Re: Connection Deny
Post by: ArtificialInsanety on 11 February, 2009, 09:13:35
Thanks for the conversion.I need it to block(don't allow user to connect to hub without connection - some dc client with proxy does that).I think its related to its myinfo sent to hub, hope u know what i mean.
Title: Re: Connection Deny
Post by: Madman on 11 February, 2009, 09:44:02
Blocking proxys are a completly diffrent thing

This script blocks Connections, that are set in the client. It dosent read proxys at all.
I think there is a script to block proxys, don't rember it's name tho
Title: Re: Connection Deny
Post by: ArtificialInsanety on 11 February, 2009, 17:05:03
I know what this script does , all i'm asking is to make it to block client if no connection is sent.I already have script that blocks proxys(socks5).
Title: Re: Connection Deny
Post by: CrazyGuy on 11 February, 2009, 19:10:13

-- ConDeny 2.0
-- Made by Madman
-- Request by Helios
-- Converted to API 2 by Madman
-- Requested by ArtificialInsanety
-- Added Action execution on 'empty' connection by CrazyGuy

Bot = "ConDeny"
Action = 1 -- 1 = disconnect, 2 = timeban, 3 = redirect
TimeBanTime = 5 -- Minutes to timeban
RedirAddres = "myotherhub.org" -- addy to redirect to
Msg = "Your connection type is not allowed in this hub" -- msg to send
Owner = "Madman"
informOwn = true -- if true, pm owner about connetion not in table

-- true = Deny, false = Allow
Connection = {
["28.8Kbps"] = false,
["33.6Kbps"] = false,
["56Kbps"] = false,
["ISDN"] = false,
["Satellite"] = false,
["Cable"] = false,
["DSL"] = false,
["LAN(T1)"] = false,
["LAN(T3)"] = false,
}

function UserConnected(user)
Core.GetUser(user,4)
if (user.sConnection == nil) or (Connection[user.sConnection] == true) then
if Action == 1 then
Core.SendToUser(user,"<" ..Bot.. "> " ..Msg)
Core.Disconnect(user)
elseif Action == 2 then
BanMan.TempBan(user,TimeBanTimer,Msg,Bot,false)
elseif Action == 3 then
Core.Redirect(user,RedirAddress,Msg)
end
elseif (user.sConnection) and (Connection[user.sConnection] == nil) and (informOwn) then
Core.SendPmToNick(Owner,SetMan.GetString(21),user.sNick.. " logged in with an connection that aren't in the Connection table. His/Hers connection is -->" ..user.sConnection .. "<--")
end
end
Title: Re: Connection Deny
Post by: ArtificialInsanety on 11 February, 2009, 20:18:03
I get this right after I load the script
Syntax H:\dchub\hub\scripts\condeny.lua:30: bad argument #1 to 'GetUser' (string expected, got table)
Title: Re: Connection Deny
Post by: CrazyGuy on 11 February, 2009, 21:13:31
Quote from: ArtificialInsanety on 11 February, 2009, 20:18:03
I get this right after I load the script
Syntax H:\dchub\hub\scripts\condeny.lua:30: bad argument #1 to 'GetUser' (string expected, got table)

You must have had that problem before, as I didn't change anything that has to do with GetUser.

EDIT: Clearly you didn't try Madmans code, as the problem was in there (GetUser vs GetUserData ;))
Below code fixed.

-- ConDeny 2.0
-- Made by Madman
-- Request by Helios
-- Converted to API 2 by Madman
-- Requested by ArtificialInsanety
-- Added Action execution on 'empty' connection by CrazyGuy

Bot = "ConDeny"
Action = 1 -- 1 = disconnect, 2 = timeban, 3 = redirect
TimeBanTime = 5 -- Minutes to timeban
RedirAddres = "myotherhub.org" -- addy to redirect to
Msg = "Your connection type is not allowed in this hub" -- msg to send
Owner = "Madman"
informOwn = true -- if true, pm owner about connetion not in table

-- true = Deny, false = Allow
Connection = {
["28.8Kbps"] = false,
["33.6Kbps"] = false,
["56Kbps"] = false,
["ISDN"] = false,
["Satellite"] = false,
["Cable"] = false,
["DSL"] = false,
["LAN(T1)"] = false,
["LAN(T3)"] = false,
}

function UserConnected(user)
Core.GetUserData(user,4)
if (user.sConnection == nil) or (Connection[user.sConnection] == true) then
if Action == 1 then
Core.SendToUser(user,"<" ..Bot.. "> " ..Msg)
Core.Disconnect(user)
elseif Action == 2 then
BanMan.TempBan(user,TimeBanTimer,Msg,Bot,false)
elseif Action == 3 then
Core.Redirect(user,RedirAddress,Msg)
end
elseif (user.sConnection) and (Connection[user.sConnection] == nil) and (informOwn) then
Core.SendPmToNick(Owner,SetMan.GetString(21),user.sNick.. " logged in with an connection that aren't in the Connection table. His/Hers connection is -->" ..user.sConnection .. "<--")
end
end
/code]
Title: Re: Connection Deny
Post by: ArtificialInsanety on 13 February, 2009, 19:49:38
Thanks :)