Skip to content

Commit

Permalink
Allow trailing "_" in hostname attribute. (#354)
Browse files Browse the repository at this point in the history
Needed e.g. for domains like "_acme-challenge.example.com"
  • Loading branch information
brainexe authored May 15, 2024
1 parent 0e053d1 commit 4c055ac
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 3 deletions.
2 changes: 1 addition & 1 deletion .docker/web/entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ python3 -m pipenv install --dev

# Wait for database to be available before running migrations
until pg_isready -h "$POSTGRES_HOST" -U "$POSTGRES_USER" &> /dev/null; do
echo "Waiting for database to be ready ..."
echo "Waiting for database to be ready on ${POSTGRES_HOST} ..."
sleep 5
done

Expand Down
2 changes: 1 addition & 1 deletion serveradmin.sql
Original file line number Diff line number Diff line change
Expand Up @@ -885,7 +885,7 @@ CREATE TABLE public.server (
hostname character varying(254) NOT NULL,
intern_ip inet,
servertype_id character varying(32) NOT NULL,
CONSTRAINT server_hostname_check CHECK (((hostname)::text ~ '\A(\*\.)?([a-z0-9]+(\.|-+))*[a-z0-9]+\Z'::text))
CONSTRAINT server_hostname_check CHECK (((hostname)::text ~ '\A(\*\.)?([a-z0-9_]+(\.|-+))*[a-z0-9]+\Z'::text))
);


Expand Down
34 changes: 34 additions & 0 deletions serveradmin/serverdb/migrations/0018_alter_server_hostname.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# Generated by Django 3.2.23 on 2024-01-04 08:23

import django.core.validators
from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('serverdb', '0017_inet_family_choice'),
]

operations = [
migrations.AlterField(
model_name='server',
name='hostname',
field=models.CharField(max_length=254, unique=True, validators=[django.core.validators.RegexValidator('\\A(\\*\\.)?([a-z0-9_]+(\\.|-+))*[a-z0-9]+\\Z', 'Invalid hostname')]),
),
migrations.RunSQL(
sql=(
"ALTER TABLE server "
"DROP CONSTRAINT server_hostname_check, "
"ADD CONSTRAINT server_hostname_check "
"CHECK (hostname::text ~ '\A(\*\.)?([a-z0-9_]+(\.|-+))*[a-z0-9]+\Z'::text);"
),
reverse_sql=(
"ALTER TABLE server "
"DROP CONSTRAINT server_hostname_check, "
"ADD CONSTRAINT server_hostname_check "
"CHECK (hostname::text ~ '\A(\*\.)?([a-z0-9]+(\.|-+))*[a-z0-9]+\Z'::text);"
)
),
]

2 changes: 1 addition & 1 deletion serveradmin/serverdb/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@

HOSTNAME_VALIDATORS = [
RegexValidator(
r'\A(\*\.)?([a-z0-9]+(\.|-+))*[a-z0-9]+\Z', 'Invalid hostname'
r'\A(\*\.)?([a-z0-9_]+(\.|-+))*[a-z0-9]+\Z', 'Invalid hostname'
),
]

Expand Down

0 comments on commit 4c055ac

Please sign in to comment.