LIBBLOCKLIST(3)
β¨ NAME β¨
okay so bestie, welcome to LIBBLOCKLIST(3) from the Library Functions Manual π β this page is the Blocklistd notification library, and it's basically the group chat between your daemon and blocklistd(8).
the main characters are:
blocklist_openblocklist_open2blocklist_closeblocklist_rblocklistblocklist_sablocklist_sa_r
and together they're the Blocklistd notification library β no cap, that's the whole NAME vibe π«Ά
π LIBRARY π
the library is βlibblocklistβ β yes bestie, that's the one π
π SYNOPSIS π
here's the exact shape of it, bestie β these signatures are literally the blueprint:
#include <blocklist.h>
struct blocklist *
blocklist_open(void);
struct blocklist *
blocklist_open2(void (*logger)(int, struct syslog_data *, va_list));
void
blocklist_close(struct blocklist *cookie);
int
blocklist(int action, int fd, const char *msg);
int
blocklist_r(struct blocklist *cookie, int action, int fd,
const char *msg);
int
blocklist_sa(int action, int fd, const struct sockaddr *sa,
socklen_t salen, const char *msg);
int
blocklist_sa_r(struct blocklist *cookie, int action, int fd,
const struct sockaddr *sa, socklen_t salen, const char *msg);
π DESCRIPTION π
okay so the whole point: these functions can be used by daemons to notify blocklistd(8) about successful and failed remote connections, so blocklistd can block or release port access to prevent Denial of Service attacks. it's giving protective bestie energy π‘οΈβ¨
blocklist_open() creates the necessary state to communicate with blocklistd(8) and returns a pointer to it, or NULL on failure. iconic little setup moment.
blocklist_open2() is similar to blocklist_open() but lets you specify a logger. if the logger is NULL, then no logging is performed β noted, bestie.
blocklist_close() frees all memory and resources used. clean up your room, periodt π§Ήπ
blocklist() sends a message to blocklistd(8), with an integer action argument specifying the type of notification, a file descriptor fd specifying the accepted file descriptor connected to the client, and an optional message in the msg argument.
the action parameter can take these values:
BLOCKLIST_AUTH_FAILβ there was an unsuccessful authentication attempt. oop, someone fumbled the login πBLOCKLIST_AUTH_OKβ a user successfully authenticated. slay, they got in β¨BLOCKLIST_ABUSIVE_BEHAVIORβ the sending daemon has detected abusive behavior from the remote system. the remote address should be blocked as soon as possible. not cute, block them immediately πBLOCKLIST_BAD_USERβ the sending daemon has determined the username presented for authentication is invalid. theblocklistd(8)daemon compares the username to a configured list of forbidden usernames and blocks the address immediately if a forbidden username matches. π«
β οΈ important caveat, bestie: β(The BLOCKLIST_BAD_USER support is not currently available.)β β don't count on that one yet, fr fr.
blocklist_r() is more efficient because it keeps the blocklist state around. lowkey the main-character version for repeated calls π
blocklist_sa() and blocklist_sa_r() can be used with unconnected sockets, where getpeername(2) will not work, the server will pass the peer name in the message. iykyk π¦
in all cases the file descriptor passed in the fd argument must be pointing to a valid socket so that blocklistd(8) can establish ownership of the local endpoint using getsockname(2). this is non-negotiable, bestie β valid socket or it's not gonna work.
by default, syslogd(8) is used for message logging. the internal bl_create() function can be used to create the required internal state and specify a custom logging function. custom logging? highkey flexible π
π RETURN VALUES π
blocklist_open() returns a cookie on success and NULL on failure setting errno to an appropriate value. a little cookie, cute πͺ
the functions blocklist(), blocklist_sa(), and blocklist_sa_r() return 0 on success and -1 on failure setting errno to an appropriate value. zero is slay, minus one is the sad trombone π
π¦ SEE ALSO π¦
π AUTHORS π
Christos Zoulas β big ups, icon π
mwah π this page comes from Debian, dated February 5, 2025, and it's LIBBLOCKLIST(3) β go be the main character of your daemon's networking, bestie π«Άβ¨
π¦ where this page comes from
- freebsd 15.1: base 15.1
- Copyright (c) 2015 The NetBSD Foundation, Inc
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms