esp-idf/examples/protocols/asio/socks4
Djordje Nedic facab8c5a7 tools: Increase the minimal supported CMake version to 3.16
This updates the minimal supported version of CMake to 3.16, which in turn enables us to use more CMake features and have a cleaner build system.
This is the version that provides most new features and also the one we use in our latest docker image for CI.
2022-06-01 06:35:02 +00:00
..
main [EXAMPLES/ASIO] Renames Kconfig parameter and clarify 2022-04-13 11:22:34 -03:00
CMakeLists.txt tools: Increase the minimal supported CMake version to 3.16 2022-06-01 06:35:02 +00:00
README.md EXAMPLES/ASIO: Adds a SOCKS4 example 2022-03-01 13:50:47 +00:00
sdkconfig.defaults EXAMPLES/ASIO: Adds a SOCKS4 example 2022-03-01 13:50:47 +00:00

Supported Targets ESP32 ESP32-S2

Async request using ASIO

(See the README.md file in the upper level 'examples' directory for more information about examples.)

The application aims to show how to connect to a Socks4 proxy using async operations with ASIO. The SOCKS protocol is briefly described by the diagram below.

               ┌──────┐                   ┌─────┐            ┌──────┐                                        
               │Client│                   │Proxy│            │Target│                                        
               └──┬───┘                   └──┬──┘            └──┬───┘                                        
                  │                          │                  │                                            
                  │                        ╔═╧══════════════╗   │                                            

══════════════════════╪════════════════════════╣ Initialization ╠═══╪════════════════════════════════════════════ │ ╚═╤══════════════╝ │
│ │ │
╔══════════════════╗│ │ │
║We establish a ░║│ Socket Connection │ │
║TCP connection ║│ <─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ > │
║and get a socket ║│ │ │
╚══════════════════╝│ │ │
│ │ │
│ ╔═╧══════════════╗ │
══════════════════════╪════════════════════════╣ Socks Protocol ╠═══╪════════════════════════════════════════════ │ ╚═╤══════════════╝ │
│ │ │
│ Client Connection Request│ │
│ ─────────────────────────> │
│ │ │
│ │ │
│ ╔════════════╪═══════╤══════════╪════════════════════════════════╗
│ ║ TARGET CONNECTION │ │ ║
│ ╟────────────────────┘ │ ╔═══════════════════╗ ║
│ ║ │ Socket Connection│ ║Proxy establishes ░║ ║
│ ║ │ <─ ─ ─ ─ ─ ─ ─ ─ > ║ TCPconnection ║ ║
│ ║ │ │ ║ with target host ║ ║
│ ╚════════════╪══════════════════╪══╚═══════════════════╝═════════╝
│ │ │
│ Response packet │ │
│ <───────────────────────── │
│ │ │
│ │ │
│ │ ╔═══════╗ │
══════════════════════╪══════════════════════════╪══╣ Usage ╠═══════╪════════════════════════════════════════════ │ │ ╚═══════╝ │
│ │ │
╔═════════════════╗│ │ │
║Client uses the ░║│ │ │
║ socket opened ║│ │ │
║ with proxy ║│ <─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─>
║to communicate ║│ │ │
║ ║│ │ │
╚═════════════════╝┴───┐ ┌──┴──┐ ┌──┴───┐
│Client│ │Proxy│ │Target│
└──────┘ └─────┘ └──────┘

Configure and Building example

This example requires the proxy address to be configured. You can do this using the menuconfig option. Proxy address and port must be configured in order for this example to work.

If using Linux ssh can be used as a proxy for testing.

ssh -N -v -D 0.0.0.0:1080 localhost

Async operations composition and automatic lifetime control

For documentation about the structure of this example look into async_request README.