mirror of
https://github.com/freedombox/FreedomBox.git
synced 2026-11-29 08:25:10 +00:00
names: Allow adding multiple static domain names
- Change the mechanism for storing domain names in /etc/hosts. Don't write hostname to /etc/hosts. Don't prepend hostname to domain name. This means that when hostname changes, set_domain_name need not be called. - This means that domain names such as example.fbx.one were not resolvable using /etc/hosts but these will now resolve to 127.0.1.1. This is a minor concern to becoming a breaking change. - Don't use socket.getfqdn() for finding the domain name of the machine. Instead read from /etc/hosts. There does not seem to a glibc/python API for querying domain names from /etc/hosts with all variations it allows. Forward resolution properly works no matter the library. - Drop a pre-Python 3 conversion from unicode to ascii string for hostname. This is no longer relevant. - Domain name form is now domain add form. Passing domain name is mandatory. Domain delete form and view have been introduced. - Use augeas to edit hosts file. Add privileged methods to add/delete/get domains. Add method to migration from old format to new. Support reading old format too in get_domains. Tests: - Without hostname written in /etc/hosts, 'resolvectl query <hostname>' and 'ping <hostname>' work. - With old /etc/hosts format apply patches and restart service. It will be converted to new format. - Adding a domain adds a new line to /etc/hosts file. The domain is shown in domains list in Names app. Applications get reconfigured with the new domain name. - Deleting a domain adds a new line to /etc/hosts file. The domain is shown in domains list in Names app. Applications get reconfigured with the new domain name. - Restarting app triggers domain added signal for all domains and all the domains are shown in the Names app. Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org> Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
This commit is contained in:
1 parent
889453daff
commit
863d170219
10 files changed
+223
-100
No files matched your search
@@ -99,8 +99,8 @@ def _domain_label_validator(domain_name):
|
||||
raise ValidationError(_('Invalid domain name'))
|
||||
|
||||
|
||||
class DomainNameForm(forms.Form):
|
||||
"""Form to update system's static domain name."""
|
||||
class DomainAddForm(forms.Form):
|
||||
"""Form to add a static domain name."""
|
||||
|
||||
domain_name = forms.CharField(
|
||||
label=_('Domain Name'), help_text=format_lazy(
|
||||
@@ -111,7 +111,7 @@ class DomainNameForm(forms.Form):
|
||||
'only alphabets, digits and hyphens. Length of each label '
|
||||
'must be 63 characters or less. Total length of domain name '
|
||||
'must be 253 characters or less.'), box_name=_(cfg.box_name)),
|
||||
required=False, validators=[
|
||||
required=True, validators=[
|
||||
validators.RegexValidator(
|
||||
r'^[a-zA-Z0-9]([-a-zA-Z0-9.]{,251}[a-zA-Z0-9])?$',
|
||||
_('Invalid domain name')), _domain_label_validator
|
||||
|
||||
Reference in new issue
Block a user