Commit Graph

25 Commits

Author SHA1 Message Date
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