Commit Graph
50 Commits
Author SHA1 Message Date
Max Lv 5f47a65c51 Parse the config file on arenas
read_jconf now reads the file and builds the JSON tree in a scratch arena
that is released before it returns, and copies the parsed strings into one
process-lifetime arena instead of a malloc per string. parse_addr and the
config parser share one address splitter.

Port test_jconf to C++ and cover every field copied out of the parse tree,
a re-read, and the densest file the size limit accepts.
2026-10-15 01:33:51 +08:00
Max Lv 53adaf380e Replace uthash and ss_list with the C++ containers
The C cache (now used only by the reference codecs) moves to
tests/reference and src/uthash.h is deleted. ACL rules and ss-manager's
servers are ListNodes on IntrusiveLists; destroying an element unlinks
it, so the free paths no longer have to remember to. core.h keeps only
ss_ip. test_rule is ported to C++ and also covers literal rules.
2026-10-15 00:34:31 +08:00
Max Lv 34da0def95 Move the C codecs to tests/reference and drop uthash from ss-manager
The programs now use only the C++ codecs. The C stream/AEAD/AEAD-2022
implementations stay as the reference the differential tests and the C
unit tests compare against. Key derivation and the cipher tables used by
the doc snippets move to src/crypto/keys.{hpp,cpp}.

ss-manager keeps its servers in an ss_list (at most MAX_PORT_NUM,
looked up only on control messages) instead of a uthash table, and
tests/test_manager.py covers add/ping/list/remove end to end.
2026-10-15 00:34:31 +08:00
Max Lv 3efcb79010 Remove ss_event and the C resolver shim
Each program's loop, signals, plugin watcher and stats timer now go
through ss::event::Program (src/event/program.hpp), held on main()'s
stack; ss-manager uses it too. ss-server resolves the manager address
with the relay resolver. With no C caller left, ss_event.cpp/.h,
resolv.cpp/.h and their C tests go; test_resolver_cpp.cpp replaces the
resolver tests against the same delayed local DNS server, and ss_ev is
now an interface target over libuv.
2026-10-15 00:34:31 +08:00
Max Lv bde90e4ae4 Run ss-redir and every UDP relay on the C++ engines
ss-redir's TCP side moves onto the relay engine (per-listener TOS for the
DSCP ports). src/relay/udp replaces udprelay.cpp: sessions keyed by
client address own their upstream socket and live in a fixed LRU,
AEAD-2022 server sessions are shared through RefPtr between the
session-ID table and the relays using them, and datagrams waiting for
DNS sit in pool slots. Packets are received into and built in
relay-owned buffers instead of a 64 KiB allocation per datagram. The
programs no longer call crypto_init(); Method sets up libsodium and the
replay filter.
2026-10-14 22:53:09 +08:00
Max Lv 46f5ddcf80 Run ss-server on the C++ TCP relay engine
The request header, outbound ACL, target resolution through the relay's
resolver, the anti-probing stop stage and the manager traffic counters
are engine code now; the connmark-to-TOS tracker becomes a pair of relay
hooks. server.cpp keeps option parsing, nftables and the stats timer.
2026-10-14 22:53:09 +08:00
Max Lv c8311a1c35 Run ss-local and libshadowsocks-c on the C++ TCP relay engine
The SOCKS5 handshake, the ACL bypass decision (with its own resolver for
host-name rules) and the short wait for a first payload are now engine
code; local.cpp keeps only option parsing and startup. The library entry
points start the same engine.
2026-10-14 22:53:09 +08:00
Max Lv 892b45d1e5 Add the C++ TCP relay engine and run ss-tunnel on it
One engine (src/relay/tcp) for the four TCP relays: connections live in a
fixed pool owned through PoolPtr, handshake, cipher state and buffers are
inline, timeouts are intrusive deadline lists on one timer and DNS answers
come back through generation-checked handles. A full pool refuses new
connections and pauses accepting until a slot frees.

ss-tunnel is the first user; its hand-written relay callbacks are gone.
tests/tunnel_interop.py covers every method against ss-server and
shadowsocks-rust.
2026-10-14 22:53:09 +08:00
Max Lv 78ca0af745 Rewrite the resolver in C++ on a fixed query pool
Queries live in pool slots with their first A and AAAA answer inline,
c-ares sockets are watched from a fixed table, and answers reach the
waiter through a callback plus opaque words instead of a back-pointer.
resolv.cpp keeps the C API as a shim. The event Loop can now adopt the
ss_event loop, and a Poll can stop watching a socket it does not own.
2026-10-14 22:53:09 +08:00
Max Lv ed75faf80f Rewrite the cache on a fixed slab without per-entry allocation
cache.cpp keeps its C API but replaces uthash and the two mallocs per
entry with one slab of nodes holding their keys inline, linked in
last-use order, and an open-addressing index of node ids that hashes
through the slab with a per-cache random seed. Both blocks are reserved
by cache_create() and touched only as entries are used, so a large,
mostly empty cache costs no resident memory.

Semantics are unchanged: an insert evicts the least recently used entry
once the cache holds capacity entries (the AEAD-2022 session table's
4095/4096 boundary), lookups refresh recency and age, cache_clear()
drops stale entries, and free_cb may re-enter the cache. Re-inserting a
key now replaces its data instead of shadowing it. cache_create_keyed()
sizes keys per cache; the AEAD-2022 salt pool and session table use it.

test_cache_cpp covers the boundary, ordering, replacement, ageing,
re-entrant callbacks and limits; alloc_steady_cache requires zero
allocations across 100,000 inserts on a full cache. AEAD-2022 ss-server
drops from 84 to 80 allocations per relayed connection.
2026-10-14 22:53:07 +08:00
Max Lv 227ad1bb9c Compile the event loop, UDP relay and programs as C++
Rename utils, ss_event, udprelay, winsock, local, server, tunnel, redir
and manager from .c to .cpp. Inside the moved files only the
\snippet{doc} file references and header comments change; snippet
references in doc/*.md, tests/test_cli_docs.py, the build files and
CONTRIBUTION.md follow the new names.

Also cast the Windows-only string literal returned by
get_default_conf(), found by the zig x86_64-windows-gnu build.

Every module of src/ except the unbuilt android.c and the vendored
blake3 is now compiled as C++20. The new .cpp files join the no-heap
ratchet baseline.
2026-10-14 22:51:17 +08:00
Max Lv 349d895fd2 Compile the crypto, config, DNS, ACL and plugin modules as C++
Rename netutils, jconf, stream, aead, aead2022, aead2022_udp, crypto,
acl, plugin, plugin_disabled and resolv from .c to .cpp without changing
their contents, and update source lists, snippet references, test
comments and debian/copyright.

The Doxygen source list and scripts/check_cli_docs.py now accept either
extension for each module, so the remaining programs can move one at a
time. The new .cpp files are added to the no-heap ratchet baseline.
2026-10-14 22:51:16 +08:00
Max Lv e16c6bcd3e check_cxx_runtime: ignore glibc symbol versions
nm on glibc prints __cxa_atexit@GLIBC_2.2.5, which the allowlist for the
libc-provided __cxa_atexit/__cxa_finalize did not match.
2026-10-14 22:51:15 +08:00
Max Lv 738956b5da Compile the leaf modules as C++
Rename base64, json, ipset, process, ppbloom, rule, ssurl and cache from
.c to .cpp without touching their contents, and update the CMake source
lists, debian/copyright and the docs.

Ported code keeps -Wall; -Wextra is now opt-in through
ss_strict_warnings() for code written as C++ (the core tests).
check_no_heap.py gains a ratchet baseline for the converted modules,
which still allocate the way the C code did. A new check_cxx_runtime
test verifies with nm that the programs and libshadowsocks-c.a still
need no C++ runtime library, so C consumers are unaffected.
2026-10-14 22:51:15 +08:00
Max Lv f90cfe9034 Add C++20 ownership and allocation core
Header-only primitives for the no-heap-after-startup design:
Result/Status, Region, ObjectPool with PoolPtr (std::unique_ptr with a
pool deleter), generation-checked Handle and asynchronous close support,
intrusive RefPtr, FixedBuffer, MonotonicArena, FixedHashMap and FixedLru,
IntrusiveList, and a bounded FixedHeap for third-party allocator hooks.

Unit tests cover each primitive (test_core_*). scripts/check_no_heap.py
rejects heap allocation in C++ sources under src/ and runs as a ctest.
clang-tidy now also analyses C++ sources and the core headers.
2026-10-14 12:51:47 +08:00
Max Lv ea951e6bd1 Redesign CLI flags, help, and argument validation 2026-09-12 21:17:38 +08:00
Max Lv f5d5bf0be1 Publish native Doxygen documentation with GitHub Pages 2026-09-12 14:46:42 +08:00
Max Lv 146818c182 Generate CLI manual sections from source option declarations 2026-09-12 10:51:25 +08:00
Max Lv bdc77408cb Rename to shadowsocks-c with libuv, async DNS and CI lint (#3051)
Rename the project to shadowsocks-c while retaining ss-* commands, the embedding ABI, and legacy library/package lookup compatibility.

Replace libev with bundled libuv for IOCP/kqueue event backends, expand asynchronous runtime DNS coverage, and add actionlint/Ruff with strict clang-tidy failure handling. Validate native platforms, static builds, packaging, interoperability, sanitizers, and canonical/legacy consumers.

All 22 hosted checks pass at reviewed head a8493250eb.
2026-09-11 14:18:37 +08:00
Max Lv 201e70c4bd Modernize C builds with offline dependencies and portable runtime helpers (#3050)
Bundle pinned offline dependencies, remove libcork/libipset and submodule requirements, and add portable runtime helpers with relocatable static/shared library installations.

Add Clang static build validation for Linux/musl, macOS and Windows, real TCP/UDP and SIP003 interoperability coverage, and recorded performance tradeoffs. All 21 hosted checks pass at the reviewed PR head 8d504e6218.
2026-09-11 13:42:11 +08:00
Max LvandClaude Opus 4.6 5c2d0e43fa Add ss-setup TUI tool with unit tests and CI integration
Interactive whiptail/dialog TUI for server/client config generation,
systemd service management, SIP003 plugin installation, and ss:// URI
output. Includes 131 bash unit tests covering all utility functions
(validation, JSON generation, URI encoding, config round-trip parsing).
Tests run in CTest and as a dedicated GitHub Actions step.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-07 18:30:20 +08:00
Max Lv 1b3001007d Clean up 2019-06-14 16:56:00 +08:00
fanck0605 52ee4c7ded update url 2018-07-09 09:15:45 +08:00
Max Prokhorov 999e0555c7 Fedora COPR support
- Support .copr/Makefile for 'SCM / make srpm' COPR package
- Use genrpm.sh to generate srpm and optionally build it
- Use generic substitution syntax in specfile
2018-05-14 09:38:07 +03:00
Roger Shimizu c19f0ed46d Add scripts/chroot_build.sh to call build_deb.sh in a chrooted env
Support common debian and ubuntu version, such as jessie, stretch,
trusty, and xenial, etc.

e.g.
$ sudo scripts/chroot_build.sh jessie
2018-04-12 23:29:57 +09:00
Roger Shimizu 540f0903f5 scripts/build_deb.sh: Update libsodium build due to debhelper 11 2018-04-12 23:29:57 +09:00
Roger Shimizu a98587fa5f scripts/build_deb.sh: Update URL in script
- Use https URL when possible.
- Use salsa git repo instead of alioth (anonscm) for those already
  migrated in debian.
2018-04-07 12:05:00 +09:00
Roger Shimizu f35e24f6d6 scripts/build_deb.sh: Support ubuntu artful and bionic 2017-11-01 23:03:29 +09:00
Roger Shimizu da85fa17d4 Fix scripts/build_deb.sh for debian jessie
Thanks to Tom <hexuxin@foxmail.com> for the bug report.
2017-09-19 08:46:45 +08:00
Roger Shimizu 9a2c74193f Update README and build_deb since libsodium 1.0.13 is backported
libsodium 1.0.13 is current in Debian apt repository of:
 - stretch-backports
 - jessie-backports-sloppy
2017-08-20 02:28:32 -07:00
Roger Shimizu 15a54beb8c Minor fix for build_deb.sh script
- Install libbloom-dev in backports repository.
- Clone libsodium git under "libsodium" directory.
- Change to a safer way to check debhelper version.
- Remove simple-obfs for jessie/stretch because it's just
  accepted to backports repository.
2017-07-28 20:58:44 +09:00
Roger Shimizu cae2625513 Update scripts/build_deb.sh after stretch release
- Update build of libsodium to use debian's git repo
- Now libbloom is available in stretch-backports and
  jessie-backports-sloppy
2017-07-28 06:33:02 +09:00
Roger Shimizu 6c5142a2de Update simple-obfs git repo and branch
simple-obfs is released to debian unstable, and its git repo
is moved to alioth.
So update the URL of git repo and branch accordingly.
2017-05-04 22:01:52 +08:00
Roger Shimizu aaff27ed4d Update scripts/build_deb.sh
- Update debian pkg dsc URL of libsodium to 1.0.11-2.
- Update libbloom git repo to debian's anonscm (alioth).
- Update branch of libbloom git repo from exp1 to master.
  It's got released to debian unstable.
- Update branch of shadowsocks-libev git repo from exp1 to master
  It's got released to debian experimental.
2017-04-19 14:33:56 +08:00
Roger Shimizu f74c730611 Update scripts/build_deb.sh
- Cleanup
- KCP now confirms to work on jessie/stretch/xenial
- install pristine-tar specifically (was through recommends of
  git-buildpackage previously)
2017-04-04 19:33:03 +08:00
Roger Shimizu 669ddeba19 Add kcptun package build support to build_deb.sh script
Confirmed under xenial and jessie-backports.
Other distro still need some work, but should be similar.
2017-03-14 13:42:01 +08:00
Roger Shimizu 6a8adfb26f Make build_deb.sh script to build libraries and binaries separately
Also add usage help and a few code cleanup
2017-03-01 07:20:29 +08:00
Roger Shimizu fc2031f03b Cleanup build_deb.sh script
- Use "lsb_release -cs" command to get distro info.
- Limit xz memory usage to 128MiB.
- Other minor fixes.
2017-02-27 20:59:51 +08:00
Roger Shimizu e9c1116f0f Add simple-obfs support to build_deb.sh script 2017-02-27 07:40:42 +08:00
Roger Shimizu 12c4344a42 Update build_deb.sh to add libbloom support
Also includes fixes for yakkety.
2017-02-25 07:04:28 +08:00
Roger Shimizu 9185afb142 Update build script to enable jessie/stretch etc
Also include a few cleanup that simplified pkg installation from
backports repository.
2017-02-20 07:28:58 +08:00
Roger Shimizu 67661fb9dd Update deb build script
Now build script is able to auto detect system and choose libraries
necessary to build.

Also update the README accordingly.
2017-02-19 18:35:11 +08:00
Roger Shimizu 97ac602dbf Add xenial-backports repository
Because user may upgrade from previous LTS version, xenial-backports
is better to be added by us for safety.

And use debhelper 10 for shadowsocks-libev only.
2017-02-17 08:33:35 +08:00
Roger Shimizu d7888abbf1 Update trusty build script
- Move Build-Depends dh-autoreconf dh-systemd to debian/control
- Also change debian/compat to 9 (debhelper 9)
2017-02-17 08:33:25 +08:00
Neal Feng 0437e05aa8 iperf.sh: wait one second before killing processes 2017-02-16 12:33:40 +08:00
Roger Shimizu d12a7b911e Add more cleanup pkg to trusty script
For xenial script, it's clean enough so far.
2017-02-15 08:00:43 +08:00
Roger Shimizu 0553da0692 dh-systemd dependency should be removed for debhelper >=10
For trusty, debhelper is 9, so need to add the Build-Depends
for the build script.

With a few other fixes for trusty script.
2017-02-14 09:37:24 +08:00
Roger Shimizu e7e4291f03 Add deb build script for ubuntu xenial 16.04 2017-02-13 22:31:16 +08:00
Roger Shimizu 14a79b5500 Add deb build script for ubuntu trusty 14.04 2017-02-13 20:55:37 +08:00
Max Lv 95ef3d5635 Add iperf.sh 2017-02-03 18:47:29 +08:00