mirror of
https://github.com/chatmail/relay.git
synced 2026-05-16 19:58:58 +00:00
Compare commits
1 Commits
link2xt/up
...
link2xt/st
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
2bdb91a16b |
@@ -1,20 +0,0 @@
|
|||||||
;; Zone file for staging.testrun.org
|
|
||||||
|
|
||||||
$ORIGIN staging.testrun.org.
|
|
||||||
$TTL 300
|
|
||||||
|
|
||||||
@ IN SOA ns.testrun.org. root.nine.testrun.org (
|
|
||||||
2023010101 ; Serial
|
|
||||||
7200 ; Refresh
|
|
||||||
3600 ; Retry
|
|
||||||
1209600 ; Expire
|
|
||||||
3600 ; Negative response caching TTL
|
|
||||||
)
|
|
||||||
|
|
||||||
;; Nameservers.
|
|
||||||
@ IN NS ns.testrun.org.
|
|
||||||
|
|
||||||
;; DNS records.
|
|
||||||
@ IN A 37.27.37.98
|
|
||||||
mta-sts.staging.testrun.org. CNAME staging.testrun.org.
|
|
||||||
www.staging.testrun.org. CNAME staging.testrun.org.
|
|
||||||
72
.github/workflows/test-and-deploy.yaml
vendored
72
.github/workflows/test-and-deploy.yaml
vendored
@@ -1,72 +0,0 @@
|
|||||||
name: deploy on staging.testrun.org, and run tests
|
|
||||||
|
|
||||||
on:
|
|
||||||
push:
|
|
||||||
branches:
|
|
||||||
- main
|
|
||||||
- staging-ci
|
|
||||||
|
|
||||||
jobs:
|
|
||||||
deploy:
|
|
||||||
name: deploy on staging.testrun.org, and run tests
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
steps:
|
|
||||||
- uses: actions/checkout@v3
|
|
||||||
|
|
||||||
- name: prepare SSH
|
|
||||||
run: |
|
|
||||||
mkdir ~/.ssh
|
|
||||||
echo "${{ secrets.STAGING_SSH_KEY }}" >> ~/.ssh/id_ed25519
|
|
||||||
chmod 600 ~/.ssh/id_ed25519
|
|
||||||
ssh-keyscan staging.testrun.org > ~/.ssh/known_hosts
|
|
||||||
# rsync -avz root@staging.testrun.org:/var/lib/acme . || true
|
|
||||||
# rsync -avz root@staging.testrun.org:/var/lib/rspamd/dkim . || true
|
|
||||||
|
|
||||||
#- name: rebuild staging.testrun.org to have a clean VPS
|
|
||||||
# run: |
|
|
||||||
# curl -X POST \
|
|
||||||
# -H "Authorization: Bearer ${{ secrets.HETZNER_API_TOKEN }}" \
|
|
||||||
# -H "Content-Type: application/json" \
|
|
||||||
# -d '{"image":"debian-12"}' \
|
|
||||||
# "https://api.hetzner.cloud/v1/servers/${{ secrets.STAGING_SERVER_ID }}/actions/rebuild"
|
|
||||||
|
|
||||||
- run: scripts/initenv.sh
|
|
||||||
|
|
||||||
- name: append venv/bin to PATH
|
|
||||||
run: echo venv/bin >>$GITHUB_PATH
|
|
||||||
|
|
||||||
- name: run formatting checks
|
|
||||||
run: cmdeploy fmt -v
|
|
||||||
|
|
||||||
- name: run deploy-chatmail offline tests
|
|
||||||
run: pytest --pyargs cmdeploy
|
|
||||||
|
|
||||||
#- name: upload TLS cert after rebuilding
|
|
||||||
# run: |
|
|
||||||
# echo " --- wait until staging.testrun.org VPS is rebuilt --- "
|
|
||||||
# rm ~/.ssh/known_hosts
|
|
||||||
# while ! ssh -o ConnectTimeout=180 -o StrictHostKeyChecking=accept-new -v root@staging.testrun.org id -u ; do sleep 1 ; done
|
|
||||||
# ssh -o StrictHostKeyChecking=accept-new -v root@staging.testrun.org id -u
|
|
||||||
# rsync -avz acme root@staging.testrun.org:/var/lib/ || true
|
|
||||||
# rsync -avz dkim root@staging.testrun.org:/var/lib/rspamd/ || true
|
|
||||||
|
|
||||||
- run: cmdeploy init staging.testrun.org
|
|
||||||
|
|
||||||
- run: cmdeploy run
|
|
||||||
|
|
||||||
- name: set DNS entries
|
|
||||||
run: |
|
|
||||||
#ssh -o StrictHostKeyChecking=accept-new -v root@staging.testrun.org chown _rspamd:_rspamd -R /var/lib/rspamd/dkim
|
|
||||||
cmdeploy dns --zonefile staging-generated.zone
|
|
||||||
cat staging-generated.zone >> .github/workflows/staging.testrun.org-default.zone
|
|
||||||
cat .github/workflows/staging.testrun.org-default.zone
|
|
||||||
scp -o StrictHostKeyChecking=accept-new .github/workflows/staging.testrun.org-default.zone root@ns.testrun.org:/etc/nsd/staging.testrun.org.zone
|
|
||||||
ssh root@ns.testrun.org nsd-checkzone staging.testrun.org /etc/nsd/staging.testrun.org.zone
|
|
||||||
ssh root@ns.testrun.org systemctl reload nsd
|
|
||||||
|
|
||||||
- name: cmdeploy test
|
|
||||||
run: CHATMAIL_DOMAIN2=nine.testrun.org cmdeploy test --slow
|
|
||||||
|
|
||||||
- name: cmdeploy dns (try 3 times)
|
|
||||||
run: cmdeploy dns || cmdeploy dns || cmdeploy dns
|
|
||||||
|
|
||||||
@@ -442,10 +442,7 @@ def deploy_chatmail(config_path: Path) -> None:
|
|||||||
)
|
)
|
||||||
server.shell(
|
server.shell(
|
||||||
name="Generate root keys for validating DNSSEC",
|
name="Generate root keys for validating DNSSEC",
|
||||||
commands=[
|
commands=["unbound-anchor -a /var/lib/unbound/root.key || true"],
|
||||||
"unbound-anchor -a /var/lib/unbound/root.key || true",
|
|
||||||
"systemctl reset-failed unbound.service",
|
|
||||||
],
|
|
||||||
)
|
)
|
||||||
systemd.service(
|
systemd.service(
|
||||||
name="Start and enable unbound",
|
name="Start and enable unbound",
|
||||||
|
|||||||
@@ -82,8 +82,7 @@ def dns_cmd_options(parser):
|
|||||||
|
|
||||||
def dns_cmd(args, out):
|
def dns_cmd(args, out):
|
||||||
"""Generate dns zone file."""
|
"""Generate dns zone file."""
|
||||||
exit_code = show_dns(args, out)
|
show_dns(args, out)
|
||||||
exit(exit_code)
|
|
||||||
|
|
||||||
|
|
||||||
def status_cmd(args, out):
|
def status_cmd(args, out):
|
||||||
|
|||||||
@@ -47,8 +47,7 @@ class DNS:
|
|||||||
return result == f"{mail_domain}."
|
return result == f"{mail_domain}."
|
||||||
|
|
||||||
|
|
||||||
def show_dns(args, out) -> int:
|
def show_dns(args, out):
|
||||||
"""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
|
||||||
ssh = f"ssh root@{mail_domain}"
|
ssh = f"ssh root@{mail_domain}"
|
||||||
@@ -71,7 +70,7 @@ def show_dns(args, out) -> int:
|
|||||||
acme_account_url = out.shell_output(f"{ssh} -- acmetool account-url")
|
acme_account_url = out.shell_output(f"{ssh} -- acmetool account-url")
|
||||||
except subprocess.CalledProcessError:
|
except subprocess.CalledProcessError:
|
||||||
print("Please run `cmdeploy run` first.")
|
print("Please run `cmdeploy run` first.")
|
||||||
return 1
|
return
|
||||||
dkim_entry = read_dkim_entries(
|
dkim_entry = read_dkim_entries(
|
||||||
out.shell_output(f"{ssh} -- cat /var/lib/rspamd/dkim/{mail_domain}.dkim.zone")
|
out.shell_output(f"{ssh} -- cat /var/lib/rspamd/dkim/{mail_domain}.dkim.zone")
|
||||||
)
|
)
|
||||||
@@ -100,7 +99,7 @@ def show_dns(args, out) -> int:
|
|||||||
with open(args.zonefile, "w+") as zf:
|
with open(args.zonefile, "w+") as zf:
|
||||||
zf.write(zonefile)
|
zf.write(zonefile)
|
||||||
print(f"DNS records successfully written to: {args.zonefile}")
|
print(f"DNS records successfully written to: {args.zonefile}")
|
||||||
return 0
|
return
|
||||||
except TypeError:
|
except TypeError:
|
||||||
pass
|
pass
|
||||||
started_dkim_parsing = False
|
started_dkim_parsing = False
|
||||||
@@ -154,7 +153,6 @@ def show_dns(args, out) -> int:
|
|||||||
else:
|
else:
|
||||||
to_print.append(dkim_entry)
|
to_print.append(dkim_entry)
|
||||||
|
|
||||||
exit_code = 0
|
|
||||||
if to_print:
|
if to_print:
|
||||||
to_print.insert(
|
to_print.insert(
|
||||||
0, "You should configure the following DNS entries at your provider:\n"
|
0, "You should configure the following DNS entries at your provider:\n"
|
||||||
@@ -163,7 +161,6 @@ def show_dns(args, out) -> int:
|
|||||||
"\nIf you already configured the DNS entries, wait a bit until the DNS entries propagate to the Internet."
|
"\nIf you already configured the DNS entries, wait a bit until the DNS entries propagate to the Internet."
|
||||||
)
|
)
|
||||||
print("\n".join(to_print))
|
print("\n".join(to_print))
|
||||||
exit_code = 1
|
|
||||||
else:
|
else:
|
||||||
out.green("Great! All your DNS entries are correct.")
|
out.green("Great! All your DNS entries are correct.")
|
||||||
|
|
||||||
@@ -183,8 +180,6 @@ def show_dns(args, out) -> int:
|
|||||||
print(
|
print(
|
||||||
"You can do so at your hosting provider (maybe this isn't your DNS provider)."
|
"You can do so at your hosting provider (maybe this isn't your DNS provider)."
|
||||||
)
|
)
|
||||||
exit_code = 1
|
|
||||||
return exit_code
|
|
||||||
|
|
||||||
|
|
||||||
def check_necessary_dns(out, mail_domain):
|
def check_necessary_dns(out, mail_domain):
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ def test_gen_qr_png_data(maildomain):
|
|||||||
|
|
||||||
|
|
||||||
def test_fastcgi_working(maildomain, chatmail_config):
|
def test_fastcgi_working(maildomain, chatmail_config):
|
||||||
url = f"https://{maildomain}/new"
|
url = f"https://{maildomain}/cgi-bin/newemail.py"
|
||||||
print(url)
|
print(url)
|
||||||
res = requests.post(url)
|
res = requests.post(url)
|
||||||
assert maildomain in res.json().get("email")
|
assert maildomain in res.json().get("email")
|
||||||
@@ -18,7 +18,7 @@ def test_fastcgi_working(maildomain, chatmail_config):
|
|||||||
|
|
||||||
def test_newemail_configure(maildomain, rpc):
|
def test_newemail_configure(maildomain, rpc):
|
||||||
"""Test configuring accounts by scanning a QR code works."""
|
"""Test configuring accounts by scanning a QR code works."""
|
||||||
url = f"DCACCOUNT:https://{maildomain}/new"
|
url = f"DCACCOUNT:https://{maildomain}/cgi-bin/newemail.py"
|
||||||
for i in range(3):
|
for i in range(3):
|
||||||
account_id = rpc.add_account()
|
account_id = rpc.add_account()
|
||||||
rpc.set_config_from_qr(account_id, url)
|
rpc.set_config_from_qr(account_id, url)
|
||||||
|
|||||||
@@ -48,7 +48,7 @@ def test_reject_missing_dkim(cmsetup, maildata, from_addr):
|
|||||||
recipient = cmsetup.gen_users(1)[0]
|
recipient = cmsetup.gen_users(1)[0]
|
||||||
msg = maildata("plain.eml", from_addr=from_addr, to_addr=recipient.addr).as_string()
|
msg = maildata("plain.eml", from_addr=from_addr, to_addr=recipient.addr).as_string()
|
||||||
with smtplib.SMTP(cmsetup.maildomain, 25) as s:
|
with smtplib.SMTP(cmsetup.maildomain, 25) as s:
|
||||||
with pytest.raises(smtplib.SMTPDataError, match="missing DKIM signature"):
|
with pytest.raises(smtplib.SMTPDataError, match="Spam message rejected"):
|
||||||
s.sendmail(from_addr=from_addr, to_addrs=recipient.addr, msg=msg)
|
s.sendmail(from_addr=from_addr, to_addrs=recipient.addr, msg=msg)
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
set -e
|
set -e
|
||||||
python3 -m venv --upgrade-deps venv
|
python3 -m venv venv
|
||||||
|
|
||||||
venv/bin/pip install -e chatmaild
|
venv/bin/pip install -e chatmaild
|
||||||
venv/bin/pip install -e cmdeploy
|
venv/bin/pip install -e cmdeploy
|
||||||
|
|||||||
Reference in New Issue
Block a user