mirror of
https://github.com/valitydev/salt.git
synced 2024-11-08 09:23:56 +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
|
return addr
|
||||||
|
|
||||||
|
|
||||||
|
def refresh_dns():
|
||||||
|
'''
|
||||||
|
issue #21397: force glibc to re-read resolv.conf
|
||||||
|
'''
|
||||||
|
if HAS_RESINIT:
|
||||||
|
res_init()
|
||||||
|
|
||||||
|
|
||||||
@jinja_filter('dns_check')
|
@jinja_filter('dns_check')
|
||||||
def dns_check(addr, port, safe=False, ipv6=None):
|
def dns_check(addr, port, safe=False, ipv6=None):
|
||||||
'''
|
'''
|
||||||
@ -775,9 +783,7 @@ def dns_check(addr, port, safe=False, ipv6=None):
|
|||||||
lookup = addr
|
lookup = addr
|
||||||
seen_ipv6 = False
|
seen_ipv6 = False
|
||||||
try:
|
try:
|
||||||
# issue #21397: force glibc to re-read resolv.conf
|
refresh_dns()
|
||||||
if HAS_RESINIT:
|
|
||||||
res_init()
|
|
||||||
hostnames = socket.getaddrinfo(
|
hostnames = socket.getaddrinfo(
|
||||||
addr, None, socket.AF_UNSPEC, socket.SOCK_STREAM
|
addr, None, socket.AF_UNSPEC, socket.SOCK_STREAM
|
||||||
)
|
)
|
||||||
|
@ -15,6 +15,7 @@ import os.path
|
|||||||
import pprint
|
import pprint
|
||||||
import socket
|
import socket
|
||||||
import yaml
|
import yaml
|
||||||
|
import re
|
||||||
|
|
||||||
import ssl
|
import ssl
|
||||||
try:
|
try:
|
||||||
@ -157,6 +158,10 @@ def query(url,
|
|||||||
if not backend:
|
if not backend:
|
||||||
backend = opts.get('backend', 'tornado')
|
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 backend == 'requests':
|
||||||
if HAS_REQUESTS is False:
|
if HAS_REQUESTS is False:
|
||||||
ret['error'] = ('http.query has been set to use requests, but the '
|
ret['error'] = ('http.query has been set to use requests, but the '
|
||||||
|
Loading…
Reference in New Issue
Block a user