当前位置: 首页>>代码示例>>Python>>正文


Python Control.connect方法代码示例

本文整理汇总了Python中control.Control.connect方法的典型用法代码示例。如果您正苦于以下问题:Python Control.connect方法的具体用法?Python Control.connect怎么用?Python Control.connect使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在control.Control的用法示例。


在下文中一共展示了Control.connect方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: datagramReceived

# 需要导入模块: from control import Control [as 别名]
# 或者: from control.Control import connect [as 别名]
    def datagramReceived(self, data, addr):
        """Event handler of receiving a UDP request.
        Verify the identity of the client and assign a Control
        to it if it is trusted.
        """
        logging.debug("received DNS request from %s:%d" % (addr[0], addr[1]))

        if not self.transmit:
            try:
                dnsq = dnslib.DNSRecord.parse(data)
                query_data = str(dnsq.q.qname).split('.')
                # Give a NXDOMAIN response
                self.answer(dnsq, addr)
            except KeyError:
                logging.info("Corrupt request")

        try:
            # One control corresponds to one client (with a unique SHA1)

            # TODO: get obfs level from query length

            if self.transmit:
                main_pw, client_sha1, number, tcp_port, remote_ip, certs_str, signature = \
                    self.parse_udp_msg_transmit(data)
            else:
                main_pw, client_sha1, number, tcp_port, remote_ip, certs_str, signature = \
                    self.parse_udp_msg(*query_data[:6])
            if (client_sha1 + main_pw) not in self.controls:
                cert = self.certs_db.query(client_sha1)
                control = Control(self, signature, client_sha1, cert[0], cert[1],
                                  remote_ip, tcp_port,
                                  main_pw, number, certs_str)
                self.controls[client_sha1 + main_pw] = control
            else:
                control = self.controls[client_sha1 + main_pw]
                control.update(remote_ip, tcp_port, number)

            control.connect()

        except CorruptedReq:
            logging.debug("corrupt request")
        except KeyError:
            logging.warning("untrusted client attempting to connect")
        except AssertionError:
            logging.debug("authentication failed or corrupt request")
        except BlacklistReq:
            logging.debug("request or salt on blacklist")
        except IllegalReq:
            logging.debug("request for too many connections")
开发者ID:projectarkc,项目名称:arkc-server,代码行数:51,代码来源:coordinator.py

示例2: datagramReceived

# 需要导入模块: from control import Control [as 别名]
# 或者: from control.Control import connect [as 别名]
    def datagramReceived(self, data, addr):
        """Event handler of receiving a UDP request.
        Verify the identity of the client and assign a Control
        to it if it is trusted.
        """
        logging.debug("received DNS request from %s:%d" % (addr[0], addr[1]))
        try:
            dnsq = dnslib.DNSRecord.parse(data)
            query_data = str(dnsq.q.qname).split('.')
            # Give a NXDOMAIN response
            self.answer(dnsq, addr)
        except KeyError:
            logging.info("Corrupt request")

        try:
            # One control corresponds to one client (with a unique SHA1)

            # TODO: get obfs level from query length

            main_pw, client_sha1, number, tcp_port, remote_ip, certs_str = \
                self.parse_udp_msg(*query_data[:6])
            if client_sha1 is None:
                raise DuplicateError
            if client_sha1 not in self.controls:
                client_pub = self.certs[client_sha1][0]
                control = Control(self, client_pub, self.certs[client_sha1][1],
                                  remote_ip, tcp_port,
                                  main_pw, number, certs_str)
                self.controls[client_sha1] = control
            else:
                control = self.controls[client_sha1]
                control.update(remote_ip, tcp_port, main_pw, number)

            control.connect()

        except CorruptedReq:
            logging.info("Corrupt request")
        except KeyError:
            logging.error("untrusted client")
        except AssertionError:
            logging.error("authentication failed or corrupt request")
        except ClientAddrChanged:
            logging.error("client address or port changed")
开发者ID:CheckMySoul,项目名称:arkc-server,代码行数:45,代码来源:coordinator.py


注:本文中的control.Control.connect方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。