From e648a3b8ef434aa560627b51e10a443b06fdbe41 Mon Sep 17 00:00:00 2001 From: Inex Code Date: Fri, 24 Nov 2023 13:57:52 +0300 Subject: [PATCH] feat: Provide display names in DNS records --- selfprivacy_api/graphql/common_types/dns.py | 1 + .../graphql/common_types/service.py | 1 + selfprivacy_api/graphql/queries/system.py | 1 + selfprivacy_api/services/__init__.py | 2 ++ .../services/bitwarden/__init__.py | 2 ++ selfprivacy_api/services/gitea/__init__.py | 2 ++ .../services/jitsimeet/__init__.py | 2 ++ .../services/mailserver/__init__.py | 22 ++++++++++++++++--- .../services/nextcloud/__init__.py | 2 ++ selfprivacy_api/services/ocserv/__init__.py | 2 ++ selfprivacy_api/services/pleroma/__init__.py | 2 ++ selfprivacy_api/services/service.py | 1 + .../services/test_service/__init__.py | 2 ++ 13 files changed, 39 insertions(+), 3 deletions(-) diff --git a/selfprivacy_api/graphql/common_types/dns.py b/selfprivacy_api/graphql/common_types/dns.py index c9f8413..1c79036 100644 --- a/selfprivacy_api/graphql/common_types/dns.py +++ b/selfprivacy_api/graphql/common_types/dns.py @@ -11,3 +11,4 @@ class DnsRecord: content: str ttl: int priority: typing.Optional[int] + display_name: str diff --git a/selfprivacy_api/graphql/common_types/service.py b/selfprivacy_api/graphql/common_types/service.py index 319ce3e..56e12b1 100644 --- a/selfprivacy_api/graphql/common_types/service.py +++ b/selfprivacy_api/graphql/common_types/service.py @@ -139,6 +139,7 @@ def service_to_graphql_service(service: ServiceInterface) -> Service: content=record.content, ttl=record.ttl, priority=record.priority, + display_name=record.display_name, ) for record in service.get_dns_records() ], diff --git a/selfprivacy_api/graphql/queries/system.py b/selfprivacy_api/graphql/queries/system.py index cc30fd7..82c9260 100644 --- a/selfprivacy_api/graphql/queries/system.py +++ b/selfprivacy_api/graphql/queries/system.py @@ -33,6 +33,7 @@ class SystemDomainInfo: content=record.content, ttl=record.ttl, priority=record.priority, + display_name=record.display_name, ) for record in get_all_required_dns_records() ] diff --git a/selfprivacy_api/services/__init__.py b/selfprivacy_api/services/__init__.py index 2f30636..dd0a5b4 100644 --- a/selfprivacy_api/services/__init__.py +++ b/selfprivacy_api/services/__init__.py @@ -54,12 +54,14 @@ def get_all_required_dns_records() -> list[ServiceDnsRecord]: name="api", content=ip4, ttl=3600, + display_name="SelfPrivacy API", ), ServiceDnsRecord( type="AAAA", name="api", content=ip6, ttl=3600, + display_name="SelfPrivacy API (IPv6)", ), ] for service in get_enabled_services(): diff --git a/selfprivacy_api/services/bitwarden/__init__.py b/selfprivacy_api/services/bitwarden/__init__.py index f095ef8..53fc612 100644 --- a/selfprivacy_api/services/bitwarden/__init__.py +++ b/selfprivacy_api/services/bitwarden/__init__.py @@ -135,12 +135,14 @@ class Bitwarden(Service): name="password", content=network_utils.get_ip4(), ttl=3600, + display_name="Bitwarden", ), ServiceDnsRecord( type="AAAA", name="password", content=network_utils.get_ip6(), ttl=3600, + display_name="Bitwarden (IPv6)", ), ] diff --git a/selfprivacy_api/services/gitea/__init__.py b/selfprivacy_api/services/gitea/__init__.py index ed4c9d5..82b403c 100644 --- a/selfprivacy_api/services/gitea/__init__.py +++ b/selfprivacy_api/services/gitea/__init__.py @@ -127,12 +127,14 @@ class Gitea(Service): name="git", content=network_utils.get_ip4(), ttl=3600, + display_name="Gitea", ), ServiceDnsRecord( type="AAAA", name="git", content=network_utils.get_ip6(), ttl=3600, + display_name="Gitea (IPv6)", ), ] diff --git a/selfprivacy_api/services/jitsimeet/__init__.py b/selfprivacy_api/services/jitsimeet/__init__.py index d53049b..79af845 100644 --- a/selfprivacy_api/services/jitsimeet/__init__.py +++ b/selfprivacy_api/services/jitsimeet/__init__.py @@ -136,12 +136,14 @@ class JitsiMeet(Service): name="meet", content=ip4, ttl=3600, + display_name="Jitsi", ), ServiceDnsRecord( type="AAAA", name="meet", content=ip6, ttl=3600, + display_name="Jitsi (IPv6)", ), ] diff --git a/selfprivacy_api/services/mailserver/__init__.py b/selfprivacy_api/services/mailserver/__init__.py index d0f70eb..e36a694 100644 --- a/selfprivacy_api/services/mailserver/__init__.py +++ b/selfprivacy_api/services/mailserver/__init__.py @@ -121,27 +121,43 @@ class MailServer(Service): name=domain, content=ip4, ttl=3600, + display_name="Root Domain", ), ServiceDnsRecord( type="AAAA", name=domain, content=ip6, ttl=3600, + display_name="Root Domain (IPv6)", ), ServiceDnsRecord( - type="MX", name=domain, content=domain, ttl=3600, priority=10 + type="MX", + name=domain, + content=domain, + ttl=3600, + priority=10, + display_name="Mail server record", ), ServiceDnsRecord( - type="TXT", name="_dmarc", content="v=DMARC1; p=none", ttl=18000 + type="TXT", + name="_dmarc", + content="v=DMARC1; p=none", + ttl=18000, + display_name="DMARC record", ), ServiceDnsRecord( type="TXT", name=domain, content=f"v=spf1 a mx ip4:{ip4} -all", ttl=18000, + display_name="SPF record", ), ServiceDnsRecord( - type="TXT", name="selector._domainkey", content=dkim_record, ttl=18000 + type="TXT", + name="selector._domainkey", + content=dkim_record, + ttl=18000, + display_name="DKIM key", ), ] diff --git a/selfprivacy_api/services/nextcloud/__init__.py b/selfprivacy_api/services/nextcloud/__init__.py index cb108d6..fea23fb 100644 --- a/selfprivacy_api/services/nextcloud/__init__.py +++ b/selfprivacy_api/services/nextcloud/__init__.py @@ -134,12 +134,14 @@ class Nextcloud(Service): name="cloud", content=network_utils.get_ip4(), ttl=3600, + display_name="Nextcloud", ), ServiceDnsRecord( type="AAAA", name="cloud", content=network_utils.get_ip6(), ttl=3600, + display_name="Nextcloud (IPv6)", ), ] diff --git a/selfprivacy_api/services/ocserv/__init__.py b/selfprivacy_api/services/ocserv/__init__.py index 120fd9d..3e654b8 100644 --- a/selfprivacy_api/services/ocserv/__init__.py +++ b/selfprivacy_api/services/ocserv/__init__.py @@ -110,12 +110,14 @@ class Ocserv(Service): name="vpn", content=network_utils.get_ip4(), ttl=3600, + display_name="OpenConnect VPN", ), ServiceDnsRecord( type="AAAA", name="vpn", content=network_utils.get_ip6(), ttl=3600, + display_name="OpenConnect VPN (IPv6)", ), ] diff --git a/selfprivacy_api/services/pleroma/__init__.py b/selfprivacy_api/services/pleroma/__init__.py index c367532..3d3fb5d 100644 --- a/selfprivacy_api/services/pleroma/__init__.py +++ b/selfprivacy_api/services/pleroma/__init__.py @@ -131,12 +131,14 @@ class Pleroma(Service): name="social", content=network_utils.get_ip4(), ttl=3600, + display_name="Pleroma", ), ServiceDnsRecord( type="AAAA", name="social", content=network_utils.get_ip6(), ttl=3600, + display_name="Pleroma (IPv6)", ), ] diff --git a/selfprivacy_api/services/service.py b/selfprivacy_api/services/service.py index 86082aa..42cfeb8 100644 --- a/selfprivacy_api/services/service.py +++ b/selfprivacy_api/services/service.py @@ -33,6 +33,7 @@ class ServiceDnsRecord(BaseModel): name: str content: str ttl: int + display_name: str priority: typing.Optional[int] = None diff --git a/selfprivacy_api/services/test_service/__init__.py b/selfprivacy_api/services/test_service/__init__.py index 6ae33ef..187a1c6 100644 --- a/selfprivacy_api/services/test_service/__init__.py +++ b/selfprivacy_api/services/test_service/__init__.py @@ -186,12 +186,14 @@ class DummyService(Service): name="password", content=network_utils.get_ip4(), ttl=3600, + display_name="Test Service", ), ServiceDnsRecord( type="AAAA", name="password", content=network_utils.get_ip6(), ttl=3600, + display_name="Test Service (IPv6)", ), ]