pypia.py 文件源码

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

项目:pypia 作者: dagrha 项目源码 文件源码
def get_vpn_configs(self):
        try:
            with urllib.request.urlopen(self.config_address) as url:
                config_json = url.read().decode('utf-8').split('\n')[0]
        except urllib.error.URLError:
            logger.warning('\nWARNING: There may have been an issue with certificate ' +
                           'verification to the PIA server info page. Trying to ' +
                           'bypass cert check that python performs since PEP 476.\n')
            try:
                context = ssl._create_unverified_context()
                with urllib.request.urlopen(self.config_address, context=context) as url:
                    config_json = url.read().decode('utf-8').split('\n')[0]
            except urllib.error.URLError:
                sys.exit('\nPIA VPN configurations were not able to be downloaded.' +
                     'This script needs an internet connection to be able to ' +
                     'fetch them automatically. Exiting.\n')
        configs_dict = json.loads(config_json)
        self.configs_dict = {k: v for k, v in configs_dict.items() if isinstance(v, dict) and v.get('dns')}
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号