13 Commits

Author SHA1 Message Date
4179a9bd49 Update NEWS, bump version 2018-10-21 05:44:39 +02:00
aa4e86c2a0 degesch: add a comment about ENOTCONN 2018-10-21 05:40:24 +02:00
5bbe9ceef8 Update NEWS 2018-10-21 05:40:24 +02:00
f80226620c kike: fix wildcard handling in WHOIS 2018-10-21 05:40:24 +02:00
2fccfb10f7 kike: allow STATS with no parameters
We were in plain conflict with RFC 2812 for no apparent reason.
2018-10-21 05:40:16 +02:00
b9eddabedd kike: explicit conversion from pointer to boolean
In practice the values in the map may only be 1 or 0, so it doesn't
matter, but in C it is better to be safe than sorry.
2018-08-01 09:22:59 +02:00
50ed74a740 kike: break out properly on errors in MODE processing
We used to only abort the inner loop, which was insufficient.
2018-08-01 09:21:37 +02:00
3ca08badc2 kike: reset user modes while processing USER
Since the processing always succeeds and registration cannot be undone,
this doesn't seem to fix any real issue.
2018-08-01 09:17:45 +02:00
b0f5b8c10d kike: do nothing on equivalent renicks 2018-08-01 09:17:12 +02:00
d87d533078 kike: code cleanups 2018-08-01 09:16:45 +02:00
3c47e5b354 kike: fix grammar in hostname validation
This has an entry in RFC 2812 errata, although it's held for document
update.  We can afford the strictness.
2018-08-01 09:16:45 +02:00
54d3406175 kike: fix grammar in config item description 2018-08-01 09:16:44 +02:00
f79dd027e9 kike: add a comment about identifier encoding 2018-08-01 09:16:44 +02:00
5 changed files with 51 additions and 21 deletions

View File

@@ -13,7 +13,7 @@ if ("${CMAKE_C_COMPILER_ID}" MATCHES "GNU" OR CMAKE_COMPILER_IS_GNUCC)
endif ("${CMAKE_C_COMPILER_ID}" MATCHES "GNU" OR CMAKE_COMPILER_IS_GNUCC)
# Version
set (project_version "0.9.6")
set (project_version "0.9.7")
# Try to append commit ID if it follows a version tag. It might be nicer if
# we could also detect dirty worktrees but that's very hard to get right.

14
NEWS
View File

@@ -1,3 +1,17 @@
0.9.7 (2018-10-21) "Business as Usual"
* kike: fix wildcard handling in WHOIS
* kike: properly handle STATS without parametetrs
* kike: abort earlier when an invalid mode character is detected while
processing channel MODE messages
* kike: do not send NICK notifications when the nickname doesn't really change
* kike: fix hostname string verification (only used for "server_name")
0.9.6 (2018-06-22) "I've Been Sitting Here All This Time"
* Code has been relicensed to 0BSD and moved to a private git hosting

View File

@@ -12,7 +12,7 @@ All of them have these potentially interesting properties:
- TLS support, including client certificates
- lean on dependencies (with the exception of 'degesch')
- compact and arguably easy to hack on
- permissive license
- very permissive license
degesch
-------
@@ -52,6 +52,9 @@ Not supported:
be used to implement this feature if needed
- limits of almost any kind, just connections and mode `+l`
This program has been https://git.janouch.name/p/haven/src/branch/master/hid[
ported to Go], and development continues over there.
ZyklonB
-------
The IRC bot. It builds upon the concept of my other VitaminA IRC bot. The main

View File

@@ -4758,6 +4758,8 @@ irc_real_shutdown (struct server *s)
s->transport->in_before_shutdown (s);
while (shutdown (s->socket, SHUT_WR) == -1)
// XXX: we get ENOTCONN with OpenSSL (not plain) when a localhost
// server is aborted, why? strace says read 0, write 31, shutdown -1.
if (!soft_assert (errno == EINTR))
break;

39
kike.c
View File

@@ -1,7 +1,7 @@
/*
* kike.c: the experimental IRC daemon
*
* Copyright (c) 2014 - 2016, Přemysl Janouch <p@janouch.name>
* Copyright (c) 2014 - 2018, Přemysl Janouch <p@janouch.name>
*
* Permission to use, copy, modify, and/or distribute this software for any
* purpose with or without fee is hereby granted.
@@ -50,7 +50,7 @@ static struct simple_config_item g_config_table[] =
{ "operators", NULL, "IRCop TLS cert. fingerprints" },
{ "max_connections", "0", "Global connection limit" },
{ "ping_interval", "180", "Interval between PING's (sec)" },
{ "ping_interval", "180", "Interval between PINGs (sec)" },
{ NULL, NULL, NULL }
};
@@ -194,7 +194,8 @@ irc_validate_to_str (enum validation_result result)
}
// Anything to keep it as short as possible
#define SN "[0-9A-Za-z][-0-9A-Za-z]*[0-9A-Za-z]*"
// "shortname" from RFC 2812 doesn't work how its author thought it would.
#define SN "[0-9A-Za-z](-*[0-9A-Za-z])*"
#define N4 "[0-9]{1,3}"
#define N6 "[0-9ABCDEFabcdef]{1,}"
@@ -233,6 +234,13 @@ irc_is_valid_host (const char *host)
|| irc_is_valid_hostaddr (host);
}
// TODO: currently, we are almost encoding-agnostic (strings just need to be
// ASCII-compatible). We should at least have an option to enforce a specific
// encoding, such as UTF-8. Note that with Unicode we should not allow all
// character clasess and exclude the likes of \pM with the goal of enforcing
// NFC-normalized identifiers--utf8proc is a good candidate library to handle
// the categorization and validation.
static bool
irc_is_valid_user (const char *user)
{
@@ -1428,6 +1436,10 @@ irc_handle_nick (const struct irc_message *msg, struct client *c)
if (client && client != c)
RETURN_WITH_REPLY (c, IRC_ERR_NICKNAMEINUSE, nickname);
// Nothing to do here, let's not annoy roommates
if (c->nickname && !strcmp (c->nickname, nickname))
return;
if (c->registered)
{
client_add_to_whowas (c);
@@ -1446,7 +1458,6 @@ irc_handle_nick (const struct irc_message *msg, struct client *c)
cstr_set (&c->nickname, xstrdup (nickname));
str_map_set (&ctx->users, nickname, c);
if (!c->registered)
irc_try_finish_registration (c);
}
@@ -1468,6 +1479,7 @@ irc_handle_user (const struct irc_message *msg, struct client *c)
cstr_set (&c->username, xstrdup (username));
cstr_set (&c->realname, xstrdup (realname));
c->mode = 0;
unsigned long m;
if (xstrtoul (&m, mode, 10))
@@ -1994,10 +2006,11 @@ irc_handle_chan_mode_change
mode_processor_step (&p, '+');
while (*mode_string)
if (!mode_processor_step (&p, *mode_string++))
break;
goto done_processing;
}
// TODO: limit to three changes with parameter per command
done_processing:
if (p.added.len || p.removed.len)
{
struct str message = str_make ();
@@ -2446,8 +2459,8 @@ irc_handle_whois (const struct irc_message *msg, struct client *c)
{
struct str_map_iter iter = str_map_iter_make (&c->ctx->users);
bool found = false;
while ((target = str_map_iter_next (&iter))
&& !irc_fnmatch (mask, target->nickname))
while ((target = str_map_iter_next (&iter)))
if (!irc_fnmatch (mask, target->nickname))
{
irc_send_whois_reply (c, target);
found = true;
@@ -2715,7 +2728,7 @@ irc_try_join (struct client *c, const char *channel_name, const char *key)
else if (channel_get_user (chan, c))
return;
bool invited_by_chanop = str_map_find (&c->invites, channel_name);
bool invited_by_chanop = !!str_map_find (&c->invites, channel_name);
if ((chan->modes & IRC_CHAN_MODE_INVITE_ONLY)
&& !client_in_mask_list (c, &chan->invite_list)
&& !invited_by_chanop)
@@ -2881,9 +2894,9 @@ irc_handle_stats_uptime (struct client *c)
static void
irc_handle_stats (const struct irc_message *msg, struct client *c)
{
char query;
if (msg->params.len < 1 || !(query = *msg->params.vector[0]))
RETURN_WITH_REPLY (c, IRC_ERR_NEEDMOREPARAMS, msg->command);
char query = 0;
if (msg->params.len > 0)
query = *msg->params.vector[0];
if (msg->params.len > 1 && !irc_is_this_me (c->ctx, msg->params.vector[1]))
RETURN_WITH_REPLY (c, IRC_ERR_NOSUCHSERVER, msg->params.vector[1]);
if (!(c->mode & IRC_USER_MODE_OPERATOR))
@@ -2896,7 +2909,7 @@ irc_handle_stats (const struct irc_message *msg, struct client *c)
case 'u': irc_handle_stats_uptime (c); break;
}
irc_send_reply (c, IRC_RPL_ENDOFSTATS, query);
irc_send_reply (c, IRC_RPL_ENDOFSTATS, query ? query : '*');
}
static void
@@ -3009,8 +3022,6 @@ static void
irc_process_message (const struct irc_message *msg,
const char *raw, void *user_data)
{
(void) raw;
struct client *c = user_data;
if (c->closing_link)
return;