449 Commits

Author SHA1 Message Date
contact
0a87ae1452 Make length check clearer in sendNames
git-svn-id: file:///srv/svn/repo/suika/trunk@349 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2020-07-06 08:59:34 +00:00
contact
3367f4ebd8 Accept "irc" WebSocket subprotocol
git-svn-id: file:///srv/svn/repo/suika/trunk@348 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2020-07-02 09:05:49 +00:00
contact
51df0c157e Add RemoteAddr to ircConn interface
git-svn-id: file:///srv/svn/repo/suika/trunk@347 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2020-07-01 15:02:37 +00:00
hubert
3f1ece2d19 Send compact channel name lists
This commit resolves `sendNames`' TODO.

git-svn-id: file:///srv/svn/repo/suika/trunk@346 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2020-06-30 08:28:05 +00:00
contact
e9f9453cba Only read X-Forwarded-* if remote address is loopback
git-svn-id: file:///srv/svn/repo/suika/trunk@345 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2020-06-29 16:33:23 +00:00
contact
d97de5552f Extract X-Forwarded-* headers for WebSocket connections
git-svn-id: file:///srv/svn/repo/suika/trunk@344 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2020-06-29 16:27:43 +00:00
contact
35c7c0df7f Reply to WHO BouncerServ
Closes: https://todo.sr.ht/~emersion/soju/75

git-svn-id: file:///srv/svn/repo/suika/trunk@343 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2020-06-29 16:09:48 +00:00
contact
929f7b48c6 Handle registration failures
References: https://todo.sr.ht/~emersion/soju/30

git-svn-id: file:///srv/svn/repo/suika/trunk@342 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2020-06-29 15:52:49 +00:00
contact
8bf8de560b Return io.EOF on websocket connection closure
git-svn-id: file:///srv/svn/repo/suika/trunk@341 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2020-06-29 08:24:41 +00:00
hubert
a23ecb0998 Don't save corrupted NickServ credentials
soju saved most NickServ messages[0] as credentials because of a missing
`default` clause in the check of the NickServ command.

[0] messages that had at least a command and two other parameters

git-svn-id: file:///srv/svn/repo/suika/trunk@340 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2020-06-24 21:02:46 +00:00
contact
b371ea1bf2 service: list commands in lexicographic order
git-svn-id: file:///srv/svn/repo/suika/trunk@339 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2020-06-24 10:08:35 +00:00
delthas
a97dcd348b Fix sending messages from detached channels
Currently, a downstream receives MODE, RPL_CHANNELMODEIS and
RPL_CREATIONTIME messages from soju for detached channels. It should not
be sent any of these messages.

This adds a detach check to the handling of these messages to avoid
receiving these messages.

git-svn-id: file:///srv/svn/repo/suika/trunk@338 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2020-06-12 12:43:45 +00:00
contact
cd18b98c2a readme: extend copyright notice to all contributors
soju now has multiple contributors. Even if they weren't explicitly
listed as copyright holders, they still retain copyright ownership for
their contributions. Make this clear. See [1].

[1]: https://www.linuxfoundation.org/blog/2020/01/copyright-notices-in-open-source-software-projects/

git-svn-id: file:///srv/svn/repo/suika/trunk@337 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2020-06-12 12:37:43 +00:00
contact
6b4ba2d4ad readme: add link to website
git-svn-id: file:///srv/svn/repo/suika/trunk@336 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2020-06-10 21:00:50 +00:00
contact
3b3d7c4f5a Fix missing appendServiceCommandSetHelp argument
git-svn-id: file:///srv/svn/repo/suika/trunk@335 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2020-06-10 14:34:45 +00:00
fox.cpp
c3141986b1 Do not panic if BouncerServ command without handler is sent
git-svn-id: file:///srv/svn/repo/suika/trunk@334 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2020-06-10 14:33:13 +00:00
kl
969469c37d service: Handle zero-value in stringPtrFlag.String
FlagSet.PrintDefaults uses reflection to construct a zero value, calls
.String on it, and compares the result with the current flag value to
detect zero-value flags. For stringPtrFlag, this would result in a
panic, as String() always dereferenced the first level of its **string.

Add another check so that both pointer levels are nil-checked.

git-svn-id: file:///srv/svn/repo/suika/trunk@333 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2020-06-10 14:18:15 +00:00
contact
c9a86bef5f ci: check scdoc is happy
git-svn-id: file:///srv/svn/repo/suika/trunk@332 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2020-06-10 14:15:20 +00:00
kl
8851fa97a9 docs: Fix manpage syntax
git-svn-id: file:///srv/svn/repo/suika/trunk@331 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2020-06-10 14:10:17 +00:00
delthas
535e85051f sojuctl: Add support for creating admin users
This adds a new flag, `-admin` for creating admin users, which can
access admin service commands, among which create-user to create other
users on-the-fly.

Since the person running the commands in the README will be the local
soju administrator, the user they create should be admin as well, hence
the README update.

git-svn-id: file:///srv/svn/repo/suika/trunk@330 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2020-06-08 20:30:09 +00:00
delthas
6a71f953cb Add support for the user create admin service command
This adds support for user create, a new service command only accessible
to admin users. This lets users create other users on the fly and makes
soju start the user routine immediately; unlike sojuctl which currently
requires closing soju, creating the user, and starting soju again.

git-svn-id: file:///srv/svn/repo/suika/trunk@329 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2020-06-08 20:30:09 +00:00
delthas
ff63d3e24e Add support for admin-restricted service commands
This is preparatory work for creating new users from a service command.

This adds support for specifying specific service commands as
admin-restricted. Only admin users can run these commands. These
commands won't show up in the help when run from a non-admin
user, unless the user is requesting help for that specific command.

git-svn-id: file:///srv/svn/repo/suika/trunk@328 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2020-06-08 20:30:09 +00:00
delthas
d6d3e9ed7a Add an admin flag to users
This is preparatory work for letting some users access admin-exclusive
service commands, such as creating new users.

This adds a boolean admin flag to the User schema. Old users will stay
non-admin after the DB migration.

git-svn-id: file:///srv/svn/repo/suika/trunk@327 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2020-06-08 20:30:09 +00:00
delthas
7f49fa7971 Fix: Check the stdin scanner for errors when reading the password
Reading from stdin with Scanner.Scan() can either fail because of a read
error, or return no bytes because the EOF was reached.

This adds support for checking these cases before actually reading the
password.

git-svn-id: file:///srv/svn/repo/suika/trunk@326 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2020-06-08 20:30:09 +00:00
delthas
e853516870 Rename handleServiceCreateNetwork to handleServiceNetworkCreate
This renames handleServiceCreateNetwork for consistency with other
service commands.

git-svn-id: file:///srv/svn/repo/suika/trunk@325 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2020-06-08 20:30:09 +00:00
contact
7c4131cbdb Introduce User.Created
For Network and Channel, the database only needed to define one Store
operation to create/update a record. However since User is missing an ID
we couldn't have a single StoreUser function like other types. We had
CreateUser and UpdatePassword. As new User fields get added (e.g. the
upcoming Admin flag) this isn't sustainable.

We could have CreateUser and UpdateUser, but this wouldn't be consistent
with other types. Instead, introduce User.Created which indicates
whether the record is already stored in the DB. This can be used in a
new StoreUser function to decide whether we need to UPDATE or INSERT
without relying on SQL constraints and INSERT OR UPDATE.

The ListUsers and GetUser functions set User.Created to true.

git-svn-id: file:///srv/svn/repo/suika/trunk@324 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2020-06-08 09:59:03 +00:00
contact
f38af41317 Add support for WebSocket connections
WebSocket connections allow web-based clients to connect to IRC. This
commit implements the WebSocket sub-protocol as specified by the pending
IRCv3 proposal [1].

WebSocket listeners can now be set up via a "wss" protocol in the
`listen` directive. The new `http-origin` directive allows the CORS
allowed origins to be configured.

[1]: https://github.com/ircv3/ircv3-specifications/pull/342

git-svn-id: file:///srv/svn/repo/suika/trunk@323 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2020-06-07 12:13:46 +00:00
contact
b70a72598e Fail auth on empty password in DB
git-svn-id: file:///srv/svn/repo/suika/trunk@322 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2020-06-06 10:52:22 +00:00
contact
73e3e9a645 doc: update URL to sr.ht hub in man page
git-svn-id: file:///srv/svn/repo/suika/trunk@321 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2020-06-05 22:23:25 +00:00
contact
d0e4ccf213 doc: add missing change-password service command
git-svn-id: file:///srv/svn/repo/suika/trunk@320 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2020-06-05 22:21:37 +00:00
delthas
a079662c1b Add support for downstream CHATHISTORY
This adds support for the WIP (at the time of this commit)
draft/chathistory extension, based on the draft at [1] and the
additional comments at [2].

This gets the history by parsing the chat logs, and is therefore only
enabled when the logs are enabled and the log path is configured.

Getting the history only from the logs adds some restrictions:
- we cannot get history by msgid (those are not logged)
- we cannot get the users masks (maybe they could be inferred from the
  JOIN etc, but it is not worth the effort and would not work every
  time)

The regular soju network history is not sent to clients that support
draft/chathistory, so that they can fetch what they need by manually
calling CHATHISTORY.

The only supported command is BEFORE for now, because that is the only
required command for an app that offers an "infinite history scrollback"
feature.

Regarding implementation, rather than reading the file from the end in
reverse, we simply start from the beginning of each log file, store each
PRIVMSG into a ring, then add the last lines of that ring into the
history we'll return later. The message parsing implementation must be
kept somewhat fast because an app could potentially request thousands of
messages in several files. Here we are using simple sscanf and indexOf
rather than regexps.

In case some log files do not contain any message (for example because
the user had not joined a channel at that time), we try up to a 100 days
of empty log files before giving up.

[1]: https://github.com/prawnsalad/ircv3-specifications/pull/3/files
[2]: https://github.com/ircv3/ircv3-specifications/pull/393/files#r350210018

git-svn-id: file:///srv/svn/repo/suika/trunk@319 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2020-06-05 21:50:31 +00:00
fox.cpp
69e7615895 Fix handling of empty response to SASL challenge
git-svn-id: file:///srv/svn/repo/suika/trunk@318 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2020-06-05 09:35:43 +00:00
contact
adbb37b8d7 Allow multiple listeners, default to ircs
Users can now specify multiple "listen" directives in their
configuration file. If -listen is specified on the CLI, it's added to
the list of listeners.

Listeners are now parsed as URLs. If the scheme is missing "ircs" is
assumed. URLs allow to enable/disable TLS on a per-listener basis and
will be used for Unix sockets too.

The default listening address is changed from irc+insecure://:6667 to
ircs://:6697. This avoids setting up an insecure listener opened to
everybody.

git-svn-id: file:///srv/svn/repo/suika/trunk@317 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2020-06-04 18:16:23 +00:00
contact
17b8361e8b Remove keepAlivePeriod
This is a remnant of setKeepAlive.

Fixes: 77faf72fa33a ("Remove setKeepAlive")

git-svn-id: file:///srv/svn/repo/suika/trunk@316 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2020-06-04 16:38:04 +00:00
contact
5aef4e44a8 Introduce ircConn
This interface will allow a conn to be backed by a websocket.

git-svn-id: file:///srv/svn/repo/suika/trunk@315 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2020-06-04 15:27:57 +00:00
contact
e4b8266f5c Remove setKeepAlive
Go sets a default keep-alive interval of 15 seconds on all TCP
connections, if the platform supports it. See
net.ListenConfig.KeepAlive and net.Dialer.KeepAlive.

git-svn-id: file:///srv/svn/repo/suika/trunk@314 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2020-06-04 14:58:31 +00:00
contact
d7d1f89ecf Add network update command
The user.updateNetwork function is a bit involved because we need to
make sure that the upstream connection is closed before re-connecting
(would otherwise cause "Nick already used" errors) and that the
downstream connections' state is kept in sync.

References: https://todo.sr.ht/~emersion/soju/17

git-svn-id: file:///srv/svn/repo/suika/trunk@313 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2020-06-04 11:04:39 +00:00
contact
bbae37410e Close net.Conn in conn.Close
Close the connection in conn.Close. This ensures the connection isn't
still alive after conn.Close, which would cause issues when
disconnecting and reconnecting quickly to an upstream server.

git-svn-id: file:///srv/svn/repo/suika/trunk@312 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2020-06-04 10:18:51 +00:00
contact
297ef18a09 Introduce network.isClosed
git-svn-id: file:///srv/svn/repo/suika/trunk@311 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2020-06-03 15:28:31 +00:00
contact
cc7baf5863 Only send JOIN message if we have channels to join
Don't send a JOIN command to upstream server when no channels are configured.

git-svn-id: file:///srv/svn/repo/suika/trunk@310 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2020-06-03 15:18:57 +00:00
contact
6d56da1757 Unexport network.Stop
An exported function makes it look like it can be called from any
goroutine.

git-svn-id: file:///srv/svn/repo/suika/trunk@309 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2020-06-03 14:18:56 +00:00
admin
1f83ec54b1 Allow to read password when stdin is not a tty.
git-svn-id: file:///srv/svn/repo/suika/trunk@308 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2020-06-03 13:51:56 +00:00
fox.cpp
5f49770e07 Implement upstream SASL EXTERNAL support
Closes: https://todo.sr.ht/~emersion/soju/47

git-svn-id: file:///srv/svn/repo/suika/trunk@307 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2020-06-02 09:24:22 +00:00
hubert.hirtz
5de3081265 Send the full user mask in RPL_LOGGEDIN
As per the spec [1]:

    :server 900 <nick> <nick>!<ident>@<host> <account> :Now logged in

[1]: https://ircv3.net/specs/extensions/sasl-3.1

git-svn-id: file:///srv/svn/repo/suika/trunk@306 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2020-06-01 16:57:20 +00:00
ecs
bd6074df78 Join all channels with a single JOIN message
git-svn-id: file:///srv/svn/repo/suika/trunk@305 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2020-05-28 14:26:28 +00:00
delthas
0f15604644 Fix parsing upstream RPL_INVITING messages
Previously, we did not skip the first RPL_INVITING parameter, which is
the user nick (like in all replies), which made the parsing for that
reply incorrect.

This fixes RPL_INVITING parsing by skipping the first parameter.

git-svn-id: file:///srv/svn/repo/suika/trunk@304 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2020-05-27 21:51:44 +00:00
delthas
dd583107cd 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.

git-svn-id: file:///srv/svn/repo/suika/trunk@303 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2020-05-27 21:48:08 +00:00
delthas
85d6b50f07 Forward all labeled errors and unknown messages to their downstream
This adds support for forwarding all errors and unknown messages labeled
with a specific downstream to that downstream.

Provided that the upstream supports labeled-response, users will now be
able to receive an error only on their client when making a command that
returns an error, as well as receiving any reply unknown to soju.

git-svn-id: file:///srv/svn/repo/suika/trunk@302 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2020-05-27 21:47:49 +00:00
delthas
fde7afdd98 Send a label with all messages sent from downstream
This is preparatory work for forwarding errors of downstream-initiated
messages to their sender, as well as any other unknown message.

Preivously, we only sent labels (for labeled-response) for specific
downstream messages, such as WHO, where we knew the reply should only be
sent to that specific downstream.

However, in the case of an error of a message that is not labeled, the
error reply is not be tagged with a downstream id label and we can't
forward it to a specific downstream. It is not a good solution either to
forward this error to all downstreams.

This adds labels to all downstream-initiated messages (provided the
upstream supports it).

git-svn-id: file:///srv/svn/repo/suika/trunk@301 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2020-05-27 21:46:31 +00:00
delthas
d4088ba6a9 Add support for upstream ban, invite, and exception lists
This does not try to marshal nicks in masks, for simplicity and
consistency with the current behaviour of marshaling MODE messages.

git-svn-id: file:///srv/svn/repo/suika/trunk@300 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2020-05-27 21:45:13 +00:00