for i in ips: result.append({ "hostname": host, "host": i, "port": port, "family": family, "proto": 0, "flags": socket.AI_NUMERICHOST | socket.AI_NUMERICSERV, }) return result
for url in URLS: try: asyncwith aiohttp.ClientSession() as session: asyncwith session.get(url, params=params, timeout=timeout) as rsp: response = await rsp.text() obj = json.loads(response) pattern = re.compile( "((\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.){3}(1\d\d|2[0-4]\d|25[0-5]|[1-9]\d|\d)") result = [] for i in obj["Answer"]: ip = i["data"]
if pattern.match(ip) isnotNone: result.append(ip) print(result) return result
if server_hostname isNoneand ssl: # Use host as default for server_hostname. It is an error # if host is empty or not set, e.g. when an # already-connected socket was passed or when only a port # is given. To avoid this error, you can pass # server_hostname='' -- this will bypass the hostname # check. (This also means that if host is a numeric # IP/IPv6 address, we will attempt to verify that exact # address; this will probably fail, but it is possible to # create a certificate for a specific IP address, so we # don't judge it here.) ifnot host: raise ValueError('You must set server_hostname ' 'when using ssl without a host') server_hostname = host
ips = await self.require_appapi_hosts(new_host) result = []
for i in ips: result.append({ "hostname": "", "host": i, "port": port, "family": family, "proto": 0, "flags": socket.AI_NUMERICHOST | socket.AI_NUMERICSERV, }) return result
for url in URLS: try: asyncwith aiohttp.ClientSession() as session: asyncwith session.get(url, params=params, timeout=timeout) as rsp: response = await rsp.text() obj = json.loads(response) pattern = re.compile( "((\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.){3}(1\d\d|2[0-4]\d|25[0-5]|[1-9]\d|\d)") result = [] for i in obj["Answer"]: ip = i["data"]
if pattern.match(ip) isnotNone: result.append(ip) print(result) return result