Ejemplo n.º 1
0
    def __init__(self, observable_update_callback, host_ip, sender_callback, *args, **keys):
        """Shall initialize the given parameters as attributes and call the constructor of the super class.

        The observable_update_callback is in fact the update method of the observable
        implementation (in this case it may be UDPUpdateObservable). This method is called
        as a request is precessed by the handle method. As long as the received data is not
        sent by the the same host as it was received (I sent data to myself), the callback
        method is called. I define the "I sent data to myself"-thing as kickback.

        As a result of receiving lists from other hosts, the rhythm of sending our list
        to the multicast group has to be expanded. This is done by calling the sender_callback
        method. Which in fact is to expand the time of the sending rhythm.

        :param observable_update_callback: The callback of the observable implementation
        :param host_ip: The ip address of the host, where this handler is running
        :param sender_callback: The callback of the sending Thread.
        :param args: arguments for the BaseRequestHandler
        :param keys: keys for the BaseRequestHandler
        :return: None
        """
        self._observable_callback = observable_update_callback
        self._sender_callback = sender_callback

        self._own_ip = host_ip
        self._logger = Log.get_logger(self.__class__.__name__)
        BaseRequestHandler.__init__(self, *args, **keys)
Ejemplo n.º 2
0
 def __init__(self, request, client_address, server):
     # circumvent Transport.__init__, since none of the threading logic is used here
     #Transport.__init__(self)
     self._on_received = None
     self.keepalive_msg = server.mux.keepalive_msg
     self.keepalive_interval = server.mux.keepalive_interval
     self.buffersize = server.mux.buffersize
     self._keepalive_countdown = self.keepalive_interval
     BaseRequestHandler.__init__(self, request, client_address, server)
Ejemplo n.º 3
0
  def __init__(self, request, client_address, server, handshake_keys, output_handler):
    self._handshake = handshake_keys[0]
    self._close_key = handshake_keys[1]

    # If no handshake, authentication is assummed
    self._wait_for_right_client = True if self._handshake else False
    self._client_connected = False
    self._pinger = None
    self._closed_by_client = False
    self._output_handler = output_handler

    BaseRequestHandler.__init__(self, request, client_address, server)
Ejemplo n.º 4
0
    def __init__(self, request, client_address, server):
        """Constructor.

        When called without arguments, create an unconnected instance.
        With a hostname argument, it connects the instance; a port
        number is optional.
        """
        # Am I doing the echoing?
        self.DOECHO = True
        # What opts have I sent DO/DONT for and what did I send?
        self.DOOPTS = {}
        # What opts have I sent WILL/WONT for and what did I send?
        self.WILLOPTS = {}

        # What commands does this CLI support
        self.COMMANDS = {}
        self.sock = None  # TCP socket
        self.rawq = ''  # Raw input string
        self.sbdataq = ''  # Sub-Neg string
        self.eof = 0  # Has EOF been reached?
        self.iacseq = ''  # Buffer for IAC sequence.
        self.sb = 0  # Flag for SB and SE sequence.
        self.history = []  # Command history
        self.RUNSHELL = True
        # A little magic - Everything called cmdXXX is a command
        # Also, check for decorated functions
        for k in dir(self):
            method = getattr(self, k)
            try:
                name = method.command_name
            except:
                if k[:3] == 'cmd':
                    name = k[3:]
                else:
                    continue

            name = name.upper()
            self.COMMANDS[name] = method
            for alias in getattr(method, "aliases", []):
                self.COMMANDS[alias.upper()] = self.COMMANDS[name]

        BaseRequestHandler.__init__(self, request, client_address, server)
Ejemplo n.º 5
0
 def __init__(self, request, client_address, server):
     self.request = request
     self.client_address = client_address
     self.tcp_server = server
     
     # Keep track of channel information from the transport
     self.channels = {}
     
     self.client = request._sock
     # Transport turns the socket into an SSH transport
     self.transport = Transport(self.client)
     
     # Create the PTY handler class by mixing in
     TelnetHandlerClass = self.telnet_handler
     class MixedPtyHandler(TelnetToPtyHandler, TelnetHandlerClass):
         # BaseRequestHandler does not inherit from object, must call the __init__ directly
         def __init__(self, *args):
             TelnetHandlerClass.__init__(self, *args)
     self.pty_handler = MixedPtyHandler
     
     
     # Call the base class to run the handler
     BaseRequestHandler.__init__(self, request, client_address, server)
Ejemplo n.º 6
0
 def __init__(self, request, client_address, server):
     self._request_id = itertools.count(1)
     Thread(target=self._heartbeat_loop, daemon=True).start()
     BaseRequestHandler.__init__(self, request, client_address, server)
Ejemplo n.º 7
0
 def __init__(self, callback, srv_uri, *args, **keys):
     self.callback = callback
     self.srv_uri = srv_uri
     BaseRequestHandler.__init__(self, *args, **keys)
Ejemplo n.º 8
0
 def __init__(self, request, client_address, server):
     print("__init__")
     #self.b = SMBus(5)
     BaseRequestHandler.__init__(self, request, client_address, server)
Ejemplo n.º 9
0
 def __init__(self, request, client_address, server):
     logging.debug("__init__")
     BaseRequestHandler.__init__(self, request, client_address, server)
Ejemplo n.º 10
0
 def __init__(self, request, client_address, server):
     self.my_init()
     BaseRequestHandler.__init__(self, request, client_address, server)
     return
Ejemplo n.º 11
0
 def __init__(self, balance: Onionbalance, *args, **kwargs):
     StatusSocketHandlerMixin.__init__(self, balance)
     BaseRequestHandler.__init__(self, *args, **kwargs)
Ejemplo n.º 12
0
 def __init__(self, callbacks: TCPCallbacks,
              settingsManager: ConfigurationManager, *args, **kwargs):
     self._callbacks = callbacks
     self._settingsManager = settingsManager
     BaseRequestHandler.__init__(self, *args, **kwargs)
Ejemplo n.º 13
0
 def __init__(self, request, client_address, server):
     BaseRequestHandler.__init__(self, request, client_address, server)
     Transport.__init__(self)
Ejemplo n.º 14
0
 def __init__(self, *args):
     '''
     Constructor
     '''
     BaseRequestHandler.__init__(self, *args)
     self.callback = None
Ejemplo n.º 15
0
 def __init__(self, request, client_address, server, filesystem):
     self._fs = filesystem
     self._cwd = PurePosixPath('/')
     BaseRequestHandler.__init__(self, request, client_address, server)
Ejemplo n.º 16
0
 def __init__(self, *args):
     BaseRequestHandler.__init__(self, *args)