Exemple #1
0
    def create_conn(self, sock, host, port):

        if not self.running:
            xlog.debug("session not running, try to connect")
            if not self.start():
                return None

        elif time.time() - self.last_roundtrip_time > 5 * 60 - 5:
            if not self.reset():
                return None

        self.mutex.acquire()
        self.last_conn_id += 1
        conn_id = self.last_conn_id
        self.mutex.release()

        seq = 0
        cmd_type = 0  # create connection
        sock_type = 0  # TCP
        data = struct.pack("<IBBH", seq, cmd_type, sock_type,
                           len(host)) + host + struct.pack("<H", port)
        self.send_conn_data(conn_id, data)

        self.conn_list[conn_id] = base_container.Conn(self, conn_id, sock,
                                                      host, port,
                                                      g.config.windows_size,
                                                      g.config.windows_ack,
                                                      True, xlog)
        return conn_id
Exemple #2
0
    def create_conn(self, sock, host, port):
        if not self.running:
            xlog.warn("session not running, can't connect")
            return

        self.mutex.acquire()
        self.last_conn_id += 1
        conn_id = self.last_conn_id
        self.mutex.release()

        seq = 0
        cmd_type = 0  # create connection
        sock_type = 0  # TCP
        data = struct.pack("<IBBH", seq, cmd_type, sock_type,
                           len(host)) + host + struct.pack("<H", port)
        self.send_conn_data(conn_id, data)

        self.conn_list[conn_id] = base_container.Conn(self,
                                                      conn_id,
                                                      sock,
                                                      host,
                                                      port,
                                                      g.config.windows_size,
                                                      g.config.windows_ack,
                                                      is_client=True)
        return conn_id
Exemple #3
0
    def create_conn(self, sock, host, port):
        self.mutex.acquire()
        self.last_conn_id += 1
        conn_id = self.last_conn_id
        self.mutex.release()

        seq = 0
        cmd_type = 0  # create connection
        sock_type = 0  # TCP
        data = struct.pack("<IBBH", seq, cmd_type, sock_type, len(host)) + host + struct.pack("<H", port)
        self.send_conn_data(conn_id, data)

        self.conn_list[conn_id] = base_container.Conn(self, conn_id, sock, host, port, g.config.windows_size,
                                                      g.config.windows_ack, True, xlog)
        return conn_id