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')}
评论列表
文章目录