32 Commits
Author SHA1 Message Date
Max Lv 002b4093fd C++20 port 14/14: remove the C shims, report, fixes (#3077)
* 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.

* Reinitialize the event loop after daemonize()

The loop is created before the programs fork into the background, and
kqueue/epoll descriptors do not survive fork(), so ss-server -f (which
ss-manager always uses) died as soon as it ran. Call uv_loop_fork() in
the child.

* 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.

* 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.

* Describe the C++20/libuv build in the Debian and snap metadata

* Keep clang-tidy clean in the new C++ tests

* Add --max-dns-queries / max_dns_queries

Sizes the resolver's query pool, the last of the capacity settings the
no-heap-after-startup design calls for. Defaults are unchanged: the
connection limit (plus 64 on ss-server, which also resolves for its
statistics).

* Report the C++20 rewrite: allocation, size, throughput and memory

docs/performance.md compares master (C) with the C++ engine on macOS
arm64: zero heap allocations per connection or datagram (from 27-89),
TCP throughput within noise, and about 20 MiB more RSS at 1,000 open
connections from the inline per-connection buffers. docs/cpp-core.md
and CLAUDE.md now describe the finished layout.

* Fix the MinGW build of ss-server: stat_resolver is POSIX-only

* Fix the fully static image and the build image for the C++ sources

docker/static: the C++ unit tests link the static libstdc++, whose error
paths need an unwinder that --rtlib=compiler-rt does not provide; link
llvm-libunwind. The programs themselves still need no C++ runtime.

docker/build: build in the default bundled mode with CMake instead of
against libev/udns (Alpine's Mbed TLS 4 is not supported by system
mode).

* Fall back to the system heap when a library realloc cannot be served

heap_realloc returned NULL when a block outgrew the largest size class or
the budget, and libuv aborts when growing its watcher array fails: a poll
on fd 8190 or above (about 4,000 connections) killed the process.
Move the block to the system heap instead, as malloc and calloc already
do. test_heap_guard_cpp polls fd 16380 with the heaps installed.

* Leave pool room for UDP sessions that are still closing

An evicted session keeps its pool slot until its socket's close callback
runs, so with pool capacity equal to the table's the acquire after an
eviction failed: a full table dropped new-session packets after evicting
a live session for nothing. The AEAD-2022 shared-session pool had the
same problem with entries still referenced by relay sessions.

* Time client-side TCP connections when idle, not only while connecting

ss-local, ss-tunnel and ss-redir only timed the upstream connect (as the
C relays did), so a client that never finished its SOCKS handshake, or a
stream whose peer vanished without a FIN, held a pool slot forever. With
the pool now a hard cap that pauses accepting when full, enough of them
stopped the listener for good. Every connection now starts with the idle
deadline, connected() re-arms it, and traffic refreshes it for all kinds
(the idle timeout keeps its 24 h floor, MIN_TCP_IDLE_TIMEOUT).

* Include <algorithm> for std::min in crypto/keys.cpp (CLANG64)

* test.py: accept host:port for --dns

The tunnel test hard-coded port 53, so it could only use a public
resolver or root. With a port it runs against a local DNS stand-in.

* Use the Mbed TLS compat wrappers for MD5 key derivation

* Fix the documentation build after moving the codecs

utils.cpp's \snippet aead.cpp and stream.cpp now live in src/crypto/,
which was not on Doxygen's EXAMPLE_PATH, so the man1 and HTML builds
failed. List the documentation sources explicitly instead of guessing
their extension.
2026-10-15 10:11:56 +08:00
Max Lv f5d5bf0be1 Publish native Doxygen documentation with GitHub Pages 2026-09-12 14:46:42 +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
mesher2024 2d8af6e56c Update build-depends in debian/control
Replace libpcre3-dev with libpcre2-dev.
2026-02-08 09:59:34 +08:00
Roger Shimizu 0d96da4471 Sync debian/ folder with debian version 3.3.4+ds-3 2020-03-29 17:49:39 +09:00
Roger Shimizu 24ecf4d780 Sync debian/ folder with debian release 3.1.1+ds-1~exp1 2017-11-23 20:06:38 +09:00
Howard Liu 7525d518de Fixed Debian Package Control (#1656)
Removed dependency libudns-dev, added libc-ares-dev
2017-09-01 09:21:23 +08:00
Patrick Li f32ac38c2f Allow the use of pwgen to generate passwords 2017-03-07 16:26:46 +08:00
Roger Shimizu 91643523c4 Bump debhelper 10
debhelper 10 is available in the following Debian/Ubuntu releases:
 - Debian 8.x Jessie (jessie-backports)
 - Debian 9.x Stretch / unstable
 - Ubuntu 16.04 Xenial (xenial-backports)
 - Ubuntu 16.10 Yakkety

debhelper supports dh-autoreconf and dh-systemd by default, so we can
safely remove a few Build-Depends and dh params.

We also sync a few other files under debian/ folder with Debian release
3.0.2+ds-1~exp1.
2017-02-16 20:38:08 +08:00
Boyuan Yang 4f88092311 debian: Update packaging instructions (Fix #1198)
This commit will fix .deb packaging instructions for Ubuntu 16.04.
Meanwhile, .deb packaging for Debian/Ubuntu is now only suitable
for Ubuntu 16.04 LTS or higher, Debian 9 or higher.

Debian 8 users won't be able to build from source too because this
project now requires libsodium >= 1.0.8. Jessie-packports is needed
to build on Debian 8.
2017-02-08 17:18:25 +08:00
Roger Shimizu 71d5453f88 Sync debian/ folder with debian version 2.6.2+ds-1
Use asciidoc as Build-Depends, because user may build under Wheezy
or Ubuntu 14.04.
2017-01-22 13:29:12 +08:00
Roger Shimizu cc30c7b6eb debian/shadowsocks-libev.{default,init,service}: Run service as non-root 2017-01-22 12:57:42 +08:00
Roger Shimizu 1ce4bf903d Sync debian/ folder with v2.6.0+ds-2 2017-01-06 05:49:37 -06:00
Zhengjun Zhang 363bf5735e Add capabilities for Debian Linux, so you can run ss-* as non-root. 2016-12-31 20:23:05 -06:00
Roger Shimizu 65773723e4 sync debian/ folder with debian package 2.5.3+ds-1 (#866) 2016-10-04 09:55:42 -05:00
Boyuan Yang c12e450e98 Update Debian dependency and bump library soname (#814)
* debian: add libpcre3-dev as build dependency.

* Bump soname of libshadowsocks-libev.

Soname for libshadowsocks-libev is bumped
from 1:0:0 to 2:0:0 due to ABI breakage
between shadowsocks-libev 2.5.0 and 2.5.1.
2016-09-08 22:35:27 +08:00
Max Lv d8606c53b8 Refine libpcre searching 2016-09-08 22:20:48 +08:00
Boyuan Yang 2ca39faa4b Update debian package script (#709)
* Fix d/control dependency
* Add --disable-ssp in d/rules and depend on dpkg-buildflags
2016-07-06 02:50:46 -05:00
Roger Shimizu 75aeacadd1 Sync debian/ folder (#681)
A few itmes deserve to be mentioned:
 - use apg to generate random password when install.
 - generated password won't get updated when upgrading / reinstall.
 - add more to description to make lintian happy.
 - generated Makefile.am don't need to be listed in debian/copyright.
 - the way of installing systemd service is changed. Thanks to advice
   from Boyuan.
 - multi-arch can be archived without specific setting in debian/rules
 - add debian/watch file
2016-06-19 19:58:52 -05:00
Boyuan Yang 835a50fece Another fix for #668 (#671) 2016-06-10 08:50:05 -05:00
Max Lv 6fc1dccc58 Rename libshadowsocks to libshadowsocks-libev 2016-06-01 18:12:27 +08:00
Roger Shimizu cd736d3e94 A few commit recommend for Debian uploading (#636)
* Add Security Hardening

ref: https://wiki.debian.org/Hardening

* Add debian/source/format

* Remove -dbg package

Debug Package is already generated automatically, as -dbgsym package
ref: https://wiki.debian.org/DebugPackage

* Do not include a duplicated changelog into deb package

* Upgrade to policy version 3.9.8

No change is required, based on:
https://www.debian.org/doc/debian-policy/upgrading-checklist.html

* Update configure not to use local libs at all when choosing so
2016-05-17 20:11:05 +08:00
Boyuan Yang 14c611a337 fix debian packaging 2015-09-29 13:03:06 +08:00
Boyuan Yang 643d579bdf Improve Debian packaging script.
if debuild or dpkg-buildpackage is used, it will generate 4 packages
to fit Debian's packaging policy.
2015-09-22 15:44:39 +08:00
Max Lv 8be933153a fix #225 2015-01-14 20:29:04 +08:00
Max Lv 5f07c23ad1 update URLs 2014-12-28 10:02:56 +08:00
Max Lv d4781f9359 bump version and fix #157 2014-11-17 14:16:18 +08:00
Symeon Huang 50dbeef003 completely rename as shadowsocks-libev.
it's not conflicted with shadowsocks-python now. users can install both python and libev
ports of shaowsocks now. but they should migrate their old configuration file from
/etc/shadowsocks/config.json to /etc/shadowsocks-libev/config.json
2014-11-16 19:56:04 +00:00
Symeon Huang 5432aa1321 change name to shadowsocks-libev.
Note:

Debian/Ubuntu users may have to `sudo rm -f /etc/shadowsocks` before install
the new `shadowsocks-libev` package.

For library user, the pkg-config package is renamed to `shadowsocks-libev` but
the library name is still the `libshadowsocks` (use `-lshadowsocks` to link)
2014-11-15 15:13:06 +00:00
Max lv c97f5bbf9a fix building issues 2013-06-20 21:08:11 -05:00
Max Lv ff08838a19 add debian package description 2013-04-06 18:00:46 +08:00