[Request] Please convert DHT Blocker script

Post finished Hubside Scripts here, known supporting hubsofts for LUA scripting.

ADCH++ | DCWatch | LUADCH
Locked
tonimontana
Junior Member
Posts: 18
Joined: 10 Apr 2010, 10:41

[Request] Please convert DHT Blocker script

Post by tonimontana » 19 Jun 2010, 16:03

Would be nice if somebody could convert the dhtblocker script for the use with ADCH++.
Here a link to the original luadch script:
http://www.adcportal.com/forums/viewtop ... f=31&t=642

I have used this script with luadch 0.0.8 and would be happy if i could use it with ADCH++ 2.5.0 too.

best regards
ToniMontana

tonimontana
Junior Member
Posts: 18
Joined: 10 Apr 2010, 10:41

Re: [Request] Please convert DHT Blocker script

Post by tonimontana » 01 Sep 2010, 08:42

Its no longer needed that this script gets converted.
There is another solution for this.
DHT Block by Mutor
http://board.ptokax.ch/index.php/topic, ... l#msg79600

Tested with ADCH++ 2.5.3 rev.377 mingw debug and ADCH++-PtokaX-Bridge rev.76

Toast

Re: [Request] Please convert DHT Blocker script

Post by Toast » 01 Sep 2010, 09:34

Dont link it include it in post instead :)

tonimontana
Junior Member
Posts: 18
Joined: 10 Apr 2010, 10:41

Re: [Request] Please convert DHT Blocker script

Post by tonimontana » 01 Sep 2010, 11:37

Couldnt edit my previous post so here is the script.

Code: Select all

-- Admin's nick for status / error messages ["" = OpChat]
OpNick = "Mutor"
--Penalty for DHT enabled [0 = None,report only / 1 = Disconnect / 2= Tempban / 3 = Redirect]
Penalty = 3

OnStartup = function()
	Hub,Bot,Tab,Tmr = SetMan.GetString(0),SetMan.GetString(21),{},TmrMan.AddTimer(1000,"Process")
	Msg1 = "DHT is not allowed here. Please disable DHT functions in your client.|"
	Msg2 = "Uncheck: Settings\\Advanced\\Publish shared files on DHT and use it for searching alternate sources."
end

OnError = function(msg)
	if msg then
		local user,bot = Core.GetUser(OpNick),"<"..Bot.."> "
		if user then Core.SendToUser(user,bot..msg.."|") else Core.SendToOpChat(bot..msg.."|") end
	end
end

SupportsArrival = function(user,data)
	if data:find("DHT0") then Tab[user.sIP] = {os.time()} end
end

UserConnected = function(user)
	if Tab[user.sIP] then
		table.insert(Tab[user.sIP],1,GetProf(user))
		table.insert(Tab[user.sIP],1,user.sNick)
		if not Tmr then Tmr = TmrMan.AddTimer(1000,"Process") end
	end
end
RegConnected,OpConnected = UserConnected,UserConnected

UserDisconnected = function(user)
	if Tab[user.sIP] then Tab[user.sIP] = nil end
end
RegDisconnected,OpDisconnected = UserDisconnected,UserDisconnected

Process = function()
	local t,n = os.time(),0
	for i,v in pairs(Tab) do
		if #v == 3 and ((t - v[3]) > 5) then
			local rep = "The "..v[2]..", "..v[1].." with I.P.: "..i.." is using DHT."
			local user = Core.GetUser(v[1])
			if user then
				Core.SendToUser(user,"<"..Bot.."> "..Msg1)
				Core.SendToUser(user,"<"..Bot.."> "..Msg2)
				local s,n = "DHT Enabled",user.sNick
				if Penalty > 0 then
					local Reply = {"disconnected from "..SetMan.GetString(0),
					"tempbanned for "..tostring(SetMan.GetNumber(16)).." minutes",
					"redirected to "..SetMan.GetString(6)}
					if Reply[Penalty] then
						Core.SendToUser(user,"<"..Bot.."> You will be "..Reply[Penalty])
						if Penalty == 1 then
							Core.Disconnect(user)
						elseif Penalty == 2 then
							BanMan.TempBan(user,0,s,Bot,false)
						elseif Penalty == 3 then
							Core.Redirect(user,SetMan.GetString(6),s)
						end
					end
				else
					OnError(rep)
				end
			else
				i = nil
			end
		else
			n = n + 1
		end
	end
	if n == 0 then
		TmrMan.RemoveTimer(Tmr)
		Tmr = nil
	end
end

GetProf = function(user)
	local Prof = "Unregistered User"
	if user.iProfile ~= -1 then Prof = ProfMan.GetProfile(user.iProfile).sProfileName end
	return Prof
end

Pirre
Junior Member
Posts: 31
Joined: 10 Nov 2009, 11:57

Re: [Request] Please convert DHT Blocker script

Post by Pirre » 23 Jan 2011, 22:01

Well lets make this simple, you can NOT detect users sharing in public hubs, when they register there so why port this old nmdc saga in adc ?

Locked