mirror of
https://github.com/valitydev/salt.git
synced 2024-11-08 01:18:58 +00:00
Merge pull request #41918 from rongzeng54/develop
force glibc to re-read resolv.conf for fix unexpected error dns parsing
This commit is contained in:
commit
aff5d76081
@ -763,6 +763,14 @@ def ip_bracket(addr):
|
||||
return addr
|
||||
|
||||
|
||||
def refresh_dns():
|
||||
'''
|
||||
issue #21397: force glibc to re-read resolv.conf
|
||||
'''
|
||||
if HAS_RESINIT:
|
||||
res_init()
|
||||
|
||||
|
||||
@jinja_filter('dns_check')
|
||||
def dns_check(addr, port, safe=False, ipv6=None):
|
||||
'''
|
||||
@ -775,9 +783,7 @@ def dns_check(addr, port, safe=False, ipv6=None):
|
||||
lookup = addr
|
||||
seen_ipv6 = False
|
||||
try:
|
||||
# issue #21397: force glibc to re-read resolv.conf
|
||||
if HAS_RESINIT:
|
||||
res_init()
|
||||
refresh_dns()
|
||||
hostnames = socket.getaddrinfo(
|
||||
addr, None, socket.AF_UNSPEC, socket.SOCK_STREAM
|
||||
)
|
||||
|
@ -15,6 +15,7 @@ import os.path
|
||||
import pprint
|
||||
import socket
|
||||
import yaml
|
||||
import re
|
||||
|
||||
import ssl
|
||||
try:
|
||||
@ -157,6 +158,10 @@ def query(url,
|
||||
if not backend:
|
||||
backend = opts.get('backend', 'tornado')
|
||||
|
||||
match = re.match(r'https?://((25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(25[0-5]|2[0-4]\d|[01]?\d\d?)($|/)', url)
|
||||
if not match:
|
||||
salt.utils.refresh_dns()
|
||||
|
||||
if backend == 'requests':
|
||||
if HAS_REQUESTS is False:
|
||||
ret['error'] = ('http.query has been set to use requests, but the '
|
||||
|
Loading…
Reference in New Issue
Block a user