Connection Deny
 

Connection Deny

Started by ArtificialInsanety, 09 February, 2009, 21:15:43

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

ArtificialInsanety

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

Madman

-- 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?
We suffer in silence, we lurk in the shadows, we kill in the night
Site currently down, ETA of returning online is 2099 ;p

ArtificialInsanety

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.

Madman

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
We suffer in silence, we lurk in the shadows, we kill in the night
Site currently down, ETA of returning online is 2099 ;p

ArtificialInsanety

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).

CrazyGuy

-- 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

ArtificialInsanety

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)

CrazyGuy

#7
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]

ArtificialInsanety


SMF spam blocked by CleanTalk