]> git.gir.st - ircpipe.git/log
ircpipe.git
4 weeks agoadd LF to error message
Tobias Girstmair [Sat, 25 May 2024 12:33:14 +0000 (14:33 +0200)]
add LF to error message

5 weeks agodocument non-filtering of escape sequences
Tobias Girstmair [Mon, 20 May 2024 16:44:59 +0000 (18:44 +0200)]
document non-filtering of escape sequences

5 weeks agofree TLS context after closing
Tobias Girstmair [Mon, 20 May 2024 16:36:50 +0000 (18:36 +0200)]
free TLS context after closing

as per libretls docs.

5 weeks agoupdate ircpipe spec document
Tobias Girstmair [Mon, 20 May 2024 16:17:07 +0000 (18:17 +0200)]
update ircpipe spec document

note that joining multiple channels doesn't need special handling; c.f.
     Command: JOIN
  Parameters: <channel>{,<channel>} [<key>{,<key>}]
  Alt Params: 0
one can just say `-j '#chan1,#chan2`. even protected channels work:
  -j '#chan1,#chan2 key1,key2'

5 weeks agoimprove PONG sending
Tobias Girstmair [Mon, 20 May 2024 16:04:18 +0000 (18:04 +0200)]
improve PONG sending

this gets rid of the double-send(2) (which in theory allows us to enable
Nagle's TCP_NODELAY). we need to restore the line terminator that strtok
removed. while the spec says we should send \r\n, it would probably
suffice to non-compliantly just do line[n] = '\n' (and rely on postel's
law to save us). but strtok only overwrites the first delimeter;
transforming "...\n..." into "...\0..." and "...\r\n..." into
"...\0\n...". so by looking ahead one byte we can determine which
terminator(s) were sent by the server and send back the same one(s). of
course, this doesn't hold for \n\r, just \r or \n\n (neither of which we
expect), but it would fall back to a sensible form regardless.

5 weeks agosimplify error messages for non-syscalls
Tobias Girstmair [Mon, 20 May 2024 15:49:06 +0000 (17:49 +0200)]
simplify error messages for non-syscalls

makes no sense to simulate perror for that kind of error.

5 weeks agoimplement socket timeout on connect
Tobias Girstmair [Mon, 20 May 2024 15:44:30 +0000 (17:44 +0200)]
implement socket timeout on connect

before this, we could have hung connecting to unavailable servers for
essentially ever. we only set SO_SNDTIMEO (not SO_RCVTIMEO) as we only
care when packets we send don't get ACKed in time (more specifically, we
only care about the server ACKing our initial SYN), not when the server
stops sending data for a while (the latter we handle using PING/PONG
ourselves).

c.f. https://stackoverflow.com/a/4182564. should cause EINPROGRESS for
connect(2), EAGAIN or EWOULDBLOCK otherwise.

5 weeks agoimplement handler for the usual terminating signals
Tobias Girstmair [Mon, 20 May 2024 15:40:21 +0000 (17:40 +0200)]
implement handler for the usual terminating signals

right now, we just send /QUIT and cleanly shut down the socket. in the
future, this allows us to do something to the socket on SIGUSR{1,2}, for
example.

6 weeks agoinitiate PING if socket idles for too long
Tobias Girstmair [Fri, 17 May 2024 14:55:37 +0000 (16:55 +0200)]
initiate PING if socket idles for too long

note that we only start tracking the monotonic timestamp of last
incoming socket activity in irc_poll(). because of that, we must
initialize recv_ts or we risk never sending the first PING when the
server doesn't send anything after the 001 numeric (e.g. znc with no
joined channels).

there isn't really a reason to configure ping interval/pong timeout, so
we just pick some values.

6 weeks agosimplify sasl handling
Tobias Girstmair [Fri, 17 May 2024 12:10:06 +0000 (14:10 +0200)]
simplify sasl handling

note that we still don't support multiple SASL chunks; the error
handling was just removed from irc_base64() (OR_DIE is incompatible with
assignment). we should probably verify this constraint in main().

6 weeks agodirectly exit from irc_answer() on error, improve error handling
Tobias Girstmair [Sun, 12 May 2024 18:56:26 +0000 (20:56 +0200)]
directly exit from irc_answer() on error, improve error handling

e.g. ERR_YOUREBANNEDCREEP (465) is sent after 001 but before JOIN.

6 weeks agoNULL-terminate read() calls
Tobias Girstmair [Sun, 12 May 2024 18:29:46 +0000 (20:29 +0200)]
NULL-terminate read() calls

we reuse the samme buffer for all network and local read(2)s. irc_answer
(or more specifically, strtok(3)) expects NULL-terminated strings. this
caused us to re-parse older strings when the buffer shrank between two
consecutive read(2) calls.

6 weeks agorework irc_answer to catch specific error replies and exit when encountered
Tobias Girstmair [Sun, 12 May 2024 17:27:08 +0000 (19:27 +0200)]
rework irc_answer to catch specific error replies and exit when encountered

we still need to pass the error line to the OR_DIE_irc macro, so it's
displayed on stderr (stdout is likely redirected).

8 weeks agorename PORT_PLAIN to PORT_TCP
Tobias Girstmair [Fri, 3 May 2024 18:30:09 +0000 (20:30 +0200)]
rename PORT_PLAIN to PORT_TCP

8 weeks agopartially revert IRCv3 USER
Tobias Girstmair [Fri, 3 May 2024 17:14:45 +0000 (19:14 +0200)]
partially revert IRCv3 USER

tilde prefixing to disable ident lookup seems to not be supported by
libera, so don't bother.

8 weeks agouse IRCv3 USER command
Tobias Girstmair [Fri, 3 May 2024 16:56:40 +0000 (18:56 +0200)]
use IRCv3 USER command

* mode must be '0'
* if the client's host does not expose an ident server, the username
  should be prefixed by '~'

living standard document: https://modern.ircdocs.horse/#user-message

2 months agoswitch to RFC2812 style USER command
Tobias Girstmair [Sat, 27 Apr 2024 12:18:17 +0000 (14:18 +0200)]
switch to RFC2812 style USER command

we don't (yet?) allow setting user mode, though.

2 months agoimplement TLS_WANT_POLL{IN,OUT}
Tobias Girstmair [Sat, 27 Apr 2024 10:43:40 +0000 (12:43 +0200)]
implement TLS_WANT_POLL{IN,OUT}

we always listen for POLLIN events, so we don't need to explicitly check
for it. not sure if this implementation is correct. modeled after
https://github.com/openbsd/src/blob/master/usr.bin/nc/netcat.c

2 months agodefend against malformed messages
Tobias Girstmair [Sat, 27 Apr 2024 10:41:31 +0000 (12:41 +0200)]
defend against malformed messages

if a message consists of only the prefix, we'd overrun the buffer.

2 months agodocument password and tls related flags
Tobias Girstmair [Sat, 27 Apr 2024 10:41:11 +0000 (12:41 +0200)]
document password and tls related flags

4 months agoimplement TLS support using libtls or libretls
Tobias Girstmair [Fri, 16 Feb 2024 20:56:12 +0000 (21:56 +0100)]
implement TLS support using libtls or libretls

also fixes some c90 related pedantic warnings and improves error
messages for bad or missing cli parameters.

3 years agoremove debug printfs
Tobias Girstmair [Mon, 28 Dec 2020 16:32:39 +0000 (17:32 +0100)]
remove debug printfs

3 years agouse getaddrinfo() for transparent ipv4/6 support
Tobias Girstmair [Mon, 28 Dec 2020 16:18:22 +0000 (17:18 +0100)]
use getaddrinfo() for transparent ipv4/6 support

introduces a malloc :(

3 years agofix polling standard input
Tobias Girstmair [Mon, 28 Dec 2020 15:15:08 +0000 (16:15 +0100)]
fix polling standard input

3 years agosupport server password (PASS message)
Tobias Girstmair [Mon, 28 Dec 2020 15:00:48 +0000 (16:00 +0100)]
support server password (PASS message)

3 years agoinitial commit
Tobias Girstmair [Wed, 23 Dec 2020 21:16:47 +0000 (22:16 +0100)]
initial commit

Imprint / Impressum