Move mouse over the terminal to route incoming packets.
System Architecture
Multi-threading Core
Leverages POSIX threads (pthreads) to handle multiple concurrent client connections. A semaphore system enforces a strict MAX_CLIENTS limit, preventing memory exhaustion and ensuring stable throughput under high load.
HTTPS Secure Tunneling
Intercepts the HTTP CONNECT method to establish a blind TCP relay. By utilizing the select() system call, the proxy seamlessly multiplexes encrypted TLS traffic between the client and upstream servers without deep packet inspection.
The Cache Evolution: O(N) to O(1)
The most critical performance bottleneck in early iterations was the caching mechanism. Scanning a standard Linked List to find URLs or identify the oldest items for eviction scales linearly O(N), causing high CPU latency as the cache grows.
The system was re-architected to achieve Amortized O(1) time complexity for both lookups and evictions by combining two advanced data structures:
The Hash Map (O(1) Lookup): Uses the djb2 string hashing algorithm to map incoming URLs directly to their memory addresses in a bucket array. This bypasses linear traversal entirely.
The Doubly Linked List (O(1) Eviction): Maintains the strict time-based order of the Least Recently Used (LRU) policy. When a cache hit occurs, the node is isolated and moved to the head in constant time. When the cache overflows, the tail pointer is deleted instantly.