Skip to content

Definisi/socks5-proxy-server-cpp

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

SOCKS5 Proxy Server (C++)

A high-performance SOCKS5 proxy server implementation in C++ with UDP relay support.

Features

  • SOCKS5 proxy server (RFC 1928)
  • TCP CONNECT command
  • UDP ASSOCIATE command for UDP relay
  • Cross-platform (Windows and Linux)
  • IPv4 and IPv6 support
  • Domain name resolution
  • Multi-threaded client handling
  • Non-blocking I/O for efficient data relay

Building

Prerequisites

  • C++17 compatible compiler (GCC 7+, Clang 5+, MSVC 2017+)
  • CMake 3.15 or higher

Build Instructions

# Clone the repository
git clone https://github.com/definisi/socks5-proxy-server-cpp.git
cd socks5-proxy-server-cpp

# Create build directory
mkdir build
cd build

# Configure and build
cmake ..
make

# Run the server
./bin/Release/socks5_proxy_server

Windows Build

# Clone the repository
git clone https://github.com/definisi/socks5-proxy-server-cpp.git
cd socks5-proxy-server-cpp

# Build using batch script
.\build.bat

# Run the server
.\build\bin\Release\socks5_proxy_server.exe

Usage

By default, the server listens on 0.0.0.0:1080 for SOCKS5 connections.

Testing with curl

# Test SOCKS5 proxy
curl --socks5-hostname 127.0.0.1:1080 https://example.com

Testing with Python

# Run the included test script
python test/test_socks5.py

Testing with browser

You can configure your browser to use the SOCKS5 proxy:

  • SOCKS5 Proxy: 127.0.0.1:1080

Project Structure

/src/
├── main.cpp                  - Entry point
├── socks5_server.hpp         - SOCKS5 server header
├── socks5_server_fixed.cpp   - SOCKS5 core logic (fixed version)
├── udp_relay.cpp             - UDP relay logic
├── udp_relay.hpp             - UDP relay header
├── config.hpp                - Config & constants
├── platform/
│   ├── net.hpp               - Network abstraction layer
│   ├── net_win.cpp           - Windows socket API
│   └── net_unix.cpp          - Linux socket API
/test/
└── test_socks5.py            - Python test script

License

This project is licensed under the Creative Commons Attribution-NonCommercial 4.0 International License.

You may use, share, and modify the code as long as you give appropriate credit and do not use it for commercial purposes.

View the full license at: https://creativecommons.org/licenses/by-nc/4.0/

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

About

A high-performance SOCKS5 proxy server implementation in C++ with UDP relay support.

Resources

License

Stars

Watchers

Forks

Contributors