Skip to content

Instantly share code, notes, and snippets.

View verlaine-muhungu's full-sized avatar
🎯
Focusing

Verlaine_Devnet verlaine-muhungu

🎯
Focusing
View GitHub Profile
@atoonk
atoonk / hosts_allow.go
Last active November 19, 2024 05:08
A simple Go TCP server demonstrating how to use libwrap with /etc/hosts.allow and /etc/hosts.deny for access control. The server listens on port 12344 and filters client connections based on TCP Wrappers rules, showcasing basic integration with hosts_access via cgo.
package main
/*
#cgo LDFLAGS: -lwrap
#include <stdlib.h>
#include <tcpd.h>
// Wrapper for request_init to avoid variadic arguments
// Initializes the request_info struct with daemon name and client address.
void my_request_init(struct request_info *req, const char *daemon, const char *client_addr) {