Commit Graph

1131 Commits

Author SHA1 Message Date
Simon Ser
d2067f74d8 database/sqlite: delete push subscriptions and msgstore in DeleteUser 2023-03-17 10:23:37 +01:00
Simon Ser
a30ca70713 Simplify push subscription pruning logic
Let's just delete on too old + any failure instead. This leaves
alone old + success, which can be beneficial when a device is
offline for a while.
2023-03-17 00:20:53 +01:00
Simon Ser
a14ea80cb9 Bump update time on success in network.broadcastWebPush
Allows us to skip checks when the client sends WEBPUSH REGISTER
and avoid pruning subscriptions that still work fine.
2023-03-17 00:06:13 +01:00
Simon Ser
93af53c91d Prune old Web Push subscriptions 2023-03-17 00:00:50 +01:00
Simon Ser
02ed7aa308 Set User-Agent when sending Web Push notifications
This allows push servers to figure out where the notifications are
coming from.
2023-03-16 23:31:39 +01:00
Simon Ser
2ce370d627 makefile: add variable with command list 2023-03-15 18:36:04 +01:00
Simon Ser
c183d938ff doc: add man page for sojuctl 2023-03-15 18:34:50 +01:00
Simon Ser
4c8e955946 Move DefaultUnixAdminPath to config package
We can drop the soju package import. This shrinks down sojuctl's
size significantly (18M to 3M).
2023-03-15 17:47:47 +01:00
Simon Ser
4ca8dfa37d downstream: fix nil pointer deref in downstreamConn.setUser
References: https://lists.sr.ht/~emersion/soju-dev/%3CCR6PX9SU5FSO.3UR92LHKXOXML%40hades.moritz.sh%3E
2023-03-15 17:34:18 +01:00
Simon Ser
6b82ed990c downstream: fix nickCM out-of-sync with effective case-mapping
We were unconditionally using the ASCII case-mapping in updateNick(),
for instance.

Introduce downstreamConn.casemap to fix this, and use it everywhere.
2023-03-01 14:59:08 +01:00
Simon Ser
aecff32103 Introduce UserUpdateFunc
References: https://todo.sr.ht/~emersion/soju/206
2023-03-01 14:16:33 +01:00
Simon Ser
67335130b1 service: use database.User.SetPassword instead of bcrypt 2023-03-01 14:14:09 +01:00
Simon Ser
4bebe4a1f2 xirc: improve CaseMapping docs 2023-03-01 13:59:27 +01:00
Simon Ser
7b41b0302d xirc: drop CaseMappingNone
Servers can't actually use this, so it's not very useful.
2023-03-01 13:58:01 +01:00
Simon Ser
ebd101820b Migrate casemapMap to xirc 2023-03-01 13:52:33 +01:00
Simon Ser
2b7a83b676 Take case-mapping as param in newCasemapMap()
Avoids situations where we forget to initialize it.
2023-03-01 13:43:51 +01:00
Simon Ser
de90648eaa Rename casemapMap.setCasemapping to setCaseMapping 2023-03-01 13:35:03 +01:00
Simon Ser
3eb2679612 Migrate case-mapping to xirc 2023-03-01 13:35:03 +01:00
Simon Ser
07cd1f2f5d Use generics for casemapMap 2023-03-01 13:15:38 +01:00
Simon Ser
3da6c23ad4 Pass-through ISUPPORT CASEMAPPING 2023-03-01 12:55:49 +01:00
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