def probe(self) -> 'DNSResolver': self.kind = next( (t for t in DNSResolverType.as_services() if self.service.status(t.config.identity).is_enabled()), self.kind) if self.kind.might_be_command(): self.kind = next(t for t in DNSResolverType.as_command() if SystemHelper.verify_command(t.config.identity)) if self.kind.is_unknown(): logger.warn( 'Unknown DNS resolver. DNS VPN IP might be not resolved correctly' ) if self.kind not in [DNSResolverType.DNSMASQ, DNSResolverType.UNKNOWN]: dnsmasq_name = DNSResolverType.DNSMASQ.config.identity self._is_dnsmasq = self.service.status(dnsmasq_name).is_enabled( ) or shutil.which(dnsmasq_name) is not None logger.debug( f'Current DNS resolver [{self.kind.name}], is dnsmasq available [{self._is_dnsmasq}]' ) return self
def factory(resource_dir: Union[str, Path], runtime_dir: Union[str, Path]) -> 'UnixService': if SystemHelper.verify_command(f'pidof {UnixServiceType.PROCD.value}'): raise NotImplementedError('Not yet supported OpenWRT') return None
def factory(resource_dir: Union[str, Path], runtime_dir: Union[str, Path]) -> 'UnixService': if SystemHelper.verify_command( f'pidof {UnixServiceType.SYSTEMD.value}'): return Systemd(resource_dir=resource_dir, runtime_dir=runtime_dir) return None