Commit 8f008fb5 authored by Dom Sekotill's avatar Dom Sekotill
Browse files

Re-add required resolver for port-proxy

The resolver configuration will now be taken from /etc/resolv.conf
parent 2474c7db
Loading
Loading
Loading
Loading
+15 −1
Original line number Diff line number Diff line
@@ -78,10 +78,12 @@ def add_core_config(engine, opts):
	Add a minimal Nginx configuration
	"""
	template = engine.get_template('nginx.conf')
	context = opts.__dict__.copy()
	context['nameservers'] = set(get_nameservers())
	with opts.nginx_directory as _dir:
		path = pathlib.Path(_dir)
		with path.joinpath('nginx.conf').open('w') as conf:
			conf.writelines(template.stream(**opts.__dict__))
			conf.writelines(template.stream(**context))
		path.joinpath('streams').mkdir(exist_ok=True)
		yield path

@@ -375,6 +377,18 @@ def addr_from_names(names: Iterable[str]) -> Iterable[IPAddressTypes]:
				yield ipaddress.ip_address(addrinfo[0])


def get_nameservers():
	with open('/etc/resolv.conf') as rc:
		for line in rc:
			line = line.strip()
			if not line or line[0] in '#;':
				continue
			opt, *args = line.split()
			if opt != 'nameserver':
				continue
			yield from ((a, 53) for a in args)


if __name__ == '__main__':
	logging.basicConfig()
	logger = logging.getLogger('monitor')
+1 −0
Original line number Diff line number Diff line
@@ -40,5 +40,6 @@ http {
}

stream {
	resolver {% for ns in nameservers %}{{ ns|nginx_addr }}{% endfor %} valid=10s;
	include {{ nginx_directory }}/streams/*.conf;
}