How yzhzeng/goodlink works
Main Components
• Local Client – This can be the command-line version or the Windows UI version (found in the “ui2” directory) that sets up either a SOCKS5 proxy or port-forwarding service by listening on a specified local port.
• Remote Server – This component (running with the “--remote” flag) is deployed on the host that provides access to internal resources (like remote desktop, NAS, or internal web services).
• Communication Module – The direct P2P connection between local and remote, based on QUIC, with built-in encryption (modules under “aes”, “md5”, and “tls2”). This is the secure channel established with a shared key.
• Proxy/Forwarding Logic – Depending on mode, the application uses the “socks5” module for proxy mode or parts of “proxy” and “pro” for port forwarding.
• NAT Traversal Component – “stun2” helps with traversing NAT to establish the peer-to-peer connection.
• Configuration & Utilities – Configurations and command-line arguments (in “config”), various utility tools (in “tools”), and build/infrastructure files (Dockerfile, Makefile) that support deployment.
• UI Components – For the Windows UI, the “ui2” and “theme” directories provide the graphical interface and visual theming.
Relationships and Interactions
• The Local Client sends a connection request (with parameters such as local port, key, and possibly a remote target for port-forwarding) into the network stack.
• Communication flows securely via the encrypted QUIC-based link to the Remote Server.
• In proxy mode, the local SOCKS5 server (implemented in “socks5”) intercepts application requests and forwards them over the secure channel. In forwarding mode, the connection is bridged directly between the local and remote port specifications.
• The encryption and integrity modules (in “aes”, “md5”, “tls2”) ensure data is securely exchanged.
• The NAT traversal logic (“stun2”) engages to overcome any intermediary NAT issues.
• The configuration layer (from “config”) governs command-line arguments and runtime behavior, while utility code (from “tools”) may support auxiliary functions like monitoring or additional networking capabilities.
Architectural Patterns and Core Technologies
• Modular design – Each responsibility (UI, encryption, network proxying, NAT traversal) is encapsulated in its own package or directory.
• Client-Server (or peer-to-peer) architecture – Even though there isn’t a centralized server, there are clearly defined roles (local vs. remote) which exchange information over defined network protocols.
• Protocol Abstraction – The project abstracts protocol details (QUIC, SOCKS5, and TCP port forwarding) so that multiple connection modes are supported.
• Deployment flexibility – The design supports different runtime environments (command-line, Docker, Windows UI).
Detailed Capture of Architectural Elements
• Be very explicit about how components interact and depend on the key parameter (the shared secret).
• Separate the concerns: networking layer (handling QUIC and connection retries), proxy modules (handling system-specific behaviors like SOCKS5 and port mapping), and application logic (deciding on operational mode, processing configurations).