Commit graph

50 commits

Author SHA1 Message Date
Simon Ser f3b06f4236 xirc: move over WHOX helpers 2022-05-29 18:33:29 +02:00
Simon Ser 9b37bd2eaa xirc: move over CapRegistry 2022-05-29 18:33:22 +02:00
Simon Ser fa6f52ed08 xirc: encode tokens in GenerateIsupport 2022-05-29 18:24:10 +02:00
Simon Ser c10d382a7d xirfc: move over message generation functions 2022-05-29 17:57:21 +02:00
Simon Ser 997fe723f0 xirc: move ChannelStatus over 2022-05-29 17:28:25 +02:00
Simon Ser 4af7a1b8e5 Rename join to generateJoin
For consistency with other functions.
2022-05-09 17:20:17 +02:00
Simon Ser c50fb4a26d xirc: move command constants over 2022-05-09 17:18:51 +02:00
Simon Ser b92afa7cca Introduce an xirc package 2022-05-09 16:15:00 +02:00
Simon Ser 3a7dee8128 Introduce a database package 2022-05-09 15:08:04 +02:00
Simon Ser 747263fc2d Simplify and improve WHOIS forwarding
Group together most WHOIS replies. While at it, add a few missing
replies.
2022-04-04 09:28:04 +02:00
Simon Ser 303c663d02 Refuse to change nick on bouncer connection
Also simplify the code.

Closes: https://todo.sr.ht/~emersion/soju/192
2022-04-01 14:55:36 +02:00
Simon Ser 16e43ee3a3 upstream: don't populate time tag for numerics
Allows us to save a few bytes, e.g. in WHO replies.
2022-03-22 21:14:02 +01:00
Simon Ser 78d9a84a6f Add support for RPL_VISIBLEHOST 2022-03-21 16:09:45 +01:00
Simon Ser 744c6e3f6d Enable bot mode for BouncerServ
See [1] for details.

[1]: https://ircv3.net/specs/extensions/bot-mode
2022-03-16 18:35:48 +01:00
Simon Ser 347a4979da irc: introduce capRegistry 2022-03-14 19:25:49 +01:00
Simon Ser 379e07f7d8 irc: simplify isHighlight 2022-02-25 11:32:09 +01:00
Simon Ser 1a56b2f658 Introduce formatServerTime
It's too easy to forget to convert to UTC.
2022-02-16 14:45:09 +01:00
Simon Ser 009bc29e09 Refactor generateWHOXReply
Isolate the field letter -> value logic into a separate function.
2022-02-09 15:16:54 +01:00
Simon Ser fe564af756 Handle upstream multi-line SASL
References: https://todo.sr.ht/~emersion/soju/173
2021-12-10 10:46:41 +01:00
Simon Ser 5d46dd72a4 Add support for MONITOR
Add support for MONITOR in single-upstream mode.

Each downstream has its own set of monitored targets. These sets
are merged together to compute the MONITOR commands to send to
upstream.

Each upstream has a set of monitored targets accepted by the server
alongside with their status (online/offline). This is used to
directly send replies to downstreams adding a target another
downstream has already added, and send MONITOR S[TATUS] replies.

Co-authored-by: delthas <delthas@dille.cc>
2021-11-15 14:34:04 +01:00
Hubert Hirtz 7fbaaefc9c Skip list/type A mode arguments
Type-A modes always have an argument[0], but soju doesn't care about
them since it doesn't keep track of mode lists (ban/invite/.. lists).

[0] https://modern.ircdocs.horse/#mode-message
> Type A: Modes that add or remove an address to or from a list. These
> modes MUST always have a parameter when sent from the server to a
> client.
2021-11-04 12:24:15 +01:00
Simon Ser 07c962018d Add title config option
Closes: https://todo.sr.ht/~emersion/soju/146
2021-11-02 22:38:07 +01:00
Simon Ser 832d8b89a2 Mark bouncer users and BouncerServ as authenticated in WHOX/WHOIS 2021-11-02 18:32:39 +01:00
Simon Ser 241e27b00e Add support for WHOX
This adds support for WHOX, without bothering about flags and mask2
because Solanum and Ergo [1] don't support it either.

The motivation is to allow clients to reliably query account names.

It's not possible to use WHOX tokens to route replies to the right
client, because RPL_ENDOFWHO doesn't contain it.

[1]: https://github.com/ergochat/ergo/pull/1184

Closes: https://todo.sr.ht/~emersion/soju/135
2021-11-02 18:25:43 +01:00
Simon Ser a9a066faac Add bouncer MOTD
Closes: https://todo.sr.ht/~emersion/soju/137
2021-10-13 10:58:34 +02:00
Hubert Hirtz b078ccaf7a Implement CHATHISTORY BETWEEN 2021-05-18 10:44:10 +02:00
Simon Ser 76e332b50a Move isHighlight to irc.go 2021-04-13 18:54:58 +02:00
Hubert Hirtz 70e5ed05b6 Make casemapping work over bytes instead of runes
Fixes a panic in partialCasemap when the input string was invalid UTF-8.
2021-04-13 12:48:46 +02:00
Simon Ser 6e5a307dc7 Introduce deliveredClientMap
Adds more semantics to map[string]string. Simplifies the complicated
mapStringStringCasemapMap type.
2021-03-26 11:21:14 +01:00
Hubert Hirtz bdd0c7bc06
Implement casemapping
TL;DR: supports for casemapping, now logs are saved in
casemapped/canonical/tolower form
(eg. in the #channel directory instead of #Channel... or something)

== What is casemapping? ==

see <https://modern.ircdocs.horse/#casemapping-parameter>

== Casemapping and multi-upstream ==

Since each upstream does not necessarily use the same casemapping, and
since casemappings cannot coexist [0],

1. soju must also update the database accordingly to upstreams'
   casemapping, otherwise it will end up inconsistent,
2. soju must "normalize" entity names and expose only one casemapping
   that is a subset of all supported casemappings (here, ascii).

[0] On some upstreams, "emersion[m]" and "emersion{m}" refer to the same
user (upstreams that advertise rfc1459 for example), while on others
(upstreams that advertise ascii) they don't.

Once upstream's casemapping is known (default to rfc1459), entity names
in map keys are made into casemapped form, for upstreamConn,
upstreamChannel and network.

downstreamConn advertises "CASEMAPPING=ascii", and always casemap map
keys with ascii.

Some functions require the caller to casemap their argument (to avoid
needless calls to casemapping functions).

== Message forwarding and casemapping ==

downstream message handling (joins and parts basically):
When relaying entity names from downstreams to upstreams, soju uses the
upstream casemapping, in order to not get in the way of the user.  This
does not brings any issue, as long as soju replies with the ascii
casemapping in mind (solves point 1.).

marshalEntity/marshalUserPrefix:
When relaying entity names from upstreams with non-ascii casemappings,
soju *partially* casemap them: it only change the case of characters
which are not ascii letters.  ASCII case is thus kept intact, while
special symbols like []{} are the same every time soju sends them to
downstreams (solves point 2.).

== Casemapping changes ==

Casemapping changes are not fully supported by this patch and will
result in loss of history.  This is a limitation of the protocol and
should be solved by the RENAME spec.
2021-03-24 18:15:52 +01:00
Simon Ser fa047123b9 Passthrough some ISUPPORT tokens 2021-03-15 23:41:37 +01:00
Simon Ser c654d2bac4
Format CTCP ACTION messages in logs 2020-08-17 15:01:53 +02:00
Simon Ser c490705fee
Sort and split JOIN messages
Sort channels so that channels with a key appear first. Split JOIN
messages so that we don't reach the message size limit.
2020-07-06 11:06:20 +02:00
Hubert Hirtz dc59263681
Send compact channel name lists
This commit resolves `sendNames`' TODO.
2020-06-30 10:28:05 +02:00
delthas f4e0c51366
Add support for TAGMSG and client message tags
Previously we dropped all TAGMSG as well as any client message tag sent
from downstream.

This adds support for properly forwarding TAGMSG and client message tags
from downstreams and upstreams.

TAGMSG messages are intentionally not logged, because they are currently
typically used for +typing, which can generate a lot of traffic and is
only useful for a few seconds after it is sent.
2020-05-27 23:48:08 +02:00
delthas c88700ef18
Fix parsing MODE messages by updating channel memberships
Previously, we only considered channel modes in the modes of a MODE
messages, which means channel membership changes were ignored. This
resulted in bugs where users channel memberships would not be properly
updated and cached with wrong values. Further, mode arguments
representing entities were not properly marshaled.

This adds support for correctly parsing and updating channel memberships
when processing MODE messages. Mode arguments corresponding to channel
memberships updates are now also properly marshaled.

MODE messages can't be easily sent from history because marshaling these
messages require knowing about the upstream available channel types and
channel membership types, which is currently only possible when
connected. For now this is not an issue since we do not send MODE
messages in history.
2020-05-21 22:36:54 +02:00
delthas 732b581eb2
Add support for multiple user channel memberships
User channel memberships are actually a set of memberships, not a single
value. This introduces memberships, a type representing a set of
memberships, stored as an array of memberships ordered by descending
rank.

This also adds multi-prefix to the permanent downstream and upstream
capabilities, so that we try to get all possible channel memberships.
2020-05-11 12:25:49 +02:00
Simon Ser 2053e62162
Request server-time cap
If the server didn't populate the time tag, do it ourselves.
2020-03-31 19:45:04 +02:00
delthas 3b6e175365
Add upstream RPL_CREATIONTIME support 2020-03-26 22:33:44 +01:00
delthas e19f8aaba4
Add upstream labeled-response capability support 2020-03-25 23:20:56 +01:00
delthas df8bfb75f2
Add upstream batch capability support 2020-03-25 23:16:53 +01:00
delthas 98a95e9955
Add MODE arguments support
- Add RPL_ISUPPORT support with CHANMODES, CHANTYPES, PREFIX parsing
- Add support for channel mode state with mode arguments
- Add upstream support for RPL_UMODEIS, RPL_CHANNELMODEIS
- Request channel MODE on upstream channel JOIN
- Use sane default channel mode and channel mode types
2020-03-25 09:40:08 +01:00
delthas b3ad960529 Add WHOIS support 2020-03-20 10:11:27 +01:00
Simon Ser 166d8b0626
Remove some IRCv3 constants
go-irc v3.1.2 adds some missing IRCv3 constants.
2020-03-19 14:51:45 +01:00
Simon Ser af76c3868a
Add CAP support for downstream connections 2020-03-16 15:05:24 +01:00
Simon Ser f3940117d1
Rename project to soju 2020-03-13 18:13:03 +01:00
Simon Ser 85ffadea33
Update dependencies
go-irc v3.1.1 contains a breaking change.

References: https://github.com/go-irc/irc/issues/76
2020-03-13 16:18:53 +01:00
Simon Ser 03d5600da6
Add support for SASL authentication
We now store SASL credentials in the database and automatically populate
them on NickServ REGISTER/IDENTIFY.

References: https://todo.sr.ht/~emersion/jounce/10
2020-03-13 15:12:44 +01:00
Simon Ser 96653499dc
Add parseMessageParams helper 2020-02-07 12:36:02 +01:00
Simon Ser 7876ddb9c8
Split IRC helpers to separate file 2020-02-06 19:24:32 +01:00