Miscellaneous little things
This commit is contained in:
parent
586ccd4e87
commit
d40d34b4ca
21
src/kike.c
21
src/kike.c
|
@ -95,6 +95,8 @@ setup_signal_handlers (void)
|
||||||
|
|
||||||
// --- IRC token validation ----------------------------------------------------
|
// --- IRC token validation ----------------------------------------------------
|
||||||
|
|
||||||
|
// Use the enum only if applicable and a simple boolean isn't sufficient.
|
||||||
|
|
||||||
enum validation_result
|
enum validation_result
|
||||||
{
|
{
|
||||||
VALIDATION_OK,
|
VALIDATION_OK,
|
||||||
|
@ -473,10 +475,10 @@ error_ssl_1:
|
||||||
static void
|
static void
|
||||||
connection_kill (struct connection *conn, const char *reason)
|
connection_kill (struct connection *conn, const char *reason)
|
||||||
{
|
{
|
||||||
// TODO: send a QUIT message with `reason' || "Client exited"
|
// TODO: multicast a QUIT message with `reason' || "Client exited"
|
||||||
(void) reason;
|
(void) reason;
|
||||||
|
|
||||||
// TODO: do further cleanup if the client has successfully registered
|
// TODO: do further cleanup if the client has successfully registered etc.
|
||||||
|
|
||||||
struct server_context *ctx = conn->ctx;
|
struct server_context *ctx = conn->ctx;
|
||||||
ssize_t i = poller_find_by_fd (&ctx->poller, conn->socket_fd);
|
ssize_t i = poller_find_by_fd (&ctx->poller, conn->socket_fd);
|
||||||
|
@ -740,6 +742,7 @@ on_irc_connection_available (const struct pollfd *pfd, void *user_data)
|
||||||
static bool
|
static bool
|
||||||
irc_initialize_ssl (struct server_context *ctx)
|
irc_initialize_ssl (struct server_context *ctx)
|
||||||
{
|
{
|
||||||
|
// TODO: this could definitely return an error object
|
||||||
const char *ssl_cert = str_map_find (&ctx->config, "ssl_cert");
|
const char *ssl_cert = str_map_find (&ctx->config, "ssl_cert");
|
||||||
const char *ssl_key = str_map_find (&ctx->config, "ssl_key");
|
const char *ssl_key = str_map_find (&ctx->config, "ssl_key");
|
||||||
|
|
||||||
|
@ -890,11 +893,6 @@ irc_listen (struct server_context *ctx, struct error **e)
|
||||||
const char *bind_port = str_map_find (&ctx->config, "bind_port");
|
const char *bind_port = str_map_find (&ctx->config, "bind_port");
|
||||||
hard_assert (bind_port != NULL); // We have a default value for this
|
hard_assert (bind_port != NULL); // We have a default value for this
|
||||||
|
|
||||||
if (!irc_initialize_server_name (ctx, e))
|
|
||||||
return false;
|
|
||||||
if (!irc_initialize_motd (ctx, e))
|
|
||||||
return false;
|
|
||||||
|
|
||||||
struct addrinfo gai_hints, *gai_result, *gai_iter;
|
struct addrinfo gai_hints, *gai_result, *gai_iter;
|
||||||
memset (&gai_hints, 0, sizeof gai_hints);
|
memset (&gai_hints, 0, sizeof gai_hints);
|
||||||
|
|
||||||
|
@ -934,10 +932,10 @@ irc_listen (struct server_context *ctx, struct error **e)
|
||||||
print_debug ("%s: %s", "getnameinfo", gai_strerror (err));
|
print_debug ("%s: %s", "getnameinfo", gai_strerror (err));
|
||||||
|
|
||||||
if (bind (sockfd, gai_iter->ai_addr, gai_iter->ai_addrlen))
|
if (bind (sockfd, gai_iter->ai_addr, gai_iter->ai_addrlen))
|
||||||
print_error ("bind() to %s:%s failed: %s",
|
print_error ("bind to %s:%s failed: %s",
|
||||||
real_host, real_port, strerror (errno));
|
real_host, real_port, strerror (errno));
|
||||||
else if (listen (sockfd, 16 /* arbitrary number */))
|
else if (listen (sockfd, 16 /* arbitrary number */))
|
||||||
print_error ("listen() at %s:%s failed: %s",
|
print_error ("listen at %s:%s failed: %s",
|
||||||
real_host, real_port, strerror (errno));
|
real_host, real_port, strerror (errno));
|
||||||
else
|
else
|
||||||
break;
|
break;
|
||||||
|
@ -1079,7 +1077,9 @@ main (int argc, char *argv[])
|
||||||
|
|
||||||
if (!irc_initialize_ssl (&ctx))
|
if (!irc_initialize_ssl (&ctx))
|
||||||
exit (EXIT_FAILURE);
|
exit (EXIT_FAILURE);
|
||||||
if (!irc_initialize_catalog (&ctx, &e)
|
if (!irc_initialize_server_name (&ctx, &e)
|
||||||
|
|| !irc_initialize_motd (&ctx, &e)
|
||||||
|
|| !irc_initialize_catalog (&ctx, &e)
|
||||||
|| !irc_listen (&ctx, &e))
|
|| !irc_listen (&ctx, &e))
|
||||||
{
|
{
|
||||||
print_error ("%s", e->message);
|
print_error ("%s", e->message);
|
||||||
|
@ -1088,6 +1088,7 @@ main (int argc, char *argv[])
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: daemonize
|
// TODO: daemonize
|
||||||
|
// TODO: syslog (if not running in debug mode)
|
||||||
|
|
||||||
ctx.polling = true;
|
ctx.polling = true;
|
||||||
while (ctx.polling)
|
while (ctx.polling)
|
||||||
|
|
Loading…
Reference in New Issue