Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Configure client max size #146

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions docs/man/pantalaimon.5
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,8 @@ This option configures if a proxy instance should only keep the latest version
of a room key from a certain user around. This effectively means that only newly
incoming messages will be decryptable, the proxy will be unable to decrypt the
room history. Defaults to "No".
.It Cm ClientMaxSize
The maximum size of a request, in bytes. Defaults to "104857600".
.It Cm SearchRequests
This option configures if the proxy should make additional HTTP requests to the
server when clients use the search API endpoint. Some data that is required to
Expand Down
4 changes: 4 additions & 0 deletions docs/man/pantalaimon.5.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,10 @@ The following keys are optional in the proxy instance sections:
> incoming messages will be decryptable, the proxy will be unable to decrypt the
> room history. Defaults to "No".

**ClientMaxSize**

> The maximum size of a request, in bytes. Defaults to "104857600".

Additional to the homeserver section a special section with the name
**Default**
can be used to configure the following values for all homeservers:
Expand Down
11 changes: 11 additions & 0 deletions pantalaimon/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ def __init__(self):
"HistoryFetchDelay": "3000",
"DebugEncryption": "False",
"DropOldKeys": "False",
"ClientMaxSize": "104857600",
},
converters={
"address": parse_address,
Expand Down Expand Up @@ -124,6 +125,7 @@ class ServerConfig:
requests in seconds.
drop_old_keys (bool): Should Pantalaimon only keep the most recent
decryption key around.
client_max_size (int): The maximum size of a request, in bytes.
"""

name = attr.ib(type=str)
Expand All @@ -141,6 +143,7 @@ class ServerConfig:
indexing_batch_size = attr.ib(type=int, default=100)
history_fetch_delay = attr.ib(type=int, default=3)
drop_old_keys = attr.ib(type=bool, default=False)
client_max_size = attr.ib(type=int, default=1024**2 * 100)


@attr.s
Expand Down Expand Up @@ -235,6 +238,13 @@ def read(self):
listen_set.add(listen_tuple)
drop_old_keys = section.getboolean("DropOldKeys")

client_max_size = section.getint("ClientMaxSize")

if not 0 < client_max_size:
raise PanConfigError(
"The client max size must be a positive integer"
)

server_conf = ServerConfig(
section_name,
homeserver,
Expand All @@ -249,6 +259,7 @@ def read(self):
indexing_batch_size,
history_fetch_delay / 1000,
drop_old_keys,
client_max_size,
)

self.servers[section_name] = server_conf
Expand Down
3 changes: 1 addition & 2 deletions pantalaimon/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,7 @@ async def init(data_dir, server_conf, send_queue, recv_queue):
client_store_class=store_class,
)

# 100 MB max POST size
app = web.Application(client_max_size=1024**2 * 100)
app = web.Application(client_max_size=server_conf.client_max_size)

app.add_routes(
[
Expand Down