|
System | : | Linux MiraNet 3.0.0-14-generic-pae #23-Ubuntu SMP Mon Nov 21 22:07:10 UTC 2011 i686 |
Software | : | Apache. PHP/5.3.6-13ubuntu3.10 |
ID | : | uid=65534(nobody) gid=65534(nogroup) groups=65534(nogroup)
|
|
Safe Mode | : | OFF |
Open_Basedir | : | OFF |
Freespace | : | 21.69 GB of 70.42 GB (30.8%) |
|
MySQL: ON MSSQL: OFF Oracle: OFF PostgreSQL: OFF Curl: OFF Sockets: ON Fetch: OFF Wget: ON Perl: ON |
Disabled Functions: 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,
|
[ System Info ]
[ Processes ]
[ SQL Manager ]
[ Eval ]
[ Encoder ]
[ Mailer ]
[ Back Connection ]
[ Backdoor Server ]
[ Kernel Exploit Search ]
[ MD5 Decrypter ]
[ Reverse IP ]
[ Kill Shell ]
[ FTP Brute-Force ]
|
|
/
usr/
lib/
python2.6/
dist-packages/
twisted/
protocols/
- drwxr-xr-x
|
Viewing file: stateful.py (1.67 KB) -rw-r--r--Select action/file-type:  ( +) |  ( +) |  ( +) | Code ( +) | Session ( +) |  ( +) | SDB ( +) |  ( +) |  ( +) |  ( +) |  ( +) |  ( +) |
# -*- test-case-name: twisted.test.test_stateful -*-
# Copyright (c) Twisted Matrix Laboratories. # See LICENSE for details.
from twisted.internet import protocol
try: from cStringIO import StringIO except ImportError: from StringIO import StringIO
class StatefulProtocol(protocol.Protocol): """A Protocol that stores state for you.
state is a pair (function, num_bytes). When num_bytes bytes of data arrives from the network, function is called. It is expected to return the next state or None to keep same state. Initial state is returned by getInitialState (override it). """ _sful_data = None, None, 0
def makeConnection(self, transport): protocol.Protocol.makeConnection(self, transport) self._sful_data = self.getInitialState(), StringIO(), 0
def getInitialState(self): raise NotImplementedError
def dataReceived(self, data): state, buffer, offset = self._sful_data buffer.seek(0, 2) buffer.write(data) blen = buffer.tell() # how many bytes total is in the buffer buffer.seek(offset) while blen - offset >= state[1]: d = buffer.read(state[1]) offset += state[1] next = state[0](d) if self.transport.disconnecting: # XXX: argh stupid hack borrowed right from LineReceiver return # dataReceived won't be called again, so who cares about consistent state if next: state = next if offset != 0: b = buffer.read() buffer.seek(0) buffer.truncate() buffer.write(b) offset = 0 self._sful_data = state, buffer, offset
|