def fixture_domain_types(): """Create a domain types required for tests.""" DomainType('domain-type-tor', 'Tor Onion Service', 'tor:index', can_have_certificate=False) DomainType('domain-type-test', 'Test Domain Type', 'test:index')
def fixture_domain_list(): """Return patch DomainName.list() method.""" method = 'plinth.modules.names.components.DomainName.list' with patch(method) as domain_list: DomainType._all = {} DomainType('domain-type-1', 'type-1', 'url1', False) DomainType('domain-type-2', 'type-2', 'url1', True) domain1 = DomainName('domain-name-1', 'invalid1.example', 'domain-type-1', '__all__') domain2 = DomainName('domain-name-2', 'valid.example', 'domain-type-2', '__all__') domain3 = DomainName('domain-name-3', 'invalid2.example', 'domain-type-2', '__all__') domain_list.return_value = [domain1, domain2, domain3] yield domain_list
def __init__(self): """Create components for the app.""" super().__init__() info = app_module.Info(app_id=self.app_id, version=self._version, is_essential=True, depends=['apache', 'firewall', 'names'], name=_('General Configuration'), icon='fa-cog', description=_description, manual_page='Configure') self.add(info) menu_item = menu.Menu('menu-config', _('Configure'), None, info.icon, 'config:index', parent_url_name='system') self.add(menu_item) packages = Packages('packages-config', ['zram-tools']) self.add(packages) daemon1 = RelatedDaemon('related-daemon-config1', 'systemd-journald') self.add(daemon1) daemon2 = RelatedDaemon('related-daemon-config2', 'rsyslog') self.add(daemon2) domain_type = DomainType('domain-type-static', _('Domain Name'), 'config:index', can_have_certificate=True) self.add(domain_type)
def __init__(self): """Create components for the app.""" super().__init__() info = app_module.Info(app_id=self.app_id, version=version, is_essential=is_essential, depends=depends, name=_('General Configuration'), icon='fa-cog', description=_description, manual_page='Configure') self.add(info) menu_item = menu.Menu('menu-config', _('Configure'), None, info.icon, 'config:index', parent_url_name='system') self.add(menu_item) domain_type = DomainType('domain-type-static', _('Domain Name'), 'config:index', can_have_certificate=True) self.add(domain_type) # Register domain with Name Services module. domainname = get_domainname() if domainname: domain_added.send_robust(sender='config', domain_type='domain-type-static', name=domainname, services='__all__')
def __init__(self): """Create components for the app.""" super().__init__() info = app_module.Info( app_id=self.app_id, version=self._version, depends=['names'], name=_('PageKite'), icon='fa-flag', short_description=_('Public Visibility'), description=_description, manual_page='PageKite', donation_url='https://pagekite.net/support/faq/#donate') self.add(info) menu_item = menu.Menu('menu-pagekite', info.name, info.short_description, info.icon, 'pagekite:index', parent_url_name='system') self.add(menu_item) packages = Packages('packages-pagekite', ['pagekite']) self.add(packages) domain_type = DomainType('domain-type-pagekite', _('PageKite Domain'), 'pagekite:index', can_have_certificate=True) self.add(domain_type) daemon = Daemon('daemon-pagekite', self.DAEMON) self.add(daemon) backup_restore = BackupRestore('backup-restore-pagekite', **manifest.backup) self.add(backup_restore)
def __init__(self): """Create components for the app.""" super().__init__() info = app_module.Info(app_id=self.app_id, version=version, depends=depends, name=_('PageKite'), icon='fa-flag', short_description=_('Public Visibility'), description=_description, manual_page='PageKite') self.add(info) menu_item = menu.Menu('menu-pagekite', info.name, info.short_description, info.icon, 'pagekite:index', parent_url_name='system') self.add(menu_item) domain_type = DomainType('domain-type-pagekite', _('PageKite Domain'), 'pagekite:index', can_have_certificate=True) self.add(domain_type) daemon = Daemon('daemon-pagekite', managed_services[0]) self.add(daemon) # Register kite name with Name Services module. utils.update_names_module(is_enabled=self.is_enabled())
def __init__(self): """Create components for the app.""" super().__init__() info = app_module.Info(app_id=self.app_id, version=version, is_essential=is_essential, depends=depends, name=_('Dynamic DNS Client'), icon='fa-refresh', description=_description, manual_page='DynamicDNS') self.add(info) menu_item = menu.Menu('menu-dynamicdns', info.name, None, info.icon, 'dynamicdns:index', parent_url_name='system') self.add(menu_item) domain_type = DomainType('domain-type-dynamic', _('Dynamic Domain Name'), 'dynamicdns:index', can_have_certificate=True) self.add(domain_type) users_and_groups = UsersAndGroups('users-and-groups-dynamicdns', reserved_usernames=['ez-ipupd']) self.add(users_and_groups) backup_restore = BackupRestore('backup-restore-dynamicdns', **manifest.backup) self.add(backup_restore) current_status = get_status() if current_status['enabled']: domain_added.send_robust(sender='dynamicdns', domain_type='domain-type-dynamic', name=current_status['dynamicdns_domain'], services='__all__')
def __init__(self): """Create components for the app.""" super().__init__() info = app_module.Info(app_id=self.app_id, version=version, depends=depends, name=_('PageKite'), icon='fa-flag', short_description=_('Public Visibility'), description=_description, manual_page='PageKite') self.add(info) menu_item = menu.Menu('menu-pagekite', info.name, info.short_description, info.icon, 'pagekite:index', parent_url_name='system') self.add(menu_item) domain_type = DomainType('domain-type-pagekite', _('PageKite Domain'), 'pagekite:index', can_have_certificate=True) self.add(domain_type)
def __init__(self): """Create components for the app.""" super().__init__() info = app_module.Info(app_id=self.app_id, version=version, is_essential=is_essential, depends=depends, name=_('Dynamic DNS Client'), icon='fa-refresh', description=_description, manual_page='DynamicDNS') self.add(info) menu_item = menu.Menu('menu-dynamicdns', info.name, None, info.icon, 'dynamicdns:index', parent_url_name='system') self.add(menu_item) domain_type = DomainType('domain-type-dynamic', _('Dynamic Domain Name'), 'dynamicdns:index', can_have_certificate=True) self.add(domain_type)
def __init__(self): """Create components for the app.""" super().__init__() info = app_module.Info(app_id=self.app_id, version=self._version, is_essential=True, depends=['names'], name=_('Service Discovery'), icon='fa-compass', description=_description, manual_page='ServiceDiscovery') self.add(info) menu_item = menu.Menu('menu-avahi', info.name, None, info.icon, 'avahi:index', parent_url_name='system') self.add(menu_item) packages = Packages('packages-avahi', ['avahi-daemon', 'avahi-utils']) self.add(packages) domain_type = DomainType('domain-type-local', _('Local Network Domain'), 'config:index', can_have_certificate=False) self.add(domain_type) firewall = Firewall('firewall-avahi', info.name, ports=['mdns'], is_external=False) self.add(firewall) daemon = Daemon('daemon-avahi', 'avahi-daemon') self.add(daemon) backup_restore = BackupRestore('backup-restore-avahi', **manifest.backup) self.add(backup_restore)
def __init__(self): """Create components for the app.""" super().__init__() info = app_module.Info(app_id=self.app_id, version=version, name=_('Service Discovery'), icon='fa-compass', description=_description, manual_page='ServiceDiscovery') self.add(info) menu_item = menu.Menu('menu-avahi', info.name, None, info.icon, 'avahi:index', parent_url_name='system') self.add(menu_item) domain_type = DomainType('domain-type-local', _('Local Network Domain'), 'config:index', can_have_certificate=False) self.add(domain_type) firewall = Firewall('firewall-avahi', info.name, ports=['mdns'], is_external=False) self.add(firewall) daemon = Daemon('daemon-avahi', managed_services[0]) self.add(daemon)
def on_domain_removed(sender, domain_type, name='', **kwargs): """Revoke Let's Encrypt certificate for the removed domain""" if not DomainType.get(domain_type).can_have_certificate: return False try: if name: logger.info('Revoking certificate for %s', name) certificate_revoke(name) return True except ActionError as exception: logger.warning('Failed to revoke certificate for %s: %s', name, exception.args[2]) return False
def __init__(self): """Create components for the app.""" super().__init__() info = app_module.Info(app_id=self.app_id, version=version, name=_('Service Discovery'), icon='fa-compass', description=_description, manual_page='ServiceDiscovery') self.add(info) menu_item = menu.Menu('menu-avahi', info.name, None, info.icon, 'avahi:index', parent_url_name='system') self.add(menu_item) domain_type = DomainType('domain-type-local', _('Local Network Domain'), 'config:index', can_have_certificate=False) self.add(domain_type) firewall = Firewall('firewall-avahi', info.name, ports=['mdns'], is_external=False) self.add(firewall) daemon = Daemon('daemon-avahi', managed_services[0]) self.add(daemon) backup_restore = BackupRestore('backup-restore-avahi', **manifest.backup) self.add(backup_restore) if self.is_enabled(): domain_added.send_robust(sender='avahi', domain_type='domain-type-local', name=get_hostname() + '.local', services='__all__') post_hostname_change.connect(on_post_hostname_change)
def __init__(self): """Create components for the app.""" super().__init__() info = app_module.Info(app_id=self.app_id, version=version, name=_('Tor'), icon_filename='tor', short_description=_('Anonymity Network'), description=_description, manual_page='Tor', clients=clients) self.add(info) menu_item = menu.Menu('menu-tor', info.name, info.short_description, info.icon_filename, 'tor:index', parent_url_name='apps') self.add(menu_item) domain_type = DomainType('domain-type-tor', _('Tor Onion Service'), 'tor:index', can_have_certificate=False) self.add(domain_type) firewall = Firewall('firewall-tor-socks', _('Tor Socks Proxy'), ports=['tor-socks'], is_external=False) self.add(firewall) firewall = Firewall('firewall-tor-relay', _('Tor Bridge Relay'), ports=['tor-orport', 'tor-obfs3', 'tor-obfs4'], is_external=True) self.add(firewall) daemon = Daemon('daemon-tor', managed_services[0], strict_check=True, listen_ports=[(9050, 'tcp4'), (9050, 'tcp6'), (9040, 'tcp4'), (9040, 'tcp6'), (9053, 'udp4'), (9053, 'udp6')]) self.add(daemon)
def on_domain_added(sender, domain_type='', name='', description='', services=None, **kwargs): """Obtain a certificate for the new domain""" if not DomainType.get(domain_type).can_have_certificate: return False # Check if a cert if already available for domain_name, domain_status in get_status()['domains'].items(): if domain_name == name and domain_status and \ domain_status['certificate_available'] and \ domain_status['validity'] == 'valid': return False try: if name: logger.info('Obtaining certificate for %s', name) certificate_obtain(name) return True except ActionError: return False
def __init__(self): """Create components for the app.""" super().__init__() info = app_module.Info( app_id=self.app_id, version=version, depends=depends, name=_('PageKite'), icon='fa-flag', short_description=_('Public Visibility'), description=_description, manual_page='PageKite', donation_url='https://pagekite.net/support/faq/#donate') self.add(info) menu_item = menu.Menu('menu-pagekite', info.name, info.short_description, info.icon, 'pagekite:index', parent_url_name='system') self.add(menu_item) domain_type = DomainType('domain-type-pagekite', _('PageKite Domain'), 'pagekite:index', can_have_certificate=True) self.add(domain_type) daemon = Daemon('daemon-pagekite', managed_services[0]) self.add(daemon) backup_restore = BackupRestore('backup-restore-pagekite', **manifest.backup) self.add(backup_restore) # Register kite name with Name Services module. setup_helper = globals()['setup_helper'] if setup_helper.get_state() != 'needs-setup' and self.is_enabled(): utils.update_names_module(is_enabled=True)
def __init__(self): """Create components for the app.""" super().__init__() info = app_module.Info(app_id=self.app_id, version=version, name=_('Tor'), icon_filename='tor', short_description=_('Anonymity Network'), description=_description, manual_page='Tor', clients=manifest.clients, donation_url='https://donate.torproject.org/') self.add(info) menu_item = menu.Menu('menu-tor', info.name, info.short_description, info.icon_filename, 'tor:index', parent_url_name='apps') self.add(menu_item) domain_type = DomainType('domain-type-tor', _('Tor Onion Service'), 'tor:index', can_have_certificate=False) self.add(domain_type) firewall = Firewall('firewall-tor-socks', _('Tor Socks Proxy'), ports=['tor-socks'], is_external=False) self.add(firewall) firewall = Firewall('firewall-tor-relay', _('Tor Bridge Relay'), ports=['tor-orport', 'tor-obfs3', 'tor-obfs4'], is_external=True) self.add(firewall) daemon = Daemon('daemon-tor', managed_services[0], strict_check=True, listen_ports=[(9050, 'tcp4'), (9050, 'tcp6'), (9040, 'tcp4'), (9040, 'tcp6'), (9053, 'udp4'), (9053, 'udp6')]) self.add(daemon) users_and_groups = UsersAndGroups('users-and-groups-tor', reserved_usernames=['debian-tor']) self.add(users_and_groups) backup_restore = BackupRestore('backup-restore-tor', **manifest.backup) self.add(backup_restore) # Register hidden service name with Name Services module. setup_helper = globals()['setup_helper'] if setup_helper.get_state() != 'needs-setup' and \ self.is_enabled() and app_is_running(self): status = utils.get_status(initialized=False) hostname = status['hs_hostname'] services = [int(port['virtport']) for port in status['hs_ports']] if status['hs_enabled'] and status['hs_hostname']: domain_added.send_robust(sender='tor', domain_type='domain-type-tor', name=hostname, services=services)
def __init__(self): """Create components for the app.""" super().__init__() info = app_module.Info(app_id=self.app_id, version=self._version, depends=['names'], name=_('Tor'), icon_filename='tor', short_description=_('Anonymity Network'), description=_description, manual_page='Tor', clients=manifest.clients, donation_url='https://donate.torproject.org/') self.add(info) menu_item = menu.Menu('menu-tor', info.name, info.short_description, info.icon_filename, 'tor:index', parent_url_name='apps') self.add(menu_item) packages = Packages('packages-tor', [ 'tor', 'tor-geoipdb', 'torsocks', 'obfs4proxy', 'apt-transport-tor' ]) self.add(packages) domain_type = DomainType('domain-type-tor', _('Tor Onion Service'), 'tor:index', can_have_certificate=False) self.add(domain_type) firewall = Firewall('firewall-tor-socks', _('Tor Socks Proxy'), ports=['tor-socks'], is_external=False) self.add(firewall) firewall = Firewall('firewall-tor-relay', _('Tor Bridge Relay'), ports=['tor-orport', 'tor-obfs3', 'tor-obfs4'], is_external=True) self.add(firewall) daemon = Daemon('daemon-tor', 'tor@plinth', strict_check=True, listen_ports=[(9050, 'tcp4'), (9050, 'tcp6'), (9040, 'tcp4'), (9040, 'tcp6'), (9053, 'udp4'), (9053, 'udp6')]) self.add(daemon) users_and_groups = UsersAndGroups('users-and-groups-tor', reserved_usernames=['debian-tor']) self.add(users_and_groups) backup_restore = BackupRestore('backup-restore-tor', **manifest.backup) self.add(backup_restore)