Commit Graph

920 Commits

Author SHA1 Message Date
Simon Ser
ef2dd479bf
Add accept-proxy-ip config directive
This allows to set the list of IPs allowed to act as a proxy. This is
only used for WebSockets right now, but will be expanded to TCP as well
once the PROXY protocol is supported.
2020-07-22 17:03:01 +02:00
Simon Ser
b0bf012bbc
Change unix:// to irc+unix://
When Unix socket support will be added for listeners, unix:// will be
ambiguous. It won't be clear whether to setup an IRC server, or some
other kind of server (e.g. identd).

unix:// is still recognized to avoid breaking existing DBs.
2020-07-22 15:44:19 +02:00
Simon Ser
d3661705dc
doc: add example config file in man page 2020-07-22 15:43:22 +02:00
Simon Ser
ec7c78050a
readme: mention the znc-import tool 2020-07-22 13:36:19 +02:00
Nomeji
9d27f393dc readme: expand usage 2020-07-22 13:06:03 +02:00
Simon Ser
c616a17041
doc: mention SASL EXTERNAL in the CertFP docs 2020-07-22 12:51:32 +02:00
Simon Ser
cc01ffc19d
Rename certfp reset to sasl reset
And make it reset all SASL credentials.
2020-07-22 12:20:52 +02:00
Simon Ser
2a3ae55f52
Add a sasl set-plain command
This allows to manually set the SASL credentials for a network.
2020-07-22 12:16:13 +02:00
Simon Ser
cd3eacdbfc
go fmt 2020-07-22 12:16:01 +02:00
Simon Ser
360ce5b72d
doc: document the network update command 2020-07-22 12:04:26 +02:00
Simon Ser
dcfe206bda
Implement CHATHISTORY AFTER
References: https://todo.sr.ht/~emersion/soju/12
2020-07-15 17:47:57 +02:00
Simon Ser
25d4312e0f
Prevent error handler from falling through in user.run 2020-07-09 14:20:23 +02:00
Simon Ser
907da56311
Add unix as supported upstream URL scheme to service 2020-07-09 12:19:51 +02:00
Simon Ser
1ac895430a
contrib/znc-import: new utility
Allows populating the soju database from a ZNC config file.
2020-07-09 11:25:25 +02:00
Simon Ser
7ebe47ad4a
Fix deadlock in DB.Close
This method was calling itself, instead of the underlying SQLite
database's Close method.
2020-07-09 11:23:51 +02:00
Simon Ser
51dc9f0bf9
Broadcast unhandled messages to downstream connections
In case labelled-response isn't supported, broadcast unhandled messages
to all downstream connections. That's better than silently dropping the
messages.
2020-07-08 18:21:52 +02:00
Simon Ser
1685ba23b3
Strip network name from nickname when auto-saving network 2020-07-06 18:13:40 +02:00
Simon Ser
85fad93a71
Add support for upstream Unix socket connections
References: https://todo.sr.ht/~emersion/soju/51
2020-07-06 17:31:11 +02:00
Simon Ser
7af21d9d81
Parse upstream URLs with net/url
This allows us to ignore the path part of the URL. This is preliminary
work for unix URLs.
2020-07-06 17:18:13 +02:00
Simon Ser
b46a2554e1
Check upstream address with net.SplitHostPort
Looking for a colon is incorrect, IPv6 addresses can contain colons too.
2020-07-06 16:04:56 +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
Simon Ser
4c8b01fb51
Make length check clearer in sendNames 2020-07-06 10:59:34 +02:00
Simon Ser
82990fb774
Accept "irc" WebSocket subprotocol 2020-07-02 11:05:49 +02:00
Simon Ser
3397965dea
Add RemoteAddr to ircConn interface 2020-07-01 17:02:37 +02:00
Hubert Hirtz
dc59263681
Send compact channel name lists
This commit resolves `sendNames`' TODO.
2020-06-30 10:28:05 +02:00
Simon Ser
a9887114d5
Only read X-Forwarded-* if remote address is loopback 2020-06-29 18:33:23 +02:00
Simon Ser
2c172fa8ca
Extract X-Forwarded-* headers for WebSocket connections 2020-06-29 18:27:43 +02:00
Simon Ser
90250f5be5
Reply to WHO BouncerServ
Closes: https://todo.sr.ht/~emersion/soju/75
2020-06-29 18:09:48 +02:00
Simon Ser
d26194f62d
Handle registration failures
References: https://todo.sr.ht/~emersion/soju/30
2020-06-29 17:52:49 +02:00
Simon Ser
0fa07f5f9a
Return io.EOF on websocket connection closure 2020-06-29 10:24:41 +02:00
Hubert Hirtz
cfb1de044e
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
2020-06-24 23:02:46 +02:00
Simon Ser
6c453aa5ca
service: list commands in lexicographic order 2020-06-24 12:08:35 +02:00
delthas
2232b3128b 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.
2020-06-12 14:43:45 +02:00
Simon Ser
ccf9cff351
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/
2020-06-12 14:37:43 +02:00
Simon Ser
33a69edbfe
readme: add link to website 2020-06-10 23:00:50 +02:00
Simon Ser
67f8773320
Fix missing appendServiceCommandSetHelp argument 2020-06-10 16:34:45 +02:00
fox.cpp
ce37fcc7c2
Do not panic if BouncerServ command without handler is sent 2020-06-10 16:33:13 +02:00
Kenny Levinsen
1cbdb26dd1
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.
2020-06-10 16:18:15 +02:00
Simon Ser
18250311b9
ci: check scdoc is happy 2020-06-10 16:15:20 +02:00
Kenny Levinsen
7e7393bd23
docs: Fix manpage syntax 2020-06-10 16:10:17 +02:00
delthas
21af06302a 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.
2020-06-08 22:30:09 +02:00
delthas
5be25711c7 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.
2020-06-08 22:30:09 +02:00
delthas
f5611ae3f9 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.
2020-06-08 22:30:09 +02:00
delthas
d1b4faa529 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.
2020-06-08 22:30:09 +02:00
delthas
ed943f5451 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.
2020-06-08 22:30:09 +02:00
delthas
17fe033adc Rename handleServiceCreateNetwork to handleServiceNetworkCreate
This renames handleServiceCreateNetwork for consistency with other
service commands.
2020-06-08 22:30:09 +02:00
Simon Ser
998546cdc3
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.
2020-06-08 11:59:03 +02:00
Simon Ser
d0cf1d2882
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
2020-06-07 14:13:46 +02:00
Simon Ser
4b3469335e
Fail auth on empty password in DB 2020-06-06 12:52:22 +02:00
Simon Ser
e54293cd0e
doc: update URL to sr.ht hub in man page 2020-06-06 00:23:25 +02:00