Commit Graph

1111 Commits

Author SHA1 Message Date
Simon Ser
637b989a47 Add downstreamConn.updateCasemapping()
We weren't correctly updating nickCM.
2023-03-01 12:55:10 +01:00
Simon Ser
568de1d5d2 Drop unused partialCasemap() helper 2023-03-01 12:54:43 +01:00
Simon Ser
9b31dbfb24 upstream: drop unnecessary network nil check
Remnant from multi-upstream.
2023-03-01 11:52:42 +01:00
Simon Ser
ce38d16454 downstream: reset map with correct casemapping on MONITOR C 2023-02-28 19:11:39 +01:00
Simon Ser
437f7a74f0 upstream: convert ISUPPORT tokens to upper-case 2023-02-28 18:41:10 +01:00
Simon Ser
2dfb31ac0b upstream: drop unnecessary casemapIsSet field 2023-02-28 18:40:07 +01:00
Simon Ser
36d6cb19a4 Move authError to auth package
This allows auth backends to customize the error message displayed
to the user.
2023-02-23 22:32:24 +01:00
Simon Ser
05a0775658 Silence "Web Push subscription expired" errors
These are expected to happen from time to time, nothing to worry
about.
2023-02-23 13:48:02 +01:00
Simon Ser
f7fbf2ea72 identd: use UNKNOWN for OS name
Some servers like snircd reject OTHER [1], because OTHER can be
used when the ident string is not stable (e.g. is an audit token
that changes each time the ident is queried).

[1]: 17c92003d3/ircd/s_auth.c (L559)
2023-02-23 13:27:25 +01:00
Simon Ser
21eb384bd6 identd: reference RFC 2023-02-23 13:00:01 +01:00
Simon Ser
5a1cbc425f Remove legacy Go build comments 2023-02-23 10:33:48 +01:00
Simon Ser
7e891569b8 Drop isErrClosed
We require a new enough Go version now.
2023-02-23 10:32:36 +01:00
Simon Ser
522f8a80d7 Bump minimum Go version to 1.19
Two reasons:

- Because of [1], when mattn/go-sqlite3 is used without libsqlite3,
  we need Go 1.19.
- atomic.Int64 has been introduced in Go 1.19.

[1]: https://github.com/golang/go/issues/58438
2023-02-22 23:46:14 +01:00
Simon Ser
8bbc2265be doc/packaging: new page 2023-02-22 21:25:10 +01:00
Simon Ser
8ad5a5fb3a readme: merge paragraphs about GOFLAGS 2023-02-22 21:12:22 +01:00
sentriz
5a26674614 database/postgres: fix StoreNetwork positional arguments 2023-02-18 15:42:00 +01:00
Simon Ser
8f1f67f1f0 Rate limit Web Push checks
No need to re-check that a Web Push subscription is valid every
time a downstream connects. Mobile devices may reconnect pretty
frequently.

Check at most once a day.
2023-02-18 13:27:13 +01:00
Simon Ser
b6c0841291 msgstore: move ZNC log functions to separate package 2023-02-17 14:35:25 +01:00
delthas
e510f7a461 Add support for explicit PostgreSQL schema prefixes for tests
PostgreSQL tests use pg_temp only. pg_temp is never searched for FTS
objects, so creating then altering an FTS configuration will not work
because PostgreSQL will not be able to find the FTS configuration it
just created.

Instead, we explicitly refer to the FTS objects with their full name
including their prefix, which makes PostgreSQL able to find the object.

This is only needed for tests.

See: https://stackoverflow.com/a/31095452/2347617
See: https://www.postgresql.org/message-id/15191.1208975632@sss.pgh.pa.us
2023-02-17 14:13:43 +01:00
delthas
1ccc7ce6d2 Add a database store for messages
This adds a new config option, `logs db`, which enables storing chat
logs in the soju database.

Regular store options, CHATHISTORY options, and SEARCH operations are
supported, like the fs logs backend.

Messages are stored in a new table, Message. In order to track the list
of targets we have messages for in an optimized manner, another database
is used: MessageTarget.

All new requests are backend by indexes so should be fast even with
hundreds of thousands of messages.

A contrib script is provided for migrating existing logs fs chat logs to
the database. It can be run with eg:

  go run ./contrib/migrate-logs/ logs/ sqlite3:soju.db

Co-authored-by: Simon Ser <contact@emersion.fr>
2023-02-17 14:13:43 +01:00
Simon Ser
47f0dd5b3f downstream: send MSGREFTYPES ISUPPORT
References: https://github.com/ircv3/ircv3-specifications/pull/510
2023-02-13 19:25:42 +01:00
Simon Ser
251af0d9d3 database/postgres: fix nil time errors
We need to use sql.NullTime, otherwise we get errors like these:

    sql: Scan error on column index 7, name "downstream_interacted_at": unsupported Scan, storing driver.Value type <nil> into type *time.Time
2023-02-13 19:22:15 +01:00
palm93
478bd2077b build: fix binaries not being built
Without -o, when multiple packages are built, go build discards the
resulting binaries.
2023-02-11 23:28:29 +01:00
palm93
20b1159c02 gitignore: add sojudb 2023-02-11 23:27:17 +01:00
Simon Ser
bf931709db Drop permissions on Unix admin socket 2023-02-07 10:10:05 +01:00
Simon Ser
67ccc19fdd build: invoke go build once only 2023-02-06 15:26:10 +01:00
Simon Ser
09e1393453 build: don't record DESTDIR in config.DefaultPath 2023-02-06 15:23:54 +01:00
Simon Ser
0cec35a2f8 build: add RUNDIR variable 2023-02-06 15:23:14 +01:00
Simon Ser
c0b03b943f build: add sharedstatedir variable 2023-02-06 15:19:08 +01:00
delthas
f57492af56 Add cmd/sojuctl
This new command enables communicating with the unix administrative
endpoint (unix+admin) that can be enabled on soju.

The syntax is just that of BouncerServ.

Examples:
    sojuctl -config soju.config help
    sojuctl -config soju.config user status
2023-02-06 15:15:09 +01:00
delthas
6fe955e7ff Listen on the default unix admin endpoint in the default configuration
This preserves the previous behavior of *not* enabling any unix+admin
endpoint for developement purposes, but enables it in the default
configuration installed by the Makefile.
2023-02-06 15:15:09 +01:00
delthas
2713bcba34 Add administrative unix listen endpoint
This adds support for listening on a Unix socket for administrative
connections, that then use a simple protocol for communicating with
the service (BouncerServ) as an administrator with a global context.

The wire format used by the Unix socket is IRC, but without
registration or overheads.

Example session:

    >>> BOUNCERSERV
    <<< 461 * BOUNCERSERV :Not enough parameters
    >>> BOUNCERSERV :n s
    <<< :gensou FAIL BOUNCERSERV :this command must be run as a user
    >>> BOUNCERSERV :u s
    <<< :gensou PRIVMSG * :marisa: 2 networks
    <<< :gensou PRIVMSG * :alice: 1 networks
    <<< :gensou BOUNCERSERV OK
2023-02-06 15:15:09 +01:00
delthas
ab235f0099 sojuctl: rename to sojudb
sojuctl will be used to control the soju deamon directly.

sojudb is a better name because it operates on the database file only.
2023-02-06 15:15:09 +01:00
delthas
b920facdff service: Return the error rather than printing it
This enables callers to make the difference between a successful
service call and a failed one.
2023-02-06 15:15:09 +01:00
delthas
f05bd84787 service: Enable running additional commands from a global context
Some commands do not require admin rights but are also useful to
run in a global context. For example, help.
2023-02-06 15:15:09 +01:00
delthas
d17c7d57f2 service: Enable running service commands without users
This enables support for global service contexts, that are run
independently from a user context.

These contexts are considered to be admin. They only have access
to admin commands, because those are relevant in a global context.
2023-02-06 15:15:09 +01:00
delthas
4bd600c651 service: Store the admin capability independently the user
We can acquire admin contexts independently of the user.

This is mainly for a future commit that will introduce events
without a user.
2023-02-06 15:15:09 +01:00
Simon Ser
c031e08d71 Add a default path for the config file 2023-02-06 13:16:55 +01:00
Simon Ser
b4731cbd71 downstream: only send CHATHISTORY ISUPPORT when supported 2023-02-02 19:36:18 +01:00
Simon Ser
a331d2368a config: add missing "pam" case
Fixes: 24cae474db ("Add support for PAM authentication")
2023-01-30 23:32:07 +01:00
Kirill Primak
b2d9af22c3 service: update "user {create,update}" help 2023-01-30 20:33:30 +01:00
Simon Ser
24cae474db Add support for PAM authentication 2023-01-30 11:55:43 +01:00
Simon Ser
ca2d666056 Auto-create users after external auth when enable-user-on-auth is on 2023-01-30 11:53:01 +01:00
Simon Ser
c79fc0c19e Add support for SASL OAUTHBEARER 2023-01-30 11:53:01 +01:00
Simon Ser
22a88079c2 Add support for external OAuth 2.0 authentication 2023-01-30 11:53:01 +01:00
Simon Ser
63ca247354 Add infrastructure for external authentication 2023-01-30 11:53:01 +01:00
Simon Ser
d67e59658d Use database.User.SetPassword in server tests 2023-01-30 11:20:27 +01:00
Simon Ser
979fb319fe service: add -disable-password
This can be used to disable password authentication for a user.
This is useful to prevent a disabled user account from being
auto-enabled when enable-user-on-auth is on.
2023-01-26 20:03:37 +01:00
Simon Ser
db49bc120f Add enable-user-on-auth config directive 2023-01-26 19:51:35 +01:00
Simon Ser
9df9880301 Add disable-inactive-user config option
This can be used to automatically disable users if they don't
actively use the bouncer for a while.
2023-01-26 19:42:29 +01:00