Commit Graph
72 Commits
Author SHA1 Message Date
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 Lv 8cc58cea95 Accept an ss:// server URL on the ss-local command line
shadowsocks-rust takes a whole server definition as a URL; libev could
only be given the pieces separately, so importing a server meant taking a
URL apart by hand. ss-local now accepts --server-url and reads the
address, port, cipher, password and SIP003 plugin from it.

Both encodings are handled: the SIP002 form with the userinfo in
base64url, and the older form where the whole body is one base64 blob.
The userinfo is also accepted in the clear, because that is what
shadowsocks-rust's `ssurl` emits for the 2022 ciphers, whose base64
pre-shared keys it percent-encodes instead. IPv6 literals, a trailing
slash, the plugin query and the '#' tag are all covered.

Options given later on the command line still win, since they are applied
as getopt reaches them.

ssurl.c sits with the ss-local sources rather than the shared ones: it
depends on base64.c, which ss-manager does not link.

The tests include URLs copied verbatim from `ssurl --encode` output, so
the parser is pinned against what another implementation really produces
rather than only against my reading of the spec. Verified end to end by
pointing ss-local at a rust-generated URL and proxying through their
ssserver.
2026-08-19 20:15:38 +08:00
Max Lv 46791234c0 Add Shadowsocks 2022 (SIP022) ciphers
shadowsocks-rust has supported the 2022 edition for years while libev was
stuck on the 2017 AEAD construction, the largest functional gap between
the two implementations. This adds the three SIP022 methods:

  2022-blake3-aes-128-gcm
  2022-blake3-aes-256-gcm
  2022-blake3-chacha20-poly1305

TCP uses BLAKE3 derive_key for session subkeys, standalone header chunks
carrying a type byte and timestamp, request padding, and a response header
echoing the request salt. Replay protection uses an exact-match salt pool
with 60s retention rather than the bloom filter, which SIP022 forbids
because false positives are unacceptable there.

UDP is session-based: an AES-ECB separate header for the AES methods and a
merged XChaCha20-Poly1305 construction for ChaCha, with a per-session
sliding window replay filter. Servers must route by client session ID,
which is only known after decryption, so the crypto layer owns the
server-side session table and hands the session back to udprelay for the
reply path.

The 2022 code lives in aead2022.c and aead2022_udp.c so aead.c keeps its
current size, with aead_internal.h carrying what they share. BLAKE3 is
vendored (portable backend only) as its own build target.

Keys are base64 pre-shared keys of exactly the cipher's key size; per
SIP022 a password is never stretched into a key.

Verified interoperable in both directions against shadowsocks-rust 1.24.0
for all three ciphers over TCP and UDP, including an 8MB transfer checked
by digest, plus unit tests for header framing, partial delivery, tamper
detection, and UDP replay rejection.
2026-08-19 18:15:35 +08:00
Max LvandClaude Opus 4.6 7bb250739e Modernize build: switch to CMake, add unit tests, fix man pages
* Modernize build: switch to CMake, add unit tests, fix man pages

Remove autotools (configure.ac, Makefile.am, m4/, autogen.sh) and make
CMake the sole build system. Enhance CMake with proper Find modules for
MbedTLS, libsodium, PCRE, and c-ares with version/feature detection.
Add support for connmarktos, nftables, stack protector, and MinGW.

Add 10 unit test suites (CTest) covering base64, buffer, cache, crypto,
jconf, json, netutils, ppbloom, rule, and utils modules. Add a Python
stress test measuring bandwidth per cipher with memory leak detection.

Fix man page typos ("Resovle" -> "Resolve"), document missing TCP buffer
options, fix ss-manager duplicate --executable entry, add example section
to ss-tunnel, and document --workdir and --nftables-sets options.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* Migrate from PCRE to PCRE2

Replace legacy PCRE (libpcre3) with PCRE2 (libpcre2-8). PCRE1 has been
end-of-life since 2021.

- src/rule.h: use pcre2_code and pcre2_match_data types
- src/rule.c: pcre_compile -> pcre2_compile, pcre_exec -> pcre2_match,
  pcre_free -> pcre2_code_free, with proper error message retrieval
- cmake/FindPCRE.cmake -> cmake/FindPCRE2.cmake: find libpcre2-8 via
  pkg-config, pcre2-config, or manual search
- Update all CMakeLists.txt, config.h.cmake, configure.cmake, README.md

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* Update Dockerfiles: use CMake build and pcre2-dev

The alpine Dockerfile still used autotools (autogen.sh/configure) which
were removed. Switch to cmake build and replace pcre-dev with pcre2-dev.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* Fix Docker build: disable tests and remove git dep

The tests/ directory is excluded by .dockerignore, so pass
-DBUILD_TESTING=OFF to cmake. Submodules are already checked out
by actions/checkout, no need for git inside the container.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* Fix Docker build: disable static libs (not available in alpine)

Alpine's mbedtls-dev only provides shared libraries. Disable static
build since Docker only needs shared binaries.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* Rewrite GitHub Actions: build and test directly on runner

Replace Docker-based CI with direct cmake build on ubuntu-latest and
macos-latest. Install dependencies via apt/brew, build with cmake,
run unit tests with ctest.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* Fix CI: use mbedtls@3 on macOS, disable static build

- macOS: brew's mbedtls is now v4 (incompatible), use mbedtls@3
- Disable static build since CI runners lack static lib packages

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* Fix test build on Linux: add stdint.h and link libm

- test_ppbloom.c: add missing #include <stdint.h> for uint8_t
- test_json: link against libm for pow() used in json.c

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* Fix test_ppbloom link: add libm for bloom's log()

On Linux, libbloom uses log() which requires explicit -lm linkage.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* Fix Linux build: link libm for test_buffer and test_crypto, fix warnings

Both test_buffer and test_crypto link libbloom.so which uses log() from
libm. Also fix unused variable warnings in test_json.c that would fail
with -Werror.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* Fix Linux build: link libm for test_jconf (json.c uses pow)

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* CI: add unit test and stress test steps to GitHub Actions

Split the Test step into separate "Unit tests" (ctest) and "Stress test"
(stress_test.py with 10MB transfer across all AEAD ciphers) steps for
better visibility.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-07 17:06:47 +08:00
Michael 3bcf258de1 Fix "missing configuration file" error during custom build using autotools 2022-11-23 09:39:54 +08:00
zfl9 6d4a3ad82c add tcp_tproxy option, asciidoc update 2020-07-18 17:08:56 +08:00
汪心禾 2ae8006ee3 *Shadowsocks-libev* accepts 19 different ciphers 2020-04-29 09:50:03 +08:00
汪心禾 2cc92827e5 xchacha20-ietf-poly1305 doc 2020-04-28 15:44:20 +08:00
Jamis Hoo 0aa55a29e5 Replace CMAKE_XXX_DIR with PROJECT_XXX_DIR, so that this project can be used in an enclosing project 2020-03-29 17:35:12 +08:00
Max Lv 03fb8c9f74 Revert "Add option '--long-idle' for server"
This reverts commit b4cda9dd42.
2019-09-02 09:25:30 +08:00
lixingcong b4cda9dd42 Add option '--long-idle' for server
Restore the default behavior handling timeout, make an option to enable
long idle connections.

Previously discussion:

https://github.com/shadowsocks/shadowsocks-libev/pull/2421

https://github.com/shadowsocks/shadowsocks-libev/issues/2427
2019-08-31 10:45:52 +08:00
Max Lv 4a42da641b Allow bind to local IPv4/v6 addresses. Fix #2372 2019-05-09 10:59:16 +08:00
amphineko e509a19698 doc: refine document for argument -b, fix #2353 2019-04-22 05:51:39 +08:00
ideal e64f9184cd cmake: change to absolute path to avoid command running every time to generate documents 2019-03-14 18:59:42 +08:00
ideal 56e805c99b cmake: installing man and doc files compliant to distribution standard 2019-03-11 14:57:00 +08:00
Max Lv c33cf3efc0 Fix #2267 2019-01-21 12:12:42 +08:00
Simon Shi e5d8476afe Update docs 2019-01-04 23:28:52 +08:00
Pang Linbin 3ed53a750a update the document about ss-manager 2018-11-15 19:11:01 -05:00
hwchan 00354513e6 Multipe nameservers support 2018-07-07 17:05:34 +08:00
Yegor Ievlev 8fd83e2686 Use chacha20-ietf as a default cipher instead of rc4-md5 (#2080)
* Use chacha20-ietf as a default cipher instead of rc4-md5

* Update tunnel.c

* Update utils.c

* Update ss-local.asciidoc

* Update ss-local.asciidoc

* Update tunnel.c

* Update ss-tunnel.asciidoc

* Update ss-manager.asciidoc

* Update ss-redir.asciidoc

* Update shadowsocks-libev.asciidoc

* Update aead.c

* Update local.c

* Update server.c

* Update utils.c
2018-06-07 08:58:10 +08:00
Feng Ye a8681c260e fix cmake syntax. 2018-04-03 13:58:54 +08:00
Sah 9778ce2e19 Documentation improvements
* Remove prompt 'root@Wrt:~#' from code example for better consistency
 * Fix line indentation of usage
 * Remove unnecessary note about ss-redir
2018-02-15 10:27:34 +01:00
星野ハジメ 44027da326 enable TCP_NODELAY from config file (#1757)
* Fix #1739

Refine #1739

* enable TCP_NODELAY from config file
2017-10-30 10:35:14 +08:00
Max Lv 10a2d3e3cd Fix #1693 2017-09-19 09:09:58 +08:00
Max Witten b721c0fa6d Update docs for TCP_NODELAY 2017-09-15 10:55:15 +08:00
不可描述先生 b8705cc3b2 refine doc/ss-redir.asciidoc (#1683) 2017-09-12 17:20:28 +08:00
Simon Shi adbc0be628 Update ss-tunnel.asciidoc 2017-04-07 10:11:50 +08:00
wener 1f91fbc69a 1. Fix incorrect install path.
2. set CMP0048 to OLD to prevent warning
2017-03-26 21:20:33 +08:00
wener 88ef344262 Add document build 2017-03-26 21:20:33 +08:00
Boyuan Yang 3f789cd0a7 Clarify port_password usage in docs (#1229) 2017-02-10 16:04:31 +08:00
Max Lv 0b9b8d65ce Update config.json docs 2017-02-10 15:54:58 +08:00
Simon Shi a0d38b3d91 Fix typo (#1210)
* Fix doc

* Update ss-redir.asciidoc

* Update ss-server.asciidoc
2017-02-07 08:47:34 +08:00
Max Lv ef0402eb10 Add --key option to set key directly (#1207) 2017-02-06 17:02:04 +08:00
Max Lv 894eae567c Refine ciphers 2017-02-04 20:04:48 +08:00
Max Lv 7b290f30d6 Make SO_REUSEPORT disabled by default 2017-02-02 21:05:57 +08:00
Max Lv 78cf5348f0 Update documents 2017-02-01 18:51:48 +08:00
Max Lv 56658d1c79 Merge pull request #1152 from shadowsocks/sip004
Add AEAD support
2017-02-01 18:19:40 +08:00
anonymous-contributor 98c51cd0d5 Obfsproxy standalone mode (#1156)
* ss-libev: Introduce mode parameter for start_plugin

Since obfsproxy handles client and server in different ways, no matter
standalone or manged mode, so introduce the mode for start_plugin() to
support obfsproxy.

With more comments added to plugin.h for later developers.

Signed-off-by: Adam Anonymous <anonymous_temp_mail@yahoo.co.jp>

* ss-libev: Move SS protocol plugin initialization code to start_ss_plugin

Move SS protocol plugin initialization to start_ss_plugin() function, as
the support for obfsproxy will not use that environment.

Also, remove the use of get_current_dir_name() which is a glibc
extension, such macro hack will just make code less readable.
Not to mention it already screw up code folding of vim.

Signed-off-by: Adam Anonymous <anonymous_temp_mail@yahoo.co.jp>

* ss-libev: Introduce obfsproxy standalone mode support as plugin

Now shadowsocks-libev supports to use obfsproxy as plugin.

Currently we only support to use standalone(proxy) mode of obfsproxy, as
managed mode needs to use SOCKS5 as upstream forward, while ss-libev
doesn't support it yet.

And the output from plugin is just trashed for now.
Support to pipe them into stdout/stderr will be added later.

Signed-off-by: Adam Anonymous <anonymous_temp_mail@yahoo.co.jp>

* ss-libev: doc: Fix wrong cmdline parameter for plugin options

Command line option for plugin options is "--plugin-opts", not the json
option "--plugin_opts"

Fix it.

Signed-off-by: Adam Anonymous <anonymous_temp_mail@yahoo.co.jp>
2017-02-01 18:18:43 +08:00
Max Lv 4ebe5aeb12 Add SIP004 (AEAD) support 2017-01-29 10:10:44 +08:00
Max Lv 3f8cd982e5 Drop MinGW32 support 2017-01-24 20:10:31 +08:00
Zheng Kai f4517ed7a7 Fix duplicate text 2017-01-20 18:03:26 +08:00
Max Lv 633de3e228 Remove embedded libraries 2017-01-18 11:07:40 +08:00
Simon Shi 3fba5506c5 Update ss-manager.asciidoc 2017-01-17 08:15:59 +08:00
Max Lv 9c94e6792c Bump version 2017-01-16 10:23:01 +08:00
Max Lv becb6c08e4 Update docs for JSON config 2017-01-16 10:03:07 +08:00
Max Lv 92f0baa789 Update SIP003 interfaces 2017-01-14 10:40:14 +08:00
Max Lv 3fde843ec8 Fix #1061 2017-01-12 10:24:27 +08:00
Max Lv 61b82c45c5 Add SIP003 plugin support (#1044)
https://github.com/shadowsocks/shadowsocks-org/issues/28
2017-01-08 01:10:00 -06:00
Max Lv 8cb4f81eba Add HTTP/TLS obfuscating. [SIP001] (#1009)
Add experimental HTTP/TLS obfuscating as an **optional extension** of shadowsocks protocol.

More discussions can be found here: https://github.com/shadowsocks/shadowsocks-org/issues/26

As this feature is still a SIP (Shadowsocks Improvement Proposal), it's very unstable and experimental. So, 

1. Don't enable it unless you know what it is.
2. Be very careful when using it in production environment.
2016-12-27 02:53:25 -06:00