1012 Commits
Author SHA1 Message Date
Qiu Yuzhouandty f23366dc0e feat(local): hot-reload the ACL file at runtime via SIGUSR2 (#2183)
* feat(acl): add AclHandle to swap ACL rules atomically at runtime

AccessControl is immutable after loading, and ServiceContext used to store
it directly, so rules were frozen for the lifetime of the process.

Wrap the active rules in an ArcSwap-based AclHandle. Readers take a cheap
Arc snapshot which stays valid across a swap, enabling hot-reloading
without interrupting the service. reload() re-parses the retained file
path and only swaps the new rules in when parsing succeeds.

* feat(local): hot-reload the global ACL file through ServiceContext

Store the ACL as an AclHandle in ServiceContext. set_acl keeps its
signature and wraps the rules in a handle; cloned contexts share it, so
every listener sees the same swappable rules. acl() now returns an
Arc<AccessControl> snapshot instead of a reference, which cannot be
preserved across an atomic swap.

ServiceContext::reload_acl() re-reads the ACL file, swaps the new rules
in atomically and clears the DNS relay's reverse-lookup cache, which
caches decisions derived from the old rules. On failure the previous
rules stay active.

Server keeps the global context and exposes acl_reload_context() so
embedders can trigger reloads. Contexts with a private ACL keep their
own handle and are not covered by the global reload.

* feat(local): reload the ACL file on SIGUSR2 in sslocal

sslocal already reloads its server list from the config file on SIGUSR1.
Add a second reload trigger on SIGUSR2 for the ACL file, so routing
rules can be updated without restarting the process or interrupting
established connections.

Like the SIGUSR1 reloader, the task is Unix-only and compiles away on
Windows. ssservice's local mode shares this module and inherits it.

Document both signals in the README and cover the reload with an
integration test that verifies new connections are routed by the new
rules after each reload.

* refactor(acl): address review feedback for ACL hot-reload

- Rename `AclHandle` to `AccessControlHandle`, aligning the name with `AccessControl`
- Rename `Server::acl_reload_context` to `Server::context`, so the shared global context can be reused for other runtime operations
- Fold reload logging into `AccessControlHandle::reload`, keeping `ServiceContext::reload_acl` thin
- Record the config file and the ACL file as absolute paths at load time, so both SIGUSR1 and SIGUSR2 reloads keep working after daemonizing (which `chdir`s to `/`); symlinks are deliberately preserved by resolving with cwd instead of canonicalizing

* refactor(local): drop needless pending() in the non-Unix ACL reload task stub

The task may complete immediately: the main loop already tolerates early task exit, mirroring the existing Windows behavior of the SIGUSR1 reload task. This also releases the ServiceContext clone right away instead of holding it forever.

---------

Co-authored-by: ty <zonyitoo@gmail.com>
2026-09-29 11:47:28 +08:00
Fan Yang 743d0b3931 [Feature]: Allow to chain ssserver to another socks5/http/https proxy #1397 (#2106)
* Add outbound SOCKS5 proxy chains with auth

* Add HTTP and HTTPS CONNECT support to outbound proxy chains

* Initialize outbound proxy chains in manager server configs

* Fix outbound proxy chain handling and share HTTPS transport

* docs: update README for outbound proxy chains
2026-04-11 22:10:08 +08:00
zonyitoo 1008eeec1d feat(local-http): support HTTP Basic auth (#1994) 2025-12-19 03:26:17 +08:00
Aaron Chen aa9156a794 fix: bump msrv to 1.88 (#2054) 2025-12-09 02:19:35 +08:00
zonyitoo 04b3ad8504 fix: switched from serde_json5 to json5 2025-12-07 21:38:23 +08:00
Aaron Chen 4a3db21d58 chore: make syslog-tracing optional (#2050) 2025-11-23 23:58:42 +08:00
zonyitoo fff99a9418 fix: json5 unmaintained, RUSTSEC-2025-0120 2025-11-20 21:26:29 +08:00
zonyitoo 1db36a1c73 feat(shadowsocks-rust): logging support syslog (#2044) 2025-11-17 01:30:11 +08:00
Aaron Chen 7ff3c9ac7f chore: make clippy happy (#2025) 2025-09-23 00:04:18 +08:00
ty ee0646016e chore(shadowsocks-rust): skip Daemonize compile 2025-09-22 15:59:35 +08:00
ty fc0a8ba1d9 chore(shadowsocks-rust): fixed doctest 2025-09-22 15:40:05 +08:00
ty deae27efc3 chore(shadowsocks-rust): fixed doctest 2025-09-22 15:34:44 +08:00
zonyitoo b672c3d9b4 fix(shadowsocks-rust): daemonize is unmaintained
- rustsec/advisory-db#2279
- Copied source code from knsd/daemonize and applied all unmerged PRs
2025-09-22 02:23:09 +08:00
zonyitoo de97c757d7 feat: renamed stdout to console logger writer 2025-08-29 01:20:38 +08:00
shadowsocks69420 4a105e9b0a feat: support file logging with tracing (#1993) 2025-08-29 01:10:00 +08:00
Aaron Chen 1041d5f99b chore: use Self where applicable (#1964) 2025-06-07 16:11:17 +08:00
Aaron Chen 842fba0e25 chore: make clippy happy (#1955) 2025-05-18 17:17:19 +08:00
renovate[bot]andzonyitoo 08bb31cd0c fix(deps): update rust crate xdg to v3 (#1950)
* fix(deps): update rust crate xdg to v3

* fix: xdg BaseDirectories has default values

---------

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: zonyitoo <zonyitoo@gmail.com>
2025-05-05 22:46:47 +08:00
zonyitoo 56b6c35575 fix(shadowsocks-service): online-config-allowed-plugin append list (#1943) 2025-04-29 23:49:44 +08:00
zonyitoo 76eb770472 feat(shadowsocks-service): fixed build error in sslocal (#1943) 2025-04-29 23:43:52 +08:00
zonyitoo 0bbf0aa386 feat(shadowsocks-service): online config plugin whitelist from command line arg (#1943) 2025-04-29 23:41:56 +08:00
zonyitoo 7ab6772549 feat(shadowsocks-service): online config plugin whitelist (#1943) 2025-04-29 23:35:27 +08:00
ty 9eefc2db3e feat: update hickory-resolver v0.25 public release
- ref hickory-dns/hickory-dns#2206

reformatted with 1.85 new formatter
2025-03-19 12:50:53 +08:00
zonyitoo 6973480082 feat: updated edition 2024, msrv 1.85 2025-03-14 01:12:48 +08:00
zonyitoo 3a0d20c99f fix: rand::thread_rng deprecated 2025-03-02 22:57:10 +08:00
Aaron Chen 79ad390653 chore: clippy fix (#1849) 2025-01-11 13:04:26 +08:00
ClaytonKnittel 8416f6dab8 refactor: change error handling to be strongly-typed (#1834)
* Refactor error handling to be strongly-typed.

* Remove unused function.

* Remove comment.

* Add module + type docstrings.

* Make error module private.

* Fix windows build.
2025-01-07 19:25:30 +08:00
zonyitoo c85a74194f feat(shadowsocks): ServerConfig::new returns Result
- fix #1770
- allow users to check errors instead of just panic on wrong passwords
2024-11-17 01:18:05 +08:00
zonyitoo a03006a753 chore: fix build warning for Windows 2024-10-25 00:53:47 +08:00
Vesa Vilhonen 0041f62128 feat(local): Allow configuring udp associate addr
User might want to bind the socket to a different address
than what is advertised in the Socks 5 UDP Associate responses.

This adds a new command line option to control only that but to still
default to udp bind addr and local address.

Example:

    sslocal --local-addr 0.0.0.0:1080 --udp-associate-addr 10.51.1.1:1080 -U

Here the server would without this change respond to UDP Associate request with
address 0.0.0.0:1080. With the new switch, it responds 10.51.1.1:1080.
2024-08-13 23:19:07 +08:00
zonyitoo 29fc232e1f chore: imports_granularity set to default
- imports_granularity is still unstable since 2021:
  https://rust-lang.github.io/rustfmt/?version=v1.6.0&search=#imports_granularity
2024-08-07 00:17:00 +08:00
Aaron Chen 918730497f update links 2024-07-06 11:12:23 +08:00
zonyitoo 6345c0dcf1 feat(server): tokio v1.38 stablized RuntimeMetrics::num_workers 2024-06-13 00:00:05 +08:00
ty aa0e40155d chore: clippy fix 2024-06-12 10:07:51 +08:00
zonyitoo 3b7ca91d24 fix(local): windows build 2024-06-12 02:17:38 +08:00
zonyitoo 87c1557fda feat(local-online-config): refactored with local-http client
- removed dependency to reqwest (very large)
- apply outbound configurations on sockets
- fixed #1508
2024-06-12 02:08:47 +08:00
zonyitoo e981e7eaaf fix: parse_ipnet enabled for local-fake-dns (#1558) 2024-06-11 23:28:08 +08:00
zonyitoo a77f0cb317 fix: local-fake-dns deps add ipnet (#1557) 2024-06-11 22:32:43 +08:00
ty cd537e942d feat: online-config only limits total request timeout: 30s 2024-06-10 00:39:45 +08:00
ty 27c207ec4d chore: charset is predefined in mime 2024-06-08 22:04:59 +08:00
ty d07ea6f52e feat: parse content-type with \"mime\" 2024-06-08 22:04:06 +08:00
ty 1e68e2cda2 chore: reqwest::Error print with Debug 2024-06-08 21:47:35 +08:00
ty 98013d7746 fix: wrong compression name, should be brotli 2024-06-08 12:29:13 +08:00
ty 7e272f6604 feat: online-config set http User-Agent and timeouts 2024-06-08 12:27:32 +08:00
zonyitoo ba8e07e769 feat: local-tun compilable for not-supported platforms
- Prepare for v1.19.0 release. Upgraded MSRV to 1.74
- "default" build feature now contains only basic shadowsocks features
  (BREAKING)
- Add "full" build feature for all suggested features
- Add "full-extra" build feature for including *-extra features
2024-05-24 23:13:14 +08:00
zonyitoo f3c9ecd2b3 chore: reformatted with nightlly rustc 2024-05-18 23:52:08 +08:00
zonyitoo 7aed79b201 fix: service_config warning ignored (#1529) 2024-05-18 20:54:53 +08:00
zonyitoo 60b1ecd4e9 feat(local): online_config handled only in binary 2024-05-13 23:28:42 +08:00
ty 62867b3f3e chore: suppress warnings 2024-05-13 14:43:05 +08:00
ty 562e3deb1d feat(local): check integrity for online config 2024-05-13 10:12:12 +08:00