mirror of
https://github.com/chatmail/relay.git
synced 2026-05-19 20:38:05 +00:00
introduce max_message_size config option
This commit is contained in:
@@ -20,6 +20,7 @@ class Config:
|
|||||||
self.mail_domain = params["mail_domain"]
|
self.mail_domain = params["mail_domain"]
|
||||||
self.max_user_send_per_minute = int(params["max_user_send_per_minute"])
|
self.max_user_send_per_minute = int(params["max_user_send_per_minute"])
|
||||||
self.max_mailbox_size = params["max_mailbox_size"]
|
self.max_mailbox_size = params["max_mailbox_size"]
|
||||||
|
self.max_message_size = int(params.get("max_message_size", "31457280"))
|
||||||
self.delete_mails_after = params["delete_mails_after"]
|
self.delete_mails_after = params["delete_mails_after"]
|
||||||
self.delete_inactive_users_after = int(params["delete_inactive_users_after"])
|
self.delete_inactive_users_after = int(params["delete_inactive_users_after"])
|
||||||
self.username_min_length = int(params["username_min_length"])
|
self.username_min_length = int(params["username_min_length"])
|
||||||
@@ -73,7 +74,7 @@ def write_initial_config(inipath, mail_domain, overrides):
|
|||||||
new_line = line.strip()
|
new_line = line.strip()
|
||||||
if new_line and new_line[0] not in "#[":
|
if new_line and new_line[0] not in "#[":
|
||||||
name, value = map(str.strip, new_line.split("=", maxsplit=1))
|
name, value = map(str.strip, new_line.split("=", maxsplit=1))
|
||||||
value = overrides.pop(name, value)
|
value = extra.pop(name, value)
|
||||||
new_line = f"{name} = {value}"
|
new_line = f"{name} = {value}"
|
||||||
new_lines.append(new_line)
|
new_lines.append(new_line)
|
||||||
|
|
||||||
|
|||||||
@@ -17,6 +17,9 @@ max_user_send_per_minute = 60
|
|||||||
# maximum mailbox size of a chatmail address
|
# maximum mailbox size of a chatmail address
|
||||||
max_mailbox_size = 100M
|
max_mailbox_size = 100M
|
||||||
|
|
||||||
|
# maximum message size for an e-mail in bytes
|
||||||
|
max_message_size = 31457280
|
||||||
|
|
||||||
# days after which mails are unconditionally deleted
|
# days after which mails are unconditionally deleted
|
||||||
delete_mails_after = 20
|
delete_mails_after = 20
|
||||||
|
|
||||||
|
|||||||
@@ -14,10 +14,11 @@ from chatmaild.config import read_config, write_initial_config
|
|||||||
def make_config(tmp_path):
|
def make_config(tmp_path):
|
||||||
inipath = tmp_path.joinpath("chatmail.ini")
|
inipath = tmp_path.joinpath("chatmail.ini")
|
||||||
|
|
||||||
def make_conf(mail_domain):
|
def make_conf(mail_domain, settings=None):
|
||||||
basedir = tmp_path.joinpath(f"vmail/{mail_domain}")
|
basedir = tmp_path.joinpath(f"vmail/{mail_domain}")
|
||||||
basedir.mkdir(parents=True, exist_ok=True)
|
basedir.mkdir(parents=True, exist_ok=True)
|
||||||
overrides = dict(mailboxes_dir=str(basedir))
|
overrides = settings.copy() if settings else {}
|
||||||
|
overrides["mailboxes_dir"] = str(basedir)
|
||||||
write_initial_config(inipath, mail_domain, overrides=overrides)
|
write_initial_config(inipath, mail_domain, overrides=overrides)
|
||||||
return read_config(inipath)
|
return read_config(inipath)
|
||||||
|
|
||||||
|
|||||||
@@ -58,3 +58,8 @@ def test_config_userstate_paths(make_config, tmp_path):
|
|||||||
|
|
||||||
with pytest.raises(ValueError):
|
with pytest.raises(ValueError):
|
||||||
config.get_user(".")
|
config.get_user(".")
|
||||||
|
|
||||||
|
|
||||||
|
def test_config_max_message_size(make_config, tmp_path):
|
||||||
|
config = make_config("something.testrun.org", dict(max_message_size="10000"))
|
||||||
|
assert config.max_message_size == 10000
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ def get_initial_remote_data(sshexec, mail_domain):
|
|||||||
def check_initial_remote_data(remote_data, print=print):
|
def check_initial_remote_data(remote_data, print=print):
|
||||||
mail_domain = remote_data["mail_domain"]
|
mail_domain = remote_data["mail_domain"]
|
||||||
if not remote_data["A"] and not remote_data["AAAA"]:
|
if not remote_data["A"] and not remote_data["AAAA"]:
|
||||||
print("Missing A and/or AAAA DNS records for {mail_domain}!")
|
print(f"Missing A and/or AAAA DNS records for {mail_domain}!")
|
||||||
elif not remote_data["MTA_STS"]:
|
elif not remote_data["MTA_STS"]:
|
||||||
print("Missing MTA-STS CNAME record:")
|
print("Missing MTA-STS CNAME record:")
|
||||||
print(f"mta-sts.{mail_domain}. CNAME {mail_domain}")
|
print(f"mta-sts.{mail_domain}. CNAME {mail_domain}")
|
||||||
|
|||||||
@@ -62,8 +62,7 @@ mydestination =
|
|||||||
relayhost =
|
relayhost =
|
||||||
mynetworks = 127.0.0.0/8 [::ffff:127.0.0.0]/104 [::1]/128
|
mynetworks = 127.0.0.0/8 [::ffff:127.0.0.0]/104 [::1]/128
|
||||||
mailbox_size_limit = 0
|
mailbox_size_limit = 0
|
||||||
# maximum 30MB sized messages
|
message_size_limit = {{config.max_message_size}}
|
||||||
message_size_limit = 31457280
|
|
||||||
recipient_delimiter = +
|
recipient_delimiter = +
|
||||||
inet_interfaces = all
|
inet_interfaces = all
|
||||||
inet_protocols = all
|
inet_protocols = all
|
||||||
|
|||||||
Reference in New Issue
Block a user