Compare commits
36 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
0fe0b56280
|
|||
|
f0281cf028
|
|||
|
da5dd4eb91
|
|||
|
10cb6651c0
|
|||
|
7f28dcd1ef
|
|||
|
61c52d793c
|
|||
|
b4dd0052ff
|
|||
|
e3c47c33fa
|
|||
|
80c1e8f8eb
|
|||
|
c5f49ab1e6
|
|||
|
6f62b9c0c7
|
|||
|
c1d69e3630
|
|||
|
c75ef167f2
|
|||
|
ddffc71abe
|
|||
|
5a0b2d1c57
|
|||
|
bb451a5050
|
|||
|
61f15ead8a
|
|||
|
17f430043a
|
|||
|
735096d76d
|
|||
|
1ba59e6ee0
|
|||
|
f9ba682c0e
|
|||
|
8e8ffe2c73
|
|||
|
d05c85833d
|
|||
|
2336340ad8
|
|||
|
8f5dec0456
|
|||
|
3dc6ee9a5b
|
|||
|
821ce04915
|
|||
|
2fe3b95ecd
|
|||
|
32c99c9d66
|
|||
|
cd7133e173
|
|||
|
b4ed52015a
|
|||
|
271689da99
|
|||
|
38c23d0d38
|
|||
|
439af8884c
|
|||
|
8ccf38ad76
|
|||
|
47a4c8beca
|
@@ -1,5 +1,5 @@
|
||||
cmake_minimum_required (VERSION 3.0)
|
||||
project (uirc3 VERSION 1.0.0 LANGUAGES C)
|
||||
project (uirc3 VERSION 1.2.0 LANGUAGES C)
|
||||
|
||||
# Options
|
||||
option (WANT_READLINE "Use GNU Readline for the UI (better)" ON)
|
||||
@@ -54,8 +54,6 @@ include_directories (${libssl_INCLUDE_DIRS})
|
||||
link_directories (${libssl_LIBRARY_DIRS})
|
||||
|
||||
if ("${CMAKE_SYSTEM_NAME}" MATCHES "BSD")
|
||||
include_directories (/usr/local/include)
|
||||
link_directories (/usr/local/lib)
|
||||
# Need this for SIGWINCH in FreeBSD and OpenBSD respectively;
|
||||
# our POSIX version macros make it undefined
|
||||
add_definitions (-D__BSD_VISIBLE=1 -D_BSD_SOURCE=1)
|
||||
@@ -63,7 +61,8 @@ endif ()
|
||||
|
||||
# -lrt is only for glibc < 2.17
|
||||
# -liconv may or may not be a part of libc
|
||||
foreach (extra iconv rt)
|
||||
# -lm may or may not be a part of libc
|
||||
foreach (extra iconv rt m)
|
||||
find_library (extra_lib_${extra} ${extra})
|
||||
if (extra_lib_${extra})
|
||||
list (APPEND project_libraries ${extra_lib_${extra}})
|
||||
@@ -115,7 +114,7 @@ if ((WANT_READLINE AND WANT_LIBEDIT) OR (NOT WANT_READLINE AND NOT WANT_LIBEDIT)
|
||||
elseif (WANT_READLINE)
|
||||
# OpenBSD's default readline is too old
|
||||
if ("${CMAKE_SYSTEM_NAME}" MATCHES "OpenBSD")
|
||||
include_directories (/usr/local/include/ereadline)
|
||||
include_directories (${OPENBSD_LOCALBASE}/include/ereadline)
|
||||
list (APPEND degesch_libraries ereadline)
|
||||
else ()
|
||||
list (APPEND degesch_libraries readline)
|
||||
@@ -218,7 +217,7 @@ foreach (page ${project_MAN_PAGES})
|
||||
endforeach ()
|
||||
|
||||
# CPack
|
||||
set (CPACK_PACKAGE_DESCRIPTION_SUMMARY "Experimental IRC client, daemon and bot")
|
||||
set (CPACK_PACKAGE_DESCRIPTION_SUMMARY "Unethical IRC client, daemon and bot")
|
||||
set (CPACK_PACKAGE_VERSION "${project_version_safe}")
|
||||
set (CPACK_PACKAGE_VENDOR "Premysl Eric Janouch")
|
||||
set (CPACK_PACKAGE_CONTACT "Přemysl Eric Janouch <p@janouch.name>")
|
||||
|
||||
2
LICENSE
2
LICENSE
@@ -1,4 +1,4 @@
|
||||
Copyright (c) 2014 - 2020, Přemysl Eric Janouch <p@janouch.name>
|
||||
Copyright (c) 2014 - 2021, Přemysl Eric Janouch <p@janouch.name>
|
||||
|
||||
Permission to use, copy, modify, and/or distribute this software for any
|
||||
purpose with or without fee is hereby granted.
|
||||
|
||||
35
NEWS
35
NEWS
@@ -1,3 +1,38 @@
|
||||
1.2.0 (2021-07-08) "There Are Other Countries As Well"
|
||||
|
||||
* degesch: added a /squery command for IRCnet
|
||||
|
||||
* degesch: added trivial support for SASL EXTERNAL, enabled by adding "sasl"
|
||||
to the respective server's "capabilities" list
|
||||
|
||||
* degesch: now supporting IRCv3.2 capability negotiation, including CAP DEL
|
||||
|
||||
* degesch: added support for IRCv3 chghost
|
||||
|
||||
* degesch: /deop and /devoice without arguments will use the client's user
|
||||
|
||||
* degesch: /set +=/-= now treats its argument as a string array
|
||||
|
||||
* degesch: made "/help /command" work the same way as "/help command" does
|
||||
|
||||
* degesch: /ban and /unban don't mangle extended bans anymore
|
||||
|
||||
* degesch: joining new channels no longer switches to their buffer
|
||||
automatically open them if the input buffer isn't empty
|
||||
|
||||
* censor.lua: now stripping colours from censored messages;
|
||||
their attributes are also configurable rather than always black on black
|
||||
|
||||
|
||||
1.1.0 (2020-10-31) "What Do You Mean By 'This Isn't Germany'?"
|
||||
|
||||
* degesch: made fancy-prompt.lua work with libedit
|
||||
|
||||
* kike: fixed a regression with an unspecified "bind_host"
|
||||
|
||||
* Miscellaneous minor improvements
|
||||
|
||||
|
||||
1.0.0 (2020-10-29) "We're Finally There!"
|
||||
|
||||
* Coming with real manual pages instead of help2man-generated stubs
|
||||
|
||||
19
README.adoc
19
README.adoc
@@ -3,8 +3,8 @@ uirc3
|
||||
:compact-option:
|
||||
|
||||
The [line-through]#unethical# edgy IRC trinity. This project consists of an
|
||||
experimental IRC client, daemon, and bot. It's all you're ever going to need
|
||||
for chatting, as long as you can make do with minimalist software.
|
||||
IRC client, daemon, and bot. It's all you're ever going to need for chatting,
|
||||
as long as you can make do with minimalist software.
|
||||
|
||||
All of them have these potentially interesting properties:
|
||||
|
||||
@@ -103,6 +103,7 @@ Or you can try telling CMake to make a package for you. For Debian it is:
|
||||
Usage
|
||||
-----
|
||||
'degesch' has in-program configuration. Just run it and read the instructions.
|
||||
Consult its link:degesch.adoc[man page] for details about the interface.
|
||||
|
||||
For the rest you might want to generate a configuration file:
|
||||
|
||||
@@ -124,7 +125,11 @@ as a `forking` type systemd user service.
|
||||
|
||||
Client Certificates
|
||||
-------------------
|
||||
'kike' uses SHA1 fingerprints of TLS client certificates to authenticate users.
|
||||
'degesch' will use the SASL EXTERNAL method to authenticate using the TLS
|
||||
client certificate specified by the respective server's `tls_cert` option
|
||||
if you add `sasl` to the `capabilities` option and the server supports this.
|
||||
|
||||
'kike' uses SHA-1 fingerprints of TLS client certificates to authenticate users.
|
||||
To get the fingerprint from a certificate file in the required form, use:
|
||||
|
||||
$ openssl x509 -in public.pem -outform DER | sha1sum
|
||||
@@ -152,13 +157,13 @@ Beware that you can easily break the program if you're not careful.
|
||||
How do I make degesch look like the screenshot?
|
||||
-----------------------------------------------
|
||||
First of all, you must build it with Lua support. With the defaults, degesch
|
||||
doesn't look very fancy because some things are rather hackish, and I also don't
|
||||
want to depend on UTF-8 or 256color terminals in the code. In addition to that,
|
||||
I appear to be one of the few people who use black on white terminals.
|
||||
doesn't look too fancy because I don't want to depend on Lua or 256-colour
|
||||
terminals. In addition to that, I appear to be one of the few people who use
|
||||
black on white terminals.
|
||||
|
||||
/set behaviour.date_change_line = "%a %e %b %Y"
|
||||
/set behaviour.plugin_autoload += "fancy-prompt.lua"
|
||||
/set behaviour.backlog_helper = "LESSSECURE=1 less -R +Gb -Ps'Backlog ?ltlines %lt-%lb?L/%L. .?e(END):?pB%pB\\%..'"
|
||||
/set behaviour.backlog_helper = "LESSSECURE=1 less -R +Gb1d -Ps'Backlog ?ltlines %lt-%lb?L/%L. .?e(END):?pB%pB\\%..'"
|
||||
/set attributes.userhost = "\x1b[38;5;109m"
|
||||
/set attributes.join = "\x1b[38;5;108m"
|
||||
/set attributes.part = "\x1b[38;5;138m"
|
||||
|
||||
@@ -6,7 +6,7 @@ degesch(1)
|
||||
|
||||
Name
|
||||
----
|
||||
degesch - an experimental IRC client
|
||||
degesch - terminal-based IRC client
|
||||
|
||||
Synopsis
|
||||
--------
|
||||
|
||||
@@ -85,3 +85,9 @@
|
||||
482 IRC_ERR_CHANOPRIVSNEEDED "%s :You're not channel operator"
|
||||
501 IRC_ERR_UMODEUNKNOWNFLAG ":Unknown MODE flag"
|
||||
502 IRC_ERR_USERSDONTMATCH ":Cannot change mode for other users"
|
||||
902 IRC_ERR_NICKLOCKED ":You must use a nick assigned to you"
|
||||
903 IRC_RPL_SASLSUCCESS ":SASL authentication successful"
|
||||
904 IRC_ERR_SASLFAIL ":SASL authentication failed"
|
||||
905 IRC_ERR_SASLTOOLONG ":SASL message too long"
|
||||
906 IRC_ERR_SASLABORTED ":SASL authentication aborted"
|
||||
907 IRC_ERR_SASLALREADY ":You have already authenticated using SASL"
|
||||
|
||||
@@ -6,7 +6,7 @@ kike(1)
|
||||
|
||||
Name
|
||||
----
|
||||
kike - an experimental IRC daemon
|
||||
kike - IRC daemon
|
||||
|
||||
Synopsis
|
||||
--------
|
||||
|
||||
33
kike.c
33
kike.c
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* kike.c: the experimental IRC daemon
|
||||
* kike.c: an IRC daemon
|
||||
*
|
||||
* Copyright (c) 2014 - 2020, Přemysl Eric Janouch <p@janouch.name>
|
||||
*
|
||||
@@ -614,7 +614,8 @@ struct server_context
|
||||
{
|
||||
int *listen_fds; ///< Listening socket FD's
|
||||
struct poller_fd *listen_events; ///< New connections available
|
||||
size_t n_listen_fds; ///< Number of listening sockets
|
||||
size_t listen_len; ///< Number of listening sockets
|
||||
size_t listen_alloc; ///< How many we've allocated
|
||||
|
||||
time_t started; ///< When has the server been started
|
||||
|
||||
@@ -695,7 +696,7 @@ server_context_free (struct server_context *self)
|
||||
{
|
||||
str_map_free (&self->config);
|
||||
|
||||
for (size_t i = 0; i < self->n_listen_fds; i++)
|
||||
for (size_t i = 0; i < self->listen_len; i++)
|
||||
{
|
||||
poller_fd_reset (&self->listen_events[i]);
|
||||
xclose (self->listen_fds[i]);
|
||||
@@ -746,12 +747,12 @@ irc_initiate_quit (struct server_context *ctx)
|
||||
{
|
||||
print_status ("shutting down");
|
||||
|
||||
for (size_t i = 0; i < ctx->n_listen_fds; i++)
|
||||
for (size_t i = 0; i < ctx->listen_len; i++)
|
||||
{
|
||||
poller_fd_reset (&ctx->listen_events[i]);
|
||||
xclose (ctx->listen_fds[i]);
|
||||
}
|
||||
ctx->n_listen_fds = 0;
|
||||
ctx->listen_len = 0;
|
||||
|
||||
for (struct client *iter = ctx->clients; iter; iter = iter->next)
|
||||
if (!iter->closing_link)
|
||||
@@ -3852,16 +3853,19 @@ irc_listen_resolve (struct server_context *ctx,
|
||||
int fd;
|
||||
for (gai_iter = gai_result; gai_iter; gai_iter = gai_iter->ai_next)
|
||||
{
|
||||
if (ctx->listen_len == ctx->listen_alloc)
|
||||
break;
|
||||
|
||||
if ((fd = irc_listen (gai_iter)) == -1)
|
||||
continue;
|
||||
set_blocking (fd, false);
|
||||
|
||||
struct poller_fd *event = &ctx->listen_events[ctx->n_listen_fds];
|
||||
struct poller_fd *event = &ctx->listen_events[ctx->listen_len];
|
||||
*event = poller_fd_make (&ctx->poller, fd);
|
||||
event->dispatcher = (poller_fd_fn) on_irc_client_available;
|
||||
event->user_data = ctx;
|
||||
|
||||
ctx->listen_fds[ctx->n_listen_fds++] = fd;
|
||||
ctx->listen_fds[ctx->listen_len++] = fd;
|
||||
poller_fd_set (event, POLLIN);
|
||||
}
|
||||
freeaddrinfo (gai_result);
|
||||
@@ -3882,13 +3886,20 @@ irc_setup_listen_fds (struct server_context *ctx, struct error **e)
|
||||
|
||||
struct strv ports = strv_make ();
|
||||
cstr_split (bind_port, ",", true, &ports);
|
||||
ctx->listen_fds = xcalloc (ports.len, sizeof *ctx->listen_fds);
|
||||
ctx->listen_events = xcalloc (ports.len, sizeof *ctx->listen_events);
|
||||
|
||||
// For C and simplicity's sake let's assume that the host will resolve
|
||||
// to at most two different addresses: IPv4 and IPv6 in case it is NULL
|
||||
ctx->listen_alloc = ports.len * 2;
|
||||
|
||||
ctx->listen_fds =
|
||||
xcalloc (ctx->listen_alloc, sizeof *ctx->listen_fds);
|
||||
ctx->listen_events =
|
||||
xcalloc (ctx->listen_alloc, sizeof *ctx->listen_events);
|
||||
for (size_t i = 0; i < ports.len; i++)
|
||||
irc_listen_resolve (ctx, bind_host, ports.vector[i], &gai_hints);
|
||||
strv_free (&ports);
|
||||
|
||||
if (!ctx->n_listen_fds)
|
||||
if (!ctx->listen_len)
|
||||
{
|
||||
error_set (e, "%s: %s",
|
||||
"network setup failed", "no ports to listen on");
|
||||
@@ -3991,7 +4002,7 @@ main (int argc, char *argv[])
|
||||
};
|
||||
|
||||
struct opt_handler oh =
|
||||
opt_handler_make (argc, argv, opts, NULL, "Experimental IRC daemon.");
|
||||
opt_handler_make (argc, argv, opts, NULL, "IRC daemon.");
|
||||
|
||||
int c;
|
||||
while ((c = opt_handler_get (&oh)) != -1)
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
--
|
||||
-- censor.lua: black out certain users' messages
|
||||
--
|
||||
-- Copyright (c) 2016, Přemysl Eric Janouch <p@janouch.name>
|
||||
-- Copyright (c) 2016 - 2021, Přemysl Eric Janouch <p@janouch.name>
|
||||
--
|
||||
-- Permission to use, copy, modify, and/or distribute this software for any
|
||||
-- purpose with or without fee is hereby granted.
|
||||
@@ -38,6 +38,7 @@ local read_masks = function (v)
|
||||
end
|
||||
end
|
||||
|
||||
local quote
|
||||
degesch.setup_config {
|
||||
masks = {
|
||||
type = "string_array",
|
||||
@@ -45,13 +46,29 @@ degesch.setup_config {
|
||||
comment = "user masks (optionally \"/#channel\") to censor",
|
||||
on_change = read_masks
|
||||
},
|
||||
quote = {
|
||||
type = "string",
|
||||
default = "\"\\x0301,01\"",
|
||||
comment = "formatting prefix for censored messages",
|
||||
on_change = function (v) quote = v end
|
||||
},
|
||||
}
|
||||
|
||||
local decolor = function (text)
|
||||
local rebuilt, last = {""}, 1
|
||||
for start in text:gmatch ('()\x03') do
|
||||
table.insert (rebuilt, text:sub (last, start - 1))
|
||||
local sub = text:sub (start + 1)
|
||||
last = start + (sub:match ('^%d%d?,%d%d?()') or sub:match ('^%d?%d?()'))
|
||||
end
|
||||
return table.concat (rebuilt) .. text:sub (last)
|
||||
end
|
||||
|
||||
local censor = function (line)
|
||||
-- Taking a shortcut to avoid lengthy message reassembly
|
||||
local start, text = line:match ("^(.- PRIVMSG .- :)(.*)$")
|
||||
local ctcp, rest = text:match ("^(\x01%g+ )(.*)")
|
||||
text = ctcp and ctcp .. "\x0301,01" .. rest or "\x0301,01" .. text
|
||||
text = ctcp and ctcp .. quote .. decolor (rest) or quote .. decolor (text)
|
||||
return start .. text
|
||||
end
|
||||
|
||||
|
||||
@@ -64,12 +64,13 @@ degesch.hook_prompt (function (hook)
|
||||
local lines, cols = degesch.get_screen_size ()
|
||||
x = x .. " " .. active .. string.rep (" ", cols)
|
||||
|
||||
-- Readline seems to be broken and completely corrupts the prompt
|
||||
-- (tested on 7.0.003 Archlinux, 7.0-5 Debian buster)
|
||||
x = x:gsub("[\128-\255]", "?")
|
||||
-- Readline 7.0.003 seems to be broken and completely corrupts the prompt.
|
||||
-- However 8.0.004 seems to be fine with these, as is libedit 20191231-3.1.
|
||||
--x = x:gsub("[\128-\255]", "?")
|
||||
|
||||
-- Cut off extra characters and apply formatting, including the hack.
|
||||
-- Note that this doesn't count with full-width or zero-width characters.
|
||||
-- FIXME: this doesn't count with full-width or zero-width characters.
|
||||
-- We might want to export wcwidth() above term_from_utf8 somehow.
|
||||
local overflow = utf8.offset (x, cols - 1)
|
||||
if overflow then x = x:sub (1, overflow) end
|
||||
x = "\x01\x1b[0;4;1;38;5;16m\x1b[48;5;" .. bg_color .. "m\x02" ..
|
||||
|
||||
2
test
2
test
@@ -1,5 +1,5 @@
|
||||
#!/usr/bin/expect -f
|
||||
# Very basic end-to-end testing for Travis CI
|
||||
# Very basic end-to-end testing for CI
|
||||
|
||||
# Run the daemon to test against
|
||||
system ./kike --write-default-cfg
|
||||
|
||||
26
test-nick-colors
Executable file
26
test-nick-colors
Executable file
@@ -0,0 +1,26 @@
|
||||
#!/bin/sh
|
||||
# Check whether the terminal colours filtered by our algorithm are legible
|
||||
export example=$(
|
||||
tcc "-run -lm" - <<-END
|
||||
#include <stddef.h>
|
||||
#include <stdio.h>
|
||||
#include <math.h>
|
||||
|
||||
#define N_ELEMENTS(a) (sizeof (a) / sizeof ((a)[0]))
|
||||
|
||||
$(perl -0777 -ne 'print $& if /^.*?\nfilter_color(?s:.*?)^}$/m' \
|
||||
"$(dirname "$0")"/degesch.c)
|
||||
|
||||
void main () {
|
||||
size_t len = 0;
|
||||
int *table = filter_color_cube_for_acceptable_nick_colors (&len);
|
||||
for (size_t i = 0; i < len; i++)
|
||||
printf ("<@\\x1b[38;5;%dmIRCuser\\x1b[m> I'm typing!\n", table[i]);
|
||||
}
|
||||
END
|
||||
)
|
||||
|
||||
# Both should give acceptable results,
|
||||
# which results in a bad compromise that the main author himself needs
|
||||
xterm -bg black -fg white -e 'echo $example; cat' &
|
||||
xterm -bg white -fg black -e 'echo $example; cat' &
|
||||
@@ -6,7 +6,7 @@ zyklonb(1)
|
||||
|
||||
Name
|
||||
----
|
||||
zyklonb - an experimental IRC bot
|
||||
zyklonb - modular IRC bot
|
||||
|
||||
Synopsis
|
||||
--------
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* zyklonb.c: the experimental IRC bot
|
||||
* zyklonb.c: a modular IRC bot
|
||||
*
|
||||
* Copyright (c) 2014 - 2020, Přemysl Eric Janouch <p@janouch.name>
|
||||
*
|
||||
@@ -1983,7 +1983,7 @@ main (int argc, char *argv[])
|
||||
};
|
||||
|
||||
struct opt_handler oh =
|
||||
opt_handler_make (argc, argv, opts, NULL, "Experimental IRC bot.");
|
||||
opt_handler_make (argc, argv, opts, NULL, "Modular IRC bot.");
|
||||
|
||||
int c;
|
||||
while ((c = opt_handler_get (&oh)) != -1)
|
||||
|
||||
Reference in New Issue
Block a user