netl.c is a small C library and CLI for registering named TCP or UDP listeners that dispatch each incoming connection or datagram to a shell command.
Register a TCP listener on port 8080:
netl proxy 127.0.0.1:8080 catStart the registered listener:
netl proxyList all registrations:
netl --listList one registration:
netl proxy --listRemove a registration:
netl proxy --delete| Command/Flag | Description |
|---|---|
<name> <addr>[:port] <cmd> |
Register or replace a listener. TCP by default. |
<name> <addr>[:port] --udp <cmd> |
Register a UDP listener. |
<name> -d, <name> --delete |
Remove a listener if it exists. |
<name> -l, <name> --list |
List one listener if it exists. |
-l, --list |
List all listeners as name<TAB>addr:port. |
<name> |
Start the registered listener. |
-h, --help |
Show help and usage. |
-v, --version |
Show version. |
#include "netl.h"
kc_netl_t *ctx = kc_netl_open();
kc_netl_update(ctx, "proxy", "127.0.0.1", 8080, KC_NETL_TCP, "cat");
kc_netl_list(ctx, "proxy");
kc_netl_exec(ctx, "proxy");
kc_netl_delete(ctx, "proxy");
kc_netl_close(ctx);kc_netl_open()- resolves metadata state and returns a context owned by the caller.kc_netl_update()- registers or replaces a named listener.kc_netl_exec()- starts the registered listener. Blocking on success, never returns.kc_netl_list()- lists all registrations or one named registration.kc_netl_delete()- removes a named registration.kc_netl_path()- returns the resolved metadata directory for diagnostics.kc_netl_close()- releases the context.
kc_netl_execis blocking. The caller is responsible for forking if background operation is needed.kc_netl_updatedoes not require elevated privileges.- Registration metadata is stored under
~/.local/share/netl/on Linux and%APPDATA%\netl\on Windows.
Compiled artifacts are generated under bin/{arch}/{platform}/ for the host architecture running the build.
make clean && makeThe project is prepared to build artifacts for multiple architectures under bin/{arch}/{platform}/. A plain make builds only the current host architecture, while the targets below build the full matrix or a specific target.
make all
make x86_64/linux
make x86_64/windows
make i686/linux
make i686/windows
make aarch64/linux
make aarch64/android
make armv7/linux
make armv7/android
make armv7hf/linux
make riscv64/linux
make powerpc64le/linux
make mips/linux
make mipsel/linux
make mips64el/linux
make s390x/linux
make loongarch64/linuxThis project is distributed under the GNU General Public License version 3 (GPLv3).
