machine.py 文件源码

python
阅读 25 收藏 0 点赞 0 评论 0

项目:two1-python 作者: 21dotco 项目源码 文件源码
def _get_market_address(self):
        """ Get status of 21mkt network connection.

        Returns:
            zt_ip (str): ZeroTier IP address.
        """
        try:
            zt_conf = self.docker_ssh("sudo ./zerotier-cli listnetworks -j", stderr=subprocess.DEVNULL)
            if type(zt_conf) == bytes:
                zt_conf = zt_conf.decode()
            zt_conf_json = json.loads(zt_conf)
            for net in zt_conf_json:
                if net["name"] == "21mkt":
                    if net["status"] == "OK":
                        ip_addrs = net["assignedAddresses"]
                        for addr in ip_addrs:
                            potential_match = Two1Machine.ZEROTIER_CLI_IPV6_PATTERN.search(addr)
                            if potential_match is not None:
                                return "[%s]" % potential_match.group(0)
                        return ""
                    else:
                        return ""
            return ""
        except Exception:
            return ""
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号