* ] * ] Gemini - ClientChecker [ * [ * - Page 2
 

News:

29 December 2022 - PtokaX 0.5.3.0 (20th anniversary edition) released...
11 April 2017 - PtokaX 0.5.2.2 released...
8 April 2015 Anti child and anti pedo pr0n scripts are not allowed anymore on this board!
28 September 2015 - PtokaX 0.5.2.1 for Windows 10 IoT released...
3 September 2015 - PtokaX 0.5.2.1 released...
16 August 2015 - PtokaX 0.5.2.0 released...
1 August 2015 - Crowdfunding for ADC protocol support in PtokaX ended. Clearly nobody want ADC support...
30 June 2015 - PtokaX 0.5.1.0 released...
30 April 2015 Crowdfunding for ADC protocol support in PtokaX
26 April 2015 New support hub!
20 February 2015 - PtokaX 0.5.0.3 released...
13 April 2014 - PtokaX 0.5.0.2 released...
23 March 2014 - PtokaX testing version 0.5.0.1 build 454 is available.
04 March 2014 - PtokaX.org sites were temporary down because of DDOS attacks and issues with hosting service provider.

Main Menu

* ] * ] Gemini - ClientChecker [ * [ *

Started by NightLitch, 26 December, 2004, 23:39:54

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Typhoon

please post the bandwith check function..

seems to be a small problem in that maybe..


Typhoon?



[_XStaTiC_]

Gemini - ( Bandwidth Checker )          By: NightLitch

Check.Bandwidth = function(sUser,curLimit)
	local bLimit, bBlock = Profiles[sUser.iProfile].Bandwidth, Profiles[sUser.iProfile].Block_Blimiter
	if curLimit == "unlimited" then
		return 1
	elseif tonumber(curLimit) ~= 0 and tonumber(curLimit) < tonumber(bLimit) and tonumber(bLimit) ~= 0 and bBlock ~= 1  then
		sUser:SendData(BotName,"You have limit your bandwidh to "..curLimit.." kB/s, minimum is "..bLimit.." kB/s.")
		sUser:Disconnect()
	elseif curLimit ~= 0 and bBlock ~= 0 then
		sUser:SendData(BotName,"Bandwidth Limiters are not allowed here...")
		sUser:Disconnect()
	end
end

Hope you can fix this

[_XStaTiC_]

I have made i little change, but i don't know if it makes it slower.

if Tag["R"] then Tag["B"] = "ratio" else Tag["B"] = Tag["B"] or Tag["L"] or Tag["F"]  or "unlimited" end

This doesn't check anything, only connects the hub now and it shows my Bandwidth is set to ratio

bastya_elvtars

Posting my client checker table, i hope NL will make use of it.
(offtopic: NL will we play starcraft at last? ;p)

dcpp={
		[""]={".PhantomDC++","V:(0.%d+)"},
		["
Everything could have been anything else and it would have just as much meaning.

?\'??Mm???\'

Syntax error: bad argument #1 to `strfind' (string expected, got nil)
stack traceback:
   1:  function `strfind' [C]
   2:  function `ParseMyINFO' at line 99 [file `E:\robocop\scripts\GeminiClientChecker.lua']
   3:  function `NewUserConnected' at line 41 [file `E:\robocop\scripts\GeminiClientChecker.lua']

help would be apriciated on this think this will be a good script if i can get it without the error  ;)

bastya_elvtars

I guess i have fixed it.

This is to be saved overwriting the old GeminiClientChecker.lua

--==#==#==#==#==#==#==#==#==#==#==#==#==#==#==#==#==#==#==#==#==-
--                   Gemini - ( Client Checker )          By: NightLitch
--==#==#==#==#==#==#==#==#==#==#==#==#==#==#==#==#==#==#==#==#==-
-- added hack against crash on no myinfo by bastya_elvtars
BotName = "Gemini"
cVersion = "0.7 build 3 for TD4"
Send_Client_Info_In = "PM" -- MAIN / PM
Send_Client_Info = 1 -- 1= on / 0 = off
--==#==#==#==#==#==#==#==#==#==#==#==#==#==#==#==#==#==#==#==#==-
dofile("Gemini/DescrTags.lst")
dofile("Gemini/TagClients.lst")
--==#==#==#==#==#==#==#==#==#==#==#==#==#==#==#==#==#==#==#==#==-
calcTag = {
["V"] = ":([%.%d]*)",
["M"] = ":([AP5])",
["H"] = ":([%d%/]*)",
["S"] = ":(%**%d*)",
["B"] = ":(%d+)",
["L"] = ":(%d+)",
["F"] = ":%d+%/(%d+)",
["RC"] = "(%d+)",
}
--==#==#==#==#==#==#==#==#==#==#==#==#==#==#==#==#==#==#==#==#==-
cMode = {["A"] = "Active",["P"] = "Passive", ["5"] = "Socket5"}
--==#==#==#==#==#==#==#==#==#==#==#==#==#==#==#==#==#==#==#==#==-
Send = {}
--==#==#==#==#==#==#==#==#==#==#==#==#==#==#==#==#==#==#==#==#==-
function Main()
	local file = openfile("GeminiProfiles.lst", "r")
	if file then
		closefile(file)
		dofile("GeminiProfiles.lst")
	else
		Save.Profiles()
	end
end

function NewUserConnected(sUser)
	sUser:SendData(BotName, "This hub is running Gemini ClientChecker "..cVersion)
	Get.SendData(Send_Client_Info_In)
	local Tag = ParseMyINFO(sUser.sMyInfoString)
	if Tag["C"] and Send_Client_Info == 1 then
		local line = "\r\n"
		line = line .. "\r\n\t ------------------------------------------------------------"
		line = line .. "\r\n\t Your Client Information"
		line = line .. "\r\n\t ------------------------------------------------------------"
		line = line .. "\r\n\t Client: "..Tag["C"]
		line = line .. "\r\n\t Version: "..Tag["V"]
		line = line .. "\r\n\t Share: "..Get.sUnits(Tag.Share)
		line = line .. "\r\n\t Mode: "..Tag["M"]
		line = line .. "\r\n\t Slots: "..Tag["S"].." slot(s)"
		line = line .. "\r\n\t Hubs: "..Tag["H"].." hub(s)"
		line = line .. "\r\n\t Bandwidth: "..Tag["B"].." kB/s"
		line = line .. "\r\n\t Connection Speed: "..Tag.Speed
		line = line .. "\r\n\t Tag: "..Tag["T"]
		line = line .. "\r\n\t Descr: "..Tag["D"]
		line = line .. "\r\n\t ------------------------------------------------------------\r\n"
		Send.ToNick(sUser.sName, BotName, line)
	end
end
--==#==#==#==#==#==#==#==#==#==#==#==#==#==#==#==#==#==#==#==#==-
OpConnected = NewUserConnected
--==#==#==#==#==#==#==#==#==#==#==#==#==#==#==#==#==#==#==#==#==-
function DataArrival(sUser,sData)
	if strsub(sData, 1,7) == "$MyINFO" then
		if user.sMyInfoString and strlen (user.sMyInfoString) > (strlen(user.sName)+13) then
			local c = ParseMyINFO(sData)
			if c["C"] then
				if Profiles[sUser.iProfile].Check_Client == 0 then return 1 end
				if c["Allow"] == 1 then
					if c["S"] == nil or c["H"] == nil then
						SendToOps(BotName, "User "..sUser.sName.." have bad tag for slots or hubs, Check User's Tag and send information to [EMAIL]nightlitch@swenorth.myftp.org[/EMAIL]")
						SendToOps(BotName, "User is not kicked, do that manually after you taken the Tag")
						return 1
					end
					Check.Share(sUser,c["Share"])
					Check.Slots(sUser,c["S"],c["H"])
					Check.Bandwidth(sUser,c["B"])
					Check.Mode(sUser,c["M"])
					Check.Connection(sUser,c["Speed"])
					if c.V < c.MinVer then
						sUser:SendData(BotName, "The oldest "..c.C.." version allowed is ( "..c.MinVer.." ), your client version is ( "..c.V.." ).")
						sUser:SendData(BotName, "Download newest version of "..c.C.." at "..c.Site)
						sUser:Disconnect()
					end
				else
					sUser:SendData(BotName, "Client "..c.C.." is not allowed here...")
					sUser:Disconnect()
				end
			else
				sUser:SendData(BotName, "Your client have a bad Tag or is not Allowed here...")
				sUser:Disconnect()
			end
		end
	end
end
--==#==#==#==#==#==#==#==#==#==#==#==#==#==#==#==#==#==#==#==#==-
ParseMyINFO = function(MyINFO)
	local Tag = nil
	Tag = {}
	if strfind(MyINFO, "<%P*%p*%s+V%p[%.%d]+%s*%S*%pM%p[AP5]%pH%p[%d%/]+%pS%p%**%d*%S*>") then
		local _,_,sDescr,sClient,sTag,sSpeed,sShare = strfind(MyINFO, "%$ALL%s+%S+%s+(.*)(<%S*)%s*(.*>)%$ $([^$]*)[^$]%$[^$]*%$%-*%s*(%d*)%$%|$")
		if getClient[sClient] then
			local Idx,Str = Get._Id(sTag)
			if getClient[sClient][Idx] then
				Tag = Get.TagIdx(Str,sTag)
				Tag["C"] = getClient[sClient][Idx].ClientName
				Tag["D"] = sDescr
				Tag["T"] = sClient.." "..sTag
				Tag["Allow"] = getClient[sClient][Idx].AllowClient
				Tag["MinVer"] = getClient[sClient][Idx].MinVersion
				Tag["Site"] = getClient[sClient][Idx].Site
				Tag["Speed"] = sSpeed
				Tag["Share"] = sShare
				Tag["M"] = cMode[Tag["M"]]
				Tag["B"] = Tag["B"] or Tag["L"] or Tag["F"] or "unlimited"
				Tag = Get.OtherClient(sClient,MyINFO,Tag)
				if strfind(MyINFO, "\"") then Tag["C"] = "Fake Client" end
				return Tag
			else
				return Tag
			end
		else
			return Tag
		end
	else
		return Tag
	end
end
--==#==#==#==#==#==#==#==#==#==#==#==#==#==#==#==#==#==#==#==#==-
Check = {}
Check.Share = function(sUser,curShare)
	local MinShare, MaxShare = Profiles[sUser.iProfile].Share.Min.Share * sUnit[Profiles[sUser.iProfile].Share.Min.Unit], Profiles[sUser.iProfile].Share.Max.Share * sUnit[Profiles[sUser.iProfile].Share.Max.Unit]
	if tonumber(curShare) <  tonumber(MinShare) and tonumber(MinShare) ~= 0  then
		sUser:SendData(BotName, "You have not met the requirements for minimum share "..Get.sUnits(tonumber(MinShare)))
		sUser:Disconnect()
	elseif tonumber(curShare) >  tonumber(MaxShare) and tonumber(MaxShare) ~= 0  then
		sUser:SendData(BotName, "You have met the requirements for maximum share "..Get.sUnits(tonumber(MaxShare)))
		sUser:Disconnect()
	end
end
Check.Slots = function(sUser,curSlots,curHubs)
	local MinSlots,MaxSlots,MaxHubs, SlotPerHub = Profiles[sUser.iProfile].MinSlots, Profiles[sUser.iProfile].MaxSlots,Profiles[sUser.iProfile].MaxHubs, Profiles[sUser.iProfile].SlotPerHub
	if curSlots == "unlimited" then 
		sUser:SendData(BotName,"You share unlimited slots.")
		sUser:Disconnect()
	elseif tonumber(curSlots) < tonumber(MinSlots) and tonumber(MinSlots) ~= 0 then
		sUser:SendData(BotName,"You have to few slots open, minimum is "..MinSlots.." slot(s) open.")
		sUser:Disconnect()
	elseif tonumber(curSlots) > tonumber(MaxSlots) and tonumber(MaxSlots) ~= 0 then
		sUser:SendData(BotName,"You have to many slots open, maximum is "..MaxSlots.." slot(s) open.")
		sUser:Disconnect()
	elseif tonumber(curHubs) > tonumber(MaxHubs) and MaxHubs ~= 0 then
		sUser:SendData(BotName,"You are in to many hubs, maximum is "..MaxHubs.." hub(s).")
		sUser:Disconnect()
	elseif tonumber(SlotPerHub) and tonumber(curSlots) < tonumber(curHubs)*tonumber(SlotPerHub) and SlotPerHub ~= 0 then
		sUser:SendData(BotName,"You have to few slots open per hubs, minimum is "..SlotPerHub.." slot(s) per hub(s) open.")
		sUser:Disconnect()
	end
end
Check.Connection = function(sUser,curSpeed)
	local Connection = Profiles[sUser.iProfile].Connection
	if Connection[curSpeed] == nil then
		sUser:SendData(BotName,"Your connection type ( "..curSpeed.." ) are not allowed here.")
		sUser:Disconnect()
	elseif Connection[curSpeed] == 0 then
		sUser:SendData(BotName,"Your connection type ( "..curSpeed.." ) are not allowed here.")
		sUser:Disconnect()
	end	
end
Check.Mode = function(sUser,curMode)
	local Mode = Profiles[sUser.iProfile].Mode
	if Mode[curMode] == 0 then
		sUser:SendData(BotName,"Mode "..curMode.." are not allowed here.")
		sUser:Disconnect()
	end
end
Check.Bandwidth = function(sUser,curLimit)
	local bLimit, bBlock = Profiles[sUser.iProfile].Bandwidth, Profiles[sUser.iProfile].Block_Blimiter
	if curLimit == "unlimited" then
		return 1
	elseif tonumber(curLimit) ~= 0 and tonumber(curLimit) < tonumber(bLimit) and tonumber(bLimit) ~= 0 and bBlock ~= 1  then
		sUser:SendData(BotName,"You have limit your bandwidh to "..curLimit.." kB/s, minimum is "..bLimit.." kB/s.")
		sUser:Disconnect()
	elseif curLimit ~= 0 and bBlock ~= 0 then
		sUser:SendData(BotName,"Bandwidth Limiters are not allowed here...")
		sUser:Disconnect()
	end
end
--==#==#==#==#==#==#==#==#==#==#==#==#==#==#==#==#==#==#==#==#==-
Get = {}
Get.BadCap = {["A"] = 1,["P"] = 1,["O"] = 1,["D"] =1,["C"] = 1} --,["R"] = 0}
Get._Id = function(sTag) 
	tmp = {}
	local Str = gsub(sTag, "(%u+)[%s*%.*%d*%p*%.*]*",function(char) if calcTag[char] then tmp["("..char..")"..calcTag[char]] = 1 end end)
	local Id = gsub(sTag, "(%u)[%s*%.*%d*%p*%.*]*",function(char) if Get.BadCap[char] then return "" else  return char end end)
	return Id,tmp
end
Get.TagIdx = function(Str,tag)
	local Tmp = {}
	local version = ""
	for find,_ in Str do
		local _,_,i,val = strfind(tag, find)
		if i and val then
			if i == "RC" then 
				version = val
			else
				if val == "*" then val = "unlimited" end
				Tmp[i] = val
			end
		end
	end
	if version ~= "" then Tmp["V"] = Tmp["V"].." RC"..version end
	hubs = 0
	if tonumber(Tmp["H"]) == nil then gsub(Tmp["H"], "(%d+)", function (num) hubs = hubs +tonumber(num) end) else 	hubs = tonumber(Tmp["H"])	end
	Tmp["H"] = hubs
	return Tmp
end
Get.OtherClient = function(sClient,MyINFO,Tag)
	for cTag, cTab in DescrTag do
		if strfind(MyINFO, cTag) then
			local _,_,version = strfind(MyINFO, DescrTag[cTag].VerStr)
			Tag["V"] = version
			Tag["C"] = DescrTag[cTag].ClientName
			Tag["Allow"] = DescrTag[cTag].AllowClient
			Tag["MinVer"] = DescrTag[cTag].MinVersion
			Tag["Site"] = DescrTag[cTag].Site
		end
	end
	return Tag
end
Get.sUnits = function(intSize)
	if tonumber(intSize) ~= 0 then
		local tUnits = { "Bytes", "KB", "MB", "GB", "TB" }
		intSize = tonumber(intSize);
		local sUnits;
		for index = 1, getn(tUnits) do
			if(intSize < 1024) then
				sUnits = tUnits[index];
				break;
			else 
				intSize = intSize / 1024;
			end
		end
		return format("%0.1f %s",intSize, sUnits);
	else 
		return "nothing"
	end
end
Get.SendData = function(mode)
	if mode == "MAIN" then
		Send.ToNick = function(this,from,text) SendToNick(this, "<"..from.."> "..text) end
	elseif mode == "PM" then
		Send.ToNick = function(this,from,text) SendPmToNick(this, from,text) end
	end
end
Save = {}
Save.Serialize = function(tTable, sTableName, hFile, sTab)
	assert(tTable, "tTable equals nil");
	assert(sTableName, "sTableName equals nil");
	assert(hFile, "hFile equals nil");
	assert(type(tTable) == "table", "tTable must be a table!");
	assert(type(sTableName) == "string", "sTableName must be a string!");
	sTab = sTab or "";
	write(hFile, sTab..sTableName.." = {\n" );
	for key, value in tTable do
		local sKey = (type(key) == "string") and format("[%q]",key) or format("[%d]",key);
		if(type(value) == "table") then
			Save.Serialize(value, sKey, hFile, sTab.."\t");
		else
			local sValue = (type(value) == "string") and format("%q",value) or tostring(value);
			write(hFile, sTab.."\t"..sKey.." = "..sValue);
		end
		write(hFile, ",\n");
	end
	write(hFile, sTab.."}");
end
Save.File = function(table , tablename, file)
	local hFile = openfile(file, "w");
	Save.Serialize(table, tablename, hFile);
	closefile(hFile);
end
Save.Profiles = function()
	writeto("GeminiProfiles.lst") writeto()
	Profiles = {}
	Levels = {[-1] = "User"}
	for _,ProfileName in GetProfiles() do Levels[GetProfileIdx(ProfileName)] = ProfileName end
	for Idx,ProfileName in Levels do
Profiles[Idx] = {
	["ProfileName"] = ProfileName,
	["Share"] = {["Min"] = {["Share"] = 0,	["Unit"] = "GB"},["Max"] = {["Share"] = 0,["Unit"] = "GB"}},
	["MinSlots"] = 3,
	["MaxSlots"] = 30,
	["MaxHubs"] = 5,
	["SlotPerHub"] = 1,
	["Bandwidth"] = 30,
	["Mode"] = {	["Active"] = 1,["Passive"] = 1,["Socket5"] = 1},
	["Connection"] = {["28.8Kbps"] = 0,["33.6Kbps"] = 0,["56Kbps"] = 0,["ISDN"] = 1,["Satelite"] = 1,["Cable"] = 1,["DSL"] = 1,["LAN(T1)"] = 1,["LAN(T3)"] = 1},
	["Block_Blimiter"] = 1,
	["Check_Client"] = 1,
}
	end
	Save.File(Profiles,"Profiles","GeminiProfiles.lst")
	dofile("GeminiProfiles.lst")
end
--==#==#==#==#==#==#==#==#==#==#==#==#==#==#==#==#==#==#==#==#==-
sUnit = {}
sUnit["KB"]= 1024
sUnit["MB"]= 1048576
sUnit["GB"]= 1073741824
sUnit["TB"]= 1099511627776
--==#==#==#==#==#==#==#==#==#==#==#==#==#==#==#==#==#==#==#==#==-
--// NightLitch 2004-12-26
Everything could have been anything else and it would have just as much meaning.

NightLitch

New version coming shortly... With some big changes and fixes.

//NL
//NL

NightLitch

Script is updated:

Version: 0.9 build 16 for TD4
-------------------------------------------------------------------
* Rewrote the MyINFO Parsing and Letter Capture
* Changed some things in the client tables
* Changed the tables in in script only Bandwidth Limiters is
    Letter Checked for right Cap.
-------------------------------------------------------------------

GeminiClientChecker.rar

//NightLitch
//NL

[_XStaTiC_]

#33
Hi NightLitch
Syntax error: attempt to compare nil with number
stack traceback:
   1:  method `Slots' at line 102 [file `D:\PtokaX\scripts\GeminiClientChecker.lua']
   2:  function `DataArrival' at line 69 [file `D:\PtokaX\scripts\GeminiClientChecker.lua']

I'm getting this charracter > in the  connect message by slots.
Client: DCDM++ 
	 Version: 0.041 
	 Share: nothing 
	 Mode: Active 
	 Slots: 4> slot(s) 
	 Hubs: 7 hub(s) 
	 Bandwidth: unlimited kB/s 
	 Connection Speed: Cable 
	 Tag: <++ V:0.401,M:A,H:0/1/6,S:4> 
	 Descr: <++ V:0.401,M:A,H:0/1/6,S:4>

NightLitch

Thx for notice that going to fix it... that is a serious bug one can not live with... :D

update later today.

//NL
//NL

NightLitch

Script is updated:

Version: 0.9 build 18 for TD4
-------------------------------------------------------------------
* Fixed Slot Error found by [_XStaTiC_]
* Fixed Description
-------------------------------------------------------------------

GeminiClientChecker.rar

//NL
//NL

[_XStaTiC_]

#36
Thx NightLitch...

it's running again whitout errors yet

NightLitch

So everything is fine with this script ?

Any requests ? fixes ? addition ??

//NL
//NL

[_XStaTiC_]

Hi NightLitch...

well the script is running fine, but somethimes i see this little error


Syntax error: attempt to compare nil with number
stack traceback:
   1:  method `Slots' at line 112 [file `D:\PtokaX\scripts\GeminiClientChecker.lua']
   2:  function `DataArrival' at line 96 [file `D:\PtokaX\scripts\GeminiClientChecker.lua']

bastya_elvtars

caused by fake tags. i had it in lawmaker too.
Everything could have been anything else and it would have just as much meaning.

NightLitch

QuoteOriginally posted by [_XStaTiC_]
Hi NightLitch...

well the script is running fine, but somethimes i see this little error


Syntax error: attempt to compare nil with number
stack traceback:
   1:  method `Slots' at line 112 [file `D:\PtokaX\scripts\GeminiClientChecker.lua']
   2:  function `DataArrival' at line 96 [file `D:\PtokaX\scripts\GeminiClientChecker.lua']

Good going to look at it...

you didn't get a Message just for ops to send me a report and take the users Tag ????

Well I look into it.

//NL
//NL

NightLitch

Bug fixed, download script again from any link in this thread.
//NL

[_XStaTiC_]

#42
Quoteyou didn't get a Message just for ops to send me a report and take the users Tag ????
No but..  i have seen that fake tag before.
I think it was like this one ->  S:*
 

NightLitch

QuoteOriginally posted by [_XStaTiC_]
Quoteyou didn't get a Message just for ops to send me a report and take the users Tag ????
No but..  i have seen that fake tag before.
I think it was like this one ->  S:*
 


That should be solved...
//NL

[_XStaTiC_]

ok thank u very much NightLitch

Typhoon

QuoteOriginally posted by [_XStaTiC_]
Quoteyou didn't get a Message just for ops to send me a report and take the users Tag ????
No but..  i have seen that fake tag before.
I think it was like this one ->  S:*
 


 just to make you wiser :o) , that tag is NOT fake ...
on dcgui client the user has the option to set UNLIMITED slots, and that shows up in tag like that S:*
conclusion , "*" = infinity/unlimited/more than enough
:p


Typhoon?



SMF spam blocked by CleanTalk