Join Matrix from your favorite IRC client
Matrix2051 (or M51 for short) is an IRC server backed by Matrix. You can also see it as an IRC bouncer that connects to Matrix homeservers instead of IRC servers. In other words:
IRC client
(eg. weechat or hexchat)
|
| IRC protocol
v
Matrix2051
|
| Matrix protocol
v
Your Homeserver
(eg. matrix.org)
Goals:
Non-goals:
Two notes on this screenshot:
sudo apt install elixir erlang erlang-dev erlang-inets erlang-xmerl
mix deps.get
mix test
mix run matrix2051.exs
localhost:2051
, with the following config:
user:homeserver.example.org
)See below for extra instructions to work with web clients.
See INSTALL.md
for a more production-oriented guide.
matrix2051.exs
starts M51.Application, which starts M51.Supervisor, which
supervises:
config.ex
: global config agentirc_server.ex
: a DynamicSupervisor
that receives connections from IRC clients.Every time irc_server.ex
receives a connection, it spawns irc_conn/supervisor.ex
,
which supervises:
irc_conn/state.ex
: stores the state of the connectionirc_conn/writer.ex
: genserver holding the socket and allowing
to write lines to it (and batches of lines in the future)irc_conn/handler.ex
: task busy-waiting on the incoming commands
from the reader, answers to the simple ones, and dispatches more complex
commandsmatrix_client/state.ex
: keeps the state of the connection to a Matrix homeservermatrix_client/client.ex
: handles one connection to a Matrix homeserver, as a single usermatrix_client/sender.ex
: sends events to the Matrix homeserver and with retries on failurematrix_client/poller.ex
: repeatedly asks the Matrix homeserver for new events (including the initial sync)irc_conn/reader.ex
: task busy-waiting on the incoming lines,
and sends them to the handlerUtilities:
matrix/raw_client.ex
: low-level Matrix client / thin wrapper around HTTP requestsirc/command.ex
: IRC line manipulation, including "downgrading" them for clients
that don't support some capabilities.irc/word_wrap.ex
: generic line wrappingformat/
: Convert between IRC's formatting and org.matrix.custom.html
matrix_client/chat_history.ex
: fetches message history from Matrix, when requested
by the IRC clientThere are many great IRC clients, but I can't find a Matrix client I like. Yet, some communities are moving from IRC to Matrix, so I wrote this so I can join them with a comfortable client.
This is also a way to prototype the latest IRCv3 features easily, and for me to learn the Matrix protocol.
In theory, any IRC client should work. In particular, I test it with Gamja, IRCCloud, The Lounge, and WeeChat.
Please open an issue if your client has any issue.
In theory, any, as I wrote this by reading the Matrix specs. In practice, this is only tested with Synapse.
A notable exception is registration, which uses a Synapse-specific API as Matrix itself does not specify registration.
Please open an issue if you have any issue with your homeserver (a dummy login/password I can use to connect to it would be appreciated).
At the time of writing, if both Matrix and IRC/IRCv3 support them, Matrix2051 likely will. Take a look at the list of open 'enhancement' issues.
A notable exception is direct messages, because Matrix's model differs significantly from IRC's.
To connect web clients, you need a websocket gateway. Matrix2051 was tested with KiwiIRC's webircgateway (try this patch if you need to run it on old Go versions).
Here is how you can configure it to connect to Matrix2051 with Gamja:
[fileserving]
enabled = true
webroot = "/path/to/gamja"
[upstream.1]
hostname = "localhost"
port = 2051
tls = false
# Connection timeout in seconds
timeout = 20
# Throttle the lines being written by X per second
throttle = 100
webirc = ""
serverpassword = ""
This is a reference to xkcd 1782:
Join #matrix2051 at irc.interlinked.me. (No I am not eating my own dogfood, I still prefer "native" IRC.)