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

Set LINELEN to 8k for clients that support long messages #65

Merged
merged 1 commit into from
Feb 12, 2024
Merged
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 lib/irc/handler.ex
Original file line number Diff line number Diff line change
Expand Up @@ -607,6 +607,8 @@ defmodule M51.IrcConn.Handler do
"CHANMODES=b,,,i",
"CHANTYPES=#!",
"CHATHISTORY=100",
# Matrix limit is 64k for the whole event, so this is fairly conservative.
"LINELEN=#{@multiline_max_bytes}",
"MAXTARGETS=1",
# https://github.com/ircv3/ircv3-specifications/pull/510
"MSGREFTYPES=msgid",
Expand Down
9 changes: 8 additions & 1 deletion lib/irc_server.ex
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,14 @@
end

defp accept(port, retries_left \\ 10) do
case :gen_tcp.listen(port, [:binary, :inet6, packet: :line, active: false, reuseaddr: true]) do
opts = [
:binary, :inet6,
packet: :line,
active: false,
reuseaddr: true,
buffer: M51.IrcConn.Handler.multiline_max_bytes * 2

Check warning on line 48 in lib/irc_server.ex

View workflow job for this annotation

GitHub Actions / OTP 21 / Elixir 1.7.4

function M51.IrcConn.Handler.multiline_max_bytes/0 is undefined or private

Check warning on line 48 in lib/irc_server.ex

View workflow job for this annotation

GitHub Actions / OTP 22 / Elixir 1.7.4

function M51.IrcConn.Handler.multiline_max_bytes/0 is undefined or private

Check warning on line 48 in lib/irc_server.ex

View workflow job for this annotation

GitHub Actions / OTP 21 / Elixir 1.9

function M51.IrcConn.Handler.multiline_max_bytes/0 is undefined or private

Check warning on line 48 in lib/irc_server.ex

View workflow job for this annotation

GitHub Actions / OTP 22 / Elixir 1.9

function M51.IrcConn.Handler.multiline_max_bytes/0 is undefined or private

Check warning on line 48 in lib/irc_server.ex

View workflow job for this annotation

GitHub Actions / OTP 21 / Elixir 1.11

M51.IrcConn.Handler.multiline_max_bytes/0 is undefined or private

Check warning on line 48 in lib/irc_server.ex

View workflow job for this annotation

GitHub Actions / OTP 24 / Elixir 1.11

M51.IrcConn.Handler.multiline_max_bytes/0 is undefined or private

Check warning on line 48 in lib/irc_server.ex

View workflow job for this annotation

GitHub Actions / OTP 22 / Elixir 1.13

M51.IrcConn.Handler.multiline_max_bytes/0 is undefined or private

Check warning on line 48 in lib/irc_server.ex

View workflow job for this annotation

GitHub Actions / OTP 24 / Elixir 1.13

M51.IrcConn.Handler.multiline_max_bytes/0 is undefined or private
]
case :gen_tcp.listen(port, opts) do
{:ok, server_sock} ->
Logger.info("Listening on port #{port}")
loop_accept(server_sock)
Expand Down
2 changes: 1 addition & 1 deletion test/irc/handler_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ defmodule M51.IrcConn.HandlerTest do

@cap_ls_302 ":server. CAP * LS :account-tag batch draft/account-registration=before-connect draft/channel-rename draft/chathistory draft/message-redaction draft/multiline=max-bytes=8192 draft/no-implicit-names draft/sasl-ir echo-message extended-join labeled-response message-tags sasl=PLAIN server-time soju.im/account-required standard-replies userhost-in-names\r\n"
@cap_ls ":server. CAP * LS :account-tag batch draft/account-registration draft/channel-rename draft/chathistory draft/message-redaction draft/multiline draft/no-implicit-names draft/sasl-ir echo-message extended-join labeled-response message-tags sasl server-time soju.im/account-required standard-replies userhost-in-names\r\n"
@isupport "CASEMAPPING=rfc3454 CLIENTTAGDENY=*,-draft/react,-draft/reply CHANLIMIT= CHANMODES=b,,,i CHANTYPES=#! CHATHISTORY=100 MAXTARGETS=1 MSGREFTYPES=msgid PREFIX= TARGMAX=JOIN:1,PART:1 UTF8ONLY :are supported by this server\r\n"
@isupport "CASEMAPPING=rfc3454 CLIENTTAGDENY=*,-draft/react,-draft/reply CHANLIMIT= CHANMODES=b,,,i CHANTYPES=#! CHATHISTORY=100 LINELEN=8192 MAXTARGETS=1 MSGREFTYPES=msgid PREFIX= TARGMAX=JOIN:1,PART:1 UTF8ONLY :are supported by this server\r\n"

setup do
start_supervised!({MockMatrixClient, {self()}})
Expand Down
Loading