13 Commits
Author SHA1 Message Date
p 4179a9bd49 Update NEWS, bump version 2018-10-21 05:44:39 +02:00
p aa4e86c2a0 degesch: add a comment about ENOTCONN 2018-10-21 05:40:24 +02:00
p 5bbe9ceef8 Update NEWS 2018-10-21 05:40:24 +02:00
p f80226620c kike: fix wildcard handling in WHOIS 2018-10-21 05:40:24 +02:00
p 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
p 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
p 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
p 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
p b0f5b8c10d kike: do nothing on equivalent renicks 2018-08-01 09:17:12 +02:00
p d87d533078 kike: code cleanups 2018-08-01 09:16:45 +02:00
p 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
p 54d3406175 kike: fix grammar in config item description 2018-08-01 09:16:44 +02:00
p 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
+1 -1
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) endif ("${CMAKE_C_COMPILER_ID}" MATCHES "GNU" OR CMAKE_COMPILER_IS_GNUCC)
# Version # 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 # 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. # we could also detect dirty worktrees but that's very hard to get right.
+14
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" 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 * Code has been relicensed to 0BSD and moved to a private git hosting
+4 -1
View File
@@ -12,7 +12,7 @@ All of them have these potentially interesting properties:
- TLS support, including client certificates - TLS support, including client certificates
- lean on dependencies (with the exception of 'degesch') - lean on dependencies (with the exception of 'degesch')
- compact and arguably easy to hack on - compact and arguably easy to hack on
- permissive license - very permissive license
degesch degesch
------- -------
@@ -52,6 +52,9 @@ Not supported:
be used to implement this feature if needed be used to implement this feature if needed
- limits of almost any kind, just connections and mode `+l` - 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 ZyklonB
------- -------
The IRC bot. It builds upon the concept of my other VitaminA IRC bot. The main The IRC bot. It builds upon the concept of my other VitaminA IRC bot. The main
+2
View File
@@ -4758,6 +4758,8 @@ irc_real_shutdown (struct server *s)
s->transport->in_before_shutdown (s); s->transport->in_before_shutdown (s);
while (shutdown (s->socket, SHUT_WR) == -1) 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)) if (!soft_assert (errno == EINTR))
break; break;
+30 -19
View File
@@ -1,7 +1,7 @@
/* /*
* kike.c: the experimental IRC daemon * 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 * Permission to use, copy, modify, and/or distribute this software for any
* purpose with or without fee is hereby granted. * 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" }, { "operators", NULL, "IRCop TLS cert. fingerprints" },
{ "max_connections", "0", "Global connection limit" }, { "max_connections", "0", "Global connection limit" },
{ "ping_interval", "180", "Interval between PING's (sec)" }, { "ping_interval", "180", "Interval between PINGs (sec)" },
{ NULL, NULL, NULL } { NULL, NULL, NULL }
}; };
@@ -194,7 +194,8 @@ irc_validate_to_str (enum validation_result result)
} }
// Anything to keep it as short as possible // 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 N4 "[0-9]{1,3}"
#define N6 "[0-9ABCDEFabcdef]{1,}" #define N6 "[0-9ABCDEFabcdef]{1,}"
@@ -233,6 +234,13 @@ irc_is_valid_host (const char *host)
|| irc_is_valid_hostaddr (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 static bool
irc_is_valid_user (const char *user) 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) if (client && client != c)
RETURN_WITH_REPLY (c, IRC_ERR_NICKNAMEINUSE, nickname); 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) if (c->registered)
{ {
client_add_to_whowas (c); client_add_to_whowas (c);
@@ -1446,8 +1458,7 @@ irc_handle_nick (const struct irc_message *msg, struct client *c)
cstr_set (&c->nickname, xstrdup (nickname)); cstr_set (&c->nickname, xstrdup (nickname));
str_map_set (&ctx->users, nickname, c); str_map_set (&ctx->users, nickname, c);
if (!c->registered) irc_try_finish_registration (c);
irc_try_finish_registration (c);
} }
static void static void
@@ -1468,6 +1479,7 @@ irc_handle_user (const struct irc_message *msg, struct client *c)
cstr_set (&c->username, xstrdup (username)); cstr_set (&c->username, xstrdup (username));
cstr_set (&c->realname, xstrdup (realname)); cstr_set (&c->realname, xstrdup (realname));
c->mode = 0;
unsigned long m; unsigned long m;
if (xstrtoul (&m, mode, 10)) if (xstrtoul (&m, mode, 10))
@@ -1994,10 +2006,11 @@ irc_handle_chan_mode_change
mode_processor_step (&p, '+'); mode_processor_step (&p, '+');
while (*mode_string) while (*mode_string)
if (!mode_processor_step (&p, *mode_string++)) if (!mode_processor_step (&p, *mode_string++))
break; goto done_processing;
} }
// TODO: limit to three changes with parameter per command // TODO: limit to three changes with parameter per command
done_processing:
if (p.added.len || p.removed.len) if (p.added.len || p.removed.len)
{ {
struct str message = str_make (); struct str message = str_make ();
@@ -2446,12 +2459,12 @@ irc_handle_whois (const struct irc_message *msg, struct client *c)
{ {
struct str_map_iter iter = str_map_iter_make (&c->ctx->users); struct str_map_iter iter = str_map_iter_make (&c->ctx->users);
bool found = false; bool found = false;
while ((target = str_map_iter_next (&iter)) while ((target = str_map_iter_next (&iter)))
&& !irc_fnmatch (mask, target->nickname)) if (!irc_fnmatch (mask, target->nickname))
{ {
irc_send_whois_reply (c, target); irc_send_whois_reply (c, target);
found = true; found = true;
} }
if (!found) if (!found)
irc_send_reply (c, IRC_ERR_NOSUCHNICK, mask); irc_send_reply (c, IRC_ERR_NOSUCHNICK, mask);
} }
@@ -2715,7 +2728,7 @@ irc_try_join (struct client *c, const char *channel_name, const char *key)
else if (channel_get_user (chan, c)) else if (channel_get_user (chan, c))
return; 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) if ((chan->modes & IRC_CHAN_MODE_INVITE_ONLY)
&& !client_in_mask_list (c, &chan->invite_list) && !client_in_mask_list (c, &chan->invite_list)
&& !invited_by_chanop) && !invited_by_chanop)
@@ -2881,9 +2894,9 @@ irc_handle_stats_uptime (struct client *c)
static void static void
irc_handle_stats (const struct irc_message *msg, struct client *c) irc_handle_stats (const struct irc_message *msg, struct client *c)
{ {
char query; char query = 0;
if (msg->params.len < 1 || !(query = *msg->params.vector[0])) if (msg->params.len > 0)
RETURN_WITH_REPLY (c, IRC_ERR_NEEDMOREPARAMS, msg->command); query = *msg->params.vector[0];
if (msg->params.len > 1 && !irc_is_this_me (c->ctx, msg->params.vector[1])) 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]); RETURN_WITH_REPLY (c, IRC_ERR_NOSUCHSERVER, msg->params.vector[1]);
if (!(c->mode & IRC_USER_MODE_OPERATOR)) 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; 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 static void
@@ -3009,8 +3022,6 @@ static void
irc_process_message (const struct irc_message *msg, irc_process_message (const struct irc_message *msg,
const char *raw, void *user_data) const char *raw, void *user_data)
{ {
(void) raw;
struct client *c = user_data; struct client *c = user_data;
if (c->closing_link) if (c->closing_link)
return; return;