PtokaX forum

Archive => Archived 5.0 boards => Request for scripts => Topic started by: kash? on 11 October, 2005, 23:02:41

Title: SPEED Limit !
Post by: kash? on 11 October, 2005, 23:02:41
I wanted a script which will disconnect user if he
does not keep download and upload speed
limit less than 1024 Kb/s.

In other words if a user has not set d/l and u/l
speed limit or has kept more than 1024 Kb/s,
he will get disconnection message

Clients= CZDC++ and StrongDC++

For e.g.
[02:17:16] Your nickname is registered. Please supply the password.
[02:17:16] *** Stored password sent...
[02:17:16] Please use CZDC++ or StrongDC++and set an upload transfer limit of 1024 KB/Sec.
[02:17:16] *** Disconnected

Waiting for reply,
Regards
Title:
Post by: bastya_elvtars on 11 October, 2005, 23:05:48
Search for Have2Limit, I will convert it to LUA5 ASAP.
Title:
Post by: Markitos on 12 October, 2005, 09:08:36
Try this...
-- Have2Limit by bastya_elvtars

-- if no limit set or client has a too high limit it disconnects

-- supports DCPRO and DCGUI

-- please no buuuuuuuuuuuuuugs

-- Converted to lua5 by Markitos 12/10/05


-- // 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 ChatArrival(user,data)

if str.sub(data, 1, 7) == "$MyINFO" then

if user.sMyInfoString and str.len (user.sMyInfoString) > (str.len(user.sName)+13) then

investigate(user)

end

end

end



function checklimit(user)

if str.find(user.sMyInfoString,"[BLU]") then

local upstream

local _,_,Slots = str.find(user.sMyInfoString, "H:[^,]+,S:(%d+).*>")

local _,_,limit1=str.find(user.sMyInfoString,"[BLU]:(%d+)")

local _,_,limit2 = str.find(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 str.find(user.sMyInfoString,"
return tonumber(limit)*tonumber(s)

else

return tonumber(limit)

end

end



function investigate(user)

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


Cheers
Title:
Post by: kash? on 12 October, 2005, 09:40:53
I tried that script but it's not working
He wanted speed limit
but I want that if a user has not kept speed limit
in CZDC++ or StrongDC++, he will simply get
disconnected.

For e.g. If user has not set speed limit or kept speed
limit in excess of 1024 Kb/s in File > Settings > Limits
he will simply get disconnected

PLZ I want this in urgent
If any1 can help, it will be great
Title:
Post by: Jelf on 12 October, 2005, 09:53:40
Heres the one above properly converted...
-- Have2Limit by bastya_elvtars
-- if no limit set or client has a too high limit it disconnects
-- supports DCPRO and DCGUI
-- please no buuuuuuuuuuuuuugs
-- Correctly converted to LUA5 by Jelf 12/10/05
-- // 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 MyINFOArrival(user, data)
if user.sMyInfoString and string.len (user.sMyInfoString) > (string.len(user.sName)+13) then
investigate(user)
end
end

function checklimit(user)
if string.find(user.sMyInfoString,"[BLU]") then
local upstream
local _,_,Slots = string.find(user.sMyInfoString, "H:[^,]+,S:(%d+).*>")
local _,_,limit1 = string.find(user.sMyInfoString,"[BLU]:(%d+)")
local _,_,limit2 = string.find(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 string.find(user.sMyInfoString," return tonumber(limit)*tonumber(s)
else
return tonumber(limit)
end
end

function investigate(user)
if checklevel > 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
Enjoy
Title:
Post by: bastya_elvtars on 12 October, 2005, 10:12:30
This will use a bit less CPU time.

-- Have2Limit by bastya_elvtars

-- if no limit set or client has a too high limit it disconnects

-- supports DCPRO and DCGUI

-- please no buuuuuuuuuuuuuugs

-- Correctly converted to LUA5 by Jelf 12/10/05

-- // 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.
-- converted by Jelf
-- removed TD4 workarounds by bastya_elvtars

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 MyINFOArrival(user, data)
  investigate(user)
end



function checklimit(user)
    if string.find(user.sMyInfoString,"[BLU]") then
      local upstream
      local _,_,Slots = string.find(user.sMyInfoString, "H:[^,]+,S:(%d+).*>")
      local _,_,limit1 = string.find(user.sMyInfoString,"[BLU]:(%d+)")
      local _,_,limit2 = string.find(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 string.find(user.sMyInfoString,"    return tonumber(limit)*tonumber(s)
  else
    return tonumber(limit)
  end
end

function investigate(user)
  if checklevel > 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
Title:
Post by: Jelf on 12 October, 2005, 10:20:22
nice one bastya, wasnt sure if that MyINFO line should stay there or not.

Always learning.
Title:
Post by: kash? on 12 October, 2005, 10:25:25
The script is not giving any error but I could connect
with higher d/l and u/l limit
I want to disconnect even master has kept more
speed limit
I dont know why I am not getting disconnected
Title: So...
Post by: Markitos on 12 October, 2005, 10:26:10
What was wrong with my convertion?
Title:
Post by: Jelf on 12 October, 2005, 10:33:44
kash?  - have you changed these settings?

checklevel = 2 -- checks regs & nonregs now
upload_limit = 300 -- same dimension as in BCDC++

You will only get disconnected if you have no slots or the client isnt showing how many slots.

Add this to the last line in function Investigate underneathuser:SendData("LimitChk","Please set your upload limit .... user:Disconnect()to disconnect anyone that has limit set wrong

Markitos  - you used str.find and str.len instead of string.find and string.len and ChatArrival instead of MyINFOArrival.
Title:
Post by: bastya_elvtars on 12 October, 2005, 10:42:44
QuoteOriginally posted by kash?
The script is not giving any error but I could connect
with higher d/l and u/l limit
I want to disconnect even master has kept more
speed limit
I dont know why I am not getting disconnected

Set checklevel to 6.
Title:
Post by: kash? on 12 October, 2005, 10:55:38
First of all thanx guys for responding and helping
I tried three of the scripts above but I still can
connect with higher spped limit
I have simply pasted entire script without any
editing

What I need to or I am not doing in that script
to work ?
Title: Thnks!
Post by: Markitos on 12 October, 2005, 14:26:06
QuoteOriginally posted by Jelf
kash?  - have you changed these settings?

checklevel = 2 -- checks regs & nonregs now
upload_limit = 300 -- same dimension as in BCDC++

You will only get disconnected if you have no slots or the client isnt showing how many slots.

Add this to the last line in function Investigate underneathuser:SendData("LimitChk","Please set your upload limit .... user:Disconnect()to disconnect anyone that has limit set wrong

Markitos  - you used str.find and str.len instead of string.find and string.len and ChatArrival instead of MyINFOArrival.
Title:
Post by: kash? on 12 October, 2005, 15:05:14
It is working fine for upload limit but I wanted same
limit for download also

If I increase upload limit, it gives me disconnect message
but if I increase download limit, I get connected

And also a user should be able to connect only
by CZDC++ and StrongDC++ (Only these 2 clients)
Title:
Post by: bastya_elvtars on 12 October, 2005, 15:16:34
Is DL limit shown in the tag? I think no...
Title:
Post by: kash? on 12 October, 2005, 15:43:20
If I increase upload limit, it gives me disconnect message
but if I increase download limit, I get connected
File > Settings > Limits > DOwnload Speed
Cant it be edited the same way as for upload

And also a user should be able to connect only
by CZDC++ and StrongDC++ (Only these 2 clients)
Not by DC++, oDC, etc. coz in these clients, one
can not set limits and they can d/l at higher speeds
Title:
Post by: Madman on 12 October, 2005, 16:11:43
DL Speed limit does not show in tag...
And why do you want to make user to not download above 1024 kb/s?
Title:
Post by: kash? on 12 October, 2005, 16:33:00
QuoteAnd why do you want to make user to not download above 1024 kb/s?


Otherwise our ISP will put Firewall and seperate
LAN and divide as per areas because we d/l
at the speed of 5 - 10 mbs


If I increase upload limit, it gives me disconnect message
but if I increase download limit, I get connected
File > Settings > Limits > DOwnload Speed
Cant it be edited the same way as for upload

And also a user should be able to connect only
by CZDC++ and StrongDC++
 (Only these 2 clients)
Not by DC++, oDC, etc. coz in these clients, one
can not set limits and they can d/l at higher speeds

That's why I need this script badly...
Title:
Post by: bastya_elvtars on 12 October, 2005, 17:58:46
Only 1 client can show the DL limit in the tag: DC:PRO.

CZDC++ cannot be detected properly AFAIK. Pothead? :P
Title:
Post by: kash? on 12 October, 2005, 19:25:03
When I keep upload  limit more than 1024 Kb/s
I get that disconnection message but what I want
is a user should get disconnected if he keeps download  limit more than 1024 Kb/s

With the help of above scripts posted, I can restrict users from connecting hubs with more than 1024 Kb/s
(any speed set) upload speed but can you also
add same thing for download as well

In short, user with more than 1024 kb/s (d/l and u/l both) should get disconnected and not only upload
He msut keep both speeds as per prescribed limit
in order to connect hub
Title:
Post by: casio on 12 October, 2005, 22:28:02
i req similar script
1 . limit uploads for all clients ie users even ops at 1024 k
2 . support all clients that provide upload limit
3 . rev connect, strong should be supported as they support segmented downloding from multipal source .....but upload limt of 1024 k should be maintained ...........as we run hub on lan they help us reduce network congession
4 .different messages should be displayed if the clients do not meet above req and also possible alternative
5 . ip of user should be logged on connect
6 . change in ip should be notified to user but he should be disconnected only if he logs in twice using  different ip

*****if possible temporary .ie on next log in allow user to  break upload limit only onec  control only with admin

thanks before hand