Add config parameter to set DATA size limit
Expose a new parameter: [daemon]max_data_bytes, to limit Lacre's memory usage and allow processing of messages larger than 32MB (which is the default limit).
This commit is contained in:
parent
91969dbfbb
commit
95069c06a7
|
@ -83,6 +83,11 @@ config = /etc/gpg-lacre-logging.conf
|
||||||
host = 127.0.0.1
|
host = 127.0.0.1
|
||||||
port = 10025
|
port = 10025
|
||||||
|
|
||||||
|
# Maximum size (in bytes) of message body, i.e. data provided after DATA
|
||||||
|
# message. Following value comes from aiosmtpd module's default for this
|
||||||
|
# setting.
|
||||||
|
max_data_bytes = 33554432
|
||||||
|
|
||||||
[relay]
|
[relay]
|
||||||
# the relay settings to use for Postfix
|
# the relay settings to use for Postfix
|
||||||
# gpg-mailgate will submit email to this relay after it is done processing
|
# gpg-mailgate will submit email to this relay after it is done processing
|
||||||
|
|
|
@ -56,11 +56,13 @@ class MailEncryptionProxy:
|
||||||
return RESULT_OK
|
return RESULT_OK
|
||||||
|
|
||||||
|
|
||||||
def _init_controller(keys: kcache.KeyRing, tout: float = 5):
|
def _init_controller(keys: kcache.KeyRing, max_body_bytes=None, tout: float = 5):
|
||||||
proxy = MailEncryptionProxy(keys)
|
proxy = MailEncryptionProxy(keys)
|
||||||
host, port = conf.daemon_params()
|
host, port = conf.daemon_params()
|
||||||
LOG.info(f"Initialising a mail Controller at {host}:{port}")
|
LOG.info(f"Initialising a mail Controller at {host}:{port}")
|
||||||
return Controller(proxy, hostname=host, port=port, ready_timeout=tout)
|
return Controller(proxy, hostname=host, port=port,
|
||||||
|
ready_timeout=tout,
|
||||||
|
data_size_limit=max_body_bytes)
|
||||||
|
|
||||||
|
|
||||||
def _init_reloader(keyring_dir: str, reloader) -> kcache.KeyringModificationListener:
|
def _init_reloader(keyring_dir: str, reloader) -> kcache.KeyringModificationListener:
|
||||||
|
@ -91,9 +93,12 @@ def _main():
|
||||||
_validate_config()
|
_validate_config()
|
||||||
|
|
||||||
keyring_path = conf.get_item('gpg', 'keyhome')
|
keyring_path = conf.get_item('gpg', 'keyhome')
|
||||||
|
max_data_bytes = int(conf.get_item('daemon', 'max_data_bytes', 2**25))
|
||||||
|
|
||||||
loop = asyncio.get_event_loop()
|
loop = asyncio.get_event_loop()
|
||||||
|
|
||||||
keyring = kcache.KeyRing(keyring_path, loop)
|
keyring = kcache.KeyRing(keyring_path, loop)
|
||||||
controller = _init_controller(keyring)
|
controller = _init_controller(keyring, max_data_bytes)
|
||||||
reloader = _init_reloader(keyring_path, keyring)
|
reloader = _init_reloader(keyring_path, keyring)
|
||||||
|
|
||||||
LOG.info(f'Watching keyring directory {keyring_path}...')
|
LOG.info(f'Watching keyring directory {keyring_path}...')
|
||||||
|
|
Loading…
Reference in a new issue