406 Commits
Author SHA1 Message Date
Max Lv e697eb292b chore: fix clippy 1.95 lints (io_other_error, collapsible_match, large_enum_variant) 2026-10-22 10:22:37 +08:00
Max Lv dc43297211 fix(relay): bound idle time of half-closed TCP tunnels
With a SIP003 plugin, every proxied connection is a loopback connection
from sslocal to the plugin. After the client half-closes, sslocal shuts
down its write side and waits for EOF from the plugin. Many plugins
(simple-obfs, v2ray-plugin, kcptun/smux, ...) never close their side, so
the socket stays in FIN_WAIT_2 forever (tcp_fin_timeout only applies to
orphaned sockets, keepalive is answered by the live plugin), leaking an
ephemeral port and fd per connection until local ports are exhausted.

- CopyBidirectional now fails with TimedOut if the remaining direction
  stays idle for HALF_CLOSE_IDLE_TIMEOUT (60s) after the other direction
  has been shut down. The timer restarts on every transferred byte, so
  long downloads after a half-close keep working.
- Plugin::wait_started no longer spins on connect(), and rejects a
  self-connected socket (src == dst) that would otherwise be mistaken
  for a started plugin.
2026-10-22 10:22:37 +08:00
ty a981de7bbf fix(relay): pick non-zero AEAD-2022 padding size for empty first payload
SIP022 requires that in a request header, either initial payload or
padding MUST be present. When the first payload is empty (e.g. handshake
triggered by an empty write for server-first protocols), the client
could pick padding 0 with probability 1/901, generating a header that
servers MUST reject per the spec, causing ~1/901 handshakes to fail
against ssserver built from the same crate.

Pick the padding size from 1..=AEAD2022_MAX_PADDING_SIZE instead.

fix #2184
2026-09-29 10:27:31 +08:00
ty e01605cdff fix(tcprelay): report actual plaintext length when retrying after Pending
EncryptedWriter.poll_write_encrypted keeps the encrypted buffer and its
on-wire offset across Poll::Pending, but returned the length of the
buffer passed on the *retried* call instead of the plaintext length that
was actually assembled into the pending frame.

Tokio's copy/copy_bidirectional may append freshly read data to the
input slice while the writer is Pending, so the reported count could
exceed what was actually encrypted and sent, silently dropping the
appended bytes.

Fixes #2175
2026-09-25 11:36:14 +08:00
ty b8cce0d519 Bump shadowsocks-crypto to 0.8.0 2026-08-27 02:20:13 +08:00
ty 65f6a8e166 refactor: split inbound_udp_allow_fragmentation from outbound option
Add a dedicated  config option for
inbound (listener) UDP sockets, instead of reusing the outbound option.

- SSConfig / SSServerExtConfig: new
  JSON field (global + per-server)
- Config / ServerInstanceConfig: new field, defaults to false
- server/manager/local: accept_opts.udp.allow_fragmentation now sourced
  from the inbound option; per-server override split into inbound/outbound
- README: document the new option in both JSON examples
- tests/udp.rs: fix unused import of AcceptOpts on non-Linux platforms
2026-08-27 02:07:27 +08:00
peng weikang 668ff171f4 fix: allow fragmentation for inbound UDP replies 2026-08-27 02:07:27 +08:00
gengjiawen db65eaa824 fix(net): make udp batch cfgs match the bsd module routing for tvos/watchos
`net/sys/unix/bsd/mod.rs` already routes macos, ios, watchos and tvos
to `bsd/macos.rs`, and that module unconditionally imports
`net::udp::{BatchRecvMessage, BatchSendMessage}`. But the nine cfg
gates in `net/udp.rs` list only macos and ios among the Apple
platforms, so on watchos and tvos those items are configured out while
the importer is still compiled -- E0432, the crate does not build.

Add watchos and tvos to the nine gates so the two lists agree.
2026-08-08 23:20:32 +08:00
renovate[bot] 6b96a84b99 fix(deps): update rust crate base64 to 0.23 2026-07-23 18:43:11 +00:00
renovate[bot] b8e495edfd fix(deps): update rust crate sealed to 0.7 2026-07-23 12:34:56 +00:00
renovate[bot] e5257f7e01 fix(deps): update rust crate spin to 0.12 (#2136)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2026-05-20 18:26:39 +00:00
renovate[bot]andzonyitoo d817982cd1 fix(deps): update rust crate hickory-resolver to 0.26 (#2114)
* fix(deps): update rust crate hickory-resolver to 0.26

* fix: compat hickory-resolver 0.26

* fix: remove unused import

* fix: removed unnecessary deref

---------

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: zonyitoo <zonyitoo@gmail.com>
2026-05-05 17:14:39 +08:00
Linus Färnstrand 9fca88bc93 Replace ring with aws-lc-rs across the dependency tree
Switches the cryptographic backend so that ring is no longer pulled
into shadowsocks-rust on any supported target.

* shadowsocks-crypto: use the new aws-lc-rs backend in place of
  the ring feature
* tokio-rustls: select the aws_lc_rs provider instead of ring.
* hickory-resolver: use tls-aws-lc-rs, https-aws-lc-rs and
  h3-aws-lc-rs in place of the *-ring variants.

The only remaining ring path in the dependency tree is via quinn-proto on
wasm32-unknown-unknown, which aws-lc-rs cannot target and which
shadowsocks does not support.
2026-05-05 17:13:29 +08:00
renovate[bot]andzonyitoo 75d44c7956 fix(deps): update rust crate aes to 0.9 (#2107)
* fix(deps): update rust crate aes to 0.9

* feat: compat cipher 0.5

* fix: replaced deprecated from_slice

---------

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: zonyitoo <zonyitoo@gmail.com>
2026-05-01 22:41:59 +08:00
Alessandro Riva bb039a6ac0 feat: add eih support 2026-04-26 01:24:30 +08:00
Yuwei BaandCopilot a71d8a0f40 feat: expose user_key() on CryptoStream and ProxyServerStream (#2109)
After an AEAD2022 handshake with a ServerUserManager, the authenticated
user's raw key is available inside DecryptedReader but not reachable
from the public API.  Expose it via:

  CryptoStream::user_key()       -> Option<&[u8]>
  ProxyServerStream::user_key()  -> Option<&[u8]>

This lets callers (e.g. clash-rs) identify which multi-user identity
was authenticated without having to manually peek and re-derive the
identity subkey via BLAKE3 + AES-256-ECB before the handshake.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-04-12 22:15:25 +08:00
zonyitoo 7d28db736b feat: bump version v1.25.0
- MSRV upgraded to v1.91, due to smoltcp v0.13.
- Upgrade dependencies
- Add cursor rule orientation
2026-03-23 00:03:27 +08:00
renovate[bot]andzonyitoo 2d755f05d6 fix(deps): update rust crate smoltcp to 0.13 (#2094)
* fix(deps): update rust crate smoltcp to 0.13

* chore: raise MSRV to 1.91 for smoltcp 0.13

smoltcp 0.13 requires Rust 1.91. Align rust-version, clippy msrv,
and GitHub MSRV workflow with that toolchain.

Made-with: Cursor

* fix(deps): bump aws-lc-rs for RUSTSEC-2026-0048

Update aws-lc-sys to 0.39.0 via aws-lc-rs 1.16.2 (CRL IDP validation fix).

Made-with: Cursor

---------

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: zonyitoo <zonyitoo@gmail.com>
2026-03-22 23:55:12 +08:00
renovate[bot]andzonyitoo ef671c38ad fix(deps): update rust crate rand to 0.10 (#2074)
* fix(deps): update rust crate rand to 0.10

* fix: small_rng enabled by default

* fix: small_rng enabled by default

* fix: from_os_rng replaced by make_rng

---------

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: zonyitoo <zonyitoo@gmail.com>
2026-02-11 00:37:52 +08:00
Aaron Chen 46c96ac1fb chore: fix typos 2026-02-09 15:53:16 +08:00
Aaron Chen d83d6d2246 chore: clippy fix (#2059) 2026-01-06 11:59:22 +08:00
zonyitoo 8133713b4a feat: optimized socket2::Socket with socket2::SockRef 2026-01-05 18:07:22 +08:00
zonyitoo 1008eeec1d feat(local-http): support HTTP Basic auth (#1994) 2025-12-19 03:26:17 +08:00
zonyitoo bb276eda01 chore: example.com returns HTTP/1.1 2025-12-11 07:54:16 +08:00
zonyitoo 7ee1aa9223 chore: release v1.24.0 2025-12-11 07:38:59 +08:00
Aaron Chen aa9156a794 fix: bump msrv to 1.88 (#2054) 2025-12-09 02:19:35 +08:00
renovate[bot] af7f55dbbc fix(deps): update rust crate windows-sys to 0.61 (#2015)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2025-09-23 00:06:14 +08:00
renovate[bot]andty 3f73bccfe3 fix(deps): update rust crate dynosaur to 0.3.0 (#1987)
* fix(deps): update rust crate dynosaur to 0.3.0

* fix(shadowsocks): compatible with dynosaur 0.3

---------

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: ty <zonyitoo@gmail.com>
2025-07-17 12:25:36 +08:00
renovate[bot] 11c7ac206f fix(deps): update rust crate tokio-tfo to 0.4 2025-07-05 18:05:21 +00:00
renovate[bot]andzonyitoo fa9aad3bbd fix(deps): update rust crate socket2 to 0.6 (#1984)
* fix(deps): update rust crate socket2 to 0.6

* fix: socket2 0.6 compatible

---------

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: zonyitoo <zonyitoo@gmail.com>
2025-07-06 02:04:09 +08:00
zonyitoo 8f9419efa5 chore: release v1.23.5 2025-07-04 22:57:36 +08:00
zonyitoo 636d9c5f50 feat: impls AsSocket, AsRawSocket for UdpSocket 2025-07-01 01:28:23 +08:00
Aaron Chen 393e09ce12 chore: allow clippy::uninlined_format_args (#1981) 2025-06-28 23:08:36 +08:00
zonyitoo c0bd03ad63 feat(shadowsocks): making android::SocketProtect sealed (#1974) 2025-06-22 02:47:37 +08:00
zonyitoo 12c4ff2593 feat: add MakeSocketProtect and docs, reformatted 2025-06-19 00:33:20 +08:00
Zhang San 1fff8e64ae Allow user to pass SocketProtectFn for android (#1974)
* add vpn socket protect fn for android

Signed-off-by: San Zhang <sanzhang@mail.com>

* add SocketProtect trait

Signed-off-by: San Zhang <sanzhang@mail.com>

* fix an error

Signed-off-by: San Zhang <sanzhang@mail.com>

* Add missing trait

Signed-off-by: San Zhang <sanzhang@mail.com>

* Add new impl for SocketProtect

Signed-off-by: San Zhang <sanzhang@mail.com>

* Add missing trait

Signed-off-by: San Zhang <sanzhang@mail.com>

* Add missing fn

Signed-off-by: San Zhang <sanzhang@mail.com>

* Some change

Signed-off-by: San Zhang <sanzhang@mail.com>

* Rename to call

Signed-off-by: San Zhang <sanzhang@mail.com>

* Make some change

Signed-off-by: San Zhang <sanzhang@mail.com>

---------

Signed-off-by: San Zhang <sanzhang@mail.com>
2025-06-18 23:45:30 +08:00
ty 49d00ce100 chore: FALSE could be found in Win32::Foundation 2025-06-17 14:07:14 +08:00
renovate[bot]andty 16dda13859 fix(deps): update rust crate windows-sys to 0.60 (#1973)
* fix(deps): update rust crate windows-sys to 0.60

* fix: windows-sys 0.60 BOOL moved to core

---------

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: ty <zonyitoo@gmail.com>
2025-06-17 14:02:03 +08:00
Zhang San 3a31fa6959 feat: impl AsRawFd and AsFd for UdpSocket (#1971)
Signed-off-by: San Zhang <sanzhang@mail.com>
2025-06-16 18:35:28 +08:00
zonyitoo c3004d4d5d chore: dns RuntimeProvider log ConnectOpts (#1965) 2025-06-07 22:46:27 +08:00
Aaron Chen 1041d5f99b chore: use Self where applicable (#1964) 2025-06-07 16:11:17 +08:00
Aaron Chen 85cf58abfb chore: replace once_cell::sync::Lazy with std::sync::LazyLock (#1963) 2025-06-06 10:15:53 +08:00
Aaron Chen 842fba0e25 chore: make clippy happy (#1955) 2025-05-18 17:17:19 +08:00
zonyitoo b33b7d72ae chore: updated shadowsocks to v1.23.1 2025-04-21 22:28:52 +08:00
zonyitoo d7ead5de4f feat(shadowsocks): double check AEAD-2022 ipsk length 2025-04-15 03:29:55 +08:00
Aaron Chen 6d0862cb68 fix: fixed build on android (#1936) 2025-04-12 11:06:25 +08:00
zonyitoo fe71d5f2dc fix: fixed build with duplicated io::Error use (#1934) 2025-04-09 21:50:48 +08:00
zonyitoo d8f91b806c fix: fixed build on openbsd (#1934) 2025-04-09 21:42:57 +08:00
Aaron Chen 0dbface59a chore: clippy fix (#1933) 2025-04-06 22:38:10 +08:00
zonyitoo 4940da3702 feat(shadowsocks): TCP also supports mapped outbound-bind-address (#1928) 2025-04-03 23:55:19 +08:00