Script to force that upload/download limits are set
 

Script to force that upload/download limits are set

Started by BAlexandrov, 29 December, 2004, 13:10:51

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

BAlexandrov

Hello guys!

Our hub is in serious trouble and it is possible to be closed...
It is situated in internal network of an ISP. The network is 100mbit ethernet one, and have more than 1000 users.
The hub is internally accessible only but gives very good speeds of 300 kb - 2 mb/sec depending on distance between users.
Our ISP insist that the hub overload their network will take steps to disable it.

That I am thinking of is to force all users to use bcdc and to set limits on upload and download speed to say...300-500 kb/sec this way there will be no load on the network.

I need script to enforce this policy. I
 already use Xsthetic that have limit of user agents. But for the limits - can't they be checked from the TAG?

I need that users have set limits bellow (or between) some values, if they are not - display them a message and either prevent them to download or disconnected (not banned).
Only unregistered and regular users must be checked.

What is your opinion?

PS. I failed to find forum for BCDC issues. The last version have problem with cyrillic characters but only on main chat, not in PM. Where can I ask for?

bastya_elvtars

#1
a) bcdc formatting.lua cant handle cyrillic

b) your script:

-- Have2Limit by bastya_elvtars
-- if no limit set or client has a too high limit it disconnects
-- supports DCPRO and DCGUI
-- please no buuuuuuuuuuuuuugs

-- // editable settings

-- set user levels here if you do not have the default profiles
-- [profileindex]=rank
-- the higher the rank is, the less likely user will be checked.


userlevels={

[-1]=1,

[0]=5,

[1]=4,

[2]=3,

[3]=2
}

checklevel=2 -- checks regs & nonregs now

upload_limit=300 -- same dimension as in BCDC++

-- // end of editable settings

function NewUserConnected(user)
	investigate(user)
end

function DataArrival(user,data)
	if strsub(data, 1, 7) == "$MyINFO" then
		if user.sMyInfoString and strlen (user.sMyInfoString) > (strlen(user.sName)+13) then
			investigate(user)
		end
	end
end

function checklimit(user)
	if strfind(user.sMyInfoString,"[BLU]") then
		local upstream
		local _,_,Slots = strfind(user.sMyInfoString, "H:[^,]+,S:(%d+).*>")
		local _,_,limit1=strfind(user.sMyInfoString,"[BLU]:(%d+)")
		local _,_,limit2 = strfind(user.sMyInfoString,"F:%d+/(%d+)")
		if Slots and Slots~="0" then
			if limit1 then
				upstream=calclimit(user,limit1,Slots)
			elseif limit2 then
				upstream=calclimit(user,limit2,Slots)
			end
		else
			user:SendData("SlotChk","You have a stupid client, it cannot show slots.")
			user:Disconnect()
		end
		return upstream
	end
end

function calclimit(user,limit,s)
	if strfind(user.sMyInfoString," userlevels[user.iProfile] then
		local limit=checklimit(user)
		if not limit or limit > upload_limit then
			user:SendData("LimitChk","Please set your upload limit to a maximum of "..upload_limit.." kB/s in your client. If you do not have a client capable of limiting, look at [URL]http://utrum.dyndns.org:8000/[/URL]")
		end
	end
end
Everything could have been anything else and it would have just as much meaning.

BAlexandrov

Thanks!


I test it in clear environment with PtokaX testdrive 4.99 (alternatives are acceptable)

It gives in scripts screen "Syntax Error: bad argument #1 to `strfind' (string expected, got nil)" when user connects.

plop

QuoteOriginally posted by BAlexandrov PS. I failed to find forum for BCDC issues. The last version have problem with cyrillic characters but only on main chat, not in PM. Where can I ask for?
you won't find it because it doesn't excist.
but you can try 2 ask in the dcdev hub.

plop
http://www.plop.nl lua scripts/howto\'s.
http://www.thegoldenangel.net
http://www.vikingshub.com
http://www.lua.org

>>----> he who fights hatred with hatred, drives the spreading of hatred <----<<

bastya_elvtars

#4
QuoteOriginally posted by plop
but you can try 2 ask in the dcdev hub.

plop

you must be kidding  :D

btw edited the script above.
Everything could have been anything else and it would have just as much meaning.

BAlexandrov

Hi, thanks for the fast response.

I've done little debugging with SendData's -

"local upstream" must be declared before the "if" in order to be in-scope when is returned.

Now it works well, bu there is another problem when after client is connected, user change his limits, the script is triggered with old value of the limit. (i've put "user:SendData("SlotChk","limit "..limit)" before "if not limit or limit > upload_limit then")
Why is that, can something be done?

Is there an easy way when user does not conform the limits to be prevented from downloading. If not then disconnect is enough.

bastya_elvtars

local upstream: thx missed ;)

hmm every myinfo gets checked. maybe if you fix the local upstream then it works

about dl blockling: not hard, but i do not like it and disagree with it so i won't make it. sorry
Everything could have been anything else and it would have just as much meaning.

[NL]Pur

Quotebut you can try 2 ask in the dcdev hub.

suicidal mission ?

bastya_elvtars

QuoteOriginally posted by [NL]Pur
Quotebut you can try 2 ask in the dcdev hub.

suicidal mission ?

they will say: ask in the forum
you ask in the forum: they say google it
you google it: find nothing
you ask again in the forum: they say ask in the hub
you ask in the hub: if you are lucky, you will get that answer, which is one simple sentence.  :rolleyes:
Everything could have been anything else and it would have just as much meaning.

plop

QuoteOriginally posted by bastya_elvtars
QuoteOriginally posted by [NL]Pur
Quotebut you can try 2 ask in the dcdev hub.

suicidal mission ?

they will say: ask in the forum
you ask in the forum: they say google it
you google it: find nothing
you ask again in the forum: they say ask in the hub
you ask in the hub: if you are lucky, you will get that answer, which is one simple sentence.  :rolleyes:
the way you ask is the key factor.
show in your question that you allready tryed all way's you could think of.
then you get a normal answer.
but i do agree, they can give very rude/stupid answers.

plop
http://www.plop.nl lua scripts/howto\'s.
http://www.thegoldenangel.net
http://www.vikingshub.com
http://www.lua.org

>>----> he who fights hatred with hatred, drives the spreading of hatred <----<<

bastya_elvtars

IMHO the key factor is the ? in the end of the line.

all other main chat post are welcome in dcdev.

 :D
Everything could have been anything else and it would have just as much meaning.

plop

QuoteOriginally posted by bastya_elvtars
IMHO the key factor is the ? in the end of the line.

all other main chat post are welcome in dcdev.

 :D
where did you found that weird char.

plop
http://www.plop.nl lua scripts/howto\'s.
http://www.thegoldenangel.net
http://www.vikingshub.com
http://www.lua.org

>>----> he who fights hatred with hatred, drives the spreading of hatred <----<<

bastya_elvtars

Everything could have been anything else and it would have just as much meaning.

BAlexandrov

QuoteOriginally posted by bastya_elvtars
local upstream: thx missed ;)

hmm every myinfo gets checked. maybe if you fix the local upstream then it works

about dl blockling: not hard, but i do not like it and disagree with it so i won't make it. sorry

After I've moved "local upstream" it began to work, but when limit is changed after connect - the check is triggered with the previous value of the limit.

Here is example.
In function "function investigate(user)"

Ive added user:SendData above the if like:
"
      user:SendData("SlotChk","limit "..limit)
      
      if not limit or limit > upload_limit then
"
I've connected with limit 200
then changed it to 400,500,100,150
Watch messages and the warning - they are for the previous value of the limit. Very strange...

[15:43] limit 200 <-- initial connnect
[15:43] limit 200 <-- after set 400
[15:43] limit 400 <-- after 500
[15:43] Please set your upload limit to a maximum of 300 kB/s in your client. If you do not have a client capable of limiting, look at http://utrum.dyndns.org:8000/
[15:43] limit 500 <--after 100
[15:43] Please set your upload limit to a maximum of 300 kB/s in your client. If you do not have a client capable of limiting, look at http://utrum.dyndns.org:8000/
[15:44] limit 100 <-- after 150

bastya_elvtars

#14
i bet this is a client error. it sends myinfo badly.

it analyzes every myinfo, the check is fully objective.

enable CMDs in the ptokax users and chat screen and se what myinfos you send when setting limit.
Everything could have been anything else and it would have just as much meaning.

BAlexandrov

nope... it comes correctly
I've connected with 150, then changed to 400, then 200

[17:40] 192.168.112.30:1775 > $MyINFO $ALL Bojo3 <++ V:0.668,M:A,H:1/0/0,S:20,B:150>$ $LAN(T3)$bojo@bojo$0$|
[17:40] 192.168.112.30:1775 > $MyINFO $ALL Bojo3 <++ V:0.668,M:A,H:1/0/0,S:20,B:400>$ $LAN(T3)$bojo@bojo$0$|
[17:41] 192.168.112.30:1775 > $MyINFO $ALL Bojo3 <++ V:0.668,M:A,H:1/0/0,S:20,B:200>$ $LAN(T3)$bojo@bojo$0$|

bastya_elvtars

edited the script above.
Everything could have been anything else and it would have just as much meaning.

BAlexandrov

Sorry that I have to say it but it it works the same way:
I've started with 600
then changed it to 400,200,500
PtocaX log looks like:
[19:14] 192.168.112.30:1956 > $MyINFO $ALL Bojo3 <++ V:0.668,M:A,H:1/0/0,S:20,B:400>$ $LAN(T3)$bojo@developer.bg$0$|
[19:14] 192.168.112.30:1956 > $MyINFO $ALL Bojo3 <++ V:0.668,M:A,H:1/0/0,S:20,B:200>$ $LAN(T3)$bojo@developer.bg$0$|
[19:14] 192.168.112.30:1956 > $MyINFO $ALL Bojo3 <++ V:0.668,M:A,H:1/0/0,S:20,B:500>$ $LAN(T3)$bojo@developer.bg$0$|

bcdc main chat  (i've added
"
->      user:SendData("SlotChk","limit "..limit)

      if not limit or limit > upload_limit then
")


[19:14] limit 600
[19:14] Please set your upload limit to a maximum of 300 kB/s in your client. If you do not have a client capable of limiting, look at http://utrum.dyndns.org:8000/
[19:14] limit 400
[19:14] Please set your upload limit to a maximum of 300 kB/s in your client. If you do not have a client capable of limiting, look at http://utrum.dyndns.org:8000/
[19:14] limit 200

bastya_elvtars

heh, this is not a script error.

the script gets the number from after B:/L:/U:/F: and analyzes it, so dunno what can be wrong.
Everything could have been anything else and it would have just as much meaning.

plop

dcgui can have a limiter set to 100.80.
also take this into count.

plop
http://www.plop.nl lua scripts/howto\'s.
http://www.thegoldenangel.net
http://www.vikingshub.com
http://www.lua.org

>>----> he who fights hatred with hatred, drives the spreading of hatred <----<<

BAlexandrov

QuoteOriginally posted by plop
dcgui can have a limiter set to 100.80.
also take this into count.

plop

We plan to use ptocax with bcdc, dcgui is another client with function to set limits?

What is your suggestion, plop, where is the problem with previous values?
It really looks like problem in the hub server and scripting engine...

Must I try another hub server (I use now PtocaX 0.3.2.6 testdrive 4.99), or another client (bcdc 0.668 latest)

bastya_elvtars

@plop: d'uh then it will be a bit miscounted ;)

@BAlexandrov: TD4 is downloadable from plop's site: http://www.plop.nl/ptokax/PtokaX-0.326.TestDrive4.zip

(my sig does not work atm)
Everything could have been anything else and it would have just as much meaning.

lyte

hello, can sum1 change this script to check only reg users
" checkin if reg ppl have dl and upl limited to 50KB on bcdc"

may sum1 do dat?

SMF spam blocked by CleanTalk