← Back to team overview

linuxdcpp-team team mailing list archive

[Bug 1203313] Re: Adch++ goes down

 

we have a script that might cause this problem

RatioChecker.lua

--[[

	HSS Check 1.0b LUA 5.1x [Strict] [API 2]
	
	Hub Share Slot Check
	By Mutor		12/25/07

	Provides limits per profile for:
		-Minimum share
		-Maximum hubs
		-Minimum slot:hub ratio
	Option for disconnect,kick or ban
	Messages user before removal
	Reports to: Nick, Ops or All
	Checks for myinfo changes after login
	Protect by nick option
	Action taken if MyINFO is invalid
	
	+Changes from 1.0	12/27/07
		+Added option to use hub/slot ratio or max slot setting
		+Added clean hub on script start
		~Changed MyINFO checking [checked only after connection]
		
]]

-- Reporting function
-- 0 = Disabled 1 = SendToNick 2 = SendToOps, 3 = SendToAll
local Report = 3
-- If Report = 0, then set Nick
local OpNick = ""--"Mutor"
-- Name for Bot
local Bot = SetMan.GetString(21)
-- Penalty for offenders 1=Disconnect, 2 = Kick[default tempban], 3 = Ban
local Penalty = 1
-- Set Your Profiles
-- [#] = {MinShare in GB,MaxHubs,*Slot/Hub Ratio OR Max Slots},
local Profiles = {
	[-1] = {30960,0,0},
	[0] = {0,0,0},
	[1] = {0,0,0},
	[2] = {0,0,0},
	[3] = {0,0,0},
	[4] = {0,0,0},
	[5] = {512,0,0},
	[6] = {1024,0,0},
	[7] = {10,0,0},
	}
-- *Use slot count as a ratio? [3rd value in the Profiles array] true/false
-- *If set to false slot count is max slot limit set Profiles array accordingly
local Ratio = false
local SafeNicks = {
	["[10Mbit]Ben"] = true,
	["WebReg"] = true,
	["ruler"] = true,
	["123Rizzo"] = true,
	}

OnStartup  = function()
	for _,user in ipairs(Core.GetOnlineUsers()) do
		CheckUser(user)
	end
	collectgarbage("collect")
end

UserConnected = function(user)
	CheckUser(user)
end
OpConnected,RegConnected = UserConnected,UserConnected

MyINFOArrival = function(user,data)
	if Core.GetUserValue(user,9) then
		CheckUser(user)
	end
end

CheckUser = function(user)
	if not SafeNicks[user.sNick] then
		local t = {}
		for i = 16, 21 do
			if i < 18 or i > 20 then
				local x = Core.GetUserValue(user,i)
				if x then
					table.insert(t,tonumber(x))
				end
			end
		end
		if #t == 3 then
			local tab = Profiles[user.iProfile]
			if tab then
				local rsn
				local p,m,z,x = GetProf(user.iProfile),"",1024^3
				if tab[1] > 0 and t[1] < (tab[1]* z) then
					rsn = "Under minimum share limit"
					m,x = FmtSz((tab[1]* z) - t[1]).." short of minimum share of "..
					FmtSz(tab[1] * z).." for "..p.."s.",true
				elseif tab[2] > 0 and t[2] > tab[2] then
					rsn = "Over maximum hub limit."
					m,x = t[2] - tab[2].." too many hubs (Max: "..tostring(tab[2])..
					" ) for "..p.."s.",true
				else
					if Ratio then
						--if tab[3]> 0 and (t[3]/t[2] < tab[3]*t[2]) then
						if t[2] < 1 and t[3] < 1 or tab[3]> 0 and (t[3]/t[2] < tab[3]*t[2]) then
							rsn = "Under minimum slot:hub ratio"
							local hs,cs = tab[3]*t[2],math.ceil((tab[3]*t[2]) - t[3])
							m,x = tostring(cs).." too few slots for "..p.."s. "..
							"You're logged on to "..tostring(t[2]).." hubs which requires "..
							"you to have "..tostring(hs).." slots.",true
						end
					else
						if tab[3] > 0 and t[3] > tab[3] then
							rsn = "Over maximum slot allowance"
							local hs,cs = tab[3],t[3] - tab[3]
							m,x = tostring(cs).." too many slots for "..p.."s. "..
							"You are only allowed "..tostring(hs).." slots.",true
						end
					end
				end
				if x then
					local nick = user.sNick
					Txt = {"disconnected","kicked","banned"}
					local umsg = nick..", you will be "..Txt[Penalty]..
					" for the offense: "..m
					if DumpUser(user,umsg,rsn) then
						m = m:lower():gsub("you're",nick.." is")
						m = m:lower():gsub("you",nick)
						Send(nick.." was "..Txt[Penalty].." for "..m,0)
					end
					return true
				end
			end
		else
			local msg,nick = "Your client is invalid. You may return with a proper "..
			"NMDC protocol compliant client, You will now be disconencted|",user.sNick
			if DumpUser(user,msg) then
				Send(nick.." was disconnected for bad client",0)
			end
			return true
		end
	end
end

DumpUser = function(user,msg,rsn)
	local nick = user.sNick
	Core.SendToUser(user,msg)
	local Action = {
		[1] = function(user) return Core.Disconnect(user) end,
		[2] = function(user,msg,rsn) return Core.Kick(user,Bot,rsn) end,
		[3] = function(user,msg,rsn) return BanMan.Ban(user,rsn,Bot,false) end,
	}
	local x = Action[Penalty](user,msg,rsn)
	if x and not Core.GetUser(nick) then
		return true
	end
end

GetProf = function(i)
	local Prof = "Unregistered User"
	if i >= 0 then
		Prof = ProfMan.GetProfile(i).sProfileName
	end
	return Prof
end

Send = function(msg,arg)
	if not arg then arg = Report end
		if arg > 0 then
		if arg == 1 then
			if OpNick:len() > 0 then
				local user = Core.GetUser(OpNick)
				if user then
					Core.SendToUser(user,"<"..Bot.."> "..msg.."|")
				else
					Send(msg,1)
				end
			else
				return
			end
		elseif arg == 2 then
			Core.SendToOps("<"..Bot.."> "..msg.."|")
		elseif arg == 3 then
			Core.SendToAll(msg.."|")
		end
	end
end

FmtSz = function(int)
	local i,u,x = int or 0,{"","K","M","G","T","P"},1
	while i > 1024 do i,x = i/1024,x+1 end return string.format("%.2f %sB.",i,u[x])
end


the rest is most text files like rules

-- 
You received this bug notification because you are a member of
Dcplusplus-team, which is subscribed to ADCH++.
https://bugs.launchpad.net/bugs/1203313

Title:
  Adch++ goes down

Status in ADCH++:
  New

Bug description:
  Hub goes down sometimes for some reason.why we do not know, it may be that we have too many users in the Hub we have 600-1100 users.we can not see anything in the log
  any idea why it goes down??

  ADCH++ 2.10.1 (r646) Release

  
  Janne

To manage notifications about this bug go to:
https://bugs.launchpad.net/adchpp/+bug/1203313/+subscriptions