mirror of
https://github.com/chatmail/relay.git
synced 2026-05-18 08:28:58 +00:00
making it work
This commit is contained in:
@@ -1,41 +1,25 @@
|
||||
|
||||
|
||||
from pathlib import Path
|
||||
from fnmatch import fnmatch
|
||||
import iniconfig
|
||||
|
||||
system_mailname_path = Path("/etc/mailname")
|
||||
|
||||
|
||||
def read_config(inipath, mailname=None):
|
||||
if mailname is None:
|
||||
with open(system_mailname_path) as f:
|
||||
mailname = f.read().strip()
|
||||
|
||||
ini = iniconfig.IniConfig(inipath)
|
||||
privacy = {}
|
||||
for section in ini:
|
||||
if section.name.startswith("privacy:"):
|
||||
domain = section["domain"]
|
||||
if fnmatch(mailname, domain):
|
||||
privacy = section
|
||||
break
|
||||
|
||||
return Config(inipath, mailname, privacy, params=ini.sections["params"])
|
||||
def read_config(inipath):
|
||||
cfg = iniconfig.IniConfig(inipath)
|
||||
return Config(inipath, params=cfg.sections["params"])
|
||||
|
||||
|
||||
class Config:
|
||||
def __init__(self, inipath, mailname, privacy, params):
|
||||
def __init__(self, inipath, params):
|
||||
self._inipath = inipath
|
||||
self.mailname = mailname
|
||||
self.privacy_postal = privacy.get("privacy_postal")
|
||||
self.privacy_mail = privacy.get("privacy_mail")
|
||||
self.privacy_pdo = privacy.get("privacy_pdo")
|
||||
self.privacy_supervisor = privacy.get("privacy_supervisor")
|
||||
self.mailname = params["mailname"]
|
||||
self.max_user_send_per_minute = int(params["max_user_send_per_minute"])
|
||||
self.filtermail_smtp_port = int(params["filtermail_smtp_port"])
|
||||
self.postfix_reinject_port = int(params["postfix_reinject_port"])
|
||||
self.passthrough_recipients = params["passthrough_recipients"].split()
|
||||
self.privacy_postal = params.get("privacy_postal")
|
||||
self.privacy_mail = params.get("privacy_mail")
|
||||
self.privacy_pdo = params.get("privacy_pdo")
|
||||
self.privacy_supervisor = params.get("privacy_supervisor")
|
||||
|
||||
def _getbytefile(self):
|
||||
return open(self._inipath, "rb")
|
||||
|
||||
@@ -127,7 +127,10 @@ class BeforeQueueHandler:
|
||||
|
||||
is_outgoing = recipient_domain != envelope_from_domain
|
||||
if is_outgoing and not mail_encrypted:
|
||||
is_securejoin = message.get("secure-join") in ["vc-request", "vg-request"]
|
||||
is_securejoin = message.get("secure-join") in [
|
||||
"vc-request",
|
||||
"vg-request",
|
||||
]
|
||||
if not is_securejoin:
|
||||
return f"500 Invalid unencrypted mail to <{recipient}>"
|
||||
|
||||
|
||||
Reference in New Issue
Block a user