403Webshell
Server IP : 61.19.30.66  /  Your IP : 216.73.216.15
Web Server : Apache/2.2.22 (Ubuntu)
System : Linux klw 3.11.0-15-generic #25~precise1-Ubuntu SMP Thu Jan 30 17:39:31 UTC 2014 x86_64
User : www-data ( 33)
PHP Version : 5.3.10-1ubuntu3.48
Disable Function : pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,
MySQL : ON  |  cURL : OFF  |  WGET : ON  |  Perl : ON  |  Python : ON  |  Sudo : ON  |  Pkexec : OFF
Directory :  /usr/lib/python2.7/dist-packages/twisted/protocols/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /usr/lib/python2.7/dist-packages/twisted/protocols/htb.pyc
ó
[³XMc@sdZddlmZddd!ZddlmZddlmZmZddlm	Z	d	dd
„ƒYZ
defd„ƒYZd
dd„ƒYZdefd„ƒYZ
defd„ƒYZde	jfd„ƒYZdefd„ƒYZddd„ƒYZdS(sÑHierarchical Token Bucket traffic shaping.

Patterned after U{Martin Devera's Hierarchical Token Bucket traffic
shaper for the Linux kernel<http://luxik.cdi.cz/~devik/qos/htb/>}.

@seealso: U{HTB Linux queuing discipline manual - user guide
  <http://luxik.cdi.cz/~devik/qos/htb/manual/userg.htm>}
@seealso: U{Token Bucket Filter in Linux Advanced Routing & Traffic Control
    HOWTO<http://lartc.org/howto/lartc.qdisc.classless.html#AEN682>}
@author: Kevin Turner
iÿÿÿÿ(t
nested_scopess$Revision: 1.5 $iiþÿÿÿ(ttime(t
implementst	Interface(tpcptBucketcBs>eZdZdZdZdZdd„Zd„Zd„Z	RS(snToken bucket, or something like it.

    I can hold up to a certain number of tokens, and I drain over time.

    @cvar maxburst: Size of the bucket, in bytes.  If None, the bucket is
        never full.
    @type maxburst: int
    @cvar rate: Rate the bucket drains, in bytes per second.  If None,
        the bucket drains instantaneously.
    @type rate: int
    icCs"d|_||_tƒ|_dS(Ni(tcontenttparentBucketRtlastDrip(tselfR((s9/usr/lib/python2.7/dist-packages/twisted/protocols/htb.pyt__init__3s		cCsr|jƒ|jdkr"|}nt||j|jƒ}|jdk	r_|jj|ƒ}n|j|7_|S(s³Add tokens to me.

        @param amount: A quanity of tokens to add.
        @type amount: int

        @returns: The number of tokens that fit.
        @returntype: int
        N(tdriptmaxbursttNonetminRRtadd(R	tamountt	allowable((s9/usr/lib/python2.7/dist-packages/twisted/protocols/htb.pyR8s	
	cCsˆ|jdk	r|jjƒn|jdkr;d|_tStƒ}||j}tt	d|j||jƒƒ|_||_t
SdS(sÓLet some of the bucket drain.

        How much of the bucket drains depends on how long it has been
        since I was last called.

        @returns: True if I am now empty.
        @returntype: bool
        iN(RR
RtrateRtTrueRRtlongtmaxtFalse(R	tnowtdeltaT((s9/usr/lib/python2.7/dist-packages/twisted/protocols/htb.pyRLs			
&	N(
t__name__t
__module__t__doc__R
RRt	_refcountR
RR(((s9/usr/lib/python2.7/dist-packages/twisted/protocols/htb.pyR!s	t
IBucketFiltercBseZd„ZRS(cOsdS(sNI'll give you a bucket for something.

        @returntype: L{Bucket}
        N((t
somethingstsome_kw((s9/usr/lib/python2.7/dist-packages/twisted/protocols/htb.pytgetBucketFords(RRR (((s9/usr/lib/python2.7/dist-packages/twisted/protocols/htb.pyRcstHierarchicalBucketFiltercBsKeZdZeeƒeZdZdd„Z	d„Z
d„Zd„ZRS(s÷I filter things into buckets, and I am nestable.

    @cvar bucketFactory: Class of buckets to make.
    @type bucketFactory: L{Bucket} class
    @cvar sweepInterval: Seconds between sweeping out the bucket cache.
    @type sweepInterval: int
    cCs"i|_||_tƒ|_dS(N(tbucketstparentFilterRt	lastSweep(R	R#((s9/usr/lib/python2.7/dist-packages/twisted/protocols/htb.pyR
xs		cOs²|jdk	r5tƒ|j|jkr5|jƒn|jrY|jj|||Ž}nd}|j||Ž}|jj	|ƒ}|dkr®|j
|ƒ}||j|<n|S(sÊYou want a bucket for that?  I'll give you a bucket.

        Any parameters are passed on to L{getBucketKey}, from them it
        decides which bucket you get.

        @returntype: L{Bucket}
        N(t
sweepIntervalR
RR$tsweepR#R tgetBucketKeyR"tgett
bucketFactory(R	tatkwRtkeytbucket((s9/usr/lib/python2.7/dist-packages/twisted/protocols/htb.pyR }s
	cOsdS(s²I determine who gets which bucket.

        Unless I'm overridden, everything gets the same bucket.

        @returns: something to be used as a key in the bucket cache.
        N(R
(R	R*R+((s9/usr/lib/python2.7/dist-packages/twisted/protocols/htb.pyR'•scCsXxE|jjƒD]4\}}|jdkr|jƒr|j|=qqWtƒ|_dS(s)I throw away references to empty buckets.iN(R"titemsRRRR$(R	R,R-((s9/usr/lib/python2.7/dist-packages/twisted/protocols/htb.pyR&žsN(
RRRRRRR)R
R%R
R R'R&(((s9/usr/lib/python2.7/dist-packages/twisted/protocols/htb.pyR!js
			tFilterByHostcBseZdZdZd„ZRS(s1A bucket filter with a bucket for each host.
    i<icCs|jƒdS(Ni(tgetPeer(R	t	transport((s9/usr/lib/python2.7/dist-packages/twisted/protocols/htb.pyR'¬si°(RRRR%R'(((s9/usr/lib/python2.7/dist-packages/twisted/protocols/htb.pyR/§stFilterByServercBseZdZdZd„ZRS(s4A bucket filter with a bucket for each service.
    cCs|jƒdS(Ni(tgetHost(R	R1((s9/usr/lib/python2.7/dist-packages/twisted/protocols/htb.pyR'µsN(RRRR
R%R'(((s9/usr/lib/python2.7/dist-packages/twisted/protocols/htb.pyR2°stShapedConsumercBs/eZdZeZd„Zd„Zd„ZRS(sDI wrap a Consumer and shape the rate at which it receives data.
    cCs2tjj||ƒ||_|jjd7_dS(Ni(RtProducerConsumerProxyR
R-R(R	tconsumerR-((s9/usr/lib/python2.7/dist-packages/twisted/protocols/htb.pyR
Às	cCs/|jjt|ƒƒ}tjj||| ƒS(N(R-RtlenRR5t_writeSomeData(R	tdataR((s9/usr/lib/python2.7/dist-packages/twisted/protocols/htb.pyR8ÅscCs&tjj|ƒ|jjd8_dS(Ni(RR5t
stopProducingR-R(R	((s9/usr/lib/python2.7/dist-packages/twisted/protocols/htb.pyR:Ís(RRRRtiAmStreamingR
R8R:(((s9/usr/lib/python2.7/dist-packages/twisted/protocols/htb.pyR4¹s
		tShapedTransportcBseZdZeZd„ZRS(s7I wrap a Transport and shape the rate at which it receives data.

    I am a L{ShapedConsumer} with a little bit of magic to provide for
    the case where the consumer I wrap is also a Transport and people
    will be attempting to access attributes I do not proxy as a
    Consumer (e.g. loseConnection).
    cCst|j|ƒS(N(tgetattrR6(R	tname((s9/usr/lib/python2.7/dist-packages/twisted/protocols/htb.pyt__getattr__Ýs(RRRRR;R?(((s9/usr/lib/python2.7/dist-packages/twisted/protocols/htb.pyR<ÒstShapedProtocolFactorycBs eZdZd„Zd„ZRS(sƒI dispense Protocols with traffic shaping on their transports.

    Usage::

        myserver = SomeFactory()
        myserver.protocol = ShapedProtocolFactory(myserver.protocol,
                                                  bucketFilter)

    Where SomeServerFactory is a L{twisted.internet.protocol.Factory}, and
    bucketFilter is an instance of L{HierarchicalBucketFilter}.
    cCs||_||_dS(sTell me what to wrap and where to get buckets.

        @param protoClass: The class of Protocol I will generate
          wrapped instances of.
        @type protoClass: L{Protocol<twisted.internet.interfaces.IProtocol>}
          class
        @param bucketFilter: The filter which will determine how
          traffic is shaped.
        @type bucketFilter: L{HierarchicalBucketFilter}.
        N(tprotocoltbucketFilter(R	t
protoClassRB((s9/usr/lib/python2.7/dist-packages/twisted/protocols/htb.pyR
ïs
	cs:ˆj||Ž}|j‰‡‡fd†}||_|S(sÅMake a Protocol instance with a shaped transport.

        Any parameters will be passed on to the protocol's initializer.

        @returns: a Protocol instance with a L{ShapedTransport}.
        cs+ˆjj|ƒ}t||ƒ}ˆ|ƒS(N(RBR R<(R1R-tshapedTransport(R	torigMakeConnection(s9/usr/lib/python2.7/dist-packages/twisted/protocols/htb.pytmakeConnections(RARF(R	R*R+tprotoRF((R	REs9/usr/lib/python2.7/dist-packages/twisted/protocols/htb.pyt__call__ÿs
		(RRRR
RH(((s9/usr/lib/python2.7/dist-packages/twisted/protocols/htb.pyR@ãs	N((((Rt
__future__Rt__version__Rtzope.interfaceRRttwisted.protocolsRRRR!R/R2R5R4R<R@(((s9/usr/lib/python2.7/dist-packages/twisted/protocols/htb.pyt<module>s
B=		

Youez - 2016 - github.com/yon3zu
LinuXploit