mirror of
https://github.com/shadowsocks/shadowsocks-libev.git
synced 2026-10-20 13:03:50 +00:00
<shadowsocks/control.h> starts ss-local on a library-owned thread, stops it from any thread through a libuv async handle and waits for it; <shadowsocks/shadowsocks.hpp> wraps that in a move-only, header-only shadowsocks::LocalServer whose destructor stops and waits. The library exports only C symbols, shadowsocks.h is unchanged, and the shared library version becomes 2.1.0 (SOVERSION 2). test_local_api_cpp covers the lifecycle; the installed-package consumer gains a C++ program.
11 lines
371 B
C++
11 lines
371 B
C++
// C++ consumer of the installed headers: the RAII wrapper over the C
|
|
// control API, without starting a server.
|
|
#include <shadowsocks/shadowsocks.hpp>
|
|
|
|
int main()
|
|
{
|
|
shadowsocks::LocalServer server;
|
|
static int (*volatile start)(const profile_t *, ss_local_callback, void *, ss_local_handle **) = ss_local_start;
|
|
return server.running() || start == nullptr;
|
|
}
|