from .pidfile import PidFileError, InvalidPidFileError, PidFileInUseError, PidFile
-__version__ = '0.4.2'
+__version__ = '0.5.1'
LOG = logging.getLogger(__name__)
self._show_simulate_opt = True
self.is_internal = False
+ self.named_listen_on_v6 = False
self.pidfile_name = self.default_pidfile
# Configuration files and directories
self._check_path_config(section, section_name, 'base_dir', 'named_basedir', True)
self._check_path_config(section, section_name, 'slave_dir', '_named_slavedir', False)
+ if 'listen_on_v6' in section and section['listen_on_v6'] is not None:
+ self.named_listen_on_v6 = to_bool(section['listen_on_v6'])
+
if 'masters' in section:
self._get_masters_from_cfg(section['masters'], section_name)
if m:
m = m.strip().lower()
try:
- addr_info = socket.getaddrinfo(
- m, 53, proto=socket.IPPROTO_TCP, family=socket.AF_INET)
+ addr_infos = socket.getaddrinfo(
+ m, 53, proto=socket.IPPROTO_TCP)
+ for addr_info in addr_infos:
+ if not self.named_listen_on_v6 and addr_info[0] == socket.AF_INET6:
+ continue
+ addr = addr_info[4][0]
+ if addr not in masters and addr not in self.local_addresses:
+ masters.append(addr)
+
except socket.gaierror as e:
msg = (
"Invalid hostname or address {!r} found in "
LOG.error(msg)
self.config_has_errors = True
m = None
- if m:
- masters.append(m)
if masters:
if self.verbose > 2:
LOG.debug("Using configured masters: {}".format(pp(masters)))
import copy
import json
import os
+import ipaddress
+import socket
# Third party modules
import requests
import six
+import psutil
# Own modules
from .common import pp, to_bool
from .cfg_app import PpCfgAppError, PpConfigApplication
from .pdns_zone import PdnsApiZone
-__version__ = '0.3.4'
+__version__ = '0.4.1'
LOG = logging.getLogger(__name__)
_LIBRARY_NAME = "pp-pdns-api-client"
self._user_agent = '{}/{}'.format(_LIBRARY_NAME, self.version)
self._timeout = self.default_timeout
+ self.local_addresses = []
+
self._environment = 'global'
if environment != 'global':
self.environment = environment
cfg_encoding=cfg_encoding, need_config_file=need_config_file,
)
+ for interface, snics in psutil.net_if_addrs().items():
+ for snic in snics:
+ if snic.family == socket.AF_INET or snic.family == socket.AF_INET6:
+ addr = str(ipaddress.ip_address(re.sub(r'%.*', '', snic.address)))
+ if addr not in self.local_addresses:
+ self.local_addresses.append(addr)
+
self._user_agent = '{}/{}'.format(_LIBRARY_NAME, self.version)
# -----------------------------------------------------------