How gbalog/socks5 works
This repository implements a SOCKS5 TCP proxy: it accepts client connections, negotiates/authenticates SOCKS requests, opens a destination connection, then relays the TCP stream. The sampled entry point and session code establish the manager, session, authentication, and proxy lifecycle; the tree identifies the protocol and event subsystems. Internal wiring beyond those samples is shown conservatively, so links between protocol helpers and event callbacks are omitted where their callers cannot be verified.
Main entry points: SessionMng.cpp Session manager · Session.cpp Proxy session · EventTcpServer.cpp Event TCP server · SocksLoginPassAuthorizer.cpp Password authorizer
Components 18
Application lifecycle
- Program entry
src/main.cpp - Session manager
src/SessionMng.cpp
SOCKS protocol
- Password authorizer
src/SocksLoginPassAuthorizer.cpp - Connection tracker
src/InConnTracker.cpp - Request decoder
src/SocksDecoder.cpp - Reply encoder
src/SocksEncoder.cpp - SOCKS types
src/SocksCommon.cpp
Sessions and proxying
- Proxy session
src/Session.cpp - TCP stream relay
src/TcpStreamProxy.cpp - Directed connection
src/DirectedProxyConnection.cpp
Event networking
- Event TCP server
src/Event/EventTcpServer.cpp - Client socket
src/Event/EventSocket.cpp - Destination socket
src/Event/EventSocketConnected.cpp - Event base
src/Event/EventBaseObject.cpp - Signal listener
src/Event/EventSignalListener.cpp
Other components
- SOCKS client
- TCP destination
- Credential file
Connections 18
- SOCKS client → Event TCP server: connects
- Program entry → Session manager: starts
- Session manager → Event TCP server: runs
- Event TCP server → Session manager: accepts clients
- Session manager → Proxy session: creates
- Session manager → Password authorizer: initializes
- Password authorizer → Credential file: reads credentials
- Proxy session → Connection tracker: updates
- Proxy session → Password authorizer: checks password
- Proxy session → Session manager: requests connection
- Proxy session → Destination socket: creates destination
- TCP destination → Destination socket: connects
- Proxy session → TCP stream relay: starts relay
- Event TCP server → Client socket: manages sockets
- Client socket → Event base: uses
- Destination socket → Event base: uses
- Session manager → Signal listener: registers SIGINT
- Signal listener → Event TCP server: stops server