Esempio n. 1
0
    def __init__(self, src_sock, other_side=None):
        """Proxies one side of a client-server connection.

        MinecraftProxy instances are created in pairs that have references to
        one another. Since a client initiates a connection, the client side of
        the pair is always created first, with other_side = None. The creator
        of the client proxy is then responsible for connecting to the server
        and creating a server proxy with other_side=client. Finally, the
        proxy creator should do client_proxy.other_side = server_proxy.
        """
        super(MinecraftProxy, self).__init__()

        self.sock = src_sock
        self.closed = False
        self.plugin_mgr = None
        self.other_side = other_side
        self.rsa_key = None
        self.shared_secret = None
        self.challenge_token = None
        self.send_cipher = None
        self.recv_cipher = None
        if other_side == None:
            self.side = 'client'
            self.msg_spec = messages.protocol[0][0]
            self.rsa_key = rsa_key
            self.username = None
        else:
            self.side = 'server'
            self.msg_spec = messages.protocol[0][1]
            self.other_side.other_side = self
            self.shared_secret = encryption.generate_shared_secret()
        self.stream = Stream()
        self.last_report = 0
        self.msg_queue = []
        self.out_of_sync = False
Esempio n. 2
0
    def __init__(self, src_sock, other_side=None):
        """Proxies one side of a client-server connection.

        MinecraftProxy instances are created in pairs that have references to
        one another. Since a client initiates a connection, the client side of
        the pair is always created first, with other_side = None. The creator
        of the client proxy is then responsible for connecting to the server
        and creating a server proxy with other_side=client. Finally, the
        proxy creator should do client_proxy.other_side = server_proxy.
        """
        asyncore.dispatcher_with_send.__init__(self, src_sock)
        self.plugin_mgr = None
        self.other_side = other_side
        if other_side == None:
            self.side = 'client'
            self.msg_spec = messages.protocol[0][0]
        else:
            self.side = 'server'
            self.msg_spec = messages.protocol[0][1]
            self.other_side.other_side = self
        self.stream = Stream()
        self.last_report = 0
        self.msg_queue = []
        self.out_of_sync = False