mirror of
https://github.com/chatmail/relay.git
synced 2026-05-19 20:38:05 +00:00
DKIM: only use random DKIM selector on staging.testrun.org for now
This commit is contained in:
@@ -1,5 +1,5 @@
|
|||||||
import iniconfig
|
import iniconfig
|
||||||
import datetime
|
from datetime import datetime
|
||||||
|
|
||||||
|
|
||||||
def read_config(inipath):
|
def read_config(inipath):
|
||||||
@@ -35,12 +35,15 @@ def write_initial_config(inipath, mail_domain):
|
|||||||
from importlib.resources import files
|
from importlib.resources import files
|
||||||
|
|
||||||
inidir = files(__package__).joinpath("ini")
|
inidir = files(__package__).joinpath("ini")
|
||||||
|
selector = "dkim"
|
||||||
|
if mail_domain == "staging.testrun.org":
|
||||||
|
selector = datetime.now().strftime("%Y%m%d%H%M")
|
||||||
content = (
|
content = (
|
||||||
inidir.joinpath("chatmail.ini.f")
|
inidir.joinpath("chatmail.ini.f")
|
||||||
.read_text()
|
.read_text()
|
||||||
.format(
|
.format(
|
||||||
mail_domain=mail_domain,
|
mail_domain=mail_domain,
|
||||||
dkim_selector=str(datetime.datetime.now().strftime("%Y%m%d%H%M")),
|
dkim_selector=selector,
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
if mail_domain.endswith(".testrun.org"):
|
if mail_domain.endswith(".testrun.org"):
|
||||||
|
|||||||
@@ -51,7 +51,7 @@ def show_dns(args, out) -> int:
|
|||||||
"""Check existing DNS records, optionally write them to zone file, return exit code 0 or 1."""
|
"""Check existing DNS records, optionally write them to zone file, return exit code 0 or 1."""
|
||||||
template = importlib.resources.files(__package__).joinpath("chatmail.zone.f")
|
template = importlib.resources.files(__package__).joinpath("chatmail.zone.f")
|
||||||
mail_domain = args.config.mail_domain
|
mail_domain = args.config.mail_domain
|
||||||
dkim_selector = args.config.dkim_selector
|
selector = args.config.dkim_selector
|
||||||
ssh = f"ssh root@{mail_domain}"
|
ssh = f"ssh root@{mail_domain}"
|
||||||
dns = DNS(out, mail_domain)
|
dns = DNS(out, mail_domain)
|
||||||
|
|
||||||
@@ -62,8 +62,8 @@ def show_dns(args, out) -> int:
|
|||||||
continue
|
continue
|
||||||
line = line.replace("\t", " ")
|
line = line.replace("\t", " ")
|
||||||
lines.append(line)
|
lines.append(line)
|
||||||
lines[0] = f"{dkim_selector}._domainkey.{mail_domain}. IN TXT " + lines[0].strip(
|
lines[0] = f"{selector}._domainkey.{mail_domain}. IN TXT " + lines[0].strip(
|
||||||
f"{dkim_selector}._domainkey IN TXT "
|
f"{selector}._domainkey IN TXT "
|
||||||
)
|
)
|
||||||
return "\n".join(lines)
|
return "\n".join(lines)
|
||||||
|
|
||||||
@@ -74,7 +74,9 @@ def show_dns(args, out) -> int:
|
|||||||
print("Please run `cmdeploy run` first.")
|
print("Please run `cmdeploy run` first.")
|
||||||
return 1
|
return 1
|
||||||
dkim_entry = read_dkim_entries(
|
dkim_entry = read_dkim_entries(
|
||||||
out.shell_output(f"{ssh} -- cat /var/lib/rspamd/dkim/{mail_domain}.{dkim_selector}.zone")
|
out.shell_output(
|
||||||
|
f"{ssh} -- cat /var/lib/rspamd/dkim/{mail_domain}.{selector}.zone"
|
||||||
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
ipv6 = dns.get_ipv6()
|
ipv6 = dns.get_ipv6()
|
||||||
|
|||||||
Reference in New Issue
Block a user