A modular, protocol-agnostic, and high-performance proxy server written in C using the GLib ecosystem, designed for deep inspection and extensibility.
- Overview
- Features
- Architecture
- Getting Started
- Usage
- Extending Deadlight
- Project Structure
- Development Status
- License
- Support
proxy.deadlight
is a high-performance, protocol-agnostic network proxy written in C that serves as the Protocol Bridge for the Deadlight Ecosystem. It seamlessly connects modern HTTP-only serverless platforms (like Cloudflare Workers) to foundational TCP protocols (SMTP, IMAP, SOCKS), enabling true self-sovereign infrastructure.
NEW in v5.0: Complete integration with deadlight.boo
via REST API endpoints, enabling real-time proxy management through a beautiful web interface deployable anywhere.
After a comprehensive refactoring and development cycle, proxy.deadlight
has evolved from a simple proxy into a robust, extensible framework.
- π¦ Modular, Protocol-Agnostic Architecture: Built around a
DeadlightProtocolHandler
interface that allows new protocols to be added easily as self-contained modules. - π High-Performance C Foundation: Utilizes the robust and efficient GNU/GLib ecosystem for high-throughput, low-latency network I/O and multi-threaded connection handling.
- π Secure Tunneling & Interception:
- HTTP/HTTPS Proxy: Functions as a standard forward proxy for web traffic.
- SSL (TLS) Interception: Capable of generating certificates on-the-fly for traffic inspection (MitM), a powerful tool for development and security analysis.
- IMAPS Tunneling: Securely tunnels IMAP traffic over TLS, with robust certificate validation against the system's trust store.
- π SOCKS4 Proxy Support: Provides basic IP masking and privacy by serving as a SOCKS4 proxy for compatible applications.
- ποΈ REST API Server: Complete HTTP API for external integration and management
- π Multi-Protocol Support: HTTP/HTTPS/SOCKS/SMTP/IMAP/IMAPS/API protocols
- π± Web Dashboard Integration: Real-time proxy control via modern web interface
- π§ Email-based Federation: Revolutionary approach to decentralized social media using proven email protocols
- π§ File-Based Configuration: All core settings, listeners, and protocol behaviors are controlled via a simple .ini-style configuration file.
- π REST API Interface: Complete HTTP API for integration with web applications
- π Real-time Status Monitoring: Live connection tracking and system health reporting
- π§ Email Federation Bridge: SMTP protocol translation for decentralized social media
- ποΈ Web-based Management: Full proxy control via
blog.deadlight
admin dashboard - β‘ Instant Deployment: One command deployment to global CDN with local proxy backend
API Endpoints:
GET /api/blog/status
- Blog service health and version infoGET /api/email/status
- Email queue status and processing metricsPOST /api/email/send
- Send emails through proxy SMTP bridgePOST /api/federation/send
- Federated blog post distribution via email
π DEADLIGHT ECOSYSTEM ARCHITECTURE π
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β GLOBAL WEB LAYER β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ€
β π± Any Browser/Device β π Cloudflare CDN β β‘ blog.deadlight Worker β
β (REST API Client) β
βββββββββββββββββββββββββββ¬ββββββββββββββββββββββββββββββββββββββββββββββββββββ
β
β HTTP/JSON API Calls
βΌ
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β LOCAL PROTOCOL BRIDGE β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ€
β π‘ proxy.deadlight v5.0 β
β β
β βββββββββββββββββββ βββββββββββββββββββ βββββββββββββββββββ β
β β π API β β π§ SMTP β β π SOCKS5 β β
β β Handler β β Bridge β β Proxy β β
β βββββββββββββββββββ βββββββββββββββββββ βββββββββββββββββββ β
β β
β βββββββββββββββββββ βββββββββββββββββββ βββββββββββββββββββ β
β β π HTTP/S β β π¬ IMAP β β π§ Protocol β β
β β Proxy β β Tunnel β β Detection β β
β βββββββββββββββββββ βββββββββββββββββββ βββββββββββββββββββ β
βββββββββββββββββββββββββββ¬ββββββββββββββββββββββββββββββββββββββββββββββββββββ
β
β Native TCP/SSL Protocols
βΌ
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β INTERNET SERVICES β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ€
β π§ SMTP Servers β π¬ IMAP Servers β π Web Sites β π Other Proxies β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
π― DEPLOYMENT MODEL:
ββββββββββββββββββββββ ββββββββββββββββββββββ
β π GLOBAL β β π LOCAL β
β deadlight.boo β ββββ API BRIDGE ββββ proxy.deadlight β
β Cloudflare β β VPS/Pi/Desktop β
β Workers/Pages β β localhost:8080 β
ββββββββββββββββββββββ ββββββββββββββββββββββ
Deadlight is built on a modular design managed by a central DeadlightContext
. A connection flows through the system as follows:
- The Main Thread runs a
GSocketService
, accepting new connections. - Incoming connections are passed to a Worker Thread from a
GThreadPool
. - The worker thread performs Protocol Detection by peeking at the initial bytes of the connection.
- The appropriate registered
DeadlightProtocolHandler
is invoked to handle the connection. - The handler processes the request. It can either complete the request synchronously or, for long-lived tunnels, hand off control to asynchronous I/O watchers on its own thread's event loop. This prevents the worker thread from blocking.
This is all managed by a set of distinct managers:
- Network Manager: Handles listener sockets, the worker pool, and connection state.
- SSL Manager: Manages OpenSSL contexts, CA certificates, and performs SSL interception.
- Protocol System: Manages the registration and detection of protocol handlers.
- Configuration Manager: Parses INI-style configuration files.
- Connection Pool: Manages and reuses upstream server connections.
- A C99 compliant compiler (GCC or Clang)
make
pkg-config
- GLib 2.0+ & GIO development libraries (
libglib2.0-dev
) - OpenSSL 1.1.1+ development libraries (
libssl-dev
)
On Debian/Ubuntu, install all prerequisites with:
sudo apt-get update
sudo apt-get install build-essential pkg-config libglib2.0-dev libssl-dev glib-networking
build-essential
: Provides gcc, make, etc.libglib2.0-dev
: The GLib core libraries and development headers.libopenssl-dev
: For all cryptographic and TLS functions.glib-networking
: The essential backend for GIO's TLS functionality.
Clone the repository and use the provided Makefile:
git clone https://your-repo-url/deadlight.git
cd deadlight
make
The executable will be located at bin/deadlight
.
The proxy uses an INI-style configuration file. A sample is provided at deadlight.conf.example
.
[core]
port = 8080
bind_address = 0.0.0.0
max_connections = 500
log_level = info
worker_threads = 4
[ssl]
enabled = true
ca_cert_file = /home/thatch/.deadlight/ca.crt
ca_key_file = /home/thatch/.deadlight/ca.key
cert_cache_dir = /tmp/deadlight_certs
[protocols]
http_enabled = true
https_enabled = true
connect_enabled = true
[plugins]
enabled = false
[imap]
# The upstream IMAP server to proxy connections to.
upstream_host = imap.gmail.com
upstream_port = 143
[imaps]
# The upstream IMAPS server to proxy connections to.
# This uses SSL/TLS on port 993.
upstream_host = imap.gmail.com
upstream_port = 993
./bin/deadlight -c deadlight.conf.example
Configure your browser or system to use http:/localhost:8080
as its proxy. Or, use curl
:
# Proxy a standard HTTP request
curl -x http://localhost:8080 http://example.com
# Proxy an HTTPS request (using the CONNECT method)
curl -x http://localhost:8080 https://example.com
Use curl
to route a request through the SOCKS4 handler:
curl --socks4 localhost:8080 http://example.com
Test the secure IMAP tunnel using telnet
(this proves the TLS handshake and tunneling):
telnet localhost 8080
Once connected, type the following and press Enter:
a001 NOOP
The proxy will establish a secure TLS connection to the upstream IMAP server and tunnel the data.
Deploy the integrated blog.deadlight dashboard
# Terminal 1: Start the proxy server
./bin/deadlight -c deadlight.conf.example
# Terminal 2: Start the blog with proxy integration
cd ../deadlight
wrangler dev
# Or to deploy to your live site
wrangler dev
Access http://localhost:8787/admin/proxy
for real-time proxy management including:
- Live connection monitoring
- API endpoint testing
- Federation testing
- Email system management
-c, --config FILE
: Path to configuration file.-p, --port PORT
: Port to listen on (overrides config).-d, --daemon
: Run as a background daemon.-v, --verbose
: Enable verbose (debug) logging.-h, --help
: Show help message.
curl -x http://localhost:8080 http://example.com
For TLS interception to work, you must instruct your client to trust the proxy's Certificate Authority. The CA certificate is generated automatically (e.g., in ssl/ca.crt
).
# The --cacert flag tells curl to trust our custom CA for this one request.
curl --cacert ssl/ca.crt -x http://localhost:8080 https://example.com
The core strength of Deadlight is its extensible protocol system. To add support for a new protocol:
- Create
my_protocol.c
andmy_protocol.h
in thesrc/protocols/
directory. - Implement the
DeadlightProtocolHandler
interface:detect
: A function that inspects a buffer and returns a non-zero value if it matches the protocol.handle
: The main function to process the connection. It must return aDeadlightHandlerResult
to correctly manage the connection's lifecycle (HANDLER_SUCCESS_CLEANUP_NOW
for synchronous tasks,HANDLER_SUCCESS_ASYNC
for asynchronous tasks).cleanup
: An optional function for any protocol-specific cleanup.
- Create a public registration function, e.g.,
deadlight_register_my_protocol_handler()
. - Call your registration function from
deadlight_protocols_init()
insrc/core/protocols.c
. - Add
src/protocols/my_protocol.c
to thePROTOCOL_SOURCES
list in theMakefile
. - Recompile. Your protocol is now live.
deadlight/
βββ bin/ # Compiled binaries
βββ obj/ # Compiled object files
βββ ssl/ # Directory for SSL certificates
βββ src/
β βββ core/ # Core modules (main, context, config, network, etc.)
β βββ plugins/ # Built-in plugin implementations
β βββ protocols/ # Protocol handler implementations
βββ deadlight.conf.example # Example configuration file
βββ Makefile # Build configuration
βββ README.md # This file
v5.0 BREAKTHROUGH: Complete integration achieved with blog.deadlight!
- β REST API Server: Full HTTP API implementation for external integration
- β Real-time Dashboard: Minimalist web interface for proxy management
- β Email Federation: Working email-based social media federation
- β Multi-Protocol Support: HTTP/HTTPS/SOCKS/SMTP/IMAP/IMAPS/API protocols
- β‘οΈ SOCKS5 Enhancement: Full authentication support (next milestone)
- π Production Deployment: VPS deployment with global CDN integration
This project is licensed under the MIT License - see the LICENSE file for details.