From 0b80ee18cfc8c2dc9a84064b41fb984d15108943 Mon Sep 17 00:00:00 2001 From: "github-action[bot]" Date: Sat, 7 Jun 2025 20:34:21 +0200 Subject: [PATCH] Update On Sat Jun 7 20:34:20 CEST 2025 --- .github/update.log | 1 + clash-nyanpasu/backend/Cargo.lock | 6 +- .../frontend/interface/package.json | 2 +- clash-nyanpasu/frontend/nyanpasu/package.json | 10 +- clash-nyanpasu/manifest/version.json | 4 +- clash-nyanpasu/package.json | 4 +- clash-nyanpasu/pnpm-lock.yaml | 371 ++++++++---------- clash-verge-rev/UPDATELOG.md | 207 +++++----- lede/target/linux/sunxi/Makefile | 6 +- lede/target/linux/sunxi/arm926ejs/config-6.1 | 54 --- lede/target/linux/sunxi/arm926ejs/target.mk | 11 - .../linux/sunxi/{config-6.1 => config-6.12} | 11 +- .../cortexa53/{config-6.1 => config-6.12} | 28 +- .../cortexa7/{config-6.1 => config-6.12} | 6 +- .../cortexa8/{config-6.1 => config-6.12} | 2 - lede/target/linux/sunxi/image/Makefile | 2 - lede/target/linux/sunxi/image/arm926ejs.mk | 24 -- ...dings-usb-Add-H616-compatible-string.patch | 38 -- ...special-clock-for-Allwinner-H616-PHY.patch | 79 ---- ...m64-dts-allwinner-h616-Add-USB-nodes.patch | 188 --------- ...r-h616-OrangePi-Zero-2-Add-USB-nodes.patch | 81 ---- ...inner-h616-Split-Orange-Pi-Zero-2-DT.patch | 305 -------------- ...inner-h616-Add-OrangePi-Zero-3-board.patch | 140 ------- ...inner-h616-update-emac-for-Orange-Pi.patch | 36 -- ...lwinner-h616-Add-SID-controller-node.patch | 31 -- ...am-export-register-0-for-THS-on-H616.patch | 98 ----- ...-Add-D1-T113s-THS-controller-support.patch | 47 --- ...8i-Explain-unknown-H6-register-value.patch | 79 ---- ...i-Extend-H6-calibration-to-support-4.patch | 74 ---- ...-sun8i-Add-SRAM-register-access-code.patch | 126 ------ ...-Add-support-for-H616-THS-controller.patch | 50 --- ...Dont-fail-probe-due-to-zone-registra.patch | 68 ---- ...er-h616-Add-thermal-sensor-and-zones.patch | 138 ------- ...mccc-Export-revision-soc_id-function.patch | 32 -- ...ev-Blocklist-Allwinner-H616-618-SoCs.patch | 29 -- ...q-sun50i-Refactor-speed-bin-decoding.patch | 149 ------- ...50i-Add-support-for-opp_supported_hw.patch | 132 ------- ...6.10-cpufreq-sun50i-Add-H616-support.patch | 122 ------ ...ts-allwinner-h616-Add-CPU-OPPs-table.patch | 188 --------- ...nner-h616-enable-DVFS-for-all-boards.patch | 86 ---- ...50i-Fix-build-warning-around-snprint.patch | 51 --- ...error-returns-in-dt_has_supported_hw.patch | 34 -- ...-get_soc_chipid-and-sunxi_get_serial.patch | 53 --- ...s-suniv-add-USB-related-device-nodes.patch | 35 -- ...iv-add-device-tree-for-PopStick-v1_1.patch | 123 ------ ...M-dts-suniv-licheepi-nano-enable-USB.patch | 55 --- .../patches-6.1/463-f1c100s-sram-driver.patch | 33 -- .../464-f1c100s-watchdog-compat.patch | 18 - ...OF-node-for-USB-eth-on-NanoPi-R1S-H5.patch | 0 ...angepi_pc2_usb_otg_to_host_key_power.patch | 4 +- ...a64-sopine-Add-Sopine-flash-partitio.patch | 0 .../410-sunxi-add-bananapi-p2-zero.patch | 12 +- ...ner-a64-olinuxino-add-status-LED-ali.patch | 0 ...lwinner-nanopi-r1s-h5-add-status-LED.patch | 23 ++ ...-dts-allwinner-h616-fix-cpu-max-freq.patch | 7 +- ...m64-dts-orangepi-one-plus-enable-PWM.patch | 0 ...m64-dts-enable-wifi-on-pine64-boards.patch | 0 ...csi-video-support-for-nanopi-neo-air.patch | 107 +++++ shadowsocks-rust/Cargo.lock | 4 +- .../crates/shadowsocks-service/src/acl/mod.rs | 10 +- .../src/acl/sub_domains_tree.rs | 4 +- .../crates/shadowsocks-service/src/config.rs | 120 +++--- .../shadowsocks-service/src/local/context.rs | 6 +- .../src/local/dns/client_cache.rs | 4 +- .../src/local/dns/config.rs | 10 +- .../src/local/dns/dns_resolver.rs | 4 +- .../src/local/dns/server.rs | 24 +- .../src/local/dns/upstream.rs | 40 +- .../src/local/fake_dns/manager.rs | 12 +- .../src/local/fake_dns/proto.rs | 6 +- .../src/local/fake_dns/server.rs | 8 +- .../src/local/fake_dns/tcp_server.rs | 6 +- .../src/local/fake_dns/udp_server.rs | 4 +- .../src/local/http/http_client.rs | 32 +- .../src/local/http/http_service.rs | 4 +- .../src/local/http/http_stream.rs | 12 +- .../src/local/http/server.rs | 14 +- .../src/local/loadbalancing/ping_balancer.rs | 26 +- .../src/local/loadbalancing/server_data.rs | 8 +- .../src/local/loadbalancing/server_stat.rs | 4 +- .../shadowsocks-service/src/local/mod.rs | 4 +- .../src/local/net/tcp/auto_proxy_stream.rs | 38 +- .../src/local/net/udp/association.rs | 14 +- .../local/online_config/content_encoding.rs | 10 +- .../src/local/online_config/mod.rs | 4 +- .../src/local/redir/server.rs | 8 +- .../src/local/redir/tcprelay/mod.rs | 4 +- .../local/redir/tcprelay/sys/unix/linux.rs | 2 +- .../src/local/redir/udprelay/mod.rs | 12 +- .../local/redir/udprelay/sys/unix/linux.rs | 12 +- .../local/socks/client/socks4/tcp_client.rs | 4 +- .../local/socks/client/socks5/tcp_client.rs | 8 +- .../local/socks/client/socks5/udp_client.rs | 4 +- .../src/local/socks/config.rs | 20 +- .../src/local/socks/server/mod.rs | 8 +- .../src/local/socks/server/server.rs | 4 +- .../src/local/socks/server/socks4/tcprelay.rs | 4 +- .../src/local/socks/server/socks5/tcprelay.rs | 4 +- .../src/local/socks/server/socks5/udprelay.rs | 4 +- .../src/local/socks/socks4.rs | 90 ++--- .../src/local/tun/ip_packet.rs | 18 +- .../shadowsocks-service/src/local/tun/mod.rs | 4 +- .../shadowsocks-service/src/local/tun/tcp.rs | 12 +- .../shadowsocks-service/src/local/tun/udp.rs | 8 +- .../src/local/tun/virt_device.rs | 6 +- .../src/local/tunnel/server.rs | 8 +- .../src/local/tunnel/tcprelay.rs | 4 +- .../src/local/tunnel/udprelay.rs | 4 +- .../shadowsocks-service/src/manager/server.rs | 8 +- .../shadowsocks-service/src/net/flow.rs | 6 +- .../shadowsocks-service/src/net/mon_socket.rs | 4 +- .../shadowsocks-service/src/net/mon_stream.rs | 4 +- .../src/net/packet_window.rs | 8 +- .../shadowsocks-service/src/server/context.rs | 6 +- .../shadowsocks-service/src/server/server.rs | 8 +- .../src/server/tcprelay.rs | 4 +- .../src/server/udprelay.rs | 30 +- .../crates/shadowsocks/src/config.rs | 160 ++++---- .../crates/shadowsocks/src/context.rs | 6 +- .../src/dns_resolver/hickory_dns_resolver.rs | 22 +- .../shadowsocks/src/dns_resolver/resolver.rs | 50 +-- .../crates/shadowsocks/src/manager/client.rs | 4 +- .../shadowsocks/src/manager/datagram.rs | 52 +-- .../crates/shadowsocks/src/manager/error.rs | 2 +- .../shadowsocks/src/manager/listener.rs | 4 +- .../shadowsocks/src/manager/protocol.rs | 44 +-- .../crates/shadowsocks/src/net/mod.rs | 12 +- .../shadowsocks/src/net/sys/unix/linux/mod.rs | 36 +- .../shadowsocks/src/net/sys/unix/uds.rs | 8 +- .../crates/shadowsocks/src/net/tcp.rs | 20 +- .../crates/shadowsocks/src/net/udp.rs | 36 +- .../crates/shadowsocks/src/plugin/mod.rs | 4 +- .../crates/shadowsocks/src/relay/socks5.rs | 216 +++++----- .../shadowsocks/src/relay/tcprelay/aead.rs | 16 +- .../src/relay/tcprelay/aead_2022.rs | 24 +- .../src/relay/tcprelay/crypto_io.rs | 114 +++--- .../src/relay/tcprelay/proxy_listener.rs | 12 +- .../src/relay/tcprelay/proxy_stream/client.rs | 20 +- .../tcprelay/proxy_stream/protocol/mod.rs | 26 +- .../tcprelay/proxy_stream/protocol/v1.rs | 4 +- .../tcprelay/proxy_stream/protocol/v2.rs | 4 +- .../src/relay/tcprelay/proxy_stream/server.rs | 8 +- .../shadowsocks/src/relay/tcprelay/stream.rs | 14 +- .../src/relay/udprelay/aead_2022.rs | 4 +- .../shadowsocks/src/relay/udprelay/compat.rs | 8 +- .../src/relay/udprelay/proxy_socket.rs | 24 +- .../shadowsocks/src/security/replay/mod.rs | 4 +- .../src/security/replay/ppbloom.rs | 4 +- shadowsocks-rust/src/config.rs | 18 +- shadowsocks-rust/src/service/local.rs | 8 +- shadowsocks-rust/tests/socks4.rs | 4 +- shadowsocks-rust/tests/socks5.rs | 4 +- small/mihomo/Makefile | 4 +- .../com/v2ray/ang/handler/SettingsManager.kt | 2 +- .../app/src/main/res/xml/pref_settings.xml | 2 +- v2rayng/V2rayNG/gradle/libs.versions.toml | 6 +- v2rayu/V2rayU/AppDelegate.swift | 10 + v2rayu/V2rayU/Share.swift | 34 +- v2rayu/V2rayU/Uri.swift | 128 +++++- v2rayu/V2rayU/V2rayLaunch.swift | 40 ++ xray-core/README.md | 3 +- xray-core/core/core.go | 4 +- xray-core/go.mod | 2 +- xray-core/go.sum | 4 +- xray-core/infra/conf/transport_internet.go | 70 +++- xray-core/infra/conf/transport_test.go | 31 +- xray-core/infra/conf/xray.go | 4 +- xray-core/testing/scenarios/command_test.go | 8 +- xray-core/transport/internet/config.pb.go | 231 +++++++---- xray-core/transport/internet/config.proto | 9 + xray-core/transport/internet/dialer.go | 4 +- .../transport/internet/happy_eyeballs.go | 171 ++++++++ yt-dlp/README.md | 2 +- .../test/test_pot/test_pot_builtin_utils.py | 2 +- .../test_pot/test_pot_builtin_webpospec.py | 2 +- yt-dlp/yt_dlp/extractor/mitele.py | 14 +- yt-dlp/yt_dlp/extractor/stacommu.py | 13 +- yt-dlp/yt_dlp/extractor/telecinco.py | 13 +- yt-dlp/yt_dlp/extractor/youtube/_base.py | 9 + yt-dlp/yt_dlp/extractor/youtube/_video.py | 2 +- yt-dlp/yt_dlp/extractor/youtube/pot/utils.py | 1 + 181 files changed, 2047 insertions(+), 4156 deletions(-) delete mode 100644 lede/target/linux/sunxi/arm926ejs/config-6.1 delete mode 100644 lede/target/linux/sunxi/arm926ejs/target.mk rename lede/target/linux/sunxi/{config-6.1 => config-6.12} (98%) rename lede/target/linux/sunxi/cortexa53/{config-6.1 => config-6.12} (95%) rename lede/target/linux/sunxi/cortexa7/{config-6.1 => config-6.12} (81%) rename lede/target/linux/sunxi/cortexa8/{config-6.1 => config-6.12} (88%) delete mode 100644 lede/target/linux/sunxi/image/arm926ejs.mk delete mode 100644 lede/target/linux/sunxi/patches-6.1/001-v6.2-dt-bindings-usb-Add-H616-compatible-string.patch delete mode 100644 lede/target/linux/sunxi/patches-6.1/002-v6.2-dt-bindings-phy-Add-special-clock-for-Allwinner-H616-PHY.patch delete mode 100644 lede/target/linux/sunxi/patches-6.1/003-v6.2-arm64-dts-allwinner-h616-Add-USB-nodes.patch delete mode 100644 lede/target/linux/sunxi/patches-6.1/004-v6.2-arm64-dts-allwinner-h616-OrangePi-Zero-2-Add-USB-nodes.patch delete mode 100644 lede/target/linux/sunxi/patches-6.1/005-v6.6-arm64-dts-allwinner-h616-Split-Orange-Pi-Zero-2-DT.patch delete mode 100644 lede/target/linux/sunxi/patches-6.1/006-v6.6-arm64-dts-allwinner-h616-Add-OrangePi-Zero-3-board.patch delete mode 100644 lede/target/linux/sunxi/patches-6.1/007-v6.7-arm64-dts-allwinner-h616-update-emac-for-Orange-Pi.patch delete mode 100644 lede/target/linux/sunxi/patches-6.1/008-v6.7-arm64-dts-allwinner-h616-Add-SID-controller-node.patch delete mode 100644 lede/target/linux/sunxi/patches-6.1/009-v6.9-soc-sunxi-sram-export-register-0-for-THS-on-H616.patch delete mode 100644 lede/target/linux/sunxi/patches-6.1/010-v6.8-thermal-drivers-sun8i-Add-D1-T113s-THS-controller-support.patch delete mode 100644 lede/target/linux/sunxi/patches-6.1/011-v6.9-thermal-drivers-sun8i-Explain-unknown-H6-register-value.patch delete mode 100644 lede/target/linux/sunxi/patches-6.1/012-v6.9-thermal-drivers-sun8i-Extend-H6-calibration-to-support-4.patch delete mode 100644 lede/target/linux/sunxi/patches-6.1/013-v6.9-thermal-drivers-sun8i-Add-SRAM-register-access-code.patch delete mode 100644 lede/target/linux/sunxi/patches-6.1/014-v6.9-thermal-drivers-sun8i-Add-support-for-H616-THS-controller.patch delete mode 100644 lede/target/linux/sunxi/patches-6.1/015-v6.9-thermal-drivers-sun8i-Dont-fail-probe-due-to-zone-registra.patch delete mode 100644 lede/target/linux/sunxi/patches-6.1/016-v6.9-arm64-dts-allwinner-h616-Add-thermal-sensor-and-zones.patch delete mode 100644 lede/target/linux/sunxi/patches-6.1/017-v6.10-firmware-smccc-Export-revision-soc_id-function.patch delete mode 100644 lede/target/linux/sunxi/patches-6.1/018-v6.10-cpufreq-dt-platdev-Blocklist-Allwinner-H616-618-SoCs.patch delete mode 100644 lede/target/linux/sunxi/patches-6.1/019-v6.10-cpufreq-sun50i-Refactor-speed-bin-decoding.patch delete mode 100644 lede/target/linux/sunxi/patches-6.1/020-v6.10-cpufreq-sun50i-Add-support-for-opp_supported_hw.patch delete mode 100644 lede/target/linux/sunxi/patches-6.1/021-v6.10-cpufreq-sun50i-Add-H616-support.patch delete mode 100644 lede/target/linux/sunxi/patches-6.1/022-v6.10-arm64-dts-allwinner-h616-Add-CPU-OPPs-table.patch delete mode 100644 lede/target/linux/sunxi/patches-6.1/023-v6.10-arm64-dts-allwinner-h616-enable-DVFS-for-all-boards.patch delete mode 100644 lede/target/linux/sunxi/patches-6.1/024-v6.10-cpufreq-sun50i-Fix-build-warning-around-snprint.patch delete mode 100644 lede/target/linux/sunxi/patches-6.1/025-v6.10-cpufreq-sun50i-fix-error-returns-in-dt_has_supported_hw.patch delete mode 100644 lede/target/linux/sunxi/patches-6.1/101-sunxi-add-get_soc_chipid-and-sunxi_get_serial.patch delete mode 100644 lede/target/linux/sunxi/patches-6.1/460-ARM-dts-suniv-add-USB-related-device-nodes.patch delete mode 100644 lede/target/linux/sunxi/patches-6.1/461-ARM-dts-suniv-add-device-tree-for-PopStick-v1_1.patch delete mode 100644 lede/target/linux/sunxi/patches-6.1/462-ARM-dts-suniv-licheepi-nano-enable-USB.patch delete mode 100644 lede/target/linux/sunxi/patches-6.1/463-f1c100s-sram-driver.patch delete mode 100644 lede/target/linux/sunxi/patches-6.1/464-f1c100s-watchdog-compat.patch rename lede/target/linux/sunxi/{patches-6.1 => patches-6.12}/102-sunxi-add-OF-node-for-USB-eth-on-NanoPi-R1S-H5.patch (100%) rename lede/target/linux/sunxi/{patches-6.1 => patches-6.12}/301-orangepi_pc2_usb_otg_to_host_key_power.patch (90%) rename lede/target/linux/sunxi/{patches-6.1 => patches-6.12}/400-arm64-allwinner-a64-sopine-Add-Sopine-flash-partitio.patch (100%) rename lede/target/linux/sunxi/{patches-6.1 => patches-6.12}/410-sunxi-add-bananapi-p2-zero.patch (95%) rename lede/target/linux/sunxi/{patches-6.1 => patches-6.12}/430-arm64-dts-allwinner-a64-olinuxino-add-status-LED-ali.patch (100%) create mode 100644 lede/target/linux/sunxi/patches-6.12/431-arm64-dts-allwinner-nanopi-r1s-h5-add-status-LED.patch rename lede/target/linux/sunxi/{patches-6.1 => patches-6.12}/440-arm64-dts-allwinner-h616-fix-cpu-max-freq.patch (74%) rename lede/target/linux/sunxi/{patches-6.1 => patches-6.12}/442-arm64-dts-orangepi-one-plus-enable-PWM.patch (100%) rename lede/target/linux/sunxi/{patches-6.1 => patches-6.12}/450-arm64-dts-enable-wifi-on-pine64-boards.patch (100%) create mode 100644 lede/target/linux/sunxi/patches-6.12/451-sunxi-add-csi-video-support-for-nanopi-neo-air.patch create mode 100644 xray-core/transport/internet/happy_eyeballs.go diff --git a/.github/update.log b/.github/update.log index a7d73dc550..a1477d6552 100644 --- a/.github/update.log +++ b/.github/update.log @@ -1021,3 +1021,4 @@ Update On Mon Jun 2 20:41:58 CEST 2025 Update On Tue Jun 3 20:38:26 CEST 2025 Update On Wed Jun 4 20:38:34 CEST 2025 Update On Fri Jun 6 20:37:19 CEST 2025 +Update On Sat Jun 7 20:34:12 CEST 2025 diff --git a/clash-nyanpasu/backend/Cargo.lock b/clash-nyanpasu/backend/Cargo.lock index 35cd942c27..88216c3abf 100644 --- a/clash-nyanpasu/backend/Cargo.lock +++ b/clash-nyanpasu/backend/Cargo.lock @@ -10570,12 +10570,14 @@ checksum = "06abde3611657adf66d383f00b093d7faecc7fa57071cce2578660c9f1010821" [[package]] name = "uuid" -version = "1.16.0" +version = "1.17.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "458f7a779bf54acc9f347480ac654f68407d3aab21269a6e3c9f922acd9e2da9" +checksum = "3cf4199d1e5d15ddd86a694e4d0dffa9c323ce759fea589f00fef9d81cc1931d" dependencies = [ "getrandom 0.3.3", + "js-sys", "serde", + "wasm-bindgen", ] [[package]] diff --git a/clash-nyanpasu/frontend/interface/package.json b/clash-nyanpasu/frontend/interface/package.json index e8d7742903..fa06996d49 100644 --- a/clash-nyanpasu/frontend/interface/package.json +++ b/clash-nyanpasu/frontend/interface/package.json @@ -11,7 +11,7 @@ "build": "tsc" }, "dependencies": { - "@tanstack/react-query": "5.80.5", + "@tanstack/react-query": "5.80.6", "@tauri-apps/api": "2.5.0", "ahooks": "3.8.5", "dayjs": "1.11.13", diff --git a/clash-nyanpasu/frontend/nyanpasu/package.json b/clash-nyanpasu/frontend/nyanpasu/package.json index aad132802c..435dbcc70d 100644 --- a/clash-nyanpasu/frontend/nyanpasu/package.json +++ b/clash-nyanpasu/frontend/nyanpasu/package.json @@ -18,7 +18,7 @@ "@material/material-color-utilities": "0.3.0", "@mui/icons-material": "7.1.1", "@mui/lab": "7.0.0-beta.13", - "@mui/x-date-pickers": "8.5.0", + "@mui/x-date-pickers": "8.5.1", "@mui/material": "7.1.1", "@nyanpasu/interface": "workspace:^", "@nyanpasu/ui": "workspace:^", @@ -57,10 +57,10 @@ "@emotion/react": "11.14.0", "@iconify/json": "2.2.346", "@monaco-editor/react": "4.7.0", - "@tanstack/react-query": "5.80.5", - "@tanstack/react-router": "1.120.15", - "@tanstack/react-router-devtools": "1.120.15", - "@tanstack/router-plugin": "1.120.15", + "@tanstack/react-query": "5.80.6", + "@tanstack/react-router": "1.120.18", + "@tanstack/react-router-devtools": "1.120.18", + "@tanstack/router-plugin": "1.120.18", "@tauri-apps/plugin-clipboard-manager": "2.2.2", "@tauri-apps/plugin-dialog": "2.2.2", "@tauri-apps/plugin-fs": "2.3.0", diff --git a/clash-nyanpasu/manifest/version.json b/clash-nyanpasu/manifest/version.json index 65e3b354f5..932a9d8969 100644 --- a/clash-nyanpasu/manifest/version.json +++ b/clash-nyanpasu/manifest/version.json @@ -2,7 +2,7 @@ "manifest_version": 1, "latest": { "mihomo": "v1.19.10", - "mihomo_alpha": "alpha-40587b6", + "mihomo_alpha": "alpha-939e410", "clash_rs": "v0.7.8", "clash_premium": "2023-09-05-gdcc8d87", "clash_rs_alpha": "0.7.8-alpha+sha.9e09f8c" @@ -69,5 +69,5 @@ "linux-armv7hf": "clash-armv7-unknown-linux-gnueabihf" } }, - "updated_at": "2025-06-05T22:21:11.895Z" + "updated_at": "2025-06-06T22:21:08.996Z" } diff --git a/clash-nyanpasu/package.json b/clash-nyanpasu/package.json index 2805174531..5e294c2efc 100644 --- a/clash-nyanpasu/package.json +++ b/clash-nyanpasu/package.json @@ -65,7 +65,7 @@ "@tauri-apps/cli": "2.5.0", "@types/fs-extra": "11.0.4", "@types/lodash-es": "4.17.12", - "@types/node": "22.15.29", + "@types/node": "22.15.30", "@typescript-eslint/eslint-plugin": "8.33.1", "@typescript-eslint/parser": "8.33.1", "autoprefixer": "10.4.21", @@ -84,7 +84,7 @@ "eslint-plugin-react-compiler": "19.1.0-rc.2", "eslint-plugin-react-hooks": "5.2.0", "globals": "16.2.0", - "knip": "5.60.0", + "knip": "5.60.2", "lint-staged": "16.1.0", "neostandard": "0.12.1", "npm-run-all2": "8.0.4", diff --git a/clash-nyanpasu/pnpm-lock.yaml b/clash-nyanpasu/pnpm-lock.yaml index fb14d9bd0f..833fc2d968 100644 --- a/clash-nyanpasu/pnpm-lock.yaml +++ b/clash-nyanpasu/pnpm-lock.yaml @@ -21,7 +21,7 @@ importers: devDependencies: '@commitlint/cli': specifier: 19.8.1 - version: 19.8.1(@types/node@22.15.29)(typescript@5.8.3) + version: 19.8.1(@types/node@22.15.30)(typescript@5.8.3) '@commitlint/config-conventional': specifier: 19.8.1 version: 19.8.1 @@ -44,8 +44,8 @@ importers: specifier: 4.17.12 version: 4.17.12 '@types/node': - specifier: 22.15.29 - version: 22.15.29 + specifier: 22.15.30 + version: 22.15.30 '@typescript-eslint/eslint-plugin': specifier: 8.33.1 version: 8.33.1(@typescript-eslint/parser@8.33.1(eslint@9.28.0(jiti@2.4.2))(typescript@5.8.3))(eslint@9.28.0(jiti@2.4.2))(typescript@5.8.3) @@ -101,8 +101,8 @@ importers: specifier: 16.2.0 version: 16.2.0 knip: - specifier: 5.60.0 - version: 5.60.0(@types/node@22.15.29)(typescript@5.8.3) + specifier: 5.60.2 + version: 5.60.2(@types/node@22.15.30)(typescript@5.8.3) lint-staged: specifier: 16.1.0 version: 16.1.0 @@ -173,8 +173,8 @@ importers: frontend/interface: dependencies: '@tanstack/react-query': - specifier: 5.80.5 - version: 5.80.5(react@19.1.0) + specifier: 5.80.6 + version: 5.80.6(react@19.1.0) '@tauri-apps/api': specifier: 2.5.0 version: 2.5.0 @@ -234,8 +234,8 @@ importers: specifier: 7.1.1 version: 7.1.1(@emotion/react@11.14.0(@types/react@19.1.6)(react@19.1.0))(@emotion/styled@11.14.0(@emotion/react@11.14.0(@types/react@19.1.6)(react@19.1.0))(@types/react@19.1.6)(react@19.1.0))(@types/react@19.1.6)(react-dom@19.1.0(react@19.1.0))(react@19.1.0) '@mui/x-date-pickers': - specifier: 8.5.0 - version: 8.5.0(@emotion/react@11.14.0(@types/react@19.1.6)(react@19.1.0))(@emotion/styled@11.14.0(@emotion/react@11.14.0(@types/react@19.1.6)(react@19.1.0))(@types/react@19.1.6)(react@19.1.0))(@mui/material@7.1.1(@emotion/react@11.14.0(@types/react@19.1.6)(react@19.1.0))(@emotion/styled@11.14.0(@emotion/react@11.14.0(@types/react@19.1.6)(react@19.1.0))(@types/react@19.1.6)(react@19.1.0))(@types/react@19.1.6)(react-dom@19.1.0(react@19.1.0))(react@19.1.0))(@mui/system@7.1.1(@emotion/react@11.14.0(@types/react@19.1.6)(react@19.1.0))(@emotion/styled@11.14.0(@emotion/react@11.14.0(@types/react@19.1.6)(react@19.1.0))(@types/react@19.1.6)(react@19.1.0))(@types/react@19.1.6)(react@19.1.0))(@types/react@19.1.6)(dayjs@1.11.13)(react-dom@19.1.0(react@19.1.0))(react@19.1.0) + specifier: 8.5.1 + version: 8.5.1(@emotion/react@11.14.0(@types/react@19.1.6)(react@19.1.0))(@emotion/styled@11.14.0(@emotion/react@11.14.0(@types/react@19.1.6)(react@19.1.0))(@types/react@19.1.6)(react@19.1.0))(@mui/material@7.1.1(@emotion/react@11.14.0(@types/react@19.1.6)(react@19.1.0))(@emotion/styled@11.14.0(@emotion/react@11.14.0(@types/react@19.1.6)(react@19.1.0))(@types/react@19.1.6)(react@19.1.0))(@types/react@19.1.6)(react-dom@19.1.0(react@19.1.0))(react@19.1.0))(@mui/system@7.1.1(@emotion/react@11.14.0(@types/react@19.1.6)(react@19.1.0))(@emotion/styled@11.14.0(@emotion/react@11.14.0(@types/react@19.1.6)(react@19.1.0))(@types/react@19.1.6)(react@19.1.0))(@types/react@19.1.6)(react@19.1.0))(@types/react@19.1.6)(dayjs@1.11.13)(react-dom@19.1.0(react@19.1.0))(react@19.1.0) '@nyanpasu/interface': specifier: workspace:^ version: link:../interface @@ -247,7 +247,7 @@ importers: version: 4.1.8 '@tanstack/router-zod-adapter': specifier: 1.81.5 - version: 1.81.5(@tanstack/react-router@1.120.15(react-dom@19.1.0(react@19.1.0))(react@19.1.0))(zod@3.25.51) + version: 1.81.5(@tanstack/react-router@1.120.18(react-dom@19.1.0(react@19.1.0))(react@19.1.0))(zod@3.25.51) '@tauri-apps/api': specifier: 2.5.0 version: 2.5.0 @@ -283,7 +283,7 @@ importers: version: 0.4.0 material-react-table: specifier: npm:@greenhat616/material-react-table@4.0.0 - version: '@greenhat616/material-react-table@4.0.0(b7389f75ebdae8b833bc168978d25e62)' + version: '@greenhat616/material-react-table@4.0.0(f792f3152d47990021a35f343160b990)' monaco-editor: specifier: 0.52.2 version: 0.52.2 @@ -304,7 +304,7 @@ importers: version: 1.6.5(react-dom@19.1.0(react@19.1.0))(react@19.1.0) react-hook-form-mui: specifier: 7.6.1 - version: 7.6.1(5cca61e2899c996b518d738106f3b6cc) + version: 7.6.1(d57264b30a79ce6f9a19367b42c73611) react-i18next: specifier: 15.5.2 version: 15.5.2(i18next@25.2.1(typescript@5.8.3))(react-dom@19.1.0(react@19.1.0))(react@19.1.0)(typescript@5.8.3) @@ -343,17 +343,17 @@ importers: specifier: 4.7.0 version: 4.7.0(monaco-editor@0.52.2)(react-dom@19.1.0(react@19.1.0))(react@19.1.0) '@tanstack/react-query': - specifier: 5.80.5 - version: 5.80.5(react@19.1.0) + specifier: 5.80.6 + version: 5.80.6(react@19.1.0) '@tanstack/react-router': - specifier: 1.120.15 - version: 1.120.15(react-dom@19.1.0(react@19.1.0))(react@19.1.0) + specifier: 1.120.18 + version: 1.120.18(react-dom@19.1.0(react@19.1.0))(react@19.1.0) '@tanstack/react-router-devtools': - specifier: 1.120.15 - version: 1.120.15(@tanstack/react-router@1.120.15(react-dom@19.1.0(react@19.1.0))(react@19.1.0))(@tanstack/router-core@1.120.15)(csstype@3.1.3)(react-dom@19.1.0(react@19.1.0))(react@19.1.0)(tiny-invariant@1.3.3) + specifier: 1.120.18 + version: 1.120.18(@tanstack/react-router@1.120.18(react-dom@19.1.0(react@19.1.0))(react@19.1.0))(@tanstack/router-core@1.120.17)(csstype@3.1.3)(react-dom@19.1.0(react@19.1.0))(react@19.1.0)(tiny-invariant@1.3.3) '@tanstack/router-plugin': - specifier: 1.120.15 - version: 1.120.15(@tanstack/react-router@1.120.15(react-dom@19.1.0(react@19.1.0))(react@19.1.0))(vite@6.3.5(@types/node@22.15.29)(jiti@2.4.2)(less@4.2.0)(lightningcss@1.30.1)(sass-embedded@1.88.0)(sass@1.83.0)(stylus@0.62.0)(terser@5.36.0)(tsx@4.19.4)(yaml@2.8.0)) + specifier: 1.120.18 + version: 1.120.18(@tanstack/react-router@1.120.18(react-dom@19.1.0(react@19.1.0))(react@19.1.0))(vite@6.3.5(@types/node@22.15.30)(jiti@2.4.2)(less@4.2.0)(lightningcss@1.30.1)(sass-embedded@1.88.0)(sass@1.83.0)(stylus@0.62.0)(terser@5.36.0)(tsx@4.19.4)(yaml@2.8.0)) '@tauri-apps/plugin-clipboard-manager': specifier: 2.2.2 version: 2.2.2 @@ -389,13 +389,13 @@ importers: version: 13.15.1 '@vitejs/plugin-legacy': specifier: 6.1.1 - version: 6.1.1(terser@5.36.0)(vite@6.3.5(@types/node@22.15.29)(jiti@2.4.2)(less@4.2.0)(lightningcss@1.30.1)(sass-embedded@1.88.0)(sass@1.83.0)(stylus@0.62.0)(terser@5.36.0)(tsx@4.19.4)(yaml@2.8.0)) + version: 6.1.1(terser@5.36.0)(vite@6.3.5(@types/node@22.15.30)(jiti@2.4.2)(less@4.2.0)(lightningcss@1.30.1)(sass-embedded@1.88.0)(sass@1.83.0)(stylus@0.62.0)(terser@5.36.0)(tsx@4.19.4)(yaml@2.8.0)) '@vitejs/plugin-react': specifier: 4.5.1 - version: 4.5.1(vite@6.3.5(@types/node@22.15.29)(jiti@2.4.2)(less@4.2.0)(lightningcss@1.30.1)(sass-embedded@1.88.0)(sass@1.83.0)(stylus@0.62.0)(terser@5.36.0)(tsx@4.19.4)(yaml@2.8.0)) + version: 4.5.1(vite@6.3.5(@types/node@22.15.30)(jiti@2.4.2)(less@4.2.0)(lightningcss@1.30.1)(sass-embedded@1.88.0)(sass@1.83.0)(stylus@0.62.0)(terser@5.36.0)(tsx@4.19.4)(yaml@2.8.0)) '@vitejs/plugin-react-swc': specifier: 3.10.1 - version: 3.10.1(vite@6.3.5(@types/node@22.15.29)(jiti@2.4.2)(less@4.2.0)(lightningcss@1.30.1)(sass-embedded@1.88.0)(sass@1.83.0)(stylus@0.62.0)(terser@5.36.0)(tsx@4.19.4)(yaml@2.8.0)) + version: 3.10.1(vite@6.3.5(@types/node@22.15.30)(jiti@2.4.2)(less@4.2.0)(lightningcss@1.30.1)(sass-embedded@1.88.0)(sass@1.83.0)(stylus@0.62.0)(terser@5.36.0)(tsx@4.19.4)(yaml@2.8.0)) change-case: specifier: 5.4.4 version: 5.4.4 @@ -434,19 +434,19 @@ importers: version: 13.15.15 vite: specifier: 6.3.5 - version: 6.3.5(@types/node@22.15.29)(jiti@2.4.2)(less@4.2.0)(lightningcss@1.30.1)(sass-embedded@1.88.0)(sass@1.83.0)(stylus@0.62.0)(terser@5.36.0)(tsx@4.19.4)(yaml@2.8.0) + version: 6.3.5(@types/node@22.15.30)(jiti@2.4.2)(less@4.2.0)(lightningcss@1.30.1)(sass-embedded@1.88.0)(sass@1.83.0)(stylus@0.62.0)(terser@5.36.0)(tsx@4.19.4)(yaml@2.8.0) vite-plugin-html: specifier: 3.2.2 - version: 3.2.2(vite@6.3.5(@types/node@22.15.29)(jiti@2.4.2)(less@4.2.0)(lightningcss@1.30.1)(sass-embedded@1.88.0)(sass@1.83.0)(stylus@0.62.0)(terser@5.36.0)(tsx@4.19.4)(yaml@2.8.0)) + version: 3.2.2(vite@6.3.5(@types/node@22.15.30)(jiti@2.4.2)(less@4.2.0)(lightningcss@1.30.1)(sass-embedded@1.88.0)(sass@1.83.0)(stylus@0.62.0)(terser@5.36.0)(tsx@4.19.4)(yaml@2.8.0)) vite-plugin-sass-dts: specifier: 1.3.31 - version: 1.3.31(postcss@8.5.4)(prettier@3.5.3)(sass-embedded@1.88.0)(vite@6.3.5(@types/node@22.15.29)(jiti@2.4.2)(less@4.2.0)(lightningcss@1.30.1)(sass-embedded@1.88.0)(sass@1.83.0)(stylus@0.62.0)(terser@5.36.0)(tsx@4.19.4)(yaml@2.8.0)) + version: 1.3.31(postcss@8.5.4)(prettier@3.5.3)(sass-embedded@1.88.0)(vite@6.3.5(@types/node@22.15.30)(jiti@2.4.2)(less@4.2.0)(lightningcss@1.30.1)(sass-embedded@1.88.0)(sass@1.83.0)(stylus@0.62.0)(terser@5.36.0)(tsx@4.19.4)(yaml@2.8.0)) vite-plugin-svgr: specifier: 4.3.0 - version: 4.3.0(rollup@4.40.0)(typescript@5.8.3)(vite@6.3.5(@types/node@22.15.29)(jiti@2.4.2)(less@4.2.0)(lightningcss@1.30.1)(sass-embedded@1.88.0)(sass@1.83.0)(stylus@0.62.0)(terser@5.36.0)(tsx@4.19.4)(yaml@2.8.0)) + version: 4.3.0(rollup@4.40.0)(typescript@5.8.3)(vite@6.3.5(@types/node@22.15.30)(jiti@2.4.2)(less@4.2.0)(lightningcss@1.30.1)(sass-embedded@1.88.0)(sass@1.83.0)(stylus@0.62.0)(terser@5.36.0)(tsx@4.19.4)(yaml@2.8.0)) vite-tsconfig-paths: specifier: 5.1.4 - version: 5.1.4(typescript@5.8.3)(vite@6.3.5(@types/node@22.15.29)(jiti@2.4.2)(less@4.2.0)(lightningcss@1.30.1)(sass-embedded@1.88.0)(sass@1.83.0)(stylus@0.62.0)(terser@5.36.0)(tsx@4.19.4)(yaml@2.8.0)) + version: 5.1.4(typescript@5.8.3)(vite@6.3.5(@types/node@22.15.30)(jiti@2.4.2)(less@4.2.0)(lightningcss@1.30.1)(sass-embedded@1.88.0)(sass@1.83.0)(stylus@0.62.0)(terser@5.36.0)(tsx@4.19.4)(yaml@2.8.0)) zod: specifier: 3.25.51 version: 3.25.51 @@ -482,7 +482,7 @@ importers: version: 19.1.6 '@vitejs/plugin-react': specifier: 4.5.1 - version: 4.5.1(vite@6.3.5(@types/node@22.15.29)(jiti@2.4.2)(less@4.2.0)(lightningcss@1.30.1)(sass-embedded@1.88.0)(sass@1.83.0)(stylus@0.62.0)(terser@5.36.0)(tsx@4.19.4)(yaml@2.8.0)) + version: 4.5.1(vite@6.3.5(@types/node@22.15.30)(jiti@2.4.2)(less@4.2.0)(lightningcss@1.30.1)(sass-embedded@1.88.0)(sass@1.83.0)(stylus@0.62.0)(terser@5.36.0)(tsx@4.19.4)(yaml@2.8.0)) ahooks: specifier: 3.8.5 version: 3.8.5(react@19.1.0) @@ -512,10 +512,10 @@ importers: version: 4.1.8 vite: specifier: 6.3.5 - version: 6.3.5(@types/node@22.15.29)(jiti@2.4.2)(less@4.2.0)(lightningcss@1.30.1)(sass-embedded@1.88.0)(sass@1.83.0)(stylus@0.62.0)(terser@5.36.0)(tsx@4.19.4)(yaml@2.8.0) + version: 6.3.5(@types/node@22.15.30)(jiti@2.4.2)(less@4.2.0)(lightningcss@1.30.1)(sass-embedded@1.88.0)(sass@1.83.0)(stylus@0.62.0)(terser@5.36.0)(tsx@4.19.4)(yaml@2.8.0) vite-tsconfig-paths: specifier: 5.1.4 - version: 5.1.4(typescript@5.8.3)(vite@6.3.5(@types/node@22.15.29)(jiti@2.4.2)(less@4.2.0)(lightningcss@1.30.1)(sass-embedded@1.88.0)(sass@1.83.0)(stylus@0.62.0)(terser@5.36.0)(tsx@4.19.4)(yaml@2.8.0)) + version: 5.1.4(typescript@5.8.3)(vite@6.3.5(@types/node@22.15.30)(jiti@2.4.2)(less@4.2.0)(lightningcss@1.30.1)(sass-embedded@1.88.0)(sass@1.83.0)(stylus@0.62.0)(terser@5.36.0)(tsx@4.19.4)(yaml@2.8.0)) devDependencies: '@emotion/react': specifier: 11.14.0 @@ -540,7 +540,7 @@ importers: version: 5.1.0(typescript@5.8.3) vite-plugin-dts: specifier: 4.5.4 - version: 4.5.4(@types/node@22.15.29)(rollup@4.40.0)(typescript@5.8.3)(vite@6.3.5(@types/node@22.15.29)(jiti@2.4.2)(less@4.2.0)(lightningcss@1.30.1)(sass-embedded@1.88.0)(sass@1.83.0)(stylus@0.62.0)(terser@5.36.0)(tsx@4.19.4)(yaml@2.8.0)) + version: 4.5.4(@types/node@22.15.30)(rollup@4.40.0)(typescript@5.8.3)(vite@6.3.5(@types/node@22.15.30)(jiti@2.4.2)(less@4.2.0)(lightningcss@1.30.1)(sass-embedded@1.88.0)(sass@1.83.0)(stylus@0.62.0)(terser@5.36.0)(tsx@4.19.4)(yaml@2.8.0)) scripts: dependencies: @@ -1172,6 +1172,10 @@ packages: resolution: {integrity: sha512-1x3D2xEk2fRo3PAhwQwu5UubzgiVWSXTBfWpVd2Mx2AzRqJuDJCsgaDVZ7HB5iGzDW1Hl1sWN2mFyKjmR9uAog==} engines: {node: '>=6.9.0'} + '@babel/runtime@7.27.6': + resolution: {integrity: sha512-vbavdySgbTTrmFE+EsiqUTzlOr5bzlnJtUv9PynGCAKvfQqjIXbvFdumPM/GxMDfyuGMJaJAU6TO4zc1Jf1i8Q==} + engines: {node: '>=6.9.0'} + '@babel/template@7.27.0': resolution: {integrity: sha512-2ncevenBqXI6qRMukPlXwHKHchC7RyMuu4xv5JBXRfOGVcTy1mXCD12qrp7Jsoxll1EV3+9sE4GugBVRjT2jFA==} engines: {node: '>=6.9.0'} @@ -1812,14 +1816,6 @@ packages: '@types/react': optional: true - '@mui/types@7.4.2': - resolution: {integrity: sha512-edRc5JcLPsrlNFYyTPxds+d5oUovuUxnnDtpJUbP6WMeV4+6eaX/mqai1ZIWT62lCOe0nlrON0s9HDiv5en5bA==} - peerDependencies: - '@types/react': ^17.0.0 || ^18.0.0 || ^19.0.0 - peerDependenciesMeta: - '@types/react': - optional: true - '@mui/types@7.4.3': resolution: {integrity: sha512-2UCEiK29vtiZTeLdS2d4GndBKacVyxGvReznGXGr+CzW/YhjIX+OHUdCIczZjzcRAgKBGmE9zCIgoV9FleuyRQ==} peerDependencies: @@ -1828,16 +1824,6 @@ packages: '@types/react': optional: true - '@mui/utils@7.1.0': - resolution: {integrity: sha512-/OM3S8kSHHmWNOP+NH9xEtpYSG10upXeQ0wLZnfDgmgadTAk5F4MQfFLyZ5FCRJENB3eRzltMmaNl6UtDnPovw==} - engines: {node: '>=14.0.0'} - peerDependencies: - '@types/react': ^17.0.0 || ^18.0.0 || ^19.0.0 - react: ^17.0.0 || ^18.0.0 || ^19.0.0 - peerDependenciesMeta: - '@types/react': - optional: true - '@mui/utils@7.1.1': resolution: {integrity: sha512-BkOt2q7MBYl7pweY2JWwfrlahhp+uGLR8S+EhiyRaofeRYUWL2YKbSGQvN4hgSN1i8poN0PaUiii1kEMrchvzg==} engines: {node: '>=14.0.0'} @@ -1848,8 +1834,8 @@ packages: '@types/react': optional: true - '@mui/x-date-pickers@8.5.0': - resolution: {integrity: sha512-pnivJhAopuu6C4uWbEEg7b8kDdPc7Ad0ANrlDzx4qZGUj9vFcc6n+hT7/kOFnn9uceszQmb07e3Ud+g/d8Z4vg==} + '@mui/x-date-pickers@8.5.1': + resolution: {integrity: sha512-sZXL7FhOcWvlSZTjffEwUs6aOJlGu7gAGUpaaQHWlOK6eTQyTKlQEVRy7CJdk1SBO9K6T5tmSMAI6hKBDforDQ==} engines: {node: '>=14.0.0'} peerDependencies: '@emotion/react': ^11.9.0 @@ -1885,8 +1871,8 @@ packages: moment-jalaali: optional: true - '@mui/x-internals@8.5.0': - resolution: {integrity: sha512-Ef4KJij1pBGk6/xILyVZHf76tcuRpJIX30k4Ghklsd5QJujZ9ENCGAjvd7aWRAFAs5p3ffn0H8UDESoIcroj1Q==} + '@mui/x-internals@8.5.1': + resolution: {integrity: sha512-7rAWK7SB6FxEIXKgsHsJjIzeeKOLxFJ16gePgZVWlvyew+xDb4P0fgjwW3ThcJjgvkUm0UhGGfLh/JP8l514IA==} engines: {node: '>=14.0.0'} peerDependencies: '@mui/system': ^5.15.14 || ^6.0.0 || ^7.0.0 @@ -2746,32 +2732,32 @@ packages: '@tailwindcss/postcss@4.1.8': resolution: {integrity: sha512-vB/vlf7rIky+w94aWMw34bWW1ka6g6C3xIOdICKX2GC0VcLtL6fhlLiafF0DVIwa9V6EHz8kbWMkS2s2QvvNlw==} - '@tanstack/history@1.115.0': - resolution: {integrity: sha512-K7JJNrRVvyjAVnbXOH2XLRhFXDkeP54Kt2P4FR1Kl2KDGlIbkua5VqZQD2rot3qaDrpufyUa63nuLai1kOLTsQ==} + '@tanstack/history@1.120.17': + resolution: {integrity: sha512-k07LFI4Qo074IIaWzT/XjD0KlkGx2w1V3fnNtclKx0oAl8z4O9kCh6za+FPEIRe98xLgNFEiddDbJeAYGSlPtw==} engines: {node: '>=12'} '@tanstack/match-sorter-utils@8.19.4': resolution: {integrity: sha512-Wo1iKt2b9OT7d+YGhvEPD3DXvPv2etTusIMhMUoG7fbhmxcXCtIjJDEygy91Y2JFlwGyjqiBPRozme7UD8hoqg==} engines: {node: '>=12'} - '@tanstack/query-core@5.80.5': - resolution: {integrity: sha512-kFWXdQOUcjL/Ugk3GrI9eMuG3DsKBGaLIgyOLekR2UOrRrJgkLgPUNzZ10i8FCkfi4SgLABhOtQhx1HjoB9EZQ==} + '@tanstack/query-core@5.80.6': + resolution: {integrity: sha512-nl7YxT/TAU+VTf+e2zTkObGTyY8YZBMnbgeA1ee66lIVqzKlYursAII6z5t0e6rXgwUMJSV4dshBTNacNpZHbQ==} - '@tanstack/react-query@5.80.5': - resolution: {integrity: sha512-C0d+pvIahk6fJK5bXxyf36r9Ft6R9O0mwl781CjBrYGRJc76XRJcKhkVpxIo68cjMy3i47gd4O1EGooAke/OCQ==} + '@tanstack/react-query@5.80.6': + resolution: {integrity: sha512-izX+5CnkpON3NQGcEm3/d7LfFQNo9ZpFtX2QsINgCYK9LT2VCIdi8D3bMaMSNhrAJCznRoAkFic76uvLroALBw==} peerDependencies: react: ^18 || ^19 - '@tanstack/react-router-devtools@1.120.15': - resolution: {integrity: sha512-5KcUXc3fkiLo/6Y56gOM3JqmYXG1ElIH2iyUWuG5IlcegLrpXhu4OBQ+8Q4+62CD0OKy0ifUDyemrCOAEOfCvw==} + '@tanstack/react-router-devtools@1.120.18': + resolution: {integrity: sha512-iYz1jp2AJG0a+FiyxKqpg44RM9KiVzChD57RsZTQylbwjPBF+dpP1GHhSwKPS99JgA10VhsB2moo3wc7wAsmvg==} engines: {node: '>=12'} peerDependencies: - '@tanstack/react-router': ^1.120.15 + '@tanstack/react-router': ^1.120.18 react: '>=18.0.0 || >=19.0.0' react-dom: '>=18.0.0 || >=19.0.0' - '@tanstack/react-router@1.120.15': - resolution: {integrity: sha512-apzBmXh4pHwqUGU3kD8y2FJMi7rVoUbRxh5oV7v8kEb6Aq5Xpdo+OcpThw8h/M2zv7v4Ef8IoY6WFCKKu3HBjQ==} + '@tanstack/react-router@1.120.18': + resolution: {integrity: sha512-VXEP4L7We0XGKv1zRmttTbjPZfDXma6y9IV5Jo2yTrz4V4mhL4cPb7Do+shgW08dW16nJ0Yiy7VlxFd5P8LLeA==} engines: {node: '>=12'} peerDependencies: react: '>=18.0.0 || >=19.0.0' @@ -2796,15 +2782,15 @@ packages: react: ^16.8.0 || ^17.0.0 || ^18.0.0 || ^19.0.0 react-dom: ^16.8.0 || ^17.0.0 || ^18.0.0 || ^19.0.0 - '@tanstack/router-core@1.120.15': - resolution: {integrity: sha512-soLj+mEuvSxAVFK/3b85IowkkvmSuQL6J0RSIyKJFGFgy0CmUzpcBGEO99+JNWvvvzHgIoY4F4KtLIN+rvFSFA==} + '@tanstack/router-core@1.120.17': + resolution: {integrity: sha512-AqNr/rJKua/q/BFcUJTFH1YNUWcLF7dzsRVlN+EdRyvGT4Vpz0wip2wroO5N/9A3463NIuLSacjiZI9UKO/4XQ==} engines: {node: '>=12'} - '@tanstack/router-devtools-core@1.120.15': - resolution: {integrity: sha512-AT9obPHKpJqnHMbwshozSy6sApg5LchiAll3blpS3MMDybUCidYHrdhe9MZJLmlC99IQiEGmuZERP3VRcuPNHg==} + '@tanstack/router-devtools-core@1.120.17': + resolution: {integrity: sha512-Ci2OV/hecsKy/ZXqK3gLS/h1Qg7OEl2Gy9c76iSYWIzroQ9nhKgsQ+qj+LxucImztWujNINXf23wkq5fVlR0EQ==} engines: {node: '>=12'} peerDependencies: - '@tanstack/router-core': ^1.120.15 + '@tanstack/router-core': ^1.120.17 csstype: ^3.0.10 solid-js: '>=1.9.5' tiny-invariant: ^1.3.3 @@ -2812,21 +2798,21 @@ packages: csstype: optional: true - '@tanstack/router-generator@1.120.15': - resolution: {integrity: sha512-QwZ0rNXxzgOEUDRRAEWVjofKxuxSMIYEdYC3z20k6a7jkLC6pnlCORFx41Vf4xVCO6eElqlrUKXWLTleYSsvQw==} + '@tanstack/router-generator@1.120.18': + resolution: {integrity: sha512-q6qQNy18LxI7mInIt2mZ9m9ptCHN0scOSJbFc5OTlS1AyIecr53nfMhtbwLMx4Qo4v1GrQLl/I79OjC/IP8gFA==} engines: {node: '>=12'} peerDependencies: - '@tanstack/react-router': ^1.120.15 + '@tanstack/react-router': ^1.120.18 peerDependenciesMeta: '@tanstack/react-router': optional: true - '@tanstack/router-plugin@1.120.15': - resolution: {integrity: sha512-ARuuPRKO5HzN3V0LzmkIGm0e447t5VCy2ijbUnzd08KjcJm3lG221ViC2qI+vTom1zp6yeNZHfJW1LBh1yLrTw==} + '@tanstack/router-plugin@1.120.18': + resolution: {integrity: sha512-y7dZrQeJ/PbG06diJC59fYPLol5VPeoMcnIk32NzFEOBC/SpGZB/OsAdWtuEjGxEsH4HC59GZDS/LOuWI9pd/g==} engines: {node: '>=12'} peerDependencies: '@rsbuild/core': '>=1.0.2' - '@tanstack/react-router': ^1.120.15 + '@tanstack/react-router': ^1.120.18 vite: '>=5.0.0 || >=6.0.0' vite-plugin-solid: ^2.11.2 webpack: '>=5.92.0' @@ -2842,8 +2828,8 @@ packages: webpack: optional: true - '@tanstack/router-utils@1.115.0': - resolution: {integrity: sha512-Dng4y+uLR9b5zPGg7dHReHOTHQa6x+G6nCoZshsDtWrYsrdCcJEtLyhwZ5wG8OyYS6dVr/Cn+E5Bd2b6BhJ89w==} + '@tanstack/router-utils@1.120.17': + resolution: {integrity: sha512-emgT4FthaGtTRaRg9bsr0uaq3EHdl/flS4bKLuFaetiFTt8wk8EVU2a7EZlkaaAfLLDPaiGbP1S2DDaZQ7ci+Q==} engines: {node: '>=12'} '@tanstack/router-zod-adapter@1.81.5': @@ -2863,8 +2849,8 @@ packages: '@tanstack/virtual-core@3.13.9': resolution: {integrity: sha512-3jztt0jpaoJO5TARe2WIHC1UQC3VMLAFUW5mmMo0yrkwtDB2AQP0+sh10BVUpWrnvHjSLvzFizydtEGLCJKFoQ==} - '@tanstack/virtual-file-routes@1.115.0': - resolution: {integrity: sha512-XLUh1Py3AftcERrxkxC5Y5m5mfllRH3YR6YVlyjFgI2Tc2Ssy2NKmQFQIafoxfW459UJ8Dn81nWKETEIJifE4g==} + '@tanstack/virtual-file-routes@1.120.17': + resolution: {integrity: sha512-Ssi+yKcjG9ru02ieCpUBF7QQBEKGB7WQS1R9va3GHu+Oq9WjzmJ4rifzdugjTeKD3yfT7d1I+pOxRhoWog6CHw==} engines: {node: '>=12'} '@taplo/core@0.2.0': @@ -3163,11 +3149,8 @@ packages: '@types/node@16.18.108': resolution: {integrity: sha512-fj42LD82fSv6yN9C6Q4dzS+hujHj+pTv0IpRR3kI20fnYeS0ytBpjFO9OjmDowSPPt4lNKN46JLaKbCyP+BW2A==} - '@types/node@22.15.29': - resolution: {integrity: sha512-LNdjOkUDlU1RZb8e1kOIUpN1qQUlzGkEtbVNo53vbrwDg5om6oduhm4SiUaPW5ASTXhAiP0jInWG8Qx9fVlOeQ==} - - '@types/node@22.15.3': - resolution: {integrity: sha512-lX7HFZeHf4QG/J7tBZqrCAXwz9J5RD56Y6MpP0eJkka8p+K0RY/yBTW7CYFJ4VGCclxqOLKmiGP5juQc6MKgcw==} + '@types/node@22.15.30': + resolution: {integrity: sha512-6Q7lr06bEHdlfplU6YRbgG1SFBdlsfNC4/lX+SkhiTs0cpJkOElmWls8PxDFv4yY/xKb8Y6SO0OmSX4wgqTZbA==} '@types/parse-json@4.0.2': resolution: {integrity: sha512-dISoDXWWQwUquiKsyZ4Ng+HX2KsPL7LyHKHQwgGFEA3IaKac4Obd+h2a/a6waisAoepJlBcx9paWqjA8/HVjCw==} @@ -5658,8 +5641,8 @@ packages: resolution: {integrity: sha512-dcS1ul+9tmeD95T+x28/ehLgd9mENa3LsvDTtzm3vyBEO7RPptvAD+t44WVXaUjTBRcrpFeFlC8WCruUR456hw==} engines: {node: '>=0.10.0'} - knip@5.60.0: - resolution: {integrity: sha512-r6oIbaV0Ztz/7DKe1voxg2O5IRhLi9Q0GjhplfRqUZ1gvTChew6ywmLzehuaXIHVKkPs8LF5UKOxFlc93RKzow==} + knip@5.60.2: + resolution: {integrity: sha512-TsYqEsoL3802RmhGL5MN7RLI6/03kocMYx/4BpMmwo3dSwEJxmzV7HqRxMVZr6c1llbd25+MqjgA86bv1IwsPA==} engines: {node: '>=18.18.0'} hasBin: true peerDependencies: @@ -8920,6 +8903,8 @@ snapshots: '@babel/runtime@7.27.1': {} + '@babel/runtime@7.27.6': {} + '@babel/template@7.27.0': dependencies: '@babel/code-frame': 7.26.2 @@ -8984,11 +8969,11 @@ snapshots: '@bufbuild/protobuf@2.2.3': {} - '@commitlint/cli@19.8.1(@types/node@22.15.29)(typescript@5.8.3)': + '@commitlint/cli@19.8.1(@types/node@22.15.30)(typescript@5.8.3)': dependencies: '@commitlint/format': 19.8.1 '@commitlint/lint': 19.8.1 - '@commitlint/load': 19.8.1(@types/node@22.15.29)(typescript@5.8.3) + '@commitlint/load': 19.8.1(@types/node@22.15.30)(typescript@5.8.3) '@commitlint/read': 19.8.1 '@commitlint/types': 19.8.1 tinyexec: 1.0.1 @@ -9035,7 +9020,7 @@ snapshots: '@commitlint/rules': 19.8.1 '@commitlint/types': 19.8.1 - '@commitlint/load@19.8.1(@types/node@22.15.29)(typescript@5.8.3)': + '@commitlint/load@19.8.1(@types/node@22.15.30)(typescript@5.8.3)': dependencies: '@commitlint/config-validator': 19.8.1 '@commitlint/execute-rule': 19.8.1 @@ -9043,7 +9028,7 @@ snapshots: '@commitlint/types': 19.8.1 chalk: 5.4.1 cosmiconfig: 9.0.0(typescript@5.8.3) - cosmiconfig-typescript-loader: 6.1.0(@types/node@22.15.29)(cosmiconfig@9.0.0(typescript@5.8.3))(typescript@5.8.3) + cosmiconfig-typescript-loader: 6.1.0(@types/node@22.15.30)(cosmiconfig@9.0.0(typescript@5.8.3))(typescript@5.8.3) lodash.isplainobject: 4.0.6 lodash.merge: 4.6.2 lodash.uniq: 4.5.0 @@ -9385,13 +9370,13 @@ snapshots: '@fastify/busboy@2.1.1': {} - '@greenhat616/material-react-table@4.0.0(b7389f75ebdae8b833bc168978d25e62)': + '@greenhat616/material-react-table@4.0.0(f792f3152d47990021a35f343160b990)': dependencies: '@emotion/react': 11.14.0(@types/react@19.1.6)(react@19.1.0) '@emotion/styled': 11.14.0(@emotion/react@11.14.0(@types/react@19.1.6)(react@19.1.0))(@types/react@19.1.6)(react@19.1.0) '@mui/icons-material': 7.1.1(@mui/material@7.1.1(@emotion/react@11.14.0(@types/react@19.1.6)(react@19.1.0))(@emotion/styled@11.14.0(@emotion/react@11.14.0(@types/react@19.1.6)(react@19.1.0))(@types/react@19.1.6)(react@19.1.0))(@types/react@19.1.6)(react-dom@19.1.0(react@19.1.0))(react@19.1.0))(@types/react@19.1.6)(react@19.1.0) '@mui/material': 7.1.1(@emotion/react@11.14.0(@types/react@19.1.6)(react@19.1.0))(@emotion/styled@11.14.0(@emotion/react@11.14.0(@types/react@19.1.6)(react@19.1.0))(@types/react@19.1.6)(react@19.1.0))(@types/react@19.1.6)(react-dom@19.1.0(react@19.1.0))(react@19.1.0) - '@mui/x-date-pickers': 8.5.0(@emotion/react@11.14.0(@types/react@19.1.6)(react@19.1.0))(@emotion/styled@11.14.0(@emotion/react@11.14.0(@types/react@19.1.6)(react@19.1.0))(@types/react@19.1.6)(react@19.1.0))(@mui/material@7.1.1(@emotion/react@11.14.0(@types/react@19.1.6)(react@19.1.0))(@emotion/styled@11.14.0(@emotion/react@11.14.0(@types/react@19.1.6)(react@19.1.0))(@types/react@19.1.6)(react@19.1.0))(@types/react@19.1.6)(react-dom@19.1.0(react@19.1.0))(react@19.1.0))(@mui/system@7.1.1(@emotion/react@11.14.0(@types/react@19.1.6)(react@19.1.0))(@emotion/styled@11.14.0(@emotion/react@11.14.0(@types/react@19.1.6)(react@19.1.0))(@types/react@19.1.6)(react@19.1.0))(@types/react@19.1.6)(react@19.1.0))(@types/react@19.1.6)(dayjs@1.11.13)(react-dom@19.1.0(react@19.1.0))(react@19.1.0) + '@mui/x-date-pickers': 8.5.1(@emotion/react@11.14.0(@types/react@19.1.6)(react@19.1.0))(@emotion/styled@11.14.0(@emotion/react@11.14.0(@types/react@19.1.6)(react@19.1.0))(@types/react@19.1.6)(react@19.1.0))(@mui/material@7.1.1(@emotion/react@11.14.0(@types/react@19.1.6)(react@19.1.0))(@emotion/styled@11.14.0(@emotion/react@11.14.0(@types/react@19.1.6)(react@19.1.0))(@types/react@19.1.6)(react@19.1.0))(@types/react@19.1.6)(react-dom@19.1.0(react@19.1.0))(react@19.1.0))(@mui/system@7.1.1(@emotion/react@11.14.0(@types/react@19.1.6)(react@19.1.0))(@emotion/styled@11.14.0(@emotion/react@11.14.0(@types/react@19.1.6)(react@19.1.0))(@types/react@19.1.6)(react@19.1.0))(@types/react@19.1.6)(react@19.1.0))(@types/react@19.1.6)(dayjs@1.11.13)(react-dom@19.1.0(react@19.1.0))(react@19.1.0) '@tanstack/match-sorter-utils': 8.19.4 '@tanstack/react-table': 8.21.3(react-dom@19.1.0(react@19.1.0))(react@19.1.0) '@tanstack/react-virtual': 3.13.9(react-dom@19.1.0(react@19.1.0))(react@19.1.0) @@ -9488,23 +9473,23 @@ snapshots: '@material/material-color-utilities@0.3.0': {} - '@microsoft/api-extractor-model@7.30.3(@types/node@22.15.29)': + '@microsoft/api-extractor-model@7.30.3(@types/node@22.15.30)': dependencies: '@microsoft/tsdoc': 0.15.1 '@microsoft/tsdoc-config': 0.17.1 - '@rushstack/node-core-library': 5.11.0(@types/node@22.15.29) + '@rushstack/node-core-library': 5.11.0(@types/node@22.15.30) transitivePeerDependencies: - '@types/node' - '@microsoft/api-extractor@7.51.0(@types/node@22.15.29)': + '@microsoft/api-extractor@7.51.0(@types/node@22.15.30)': dependencies: - '@microsoft/api-extractor-model': 7.30.3(@types/node@22.15.29) + '@microsoft/api-extractor-model': 7.30.3(@types/node@22.15.30) '@microsoft/tsdoc': 0.15.1 '@microsoft/tsdoc-config': 0.17.1 - '@rushstack/node-core-library': 5.11.0(@types/node@22.15.29) + '@rushstack/node-core-library': 5.11.0(@types/node@22.15.30) '@rushstack/rig-package': 0.5.3 - '@rushstack/terminal': 0.15.0(@types/node@22.15.29) - '@rushstack/ts-command-line': 4.23.5(@types/node@22.15.29) + '@rushstack/terminal': 0.15.0(@types/node@22.15.30) + '@rushstack/ts-command-line': 4.23.5(@types/node@22.15.30) lodash: 4.17.21 minimatch: 3.0.8 resolve: 1.22.8 @@ -9619,30 +9604,12 @@ snapshots: '@emotion/styled': 11.14.0(@emotion/react@11.14.0(@types/react@19.1.6)(react@19.1.0))(@types/react@19.1.6)(react@19.1.0) '@types/react': 19.1.6 - '@mui/types@7.4.2(@types/react@19.1.6)': - dependencies: - '@babel/runtime': 7.27.1 - optionalDependencies: - '@types/react': 19.1.6 - '@mui/types@7.4.3(@types/react@19.1.6)': dependencies: '@babel/runtime': 7.27.1 optionalDependencies: '@types/react': 19.1.6 - '@mui/utils@7.1.0(@types/react@19.1.6)(react@19.1.0)': - dependencies: - '@babel/runtime': 7.27.1 - '@mui/types': 7.4.2(@types/react@19.1.6) - '@types/prop-types': 15.7.14 - clsx: 2.1.1 - prop-types: 15.8.1 - react: 19.1.0 - react-is: 19.1.0 - optionalDependencies: - '@types/react': 19.1.6 - '@mui/utils@7.1.1(@types/react@19.1.6)(react@19.1.0)': dependencies: '@babel/runtime': 7.27.1 @@ -9655,13 +9622,13 @@ snapshots: optionalDependencies: '@types/react': 19.1.6 - '@mui/x-date-pickers@8.5.0(@emotion/react@11.14.0(@types/react@19.1.6)(react@19.1.0))(@emotion/styled@11.14.0(@emotion/react@11.14.0(@types/react@19.1.6)(react@19.1.0))(@types/react@19.1.6)(react@19.1.0))(@mui/material@7.1.1(@emotion/react@11.14.0(@types/react@19.1.6)(react@19.1.0))(@emotion/styled@11.14.0(@emotion/react@11.14.0(@types/react@19.1.6)(react@19.1.0))(@types/react@19.1.6)(react@19.1.0))(@types/react@19.1.6)(react-dom@19.1.0(react@19.1.0))(react@19.1.0))(@mui/system@7.1.1(@emotion/react@11.14.0(@types/react@19.1.6)(react@19.1.0))(@emotion/styled@11.14.0(@emotion/react@11.14.0(@types/react@19.1.6)(react@19.1.0))(@types/react@19.1.6)(react@19.1.0))(@types/react@19.1.6)(react@19.1.0))(@types/react@19.1.6)(dayjs@1.11.13)(react-dom@19.1.0(react@19.1.0))(react@19.1.0)': + '@mui/x-date-pickers@8.5.1(@emotion/react@11.14.0(@types/react@19.1.6)(react@19.1.0))(@emotion/styled@11.14.0(@emotion/react@11.14.0(@types/react@19.1.6)(react@19.1.0))(@types/react@19.1.6)(react@19.1.0))(@mui/material@7.1.1(@emotion/react@11.14.0(@types/react@19.1.6)(react@19.1.0))(@emotion/styled@11.14.0(@emotion/react@11.14.0(@types/react@19.1.6)(react@19.1.0))(@types/react@19.1.6)(react@19.1.0))(@types/react@19.1.6)(react-dom@19.1.0(react@19.1.0))(react@19.1.0))(@mui/system@7.1.1(@emotion/react@11.14.0(@types/react@19.1.6)(react@19.1.0))(@emotion/styled@11.14.0(@emotion/react@11.14.0(@types/react@19.1.6)(react@19.1.0))(@types/react@19.1.6)(react@19.1.0))(@types/react@19.1.6)(react@19.1.0))(@types/react@19.1.6)(dayjs@1.11.13)(react-dom@19.1.0(react@19.1.0))(react@19.1.0)': dependencies: - '@babel/runtime': 7.27.1 + '@babel/runtime': 7.27.6 '@mui/material': 7.1.1(@emotion/react@11.14.0(@types/react@19.1.6)(react@19.1.0))(@emotion/styled@11.14.0(@emotion/react@11.14.0(@types/react@19.1.6)(react@19.1.0))(@types/react@19.1.6)(react@19.1.0))(@types/react@19.1.6)(react-dom@19.1.0(react@19.1.0))(react@19.1.0) '@mui/system': 7.1.1(@emotion/react@11.14.0(@types/react@19.1.6)(react@19.1.0))(@emotion/styled@11.14.0(@emotion/react@11.14.0(@types/react@19.1.6)(react@19.1.0))(@types/react@19.1.6)(react@19.1.0))(@types/react@19.1.6)(react@19.1.0) - '@mui/utils': 7.1.0(@types/react@19.1.6)(react@19.1.0) - '@mui/x-internals': 8.5.0(@mui/system@7.1.1(@emotion/react@11.14.0(@types/react@19.1.6)(react@19.1.0))(@emotion/styled@11.14.0(@emotion/react@11.14.0(@types/react@19.1.6)(react@19.1.0))(@types/react@19.1.6)(react@19.1.0))(@types/react@19.1.6)(react@19.1.0))(@types/react@19.1.6)(react@19.1.0) + '@mui/utils': 7.1.1(@types/react@19.1.6)(react@19.1.0) + '@mui/x-internals': 8.5.1(@mui/system@7.1.1(@emotion/react@11.14.0(@types/react@19.1.6)(react@19.1.0))(@emotion/styled@11.14.0(@emotion/react@11.14.0(@types/react@19.1.6)(react@19.1.0))(@types/react@19.1.6)(react@19.1.0))(@types/react@19.1.6)(react@19.1.0))(@types/react@19.1.6)(react@19.1.0) '@types/react-transition-group': 4.4.12(@types/react@19.1.6) clsx: 2.1.1 prop-types: 15.8.1 @@ -9675,11 +9642,11 @@ snapshots: transitivePeerDependencies: - '@types/react' - '@mui/x-internals@8.5.0(@mui/system@7.1.1(@emotion/react@11.14.0(@types/react@19.1.6)(react@19.1.0))(@emotion/styled@11.14.0(@emotion/react@11.14.0(@types/react@19.1.6)(react@19.1.0))(@types/react@19.1.6)(react@19.1.0))(@types/react@19.1.6)(react@19.1.0))(@types/react@19.1.6)(react@19.1.0)': + '@mui/x-internals@8.5.1(@mui/system@7.1.1(@emotion/react@11.14.0(@types/react@19.1.6)(react@19.1.0))(@emotion/styled@11.14.0(@emotion/react@11.14.0(@types/react@19.1.6)(react@19.1.0))(@types/react@19.1.6)(react@19.1.0))(@types/react@19.1.6)(react@19.1.0))(@types/react@19.1.6)(react@19.1.0)': dependencies: - '@babel/runtime': 7.27.1 + '@babel/runtime': 7.27.6 '@mui/system': 7.1.1(@emotion/react@11.14.0(@types/react@19.1.6)(react@19.1.0))(@emotion/styled@11.14.0(@emotion/react@11.14.0(@types/react@19.1.6)(react@19.1.0))(@types/react@19.1.6)(react@19.1.0))(@types/react@19.1.6)(react@19.1.0) - '@mui/utils': 7.1.0(@types/react@19.1.6)(react@19.1.0) + '@mui/utils': 7.1.1(@types/react@19.1.6)(react@19.1.0) react: 19.1.0 transitivePeerDependencies: - '@types/react' @@ -10187,7 +10154,7 @@ snapshots: '@rtsao/scc@1.1.0': {} - '@rushstack/node-core-library@5.11.0(@types/node@22.15.29)': + '@rushstack/node-core-library@5.11.0(@types/node@22.15.30)': dependencies: ajv: 8.13.0 ajv-draft-04: 1.0.0(ajv@8.13.0) @@ -10198,23 +10165,23 @@ snapshots: resolve: 1.22.8 semver: 7.5.4 optionalDependencies: - '@types/node': 22.15.29 + '@types/node': 22.15.30 '@rushstack/rig-package@0.5.3': dependencies: resolve: 1.22.8 strip-json-comments: 3.1.1 - '@rushstack/terminal@0.15.0(@types/node@22.15.29)': + '@rushstack/terminal@0.15.0(@types/node@22.15.30)': dependencies: - '@rushstack/node-core-library': 5.11.0(@types/node@22.15.29) + '@rushstack/node-core-library': 5.11.0(@types/node@22.15.30) supports-color: 8.1.1 optionalDependencies: - '@types/node': 22.15.29 + '@types/node': 22.15.30 - '@rushstack/ts-command-line@4.23.5(@types/node@22.15.29)': + '@rushstack/ts-command-line@4.23.5(@types/node@22.15.30)': dependencies: - '@rushstack/terminal': 0.15.0(@types/node@22.15.29) + '@rushstack/terminal': 0.15.0(@types/node@22.15.30) '@types/argparse': 1.0.38 argparse: 1.0.10 string-argv: 0.3.2 @@ -10468,23 +10435,23 @@ snapshots: postcss: 8.5.4 tailwindcss: 4.1.8 - '@tanstack/history@1.115.0': {} + '@tanstack/history@1.120.17': {} '@tanstack/match-sorter-utils@8.19.4': dependencies: remove-accents: 0.5.0 - '@tanstack/query-core@5.80.5': {} + '@tanstack/query-core@5.80.6': {} - '@tanstack/react-query@5.80.5(react@19.1.0)': + '@tanstack/react-query@5.80.6(react@19.1.0)': dependencies: - '@tanstack/query-core': 5.80.5 + '@tanstack/query-core': 5.80.6 react: 19.1.0 - '@tanstack/react-router-devtools@1.120.15(@tanstack/react-router@1.120.15(react-dom@19.1.0(react@19.1.0))(react@19.1.0))(@tanstack/router-core@1.120.15)(csstype@3.1.3)(react-dom@19.1.0(react@19.1.0))(react@19.1.0)(tiny-invariant@1.3.3)': + '@tanstack/react-router-devtools@1.120.18(@tanstack/react-router@1.120.18(react-dom@19.1.0(react@19.1.0))(react@19.1.0))(@tanstack/router-core@1.120.17)(csstype@3.1.3)(react-dom@19.1.0(react@19.1.0))(react@19.1.0)(tiny-invariant@1.3.3)': dependencies: - '@tanstack/react-router': 1.120.15(react-dom@19.1.0(react@19.1.0))(react@19.1.0) - '@tanstack/router-devtools-core': 1.120.15(@tanstack/router-core@1.120.15)(csstype@3.1.3)(solid-js@1.9.5)(tiny-invariant@1.3.3) + '@tanstack/react-router': 1.120.18(react-dom@19.1.0(react@19.1.0))(react@19.1.0) + '@tanstack/router-devtools-core': 1.120.17(@tanstack/router-core@1.120.17)(csstype@3.1.3)(solid-js@1.9.5)(tiny-invariant@1.3.3) react: 19.1.0 react-dom: 19.1.0(react@19.1.0) solid-js: 1.9.5 @@ -10493,11 +10460,11 @@ snapshots: - csstype - tiny-invariant - '@tanstack/react-router@1.120.15(react-dom@19.1.0(react@19.1.0))(react@19.1.0)': + '@tanstack/react-router@1.120.18(react-dom@19.1.0(react@19.1.0))(react@19.1.0)': dependencies: - '@tanstack/history': 1.115.0 + '@tanstack/history': 1.120.17 '@tanstack/react-store': 0.7.0(react-dom@19.1.0(react@19.1.0))(react@19.1.0) - '@tanstack/router-core': 1.120.15 + '@tanstack/router-core': 1.120.17 jsesc: 3.1.0 react: 19.1.0 react-dom: 19.1.0(react@19.1.0) @@ -10523,15 +10490,15 @@ snapshots: react: 19.1.0 react-dom: 19.1.0(react@19.1.0) - '@tanstack/router-core@1.120.15': + '@tanstack/router-core@1.120.17': dependencies: - '@tanstack/history': 1.115.0 + '@tanstack/history': 1.120.17 '@tanstack/store': 0.7.0 tiny-invariant: 1.3.3 - '@tanstack/router-devtools-core@1.120.15(@tanstack/router-core@1.120.15)(csstype@3.1.3)(solid-js@1.9.5)(tiny-invariant@1.3.3)': + '@tanstack/router-devtools-core@1.120.17(@tanstack/router-core@1.120.17)(csstype@3.1.3)(solid-js@1.9.5)(tiny-invariant@1.3.3)': dependencies: - '@tanstack/router-core': 1.120.15 + '@tanstack/router-core': 1.120.17 clsx: 2.1.1 goober: 2.1.16(csstype@3.1.3) solid-js: 1.9.5 @@ -10539,16 +10506,16 @@ snapshots: optionalDependencies: csstype: 3.1.3 - '@tanstack/router-generator@1.120.15(@tanstack/react-router@1.120.15(react-dom@19.1.0(react@19.1.0))(react@19.1.0))': + '@tanstack/router-generator@1.120.18(@tanstack/react-router@1.120.18(react-dom@19.1.0(react@19.1.0))(react@19.1.0))': dependencies: - '@tanstack/virtual-file-routes': 1.115.0 + '@tanstack/virtual-file-routes': 1.120.17 prettier: 3.5.3 tsx: 4.19.4 zod: 3.25.51 optionalDependencies: - '@tanstack/react-router': 1.120.15(react-dom@19.1.0(react@19.1.0))(react@19.1.0) + '@tanstack/react-router': 1.120.18(react-dom@19.1.0(react@19.1.0))(react@19.1.0) - '@tanstack/router-plugin@1.120.15(@tanstack/react-router@1.120.15(react-dom@19.1.0(react@19.1.0))(react@19.1.0))(vite@6.3.5(@types/node@22.15.29)(jiti@2.4.2)(less@4.2.0)(lightningcss@1.30.1)(sass-embedded@1.88.0)(sass@1.83.0)(stylus@0.62.0)(terser@5.36.0)(tsx@4.19.4)(yaml@2.8.0))': + '@tanstack/router-plugin@1.120.18(@tanstack/react-router@1.120.18(react-dom@19.1.0(react@19.1.0))(react@19.1.0))(vite@6.3.5(@types/node@22.15.30)(jiti@2.4.2)(less@4.2.0)(lightningcss@1.30.1)(sass-embedded@1.88.0)(sass@1.83.0)(stylus@0.62.0)(terser@5.36.0)(tsx@4.19.4)(yaml@2.8.0))': dependencies: '@babel/core': 7.26.10 '@babel/plugin-syntax-jsx': 7.25.9(@babel/core@7.26.10) @@ -10556,10 +10523,10 @@ snapshots: '@babel/template': 7.27.0 '@babel/traverse': 7.27.0 '@babel/types': 7.27.0 - '@tanstack/router-core': 1.120.15 - '@tanstack/router-generator': 1.120.15(@tanstack/react-router@1.120.15(react-dom@19.1.0(react@19.1.0))(react@19.1.0)) - '@tanstack/router-utils': 1.115.0 - '@tanstack/virtual-file-routes': 1.115.0 + '@tanstack/router-core': 1.120.17 + '@tanstack/router-generator': 1.120.18(@tanstack/react-router@1.120.18(react-dom@19.1.0(react@19.1.0))(react@19.1.0)) + '@tanstack/router-utils': 1.120.17 + '@tanstack/virtual-file-routes': 1.120.17 '@types/babel__core': 7.20.5 '@types/babel__template': 7.4.4 '@types/babel__traverse': 7.20.6 @@ -10568,21 +10535,21 @@ snapshots: unplugin: 2.3.5 zod: 3.25.51 optionalDependencies: - '@tanstack/react-router': 1.120.15(react-dom@19.1.0(react@19.1.0))(react@19.1.0) - vite: 6.3.5(@types/node@22.15.29)(jiti@2.4.2)(less@4.2.0)(lightningcss@1.30.1)(sass-embedded@1.88.0)(sass@1.83.0)(stylus@0.62.0)(terser@5.36.0)(tsx@4.19.4)(yaml@2.8.0) + '@tanstack/react-router': 1.120.18(react-dom@19.1.0(react@19.1.0))(react@19.1.0) + vite: 6.3.5(@types/node@22.15.30)(jiti@2.4.2)(less@4.2.0)(lightningcss@1.30.1)(sass-embedded@1.88.0)(sass@1.83.0)(stylus@0.62.0)(terser@5.36.0)(tsx@4.19.4)(yaml@2.8.0) transitivePeerDependencies: - supports-color - '@tanstack/router-utils@1.115.0': + '@tanstack/router-utils@1.120.17': dependencies: '@babel/generator': 7.27.0 '@babel/parser': 7.27.0 ansis: 3.12.0 diff: 7.0.0 - '@tanstack/router-zod-adapter@1.81.5(@tanstack/react-router@1.120.15(react-dom@19.1.0(react@19.1.0))(react@19.1.0))(zod@3.25.51)': + '@tanstack/router-zod-adapter@1.81.5(@tanstack/react-router@1.120.18(react-dom@19.1.0(react@19.1.0))(react@19.1.0))(zod@3.25.51)': dependencies: - '@tanstack/react-router': 1.120.15(react-dom@19.1.0(react@19.1.0))(react@19.1.0) + '@tanstack/react-router': 1.120.18(react-dom@19.1.0(react@19.1.0))(react@19.1.0) zod: 3.25.51 '@tanstack/store@0.7.0': {} @@ -10591,7 +10558,7 @@ snapshots: '@tanstack/virtual-core@3.13.9': {} - '@tanstack/virtual-file-routes@1.115.0': {} + '@tanstack/virtual-file-routes@1.120.17': {} '@taplo/core@0.2.0': {} @@ -10700,7 +10667,7 @@ snapshots: '@types/adm-zip@0.5.7': dependencies: - '@types/node': 22.15.3 + '@types/node': 22.15.30 '@types/argparse@1.0.38': {} @@ -10731,12 +10698,12 @@ snapshots: dependencies: '@types/http-cache-semantics': 4.0.4 '@types/keyv': 3.1.4 - '@types/node': 22.15.29 + '@types/node': 22.15.30 '@types/responselike': 1.0.3 '@types/conventional-commits-parser@5.0.0': dependencies: - '@types/node': 22.15.29 + '@types/node': 22.15.30 '@types/d3-array@3.2.1': {} @@ -10874,7 +10841,7 @@ snapshots: '@types/fs-extra@11.0.4': dependencies: '@types/jsonfile': 6.1.4 - '@types/node': 22.15.29 + '@types/node': 22.15.30 '@types/geojson@7946.0.14': {} @@ -10892,11 +10859,11 @@ snapshots: '@types/jsonfile@6.1.4': dependencies: - '@types/node': 22.15.29 + '@types/node': 22.15.30 '@types/keyv@3.1.4': dependencies: - '@types/node': 22.15.29 + '@types/node': 22.15.30 '@types/lodash-es@4.17.12': dependencies: @@ -10912,11 +10879,7 @@ snapshots: '@types/node@16.18.108': {} - '@types/node@22.15.29': - dependencies: - undici-types: 6.21.0 - - '@types/node@22.15.3': + '@types/node@22.15.30': dependencies: undici-types: 6.21.0 @@ -10946,7 +10909,7 @@ snapshots: '@types/responselike@1.0.3': dependencies: - '@types/node': 22.15.29 + '@types/node': 22.15.30 '@types/retry@0.12.2': {} @@ -10966,7 +10929,7 @@ snapshots: '@types/yauzl@2.10.3': dependencies: - '@types/node': 22.15.29 + '@types/node': 22.15.30 optional: true '@typescript-eslint/eslint-plugin@8.33.1(@typescript-eslint/parser@8.33.1(eslint@9.28.0(jiti@2.4.2))(typescript@5.8.3))(eslint@9.28.0(jiti@2.4.2))(typescript@5.8.3)': @@ -11127,7 +11090,7 @@ snapshots: '@ungap/structured-clone@1.2.0': {} - '@vitejs/plugin-legacy@6.1.1(terser@5.36.0)(vite@6.3.5(@types/node@22.15.29)(jiti@2.4.2)(less@4.2.0)(lightningcss@1.30.1)(sass-embedded@1.88.0)(sass@1.83.0)(stylus@0.62.0)(terser@5.36.0)(tsx@4.19.4)(yaml@2.8.0))': + '@vitejs/plugin-legacy@6.1.1(terser@5.36.0)(vite@6.3.5(@types/node@22.15.30)(jiti@2.4.2)(less@4.2.0)(lightningcss@1.30.1)(sass-embedded@1.88.0)(sass@1.83.0)(stylus@0.62.0)(terser@5.36.0)(tsx@4.19.4)(yaml@2.8.0))': dependencies: '@babel/core': 7.26.10 '@babel/preset-env': 7.26.9(@babel/core@7.26.10) @@ -11138,19 +11101,19 @@ snapshots: regenerator-runtime: 0.14.1 systemjs: 6.15.1 terser: 5.36.0 - vite: 6.3.5(@types/node@22.15.29)(jiti@2.4.2)(less@4.2.0)(lightningcss@1.30.1)(sass-embedded@1.88.0)(sass@1.83.0)(stylus@0.62.0)(terser@5.36.0)(tsx@4.19.4)(yaml@2.8.0) + vite: 6.3.5(@types/node@22.15.30)(jiti@2.4.2)(less@4.2.0)(lightningcss@1.30.1)(sass-embedded@1.88.0)(sass@1.83.0)(stylus@0.62.0)(terser@5.36.0)(tsx@4.19.4)(yaml@2.8.0) transitivePeerDependencies: - supports-color - '@vitejs/plugin-react-swc@3.10.1(vite@6.3.5(@types/node@22.15.29)(jiti@2.4.2)(less@4.2.0)(lightningcss@1.30.1)(sass-embedded@1.88.0)(sass@1.83.0)(stylus@0.62.0)(terser@5.36.0)(tsx@4.19.4)(yaml@2.8.0))': + '@vitejs/plugin-react-swc@3.10.1(vite@6.3.5(@types/node@22.15.30)(jiti@2.4.2)(less@4.2.0)(lightningcss@1.30.1)(sass-embedded@1.88.0)(sass@1.83.0)(stylus@0.62.0)(terser@5.36.0)(tsx@4.19.4)(yaml@2.8.0))': dependencies: '@rolldown/pluginutils': 1.0.0-beta.9 '@swc/core': 1.11.29 - vite: 6.3.5(@types/node@22.15.29)(jiti@2.4.2)(less@4.2.0)(lightningcss@1.30.1)(sass-embedded@1.88.0)(sass@1.83.0)(stylus@0.62.0)(terser@5.36.0)(tsx@4.19.4)(yaml@2.8.0) + vite: 6.3.5(@types/node@22.15.30)(jiti@2.4.2)(less@4.2.0)(lightningcss@1.30.1)(sass-embedded@1.88.0)(sass@1.83.0)(stylus@0.62.0)(terser@5.36.0)(tsx@4.19.4)(yaml@2.8.0) transitivePeerDependencies: - '@swc/helpers' - '@vitejs/plugin-react@4.5.1(vite@6.3.5(@types/node@22.15.29)(jiti@2.4.2)(less@4.2.0)(lightningcss@1.30.1)(sass-embedded@1.88.0)(sass@1.83.0)(stylus@0.62.0)(terser@5.36.0)(tsx@4.19.4)(yaml@2.8.0))': + '@vitejs/plugin-react@4.5.1(vite@6.3.5(@types/node@22.15.30)(jiti@2.4.2)(less@4.2.0)(lightningcss@1.30.1)(sass-embedded@1.88.0)(sass@1.83.0)(stylus@0.62.0)(terser@5.36.0)(tsx@4.19.4)(yaml@2.8.0))': dependencies: '@babel/core': 7.26.10 '@babel/plugin-transform-react-jsx-self': 7.25.9(@babel/core@7.26.10) @@ -11158,7 +11121,7 @@ snapshots: '@rolldown/pluginutils': 1.0.0-beta.9 '@types/babel__core': 7.20.5 react-refresh: 0.17.0 - vite: 6.3.5(@types/node@22.15.29)(jiti@2.4.2)(less@4.2.0)(lightningcss@1.30.1)(sass-embedded@1.88.0)(sass@1.83.0)(stylus@0.62.0)(terser@5.36.0)(tsx@4.19.4)(yaml@2.8.0) + vite: 6.3.5(@types/node@22.15.30)(jiti@2.4.2)(less@4.2.0)(lightningcss@1.30.1)(sass-embedded@1.88.0)(sass@1.83.0)(stylus@0.62.0)(terser@5.36.0)(tsx@4.19.4)(yaml@2.8.0) transitivePeerDependencies: - supports-color @@ -11794,9 +11757,9 @@ snapshots: core-js@3.42.0: {} - cosmiconfig-typescript-loader@6.1.0(@types/node@22.15.29)(cosmiconfig@9.0.0(typescript@5.8.3))(typescript@5.8.3): + cosmiconfig-typescript-loader@6.1.0(@types/node@22.15.30)(cosmiconfig@9.0.0(typescript@5.8.3))(typescript@5.8.3): dependencies: - '@types/node': 22.15.29 + '@types/node': 22.15.30 cosmiconfig: 9.0.0(typescript@5.8.3) jiti: 2.4.2 typescript: 5.8.3 @@ -12186,7 +12149,7 @@ snapshots: dom-helpers@5.2.1: dependencies: - '@babel/runtime': 7.27.1 + '@babel/runtime': 7.27.6 csstype: 3.1.3 dom-serializer@1.4.1: @@ -13786,10 +13749,10 @@ snapshots: kind-of@6.0.3: {} - knip@5.60.0(@types/node@22.15.29)(typescript@5.8.3): + knip@5.60.2(@types/node@22.15.30)(typescript@5.8.3): dependencies: '@nodelib/fs.walk': 1.2.8 - '@types/node': 22.15.29 + '@types/node': 22.15.30 fast-glob: 3.3.3 formatly: 0.2.4 jiti: 2.4.2 @@ -13801,8 +13764,8 @@ snapshots: smol-toml: 1.3.4 strip-json-comments: 5.0.2 typescript: 5.8.3 - zod: 3.24.4 - zod-validation-error: 3.3.1(zod@3.24.4) + zod: 3.25.51 + zod-validation-error: 3.3.1(zod@3.25.51) known-css-properties@0.36.0: {} @@ -14935,14 +14898,14 @@ snapshots: react: 19.1.0 react-dom: 19.1.0(react@19.1.0) - react-hook-form-mui@7.6.1(5cca61e2899c996b518d738106f3b6cc): + react-hook-form-mui@7.6.1(d57264b30a79ce6f9a19367b42c73611): dependencies: '@mui/material': 7.1.1(@emotion/react@11.14.0(@types/react@19.1.6)(react@19.1.0))(@emotion/styled@11.14.0(@emotion/react@11.14.0(@types/react@19.1.6)(react@19.1.0))(@types/react@19.1.6)(react@19.1.0))(@types/react@19.1.6)(react-dom@19.1.0(react@19.1.0))(react@19.1.0) react: 19.1.0 react-hook-form: 7.52.1(react@19.1.0) optionalDependencies: '@mui/icons-material': 7.1.1(@mui/material@7.1.1(@emotion/react@11.14.0(@types/react@19.1.6)(react@19.1.0))(@emotion/styled@11.14.0(@emotion/react@11.14.0(@types/react@19.1.6)(react@19.1.0))(@types/react@19.1.6)(react@19.1.0))(@types/react@19.1.6)(react-dom@19.1.0(react@19.1.0))(react@19.1.0))(@types/react@19.1.6)(react@19.1.0) - '@mui/x-date-pickers': 8.5.0(@emotion/react@11.14.0(@types/react@19.1.6)(react@19.1.0))(@emotion/styled@11.14.0(@emotion/react@11.14.0(@types/react@19.1.6)(react@19.1.0))(@types/react@19.1.6)(react@19.1.0))(@mui/material@7.1.1(@emotion/react@11.14.0(@types/react@19.1.6)(react@19.1.0))(@emotion/styled@11.14.0(@emotion/react@11.14.0(@types/react@19.1.6)(react@19.1.0))(@types/react@19.1.6)(react@19.1.0))(@types/react@19.1.6)(react-dom@19.1.0(react@19.1.0))(react@19.1.0))(@mui/system@7.1.1(@emotion/react@11.14.0(@types/react@19.1.6)(react@19.1.0))(@emotion/styled@11.14.0(@emotion/react@11.14.0(@types/react@19.1.6)(react@19.1.0))(@types/react@19.1.6)(react@19.1.0))(@types/react@19.1.6)(react@19.1.0))(@types/react@19.1.6)(dayjs@1.11.13)(react-dom@19.1.0(react@19.1.0))(react@19.1.0) + '@mui/x-date-pickers': 8.5.1(@emotion/react@11.14.0(@types/react@19.1.6)(react@19.1.0))(@emotion/styled@11.14.0(@emotion/react@11.14.0(@types/react@19.1.6)(react@19.1.0))(@types/react@19.1.6)(react@19.1.0))(@mui/material@7.1.1(@emotion/react@11.14.0(@types/react@19.1.6)(react@19.1.0))(@emotion/styled@11.14.0(@emotion/react@11.14.0(@types/react@19.1.6)(react@19.1.0))(@types/react@19.1.6)(react@19.1.0))(@types/react@19.1.6)(react-dom@19.1.0(react@19.1.0))(react@19.1.0))(@mui/system@7.1.1(@emotion/react@11.14.0(@types/react@19.1.6)(react@19.1.0))(@emotion/styled@11.14.0(@emotion/react@11.14.0(@types/react@19.1.6)(react@19.1.0))(@types/react@19.1.6)(react@19.1.0))(@types/react@19.1.6)(react@19.1.0))(@types/react@19.1.6)(dayjs@1.11.13)(react-dom@19.1.0(react@19.1.0))(react@19.1.0) react-hook-form@7.52.1(react@19.1.0): dependencies: @@ -14990,7 +14953,7 @@ snapshots: react-transition-group@4.4.5(react-dom@19.1.0(react@19.1.0))(react@19.1.0): dependencies: - '@babel/runtime': 7.27.1 + '@babel/runtime': 7.27.6 dom-helpers: 5.2.1 loose-envify: 1.4.0 prop-types: 15.8.1 @@ -16312,9 +16275,9 @@ snapshots: - rollup - supports-color - vite-plugin-dts@4.5.4(@types/node@22.15.29)(rollup@4.40.0)(typescript@5.8.3)(vite@6.3.5(@types/node@22.15.29)(jiti@2.4.2)(less@4.2.0)(lightningcss@1.30.1)(sass-embedded@1.88.0)(sass@1.83.0)(stylus@0.62.0)(terser@5.36.0)(tsx@4.19.4)(yaml@2.8.0)): + vite-plugin-dts@4.5.4(@types/node@22.15.30)(rollup@4.40.0)(typescript@5.8.3)(vite@6.3.5(@types/node@22.15.30)(jiti@2.4.2)(less@4.2.0)(lightningcss@1.30.1)(sass-embedded@1.88.0)(sass@1.83.0)(stylus@0.62.0)(terser@5.36.0)(tsx@4.19.4)(yaml@2.8.0)): dependencies: - '@microsoft/api-extractor': 7.51.0(@types/node@22.15.29) + '@microsoft/api-extractor': 7.51.0(@types/node@22.15.30) '@rollup/pluginutils': 5.1.4(rollup@4.40.0) '@volar/typescript': 2.4.11 '@vue/language-core': 2.2.0(typescript@5.8.3) @@ -16325,13 +16288,13 @@ snapshots: magic-string: 0.30.17 typescript: 5.8.3 optionalDependencies: - vite: 6.3.5(@types/node@22.15.29)(jiti@2.4.2)(less@4.2.0)(lightningcss@1.30.1)(sass-embedded@1.88.0)(sass@1.83.0)(stylus@0.62.0)(terser@5.36.0)(tsx@4.19.4)(yaml@2.8.0) + vite: 6.3.5(@types/node@22.15.30)(jiti@2.4.2)(less@4.2.0)(lightningcss@1.30.1)(sass-embedded@1.88.0)(sass@1.83.0)(stylus@0.62.0)(terser@5.36.0)(tsx@4.19.4)(yaml@2.8.0) transitivePeerDependencies: - '@types/node' - rollup - supports-color - vite-plugin-html@3.2.2(vite@6.3.5(@types/node@22.15.29)(jiti@2.4.2)(less@4.2.0)(lightningcss@1.30.1)(sass-embedded@1.88.0)(sass@1.83.0)(stylus@0.62.0)(terser@5.36.0)(tsx@4.19.4)(yaml@2.8.0)): + vite-plugin-html@3.2.2(vite@6.3.5(@types/node@22.15.30)(jiti@2.4.2)(less@4.2.0)(lightningcss@1.30.1)(sass-embedded@1.88.0)(sass@1.83.0)(stylus@0.62.0)(terser@5.36.0)(tsx@4.19.4)(yaml@2.8.0)): dependencies: '@rollup/pluginutils': 4.2.1 colorette: 2.0.20 @@ -16345,39 +16308,39 @@ snapshots: html-minifier-terser: 6.1.0 node-html-parser: 5.4.2 pathe: 0.2.0 - vite: 6.3.5(@types/node@22.15.29)(jiti@2.4.2)(less@4.2.0)(lightningcss@1.30.1)(sass-embedded@1.88.0)(sass@1.83.0)(stylus@0.62.0)(terser@5.36.0)(tsx@4.19.4)(yaml@2.8.0) + vite: 6.3.5(@types/node@22.15.30)(jiti@2.4.2)(less@4.2.0)(lightningcss@1.30.1)(sass-embedded@1.88.0)(sass@1.83.0)(stylus@0.62.0)(terser@5.36.0)(tsx@4.19.4)(yaml@2.8.0) - vite-plugin-sass-dts@1.3.31(postcss@8.5.4)(prettier@3.5.3)(sass-embedded@1.88.0)(vite@6.3.5(@types/node@22.15.29)(jiti@2.4.2)(less@4.2.0)(lightningcss@1.30.1)(sass-embedded@1.88.0)(sass@1.83.0)(stylus@0.62.0)(terser@5.36.0)(tsx@4.19.4)(yaml@2.8.0)): + vite-plugin-sass-dts@1.3.31(postcss@8.5.4)(prettier@3.5.3)(sass-embedded@1.88.0)(vite@6.3.5(@types/node@22.15.30)(jiti@2.4.2)(less@4.2.0)(lightningcss@1.30.1)(sass-embedded@1.88.0)(sass@1.83.0)(stylus@0.62.0)(terser@5.36.0)(tsx@4.19.4)(yaml@2.8.0)): dependencies: postcss: 8.5.4 postcss-js: 4.0.1(postcss@8.5.4) prettier: 3.5.3 sass-embedded: 1.88.0 - vite: 6.3.5(@types/node@22.15.29)(jiti@2.4.2)(less@4.2.0)(lightningcss@1.30.1)(sass-embedded@1.88.0)(sass@1.83.0)(stylus@0.62.0)(terser@5.36.0)(tsx@4.19.4)(yaml@2.8.0) + vite: 6.3.5(@types/node@22.15.30)(jiti@2.4.2)(less@4.2.0)(lightningcss@1.30.1)(sass-embedded@1.88.0)(sass@1.83.0)(stylus@0.62.0)(terser@5.36.0)(tsx@4.19.4)(yaml@2.8.0) - vite-plugin-svgr@4.3.0(rollup@4.40.0)(typescript@5.8.3)(vite@6.3.5(@types/node@22.15.29)(jiti@2.4.2)(less@4.2.0)(lightningcss@1.30.1)(sass-embedded@1.88.0)(sass@1.83.0)(stylus@0.62.0)(terser@5.36.0)(tsx@4.19.4)(yaml@2.8.0)): + vite-plugin-svgr@4.3.0(rollup@4.40.0)(typescript@5.8.3)(vite@6.3.5(@types/node@22.15.30)(jiti@2.4.2)(less@4.2.0)(lightningcss@1.30.1)(sass-embedded@1.88.0)(sass@1.83.0)(stylus@0.62.0)(terser@5.36.0)(tsx@4.19.4)(yaml@2.8.0)): dependencies: '@rollup/pluginutils': 5.1.3(rollup@4.40.0) '@svgr/core': 8.1.0(typescript@5.8.3) '@svgr/plugin-jsx': 8.1.0(@svgr/core@8.1.0(typescript@5.8.3)) - vite: 6.3.5(@types/node@22.15.29)(jiti@2.4.2)(less@4.2.0)(lightningcss@1.30.1)(sass-embedded@1.88.0)(sass@1.83.0)(stylus@0.62.0)(terser@5.36.0)(tsx@4.19.4)(yaml@2.8.0) + vite: 6.3.5(@types/node@22.15.30)(jiti@2.4.2)(less@4.2.0)(lightningcss@1.30.1)(sass-embedded@1.88.0)(sass@1.83.0)(stylus@0.62.0)(terser@5.36.0)(tsx@4.19.4)(yaml@2.8.0) transitivePeerDependencies: - rollup - supports-color - typescript - vite-tsconfig-paths@5.1.4(typescript@5.8.3)(vite@6.3.5(@types/node@22.15.29)(jiti@2.4.2)(less@4.2.0)(lightningcss@1.30.1)(sass-embedded@1.88.0)(sass@1.83.0)(stylus@0.62.0)(terser@5.36.0)(tsx@4.19.4)(yaml@2.8.0)): + vite-tsconfig-paths@5.1.4(typescript@5.8.3)(vite@6.3.5(@types/node@22.15.30)(jiti@2.4.2)(less@4.2.0)(lightningcss@1.30.1)(sass-embedded@1.88.0)(sass@1.83.0)(stylus@0.62.0)(terser@5.36.0)(tsx@4.19.4)(yaml@2.8.0)): dependencies: debug: 4.3.7 globrex: 0.1.2 tsconfck: 3.0.3(typescript@5.8.3) optionalDependencies: - vite: 6.3.5(@types/node@22.15.29)(jiti@2.4.2)(less@4.2.0)(lightningcss@1.30.1)(sass-embedded@1.88.0)(sass@1.83.0)(stylus@0.62.0)(terser@5.36.0)(tsx@4.19.4)(yaml@2.8.0) + vite: 6.3.5(@types/node@22.15.30)(jiti@2.4.2)(less@4.2.0)(lightningcss@1.30.1)(sass-embedded@1.88.0)(sass@1.83.0)(stylus@0.62.0)(terser@5.36.0)(tsx@4.19.4)(yaml@2.8.0) transitivePeerDependencies: - supports-color - typescript - vite@6.3.5(@types/node@22.15.29)(jiti@2.4.2)(less@4.2.0)(lightningcss@1.30.1)(sass-embedded@1.88.0)(sass@1.83.0)(stylus@0.62.0)(terser@5.36.0)(tsx@4.19.4)(yaml@2.8.0): + vite@6.3.5(@types/node@22.15.30)(jiti@2.4.2)(less@4.2.0)(lightningcss@1.30.1)(sass-embedded@1.88.0)(sass@1.83.0)(stylus@0.62.0)(terser@5.36.0)(tsx@4.19.4)(yaml@2.8.0): dependencies: esbuild: 0.25.0 fdir: 6.4.4(picomatch@4.0.2) @@ -16386,7 +16349,7 @@ snapshots: rollup: 4.40.0 tinyglobby: 0.2.13 optionalDependencies: - '@types/node': 22.15.29 + '@types/node': 22.15.30 fsevents: 2.3.3 jiti: 2.4.2 less: 4.2.0 @@ -16591,6 +16554,10 @@ snapshots: dependencies: zod: 3.24.4 + zod-validation-error@3.3.1(zod@3.25.51): + dependencies: + zod: 3.25.51 + zod@3.24.4: {} zod@3.25.51: {} diff --git a/clash-verge-rev/UPDATELOG.md b/clash-verge-rev/UPDATELOG.md index 4583c7b982..fe1b32502f 100644 --- a/clash-verge-rev/UPDATELOG.md +++ b/clash-verge-rev/UPDATELOG.md @@ -1,104 +1,135 @@ ## v2.3.0 -尽管外部控制密钥已自动补全默认值且不允许为空。仍然推荐自行修改外部控制密钥。 +尽管 `external-controller` 密钥现已自动补全默认值且不允许为空,**仍建议手动修改密钥以提高安全性**。 -#### ⚠️ 已知问题 +--- -- 仅在Ubuntu 22.04/24.04,Fedora 41 **Gnome桌面环境** 做过简单测试,不保证其他其他Linux发行版可用,将在未来做进一步适配和调优 -- MacOS 下 墙贴主要为浅色,Tray 图标深色时图标闪烁;彩色 Tray 速率颜色淡 -- 窗口状态管理器已确定上游存在缺陷,暂时移除。当前不再内置窗口大小和位置记忆。 -- MacOS 下卸载服务后需手动重启软件才能与内核通信。 +### ⚠️ 已知问题 -### 2.3.0 相对于 2.2.3 +- 仅在 Ubuntu 22.04/24.04、Fedora 41 的 **GNOME 桌面环境** 做过简单测试,不保证其他 Linux 发行版兼容,后续将逐步适配和优化。 +- macOS: -#### 🐞 修复问题 + - 墙贴主要为浅色,深色 Tray 图标存在闪烁问题; + - 彩色 Tray 图标颜色偏淡; + - 卸载服务后需重启应用才能恢复内核通信。 -- 首页"代理模式"快速切换导致的卡死问题 -- 解锁测试报错信息 -- Macos 快捷键关闭窗口无法启用自动轻量模式 -- 静默启动异常窗口创建和关闭流程 -- Windows 错误的全局快捷键 `Ctrl+Q` 注册 -- Vless URL 解码时网络类型错误 -- 切换自定义代理地址导致系统代理状态异常 -- Macos TUN 默认无效网卡名称 -- 托盘更改订阅后 UI 不同步的问题 -- 修复提权漏洞,改用带认证的 IPC 通信 -- 编辑器中连字符问题 -- 安装服务模式后无法立即开启 TUN 模式 -- 同步更新多语言翻译 -- 修复 .window-state.json 无法删除的问题 -- 无法修改配置更新 HTTP 请求超时 -- 修复 getDelayFix 钩子问题 -- 使用外部扩展脚本覆写代理组时首页无法显示代理组 -- 导出诊断 Verge 版本与设置页面不同步 -- 切换语言时可能造成设置页面无法加载 +- 已确认窗口状态管理器存在上游缺陷,已暂时移除窗口大小与位置记忆功能。 -#### ✨ 新增功能 +--- -- Mihomo(Meta)内核升级至 1.19.10 -- 允许代理主机地址设置为非 127.0.0.1 对 WSL 代理友好 -- 关闭系统代理时关闭已建立的网络连接 -- 托盘显示当前轻量模式状态 -- Webdav 请求加入 UA -- Webdav 支持目录重定向 -- Webdav 备份目录检查和文件上传重试机制 -- 系统代理守卫可检查意外设置变更并恢复 -- 定时自动订阅更新也能自动回退使用代理 -- 订阅请求超时机制,防止订阅更新的时候卡死 -- 订阅卡片点击时间可切换下次自动更新时间,自动更新触发后页面有明确的成功与否提示 -- 添加网络管理器以优化网络请求处理,防止资源竞争导致的启动时 UI 卡死 -- 更新依赖,替换弃用元素 -- 首页当前节点增加排序功能 -- DNS 覆写下增加 Hosts 设置功能 -- 修复服务模式安装后无法立即开启 TUN 模式的问题 -- 支持手动卸载服务模式,回退到 Sidecar 模式 -- 添加了土耳其语,日本语,德语,西班牙语,繁体中文的支持 -- 卸载服务的按钮 -- 添加了Zashboard的一键跳转URL -- 使用操作系统默认的窗口管理器 -- 切换、升级、重启内核的状态管理 -- 更精细化控制自动日志清理,新增1天选项 -- Winodws 快捷键名称改为 `Clash Verge` -- 配置加载阶段自动补全 external-controller secret 字段。 +### 🐞 修复问题 -#### 🚀 优化改进 +- 修复首页“代理模式”快速切换导致的卡死问题 +- 修复 MacOS 快捷键关闭窗口无法启用自动轻量模式 +- 修复静默启动异常窗口的创建与关闭流程 +- 修复 Windows 下错误注册的全局快捷键 `Ctrl+Q` +- 修复解锁测试报错信息与 VLESS URL 解码时的网络类型错误 +- 修复切换自定义代理地址后系统代理状态异常 +- 修复 macOS TUN 默认无效网卡名称 +- 修复更改订阅后托盘 UI 不同步的问题 +- 修复服务模式安装后无法立即开启 TUN 模式 +- 修复无法删除 `.window-state.json` +- 修复无法修改配置更新 HTTP 请求超时问题 +- 修复 `getDelayFix` 钩子异常 +- 修复外部扩展脚本覆写代理组时首页无法显示代理组 +- 修复 Verge 导出诊断版本与设置页面不同步 +- 修复切换语言时设置页面可能加载失败 +- 修复编辑器中连字符处理问题 +- 修复提权漏洞,改用带认证的 IPC 通信机制 -- 系统代理 Bypass 设置 -- Windows 下使用 Startup 文件夹的方式实现开机自启,解决管理员模式下开机自启的各种问题 -- 切换到规则页面时自动刷新规则数据 -- 重构更新失败回退机制,使用后端完成更新失败后回退到使用 Clash 代理再次尝试更新 -- 编辑非激活订阅的时候不在触发当前订阅配置重载 -- 改进核心功能防止主进程阻塞、改进MihomoManager实现,以及优化窗口创建流程 -- 优化系统代理设置更新逻辑 -- 重构前端通知系统分离通知线程防止前端卡死 -- 优化网络请求和错误处理 -- 重构通知系统 -- 使用异步方法重构 UI 启动逻辑,解决启动软件过程中的各种卡死问题 -- MacOS 下默认关闭托盘速率显示 -- 优化服务操作流程,提升系统服务相关操作的稳定性和用户体验 -- 优化了其他语言的翻译问题 -- Mihomo 内核默认日志等级为 warn -- Clash Verge Rev 应用默认日志等级为 warn -- 重构了原来的 IP 信息请求重试机制,采用轮询检测,解决了 Network Error 和超时问题 -- 对轮询检测机制进行了优化,引入洗牌算法来增强随机性 -- 对获取系统信息的流程进行了优化,并添加了去重检测机制,确保剔除重复的信息 -- 优化窗口状态初始化逻辑和添加缺失的权限设置 -- 异步化配置:优化端口查找和配置保存逻辑 -- 重构事件通知机制到独立线程,避免前端卡死 -- 优化端口设置,每个端口可随机设置端口号 -- 优化了保存机制,使用平滑函数,防止客户端卡死 -- 优化端口设置退出和保存机制 -- 强制为 Mihomo 配置补全并覆盖 external-controller-cors 字段,默认不允许跨域和仅本地请求,提升 cors 安全性,升级配置时自动覆盖 -- 修改 端口检测范围 (1111-65536) -- 配置文件缺失 secret 字段时自动填充默认值 set-your-secret -- 优化异步处理,防止部分组件 UI 阻塞 -- 关闭 DNS 启用 -- 延迟测试链接更换为 Https 协议 https://cp.cloudflare.com/generate_204 +--- -#### 🗑️ 移除内容 +### ✨ 新增功能 -- 窗口状态管理器 -- Webdav 跨平台备份恢复限制 +- **Mihomo(Meta) 内核升级至 v1.19.10** +- 支持设置代理地址为非 `127.0.0.1`,提升 WSL 兼容性 +- 系统代理守卫:可检测意外变更并自动恢复 +- 托盘新增当前轻量模式状态显示 +- 关闭系统代理时同时断开已建立的连接 +- 新增 WebDAV 功能: + + - 加入 UA 请求头 + - 支持目录重定向 + - 备份目录检查与上传重试机制 + +- 自动订阅更新机制: + + - 加入请求超时机制防止卡死 + - 支持在代理状态下自动重试订阅更新 + - 支持订阅卡片点击切换下次自动更新时间,并显示更新结果提示 + +- DNS 设置新增 Hosts 配置功能 +- 首页代理节点支持排序 +- 支持服务模式手动卸载,回退至 Sidecar 模式 +- 核心状态管理支持切换、升级、重启 +- 配置加载阶段自动补全 `external-controller secret` +- 新增日志自动清理周期选项(含1天) +- 新增 Zashboard 一键跳转入口 +- 使用系统默认窗口管理器 + +--- + +### 🚀 优化改进 + +- **系统相关:** + + - 系统代理 Bypass 设置优化 + - 优化代理设置更新逻辑与守卫机制 + - Windows 启动方式调整为 Startup 文件夹,解决管理员模式下自启问题 + +- **性能与稳定性:** + + - 全面异步化处理配置加载、UI 启动、事件通知等关键流程,解决卡顿问题 + - 优化 MihomoManager 实现与窗口创建流程 + - 改进内核日志等级为 `warn`,减少噪音输出 + - 重构主进程与通知系统,提升响应性与分离度 + - 优化网络请求与错误处理机制 + - 添加网络管理器防止资源竞争引发 UI 卡死 + - 优化配置文件加载内存使用 + - 优化缓存 Mihomo proxy 和 providers 信息内存使用 + +- **前端与界面体验:** + + - 切换规则页自动刷新数据 + - 非激活订阅编辑时不再触发配置重载 + - 优化托盘速率显示,macOS 下默认关闭 + - Windows 快捷键名称更名为 `Clash Verge` + - 更新失败可回退至使用代理重试 + - 支持异步端口查找与保存,端口支持随机生成 + - 修改端口检测范围至 `1111-65536` + - 优化保存机制,使用平滑函数防止卡顿 + +- **配置增强与安全性:** + + - 配置缺失 `secret` 字段时自动补全为 `set-your-secret` + - 强制为 Mihomo 配置补全 `external-controller-cors` 字段(默认不允许跨域,限制本地访问)计划后续支持自定义 cors + - 优化窗口权限设置与状态初始化逻辑 + - 网络延迟测试替换为 HTTPS 协议:`https://cp.cloudflare.com/generate_204` + - 优化 IP 信息获取流程,添加去重机制与轮询检测算法 + +--- + +### 🌐 I18N 多语言支持 + +- 增加对以下语言的支持: + + - 🇹🇷 土耳其语(Turkish) + - 🇯🇵 日语(Japanese) + - 🇩🇪 德语(German) + - 🇪🇸 西班牙语(Spanish) + - 🇨🇳 繁体中文(Traditional Chinese) + +- 同步修复翻译错误与不一致项,优化整体语言体验 +- 加强语言切换后的页面稳定性,避免加载异常 + +--- + +### 🗑️ 移除内容 + +- 窗口状态管理器(上游存在缺陷) +- WebDAV 跨平台备份恢复限制 + +--- ## v2.2.3 diff --git a/lede/target/linux/sunxi/Makefile b/lede/target/linux/sunxi/Makefile index 5a0f800290..d77e8ce90a 100644 --- a/lede/target/linux/sunxi/Makefile +++ b/lede/target/linux/sunxi/Makefile @@ -7,10 +7,10 @@ include $(TOPDIR)/rules.mk ARCH:=arm BOARD:=sunxi BOARDNAME:=Allwinner ARM SoCs -FEATURES:=usb ext4 display rootfs-part rtc squashfs -SUBTARGETS:=cortexa8 cortexa7 cortexa53 arm926ejs +FEATURES:=ext4 display rootfs-part rtc squashfs usb usbgadget +SUBTARGETS:=cortexa8 cortexa7 cortexa53 -KERNEL_PATCHVER:=6.1 +KERNEL_PATCHVER:=6.12 KERNEL_TESTING_PATCHVER:=6.6 KERNELNAME:=zImage dtbs diff --git a/lede/target/linux/sunxi/arm926ejs/config-6.1 b/lede/target/linux/sunxi/arm926ejs/config-6.1 deleted file mode 100644 index b1320ee2ea..0000000000 --- a/lede/target/linux/sunxi/arm926ejs/config-6.1 +++ /dev/null @@ -1,54 +0,0 @@ -# CONFIG_ARCH_MULTI_V4 is not set -# CONFIG_ARCH_MULTI_V4T is not set -CONFIG_ARCH_MULTI_V4_V5=y -CONFIG_ARCH_MULTI_V5=y -CONFIG_ARCH_MULTIPLATFORM=y -CONFIG_ARCH_MULTI_CPU_AUTO=y -CONFIG_ARCH_NR_GPIO=416 -CONFIG_ARCH_OPTIONAL_KERNEL_RWX=y -CONFIG_ARCH_SELECT_MEMORY_MODEL=y -CONFIG_ARCH_SPARSEMEM_ENABLE=y -CONFIG_ARCH_SUNXI=y -CONFIG_ARCH_32BIT_OFF_T=y -CONFIG_ARCH_HAS_BINFMT_FLAT=y -CONFIG_ARCH_HAS_TEARDOWN_DMA_OPS=y -CONFIG_BINFMT_FLAT_ARGVP_ENVP_ON_STACK=y -CONFIG_COMPAT_32BIT_TIME=y -# CONFIG_CPU_DCACHE_WRITETHROUGH is not set -# CONFIG_CPU_CACHE_ROUND_ROBIN is not set -CONFIG_MACH_SUNIV=y -# CONFIG_MACH_SUN4I is not set -# CONFIG_MACH_SUN5I is not set -# CONFIG_MACH_SUN6I is not set -# CONFIG_MACH_SUN7I is not set -# CONFIG_MACH_SUN8I is not set -# CONFIG_MACH_SUN9I is not set -CONFIG_MDIO_BUS_MUX=y -CONFIG_MUSB_PIO_ONLY=y -# CONFIG_PHY_SUN9I_USB is not set -# CONFIG_PINCTRL_SUN4I_A10 is not set -# CONFIG_PINCTRL_SUN50I_A64 is not set -# CONFIG_PINCTRL_SUN50I_A64_R is not set -# CONFIG_PINCTRL_SUN50I_H5 is not set -# CONFIG_PINCTRL_SUN50I_H6 is not set -# CONFIG_PINCTRL_SUN50I_H6_R is not set -# CONFIG_PINCTRL_SUN5I is not set -# CONFIG_PINCTRL_SUN6I_A31 is not set -# CONFIG_PINCTRL_SUN6I_A31_R is not set -# CONFIG_PINCTRL_SUN8I_A23 is not set -# CONFIG_PINCTRL_SUN8I_A23_R is not set -# CONFIG_PINCTRL_SUN8I_A33 is not set -# CONFIG_PINCTRL_SUN8I_A83T is not set -# CONFIG_PINCTRL_SUN8I_A83T_R is not set -# CONFIG_PINCTRL_SUN8I_H3 is not set -# CONFIG_PINCTRL_SUN8I_H3_R is not set -# CONFIG_PINCTRL_SUN8I_V3S is not set -# CONFIG_PINCTRL_SUN9I_A80 is not set -# CONFIG_PINCTRL_SUN9I_A80_R is not set -CONFIG_PINCTRL_SUNIV_F1C100S=y -CONFIG_PINCTRL_SUNXI=y -CONFIG_SUNIV_F1C100S_CCU=y -CONFIG_UNWINDER_ARM=y -CONFIG_USB_MUSB_HDRC=y -CONFIG_USB_MUSB_DUAL_ROLE=y -CONFIG_USB_MUSB_SUNXI=y diff --git a/lede/target/linux/sunxi/arm926ejs/target.mk b/lede/target/linux/sunxi/arm926ejs/target.mk deleted file mode 100644 index f37aa30d70..0000000000 --- a/lede/target/linux/sunxi/arm926ejs/target.mk +++ /dev/null @@ -1,11 +0,0 @@ -# -# Copyright (C) 2024 Zoltan HERPAI -# -# This is free software, licensed under the GNU General Public License v2. -# See /LICENSE for more information. -# - -include $(TOPDIR)/rules.mk - -BOARDNAME:=Allwinner F1C100/200s -CPU_TYPE:=arm926ej-s diff --git a/lede/target/linux/sunxi/config-6.1 b/lede/target/linux/sunxi/config-6.12 similarity index 98% rename from lede/target/linux/sunxi/config-6.1 rename to lede/target/linux/sunxi/config-6.12 index 661c511ee5..5de49168b6 100644 --- a/lede/target/linux/sunxi/config-6.1 +++ b/lede/target/linux/sunxi/config-6.12 @@ -7,6 +7,8 @@ CONFIG_ARCH_HIBERNATION_POSSIBLE=y CONFIG_ARCH_KEEP_MEMBLOCK=y CONFIG_ARCH_MIGHT_HAVE_PC_PARPORT=y CONFIG_ARCH_MULTIPLATFORM=y +CONFIG_ARCH_MULTI_V6_V7=y +CONFIG_ARCH_MULTI_V7=y CONFIG_ARCH_NR_GPIO=416 CONFIG_ARCH_OPTIONAL_KERNEL_RWX=y CONFIG_ARCH_OPTIONAL_KERNEL_RWX_DEFAULT=y @@ -63,6 +65,7 @@ CONFIG_CLK_SUNXI_PRCM_SUN9I=y CONFIG_CLONE_BACKWARDS=y CONFIG_COMMON_CLK=y CONFIG_COMPAT_32BIT_TIME=y +# CONFIG_COMPRESSED_INSTALL is not set CONFIG_CONFIGFS_FS=y CONFIG_CONNECTOR=y CONFIG_CONSOLE_TRANSLATIONS=y @@ -166,7 +169,6 @@ CONFIG_FRAME_WARN=2048 CONFIG_FREEZER=y CONFIG_FS_IOMAP=y CONFIG_FS_MBCACHE=y -CONFIG_FS_POSIX_ACL=y CONFIG_FWNODE_MDIO=y CONFIG_FW_CACHE=y CONFIG_FW_LOADER_PAGED_BUF=y @@ -378,6 +380,7 @@ CONFIG_PWM_SUN4I=y CONFIG_PWM_SYSFS=y CONFIG_RATIONAL=y CONFIG_REALTEK_PHY=y +CONFIG_REALTEK_PHY_HWMON=y CONFIG_REGMAP=y CONFIG_REGMAP_I2C=y CONFIG_REGMAP_IRQ=y @@ -387,6 +390,7 @@ CONFIG_REGULATOR=y CONFIG_REGULATOR_AXP20X=y CONFIG_REGULATOR_FIXED_VOLTAGE=y CONFIG_REGULATOR_GPIO=y +CONFIG_REGULATOR_SUN20I=y CONFIG_REGULATOR_SY8106A=y CONFIG_RELAY=y CONFIG_RESET_CONTROLLER=y @@ -440,6 +444,8 @@ CONFIG_SPI_SUN6I=y CONFIG_SRCU=y CONFIG_STMMAC_ETH=y CONFIG_STMMAC_PLATFORM=y +# CONFIG_SUN20I_GPADC is not set +# CONFIG_SUN20I_PPU is not set CONFIG_SUN4I_A10_CCU=y # CONFIG_SUN4I_EMAC is not set CONFIG_SUN4I_TIMER=y @@ -478,7 +484,6 @@ CONFIG_THERMAL_OF=y CONFIG_TICK_CPU_ACCOUNTING=y CONFIG_TIMER_OF=y CONFIG_TIMER_PROBE=y -CONFIG_TMPFS_POSIX_ACL=y CONFIG_TOUCHSCREEN_SUN4I=y CONFIG_TREE_RCU=y CONFIG_TREE_SRCU=y @@ -506,8 +511,6 @@ CONFIG_VFPv3=y CONFIG_VHOST=y CONFIG_VHOST_IOTLB=y CONFIG_VHOST_NET=y -# CONFIG_VIDEO_SUN4I_CSI is not set -# CONFIG_VIDEO_SUN6I_CSI is not set CONFIG_VM_EVENT_COUNTERS=y CONFIG_VT=y CONFIG_VT_CONSOLE=y diff --git a/lede/target/linux/sunxi/cortexa53/config-6.1 b/lede/target/linux/sunxi/cortexa53/config-6.12 similarity index 95% rename from lede/target/linux/sunxi/cortexa53/config-6.1 rename to lede/target/linux/sunxi/cortexa53/config-6.12 index cac7fff4dc..824817f7f4 100644 --- a/lede/target/linux/sunxi/cortexa53/config-6.1 +++ b/lede/target/linux/sunxi/cortexa53/config-6.12 @@ -4,21 +4,23 @@ CONFIG_ARCH_MMAP_RND_BITS=18 CONFIG_ARCH_MMAP_RND_BITS_MAX=24 CONFIG_ARCH_MMAP_RND_BITS_MIN=18 CONFIG_ARCH_MMAP_RND_COMPAT_BITS_MIN=11 +# CONFIG_ARCH_NXP is not set CONFIG_ARCH_PROC_KCORE_TEXT=y CONFIG_ARCH_STACKWALK=y CONFIG_ARCH_WANTS_NO_INSTR=y CONFIG_ARM64=y CONFIG_ARM64_4K_PAGES=y CONFIG_ARM64_CRYPTO=y -CONFIG_ARM64_LD_HAS_FIX_ERRATUM_843419=y CONFIG_ARM64_ERRATUM_2051678=y -CONFIG_ARM64_ERRATUM_2077057=y -CONFIG_ARM64_ERRATUM_2658417=y CONFIG_ARM64_ERRATUM_2054223=y CONFIG_ARM64_ERRATUM_2067961=y +CONFIG_ARM64_ERRATUM_2077057=y +CONFIG_ARM64_ERRATUM_2658417=y +CONFIG_ARM64_LD_HAS_FIX_ERRATUM_843419=y CONFIG_ARM64_PAGE_SHIFT=12 CONFIG_ARM64_PA_BITS=48 CONFIG_ARM64_PA_BITS_48=y +CONFIG_ARM64_PLATFORM_DEVICES=y CONFIG_ARM64_TAGGED_ADDR_ABI=y CONFIG_ARM64_VA_BITS=39 CONFIG_ARM64_VA_BITS_39=y @@ -38,8 +40,11 @@ CONFIG_CRYPTO_CRCT10DIF_ARM64_CE=y CONFIG_CRYPTO_CRYPTD=y CONFIG_CRYPTO_GHASH_ARM64_CE=y CONFIG_CRYPTO_LIB_BLAKE2S_GENERIC=y +# CONFIG_CRYPTO_POLYVAL_ARM64_CE is not set CONFIG_CRYPTO_SHA1_ARM64_CE=y CONFIG_CRYPTO_SIMD=y +# CONFIG_CRYPTO_SM4_ARM64_CE_BLK is not set +# CONFIG_CRYPTO_SM4_ARM64_NEON_BLK is not set CONFIG_DMA_DIRECT_REMAP=y CONFIG_DWMAC_SUN8I=y CONFIG_EEPROM_AT24=y @@ -52,12 +57,14 @@ CONFIG_GENERIC_MSI_IRQ_DOMAIN=y CONFIG_ILLEGAL_POINTER_VALUE=0xdead000000000000 CONFIG_MDIO_BUS_MUX=y CONFIG_MICREL_PHY=y +# CONFIG_MITIGATE_SPECTRE_BRANCH_HISTORY is not set CONFIG_MODULES_USE_ELF_RELA=y CONFIG_MOTORCOMM_PHY=y CONFIG_MUSB_PIO_ONLY=y CONFIG_NEED_SG_DMA_LENGTH=y CONFIG_NOP_USB_XCEIV=y CONFIG_NO_IOPORT_MAP=y +# CONFIG_PAGE_TABLE_CHECK is not set CONFIG_PARTITION_PERCPU=y CONFIG_PHY_SUN50I_USB3=y CONFIG_PINCTRL_SUN50I_A100=y @@ -66,13 +73,16 @@ CONFIG_PINCTRL_SUN50I_A64=y CONFIG_PINCTRL_SUN50I_A64_R=y CONFIG_PINCTRL_SUN50I_H5=y CONFIG_PINCTRL_SUN50I_H6=y -CONFIG_PINCTRL_SUN50I_H6_R=y CONFIG_PINCTRL_SUN50I_H616=y CONFIG_PINCTRL_SUN50I_H616_R=y +CONFIG_PINCTRL_SUN50I_H6_R=y # CONFIG_PREEMPT_DYNAMIC is not set CONFIG_QUEUED_RWLOCKS=y CONFIG_QUEUED_SPINLOCKS=y +CONFIG_RANDOMIZE_KSTACK_OFFSET=y CONFIG_RODATA_FULL_DEFAULT_ENABLED=y +CONFIG_RTC_CLASS=y +CONFIG_RTC_DRV_SUN6I=y # CONFIG_SCHED_CLUSTER is not set # CONFIG_SHADOW_CALL_STACK is not set # CONFIG_SND_SUN50I_CODEC_ANALOG is not set @@ -89,7 +99,8 @@ CONFIG_SUN50I_ERRATUM_UNKNOWN1=y CONFIG_SUN50I_H616_CCU=y CONFIG_SUN50I_H6_CCU=y CONFIG_SUN50I_H6_R_CCU=y -# CONFIG_SUN6I_RTC_CCU is not set +CONFIG_SUN6I_RTC_CCU=y +CONFIG_SURFACE_PLATFORMS=y CONFIG_SYSCTL_EXCEPTION_TRACE=y CONFIG_THREAD_INFO_IN_TASK=y CONFIG_UNMAP_KERNEL_AT_EL0=y @@ -99,10 +110,3 @@ CONFIG_USB_MUSB_SUNXI=y CONFIG_USB_PHY=y CONFIG_VMAP_STACK=y CONFIG_ZONE_DMA32=y -CONFIG_SURFACE_PLATFORMS=y -# CONFIG_CRYPTO_POLYVAL_ARM64_CE is not set -# CONFIG_CRYPTO_SM4_ARM64_CE_BLK is not set -# CONFIG_CRYPTO_SM4_ARM64_NEON_BLK is not set -# CONFIG_PAGE_TABLE_CHECK is not set -CONFIG_RANDOMIZE_KSTACK_OFFSET=y -# CONFIG_ARCH_NXP is not set diff --git a/lede/target/linux/sunxi/cortexa7/config-6.1 b/lede/target/linux/sunxi/cortexa7/config-6.12 similarity index 81% rename from lede/target/linux/sunxi/cortexa7/config-6.1 rename to lede/target/linux/sunxi/cortexa7/config-6.12 index 76fdc0dff3..105c090890 100644 --- a/lede/target/linux/sunxi/cortexa7/config-6.1 +++ b/lede/target/linux/sunxi/cortexa7/config-6.12 @@ -1,11 +1,11 @@ -CONFIG_ARCH_MULTI_V6_V7=y -CONFIG_ARCH_MULTI_V7=y CONFIG_B53=y CONFIG_B53_MDIO_DRIVER=y CONFIG_CRYPTO_BLAKE2S_ARM=y CONFIG_CRYPTO_LIB_BLAKE2S_GENERIC=y CONFIG_DWMAC_SUN8I=y CONFIG_GRO_CELLS=y +# CONFIG_HARDEN_BRANCH_HISTORY is not set +# CONFIG_HARDEN_BRANCH_PREDICTOR is not set # CONFIG_MACH_SUN4I is not set # CONFIG_MACH_SUN5I is not set CONFIG_MDIO_BUS_MUX=y @@ -20,6 +20,8 @@ CONFIG_NET_DSA_TAG_BRCM_PREPEND=y CONFIG_NET_SWITCHDEV=y CONFIG_NOP_USB_XCEIV=y CONFIG_RTC_DRV_SUN6I=y +CONFIG_SUN20I_D1_CCU=y +CONFIG_SUN20I_D1_R_CCU=y CONFIG_USB_MUSB_DUAL_ROLE=y CONFIG_USB_MUSB_HDRC=y CONFIG_USB_MUSB_SUNXI=y diff --git a/lede/target/linux/sunxi/cortexa8/config-6.1 b/lede/target/linux/sunxi/cortexa8/config-6.12 similarity index 88% rename from lede/target/linux/sunxi/cortexa8/config-6.1 rename to lede/target/linux/sunxi/cortexa8/config-6.12 index 274778dd09..b893b3142e 100644 --- a/lede/target/linux/sunxi/cortexa8/config-6.1 +++ b/lede/target/linux/sunxi/cortexa8/config-6.12 @@ -1,5 +1,3 @@ -CONFIG_ARCH_MULTI_V6_V7=y -CONFIG_ARCH_MULTI_V7=y # CONFIG_ARM_LPAE is not set CONFIG_CRYPTO_BLAKE2S_ARM=y CONFIG_CRYPTO_LIB_BLAKE2S_GENERIC=y diff --git a/lede/target/linux/sunxi/image/Makefile b/lede/target/linux/sunxi/image/Makefile index fc1359d173..ee36df598a 100644 --- a/lede/target/linux/sunxi/image/Makefile +++ b/lede/target/linux/sunxi/image/Makefile @@ -34,9 +34,7 @@ define Device/Default KERNEL := kernel-bin | uImage none IMAGES := sdcard.img.gz IMAGE/sdcard.img.gz := sunxi-sdcard | append-metadata | gzip -ifdef CONFIG_LINUX_6_6 SUNXI_DTS_DIR :=allwinner/ -endif SUNXI_DTS = $$(SUNXI_DTS_DIR)$$(SOC)-$(lastword $(subst _, ,$(1))) endef diff --git a/lede/target/linux/sunxi/image/arm926ejs.mk b/lede/target/linux/sunxi/image/arm926ejs.mk deleted file mode 100644 index 1ce230febb..0000000000 --- a/lede/target/linux/sunxi/image/arm926ejs.mk +++ /dev/null @@ -1,24 +0,0 @@ -# -# Copyright (C) 2013-2024 OpenWrt.org -# -# This is free software, licensed under the GNU General Public License v2. -# See /LICENSE for more information. -# - -KERNEL_LOADADDR=0x81000000 - -define Device/licheepi-nano - DEVICE_VENDOR := LicheePi - DEVICE_MODEL := Nano - DEVICE_PACKAGES := kmod-rtc-sunxi - SOC := suniv-f1c100s -endef -TARGET_DEVICES += licheepi-nano - -define Device/popstick-v1.1 - DEVICE_VENDOR := PopStick - DEVICE_MODEL := v1.1 - DEVICE_PACKAGES := kmod-rtc-sunxi - SOC := suniv-f1c200s -endef -TARGET_DEVICES += popstick-v1.1 diff --git a/lede/target/linux/sunxi/patches-6.1/001-v6.2-dt-bindings-usb-Add-H616-compatible-string.patch b/lede/target/linux/sunxi/patches-6.1/001-v6.2-dt-bindings-usb-Add-H616-compatible-string.patch deleted file mode 100644 index c24d479534..0000000000 --- a/lede/target/linux/sunxi/patches-6.1/001-v6.2-dt-bindings-usb-Add-H616-compatible-string.patch +++ /dev/null @@ -1,38 +0,0 @@ -From 28a1a6474c5053bae01bd29946b4d5ede539176b Mon Sep 17 00:00:00 2001 -From: Andre Przywara -Date: Mon, 31 Oct 2022 11:13:52 +0000 -Subject: [PATCH] dt-bindings: usb: Add H616 compatible string - -The Allwinner H616 contains four fully OHCI/EHCI compatible USB host -controllers, so just add their compatible strings to the list of -generic OHCI/EHCI controllers. - -Signed-off-by: Andre Przywara -Acked-by: Krzysztof Kozlowski -Link: https://lore.kernel.org/r/20221031111358.3387297-2-andre.przywara@arm.com -Signed-off-by: Jernej Skrabec ---- - Documentation/devicetree/bindings/usb/generic-ehci.yaml | 1 + - Documentation/devicetree/bindings/usb/generic-ohci.yaml | 1 + - 2 files changed, 2 insertions(+) - ---- a/Documentation/devicetree/bindings/usb/generic-ehci.yaml -+++ b/Documentation/devicetree/bindings/usb/generic-ehci.yaml -@@ -30,6 +30,7 @@ properties: - - allwinner,sun4i-a10-ehci - - allwinner,sun50i-a64-ehci - - allwinner,sun50i-h6-ehci -+ - allwinner,sun50i-h616-ehci - - allwinner,sun5i-a13-ehci - - allwinner,sun6i-a31-ehci - - allwinner,sun7i-a20-ehci ---- a/Documentation/devicetree/bindings/usb/generic-ohci.yaml -+++ b/Documentation/devicetree/bindings/usb/generic-ohci.yaml -@@ -20,6 +20,7 @@ properties: - - allwinner,sun4i-a10-ohci - - allwinner,sun50i-a64-ohci - - allwinner,sun50i-h6-ohci -+ - allwinner,sun50i-h616-ohci - - allwinner,sun5i-a13-ohci - - allwinner,sun6i-a31-ohci - - allwinner,sun7i-a20-ohci diff --git a/lede/target/linux/sunxi/patches-6.1/002-v6.2-dt-bindings-phy-Add-special-clock-for-Allwinner-H616-PHY.patch b/lede/target/linux/sunxi/patches-6.1/002-v6.2-dt-bindings-phy-Add-special-clock-for-Allwinner-H616-PHY.patch deleted file mode 100644 index 5739172ceb..0000000000 --- a/lede/target/linux/sunxi/patches-6.1/002-v6.2-dt-bindings-phy-Add-special-clock-for-Allwinner-H616-PHY.patch +++ /dev/null @@ -1,79 +0,0 @@ -From 6964affe65066651eca21e97247d3b7cac5153dc Mon Sep 17 00:00:00 2001 -From: Andre Przywara -Date: Mon, 31 Oct 2022 11:13:53 +0000 -Subject: [PATCH] dt-bindings: phy: Add special clock for Allwinner H616 PHY - -The USB PHY IP in the Allwinner H616 SoC requires a quirk that involves -some resources from port 2's PHY and HCI IP. In particular the PMU clock -for port 2 must be surely ungated before accessing the REG_HCI_PHY_CTL -register of port 2. To allow each USB port to be controlled -independently of port 2, we need a handle to that particular PMU clock -in the *PHY* node, as the HCI and PHY part might be handled by separate -drivers. - -Add that clock to the requirements of the H616 PHY binding, so that a -PHY driver can apply the quirk in isolation, without requiring help from -port 2's HCI driver. - -Signed-off-by: Andre Przywara -Reviewed-by: Rob Herring -Link: https://lore.kernel.org/r/20221031111358.3387297-3-andre.przywara@arm.com -Signed-off-by: Vinod Koul ---- - .../phy/allwinner,sun8i-h3-usb-phy.yaml | 26 +++++++++++++++++++ - 1 file changed, 26 insertions(+) - ---- a/Documentation/devicetree/bindings/phy/allwinner,sun8i-h3-usb-phy.yaml -+++ b/Documentation/devicetree/bindings/phy/allwinner,sun8i-h3-usb-phy.yaml -@@ -36,18 +36,22 @@ properties: - - const: pmu3 - - clocks: -+ minItems: 4 - items: - - description: USB OTG PHY bus clock - - description: USB Host 0 PHY bus clock - - description: USB Host 1 PHY bus clock - - description: USB Host 2 PHY bus clock -+ - description: PMU clock for host port 2 - - clock-names: -+ minItems: 4 - items: - - const: usb0_phy - - const: usb1_phy - - const: usb2_phy - - const: usb3_phy -+ - const: pmu2_clk - - resets: - items: -@@ -96,6 +100,28 @@ required: - - resets - - reset-names - -+allOf: -+ - if: -+ properties: -+ compatible: -+ contains: -+ enum: -+ - allwinner,sun50i-h616-usb-phy -+ then: -+ properties: -+ clocks: -+ minItems: 5 -+ -+ clock-names: -+ minItems: 5 -+ else: -+ properties: -+ clocks: -+ maxItems: 4 -+ -+ clock-names: -+ maxItems: 4 -+ - additionalProperties: false - - examples: diff --git a/lede/target/linux/sunxi/patches-6.1/003-v6.2-arm64-dts-allwinner-h616-Add-USB-nodes.patch b/lede/target/linux/sunxi/patches-6.1/003-v6.2-arm64-dts-allwinner-h616-Add-USB-nodes.patch deleted file mode 100644 index 6dc1cf2f36..0000000000 --- a/lede/target/linux/sunxi/patches-6.1/003-v6.2-arm64-dts-allwinner-h616-Add-USB-nodes.patch +++ /dev/null @@ -1,188 +0,0 @@ -From f40cf244c3feb4e1a442f8029b691add2c65b3ab Mon Sep 17 00:00:00 2001 -From: Andre Przywara -Date: Mon, 31 Oct 2022 11:13:56 +0000 -Subject: [PATCH] arm64: dts: allwinner: h616: Add USB nodes - -Add the nodes for the MUSB and the four USB host controllers to the SoC -.dtsi, along with the PHY node needed to bind all of them together. - -EHCI/OHCI and MUSB are compatible to previous SoCs, but the PHY requires -some quirks (handled in the driver). - -Signed-off-by: Andre Przywara -Reviewed-by: Jernej Skrabec -Link: https://lore.kernel.org/r/20221031111358.3387297-6-andre.przywara@arm.com -Signed-off-by: Jernej Skrabec ---- - .../arm64/boot/dts/allwinner/sun50i-h616.dtsi | 160 ++++++++++++++++++ - 1 file changed, 160 insertions(+) - ---- a/arch/arm64/boot/dts/allwinner/sun50i-h616.dtsi -+++ b/arch/arm64/boot/dts/allwinner/sun50i-h616.dtsi -@@ -504,6 +504,166 @@ - }; - }; - -+ usbotg: usb@5100000 { -+ compatible = "allwinner,sun50i-h616-musb", -+ "allwinner,sun8i-h3-musb"; -+ reg = <0x05100000 0x0400>; -+ clocks = <&ccu CLK_BUS_OTG>; -+ resets = <&ccu RST_BUS_OTG>; -+ interrupts = ; -+ interrupt-names = "mc"; -+ phys = <&usbphy 0>; -+ phy-names = "usb"; -+ extcon = <&usbphy 0>; -+ status = "disabled"; -+ }; -+ -+ usbphy: phy@5100400 { -+ compatible = "allwinner,sun50i-h616-usb-phy"; -+ reg = <0x05100400 0x24>, -+ <0x05101800 0x14>, -+ <0x05200800 0x14>, -+ <0x05310800 0x14>, -+ <0x05311800 0x14>; -+ reg-names = "phy_ctrl", -+ "pmu0", -+ "pmu1", -+ "pmu2", -+ "pmu3"; -+ clocks = <&ccu CLK_USB_PHY0>, -+ <&ccu CLK_USB_PHY1>, -+ <&ccu CLK_USB_PHY2>, -+ <&ccu CLK_USB_PHY3>, -+ <&ccu CLK_BUS_EHCI2>; -+ clock-names = "usb0_phy", -+ "usb1_phy", -+ "usb2_phy", -+ "usb3_phy", -+ "pmu2_clk"; -+ resets = <&ccu RST_USB_PHY0>, -+ <&ccu RST_USB_PHY1>, -+ <&ccu RST_USB_PHY2>, -+ <&ccu RST_USB_PHY3>; -+ reset-names = "usb0_reset", -+ "usb1_reset", -+ "usb2_reset", -+ "usb3_reset"; -+ status = "disabled"; -+ #phy-cells = <1>; -+ }; -+ -+ ehci0: usb@5101000 { -+ compatible = "allwinner,sun50i-h616-ehci", -+ "generic-ehci"; -+ reg = <0x05101000 0x100>; -+ interrupts = ; -+ clocks = <&ccu CLK_BUS_OHCI0>, -+ <&ccu CLK_BUS_EHCI0>, -+ <&ccu CLK_USB_OHCI0>; -+ resets = <&ccu RST_BUS_OHCI0>, -+ <&ccu RST_BUS_EHCI0>; -+ phys = <&usbphy 0>; -+ phy-names = "usb"; -+ status = "disabled"; -+ }; -+ -+ ohci0: usb@5101400 { -+ compatible = "allwinner,sun50i-h616-ohci", -+ "generic-ohci"; -+ reg = <0x05101400 0x100>; -+ interrupts = ; -+ clocks = <&ccu CLK_BUS_OHCI0>, -+ <&ccu CLK_USB_OHCI0>; -+ resets = <&ccu RST_BUS_OHCI0>; -+ phys = <&usbphy 0>; -+ phy-names = "usb"; -+ status = "disabled"; -+ }; -+ -+ ehci1: usb@5200000 { -+ compatible = "allwinner,sun50i-h616-ehci", -+ "generic-ehci"; -+ reg = <0x05200000 0x100>; -+ interrupts = ; -+ clocks = <&ccu CLK_BUS_OHCI1>, -+ <&ccu CLK_BUS_EHCI1>, -+ <&ccu CLK_USB_OHCI1>; -+ resets = <&ccu RST_BUS_OHCI1>, -+ <&ccu RST_BUS_EHCI1>; -+ phys = <&usbphy 1>; -+ phy-names = "usb"; -+ status = "disabled"; -+ }; -+ -+ ohci1: usb@5200400 { -+ compatible = "allwinner,sun50i-h616-ohci", -+ "generic-ohci"; -+ reg = <0x05200400 0x100>; -+ interrupts = ; -+ clocks = <&ccu CLK_BUS_OHCI1>, -+ <&ccu CLK_USB_OHCI1>; -+ resets = <&ccu RST_BUS_OHCI1>; -+ phys = <&usbphy 1>; -+ phy-names = "usb"; -+ status = "disabled"; -+ }; -+ -+ ehci2: usb@5310000 { -+ compatible = "allwinner,sun50i-h616-ehci", -+ "generic-ehci"; -+ reg = <0x05310000 0x100>; -+ interrupts = ; -+ clocks = <&ccu CLK_BUS_OHCI2>, -+ <&ccu CLK_BUS_EHCI2>, -+ <&ccu CLK_USB_OHCI2>; -+ resets = <&ccu RST_BUS_OHCI2>, -+ <&ccu RST_BUS_EHCI2>; -+ phys = <&usbphy 2>; -+ phy-names = "usb"; -+ status = "disabled"; -+ }; -+ -+ ohci2: usb@5310400 { -+ compatible = "allwinner,sun50i-h616-ohci", -+ "generic-ohci"; -+ reg = <0x05310400 0x100>; -+ interrupts = ; -+ clocks = <&ccu CLK_BUS_OHCI2>, -+ <&ccu CLK_USB_OHCI2>; -+ resets = <&ccu RST_BUS_OHCI2>; -+ phys = <&usbphy 2>; -+ phy-names = "usb"; -+ status = "disabled"; -+ }; -+ -+ ehci3: usb@5311000 { -+ compatible = "allwinner,sun50i-h616-ehci", -+ "generic-ehci"; -+ reg = <0x05311000 0x100>; -+ interrupts = ; -+ clocks = <&ccu CLK_BUS_OHCI3>, -+ <&ccu CLK_BUS_EHCI3>, -+ <&ccu CLK_USB_OHCI3>; -+ resets = <&ccu RST_BUS_OHCI3>, -+ <&ccu RST_BUS_EHCI3>; -+ phys = <&usbphy 3>; -+ phy-names = "usb"; -+ status = "disabled"; -+ }; -+ -+ ohci3: usb@5311400 { -+ compatible = "allwinner,sun50i-h616-ohci", -+ "generic-ohci"; -+ reg = <0x05311400 0x100>; -+ interrupts = ; -+ clocks = <&ccu CLK_BUS_OHCI3>, -+ <&ccu CLK_USB_OHCI3>; -+ resets = <&ccu RST_BUS_OHCI3>; -+ phys = <&usbphy 3>; -+ phy-names = "usb"; -+ status = "disabled"; -+ }; -+ - rtc: rtc@7000000 { - compatible = "allwinner,sun50i-h616-rtc"; - reg = <0x07000000 0x400>; diff --git a/lede/target/linux/sunxi/patches-6.1/004-v6.2-arm64-dts-allwinner-h616-OrangePi-Zero-2-Add-USB-nodes.patch b/lede/target/linux/sunxi/patches-6.1/004-v6.2-arm64-dts-allwinner-h616-OrangePi-Zero-2-Add-USB-nodes.patch deleted file mode 100644 index a544e482f3..0000000000 --- a/lede/target/linux/sunxi/patches-6.1/004-v6.2-arm64-dts-allwinner-h616-OrangePi-Zero-2-Add-USB-nodes.patch +++ /dev/null @@ -1,81 +0,0 @@ -From db5f028309ede13767e2ba356c1975ac37a4fd6c Mon Sep 17 00:00:00 2001 -From: Andre Przywara -Date: Mon, 31 Oct 2022 11:13:57 +0000 -Subject: [PATCH] arm64: dts: allwinner: h616: OrangePi Zero 2: Add USB nodes - -The OrangePi Zero 2 has one USB-A host port, VBUS is provided by -a GPIO controlled regulator. -The USB-C port is meant to power the board, but is also connected to -the USB 0 port, which we configure as an MUSB peripheral. - -Signed-off-by: Andre Przywara -Reviewed-by: Jernej Skrabec -Link: https://lore.kernel.org/r/20221031111358.3387297-7-andre.przywara@arm.com -Signed-off-by: Jernej Skrabec ---- - .../allwinner/sun50i-h616-orangepi-zero2.dts | 41 +++++++++++++++++++ - 1 file changed, 41 insertions(+) - ---- a/arch/arm64/boot/dts/allwinner/sun50i-h616-orangepi-zero2.dts -+++ b/arch/arm64/boot/dts/allwinner/sun50i-h616-orangepi-zero2.dts -@@ -49,8 +49,24 @@ - regulator-max-microvolt = <5000000>; - regulator-always-on; - }; -+ -+ reg_usb1_vbus: regulator-usb1-vbus { -+ compatible = "regulator-fixed"; -+ regulator-name = "usb1-vbus"; -+ regulator-min-microvolt = <5000000>; -+ regulator-max-microvolt = <5000000>; -+ vin-supply = <®_vcc5v>; -+ enable-active-high; -+ gpio = <&pio 2 16 GPIO_ACTIVE_HIGH>; /* PC16 */ -+ }; -+}; -+ -+&ehci1 { -+ status = "okay"; - }; - -+/* USB 2 & 3 are on headers only. */ -+ - &emac0 { - pinctrl-names = "default"; - pinctrl-0 = <&ext_rgmii_pins>; -@@ -76,6 +92,10 @@ - status = "okay"; - }; - -+&ohci1 { -+ status = "okay"; -+}; -+ - &r_rsb { - status = "okay"; - -@@ -211,3 +231,24 @@ - pinctrl-0 = <&uart0_ph_pins>; - status = "okay"; - }; -+ -+&usbotg { -+ /* -+ * PHY0 pins are connected to a USB-C socket, but a role switch -+ * is not implemented: both CC pins are pulled to GND. -+ * The VBUS pins power the device, so a fixed peripheral mode -+ * is the best choice. -+ * The board can be powered via GPIOs, in this case port0 *can* -+ * act as a host (with a cable/adapter ignoring CC), as VBUS is -+ * then provided by the GPIOs. Any user of this setup would -+ * need to adjust the DT accordingly: dr_mode set to "host", -+ * enabling OHCI0 and EHCI0. -+ */ -+ dr_mode = "peripheral"; -+ status = "okay"; -+}; -+ -+&usbphy { -+ usb1_vbus-supply = <®_usb1_vbus>; -+ status = "okay"; -+}; diff --git a/lede/target/linux/sunxi/patches-6.1/005-v6.6-arm64-dts-allwinner-h616-Split-Orange-Pi-Zero-2-DT.patch b/lede/target/linux/sunxi/patches-6.1/005-v6.6-arm64-dts-allwinner-h616-Split-Orange-Pi-Zero-2-DT.patch deleted file mode 100644 index 0747e6a8e0..0000000000 --- a/lede/target/linux/sunxi/patches-6.1/005-v6.6-arm64-dts-allwinner-h616-Split-Orange-Pi-Zero-2-DT.patch +++ /dev/null @@ -1,305 +0,0 @@ -From 322bf103204b8f786547acbeed85569254e7088f Mon Sep 17 00:00:00 2001 -From: Andre Przywara -Date: Fri, 4 Aug 2023 18:08:54 +0100 -Subject: [PATCH] arm64: dts: allwinner: h616: Split Orange Pi Zero 2 DT - -The Orange Pi Zero 2 got a successor (Zero 3), which shares quite some -DT nodes with the Zero 2, but comes with a different PMIC. - -Move the common parts (except the PMIC) into a new shared file, and -include that from the existing board .dts file. - -No functional change, the generated DTB is the same, except for some -phandle numbering differences. - -Signed-off-by: Andre Przywara -Acked-by: Jernej Skrabec -Link: https://lore.kernel.org/r/20230804170856.1237202-2-andre.przywara@arm.com -Signed-off-by: Jernej Skrabec ---- - .../allwinner/sun50i-h616-orangepi-zero.dtsi | 134 ++++++++++++++++++ - .../allwinner/sun50i-h616-orangepi-zero2.dts | 119 +--------------- - 2 files changed, 135 insertions(+), 118 deletions(-) - create mode 100644 arch/arm64/boot/dts/allwinner/sun50i-h616-orangepi-zero.dtsi - ---- /dev/null -+++ b/arch/arm64/boot/dts/allwinner/sun50i-h616-orangepi-zero.dtsi -@@ -0,0 +1,134 @@ -+// SPDX-License-Identifier: (GPL-2.0+ or MIT) -+/* -+ * Copyright (C) 2020 Arm Ltd. -+ * -+ * DT nodes common between Orange Pi Zero 2 and Orange Pi Zero 3. -+ * Excludes PMIC nodes and properties, since they are different between the two. -+ */ -+ -+#include "sun50i-h616.dtsi" -+ -+#include -+#include -+#include -+ -+/ { -+ aliases { -+ ethernet0 = &emac0; -+ serial0 = &uart0; -+ }; -+ -+ chosen { -+ stdout-path = "serial0:115200n8"; -+ }; -+ -+ leds { -+ compatible = "gpio-leds"; -+ -+ led-0 { -+ function = LED_FUNCTION_POWER; -+ color = ; -+ gpios = <&pio 2 12 GPIO_ACTIVE_HIGH>; /* PC12 */ -+ default-state = "on"; -+ }; -+ -+ led-1 { -+ function = LED_FUNCTION_STATUS; -+ color = ; -+ gpios = <&pio 2 13 GPIO_ACTIVE_HIGH>; /* PC13 */ -+ }; -+ }; -+ -+ reg_vcc5v: vcc5v { -+ /* board wide 5V supply directly from the USB-C socket */ -+ compatible = "regulator-fixed"; -+ regulator-name = "vcc-5v"; -+ regulator-min-microvolt = <5000000>; -+ regulator-max-microvolt = <5000000>; -+ regulator-always-on; -+ }; -+ -+ reg_usb1_vbus: regulator-usb1-vbus { -+ compatible = "regulator-fixed"; -+ regulator-name = "usb1-vbus"; -+ regulator-min-microvolt = <5000000>; -+ regulator-max-microvolt = <5000000>; -+ vin-supply = <®_vcc5v>; -+ enable-active-high; -+ gpio = <&pio 2 16 GPIO_ACTIVE_HIGH>; /* PC16 */ -+ }; -+}; -+ -+&ehci1 { -+ status = "okay"; -+}; -+ -+/* USB 2 & 3 are on headers only. */ -+ -+&emac0 { -+ pinctrl-names = "default"; -+ pinctrl-0 = <&ext_rgmii_pins>; -+ phy-mode = "rgmii"; -+ phy-handle = <&ext_rgmii_phy>; -+ allwinner,rx-delay-ps = <3100>; -+ allwinner,tx-delay-ps = <700>; -+ status = "okay"; -+}; -+ -+&mdio0 { -+ ext_rgmii_phy: ethernet-phy@1 { -+ compatible = "ethernet-phy-ieee802.3-c22"; -+ reg = <1>; -+ }; -+}; -+ -+&mmc0 { -+ cd-gpios = <&pio 5 6 GPIO_ACTIVE_LOW>; /* PF6 */ -+ bus-width = <4>; -+ status = "okay"; -+}; -+ -+&ohci1 { -+ status = "okay"; -+}; -+ -+&spi0 { -+ status = "okay"; -+ pinctrl-names = "default"; -+ pinctrl-0 = <&spi0_pins>, <&spi0_cs0_pin>; -+ -+ flash@0 { -+ #address-cells = <1>; -+ #size-cells = <1>; -+ compatible = "jedec,spi-nor"; -+ reg = <0>; -+ spi-max-frequency = <40000000>; -+ }; -+}; -+ -+&uart0 { -+ pinctrl-names = "default"; -+ pinctrl-0 = <&uart0_ph_pins>; -+ status = "okay"; -+}; -+ -+&usbotg { -+ /* -+ * PHY0 pins are connected to a USB-C socket, but a role switch -+ * is not implemented: both CC pins are pulled to GND. -+ * The VBUS pins power the device, so a fixed peripheral mode -+ * is the best choice. -+ * The board can be powered via GPIOs, in this case port0 *can* -+ * act as a host (with a cable/adapter ignoring CC), as VBUS is -+ * then provided by the GPIOs. Any user of this setup would -+ * need to adjust the DT accordingly: dr_mode set to "host", -+ * enabling OHCI0 and EHCI0. -+ */ -+ dr_mode = "peripheral"; -+ status = "okay"; -+}; -+ -+&usbphy { -+ usb1_vbus-supply = <®_usb1_vbus>; -+ status = "okay"; -+}; ---- a/arch/arm64/boot/dts/allwinner/sun50i-h616-orangepi-zero2.dts -+++ b/arch/arm64/boot/dts/allwinner/sun50i-h616-orangepi-zero2.dts -@@ -5,95 +5,19 @@ - - /dts-v1/; - --#include "sun50i-h616.dtsi" -- --#include --#include --#include -+#include "sun50i-h616-orangepi-zero.dtsi" - - / { - model = "OrangePi Zero2"; - compatible = "xunlong,orangepi-zero2", "allwinner,sun50i-h616"; -- -- aliases { -- ethernet0 = &emac0; -- serial0 = &uart0; -- }; -- -- chosen { -- stdout-path = "serial0:115200n8"; -- }; -- -- leds { -- compatible = "gpio-leds"; -- -- led-0 { -- function = LED_FUNCTION_POWER; -- color = ; -- gpios = <&pio 2 12 GPIO_ACTIVE_HIGH>; /* PC12 */ -- default-state = "on"; -- }; -- -- led-1 { -- function = LED_FUNCTION_STATUS; -- color = ; -- gpios = <&pio 2 13 GPIO_ACTIVE_HIGH>; /* PC13 */ -- }; -- }; -- -- reg_vcc5v: vcc5v { -- /* board wide 5V supply directly from the USB-C socket */ -- compatible = "regulator-fixed"; -- regulator-name = "vcc-5v"; -- regulator-min-microvolt = <5000000>; -- regulator-max-microvolt = <5000000>; -- regulator-always-on; -- }; -- -- reg_usb1_vbus: regulator-usb1-vbus { -- compatible = "regulator-fixed"; -- regulator-name = "usb1-vbus"; -- regulator-min-microvolt = <5000000>; -- regulator-max-microvolt = <5000000>; -- vin-supply = <®_vcc5v>; -- enable-active-high; -- gpio = <&pio 2 16 GPIO_ACTIVE_HIGH>; /* PC16 */ -- }; --}; -- --&ehci1 { -- status = "okay"; - }; - --/* USB 2 & 3 are on headers only. */ -- - &emac0 { -- pinctrl-names = "default"; -- pinctrl-0 = <&ext_rgmii_pins>; -- phy-mode = "rgmii"; -- phy-handle = <&ext_rgmii_phy>; - phy-supply = <®_dcdce>; -- allwinner,rx-delay-ps = <3100>; -- allwinner,tx-delay-ps = <700>; -- status = "okay"; --}; -- --&mdio0 { -- ext_rgmii_phy: ethernet-phy@1 { -- compatible = "ethernet-phy-ieee802.3-c22"; -- reg = <1>; -- }; - }; - - &mmc0 { - vmmc-supply = <®_dcdce>; -- cd-gpios = <&pio 5 6 GPIO_ACTIVE_LOW>; /* PF6 */ -- bus-width = <4>; -- status = "okay"; --}; -- --&ohci1 { -- status = "okay"; - }; - - &r_rsb { -@@ -211,44 +135,3 @@ - vcc-ph-supply = <®_aldo1>; - vcc-pi-supply = <®_aldo1>; - }; -- --&spi0 { -- status = "okay"; -- pinctrl-names = "default"; -- pinctrl-0 = <&spi0_pins>, <&spi0_cs0_pin>; -- -- flash@0 { -- #address-cells = <1>; -- #size-cells = <1>; -- compatible = "jedec,spi-nor"; -- reg = <0>; -- spi-max-frequency = <40000000>; -- }; --}; -- --&uart0 { -- pinctrl-names = "default"; -- pinctrl-0 = <&uart0_ph_pins>; -- status = "okay"; --}; -- --&usbotg { -- /* -- * PHY0 pins are connected to a USB-C socket, but a role switch -- * is not implemented: both CC pins are pulled to GND. -- * The VBUS pins power the device, so a fixed peripheral mode -- * is the best choice. -- * The board can be powered via GPIOs, in this case port0 *can* -- * act as a host (with a cable/adapter ignoring CC), as VBUS is -- * then provided by the GPIOs. Any user of this setup would -- * need to adjust the DT accordingly: dr_mode set to "host", -- * enabling OHCI0 and EHCI0. -- */ -- dr_mode = "peripheral"; -- status = "okay"; --}; -- --&usbphy { -- usb1_vbus-supply = <®_usb1_vbus>; -- status = "okay"; --}; diff --git a/lede/target/linux/sunxi/patches-6.1/006-v6.6-arm64-dts-allwinner-h616-Add-OrangePi-Zero-3-board.patch b/lede/target/linux/sunxi/patches-6.1/006-v6.6-arm64-dts-allwinner-h616-Add-OrangePi-Zero-3-board.patch deleted file mode 100644 index 4081a82d52..0000000000 --- a/lede/target/linux/sunxi/patches-6.1/006-v6.6-arm64-dts-allwinner-h616-Add-OrangePi-Zero-3-board.patch +++ /dev/null @@ -1,140 +0,0 @@ -From f1b3ddb3ecc2eec1f912383e01156c226daacfab Mon Sep 17 00:00:00 2001 -From: Andre Przywara -Date: Fri, 4 Aug 2023 18:08:56 +0100 -Subject: [PATCH] arm64: dts: allwinner: h616: Add OrangePi Zero 3 board - support - -The OrangePi Zero 3 is a development board based on the Allwinner H618 SoC, -which seems to be just an H616 with more L2 cache. The board itself is a -slightly updated version of the Orange Pi Zero 2. It features: -- Four ARM Cortex-A53 cores, Mali-G31 MP2 GPU -- 1/1.5/2/4 GiB LPDDR4 DRAM SKUs (only up to 1GB on the Zero2) -- AXP313a PMIC (more capable AXP305 on the Zero2) -- Raspberry-Pi-1 compatible GPIO header -- extra 13 pin expansion header, exposing pins for 2x USB 2.0 ports -- 1 USB 2.0 host port -- 1 USB 2.0 type C port (power supply + OTG) -- MicroSD slot -- on-board 16MiB bootable SPI NOR flash (only 2MB on the Zero2) -- 1Gbps Ethernet port (via Motorcomm YT8531 PHY) (RTL8211 on the Zero2) -- micro-HDMI port -- (yet) unsupported Allwinner WiFi/BT chip - -Add the devicetree file describing the currently supported features, -namely LEDs, SD card, PMIC, SPI flash, USB. Ethernet seems unstable at -the moment, though the basic functionality works. - -Signed-off-by: Andre Przywara -Reviewed-by: Jernej Skrabec -Link: https://lore.kernel.org/r/20230804170856.1237202-4-andre.przywara@arm.com -Signed-off-by: Jernej Skrabec ---- - arch/arm64/boot/dts/allwinner/Makefile | 1 + - .../allwinner/sun50i-h618-orangepi-zero3.dts | 94 +++++++++++++++++++ - 2 files changed, 95 insertions(+) - create mode 100644 arch/arm64/boot/dts/allwinner/sun50i-h618-orangepi-zero3.dts - ---- a/arch/arm64/boot/dts/allwinner/Makefile -+++ b/arch/arm64/boot/dts/allwinner/Makefile -@@ -40,3 +40,4 @@ dtb-$(CONFIG_ARCH_SUNXI) += sun50i-h6-ta - dtb-$(CONFIG_ARCH_SUNXI) += sun50i-h6-tanix-tx6-mini.dtb - dtb-$(CONFIG_ARCH_SUNXI) += sun50i-h616-orangepi-zero2.dtb - dtb-$(CONFIG_ARCH_SUNXI) += sun50i-h616-x96-mate.dtb -+dtb-$(CONFIG_ARCH_SUNXI) += sun50i-h618-orangepi-zero3.dtb ---- /dev/null -+++ b/arch/arm64/boot/dts/allwinner/sun50i-h618-orangepi-zero3.dts -@@ -0,0 +1,94 @@ -+// SPDX-License-Identifier: (GPL-2.0+ or MIT) -+/* -+ * Copyright (C) 2023 Arm Ltd. -+ */ -+ -+/dts-v1/; -+ -+#include "sun50i-h616-orangepi-zero.dtsi" -+ -+/ { -+ model = "OrangePi Zero3"; -+ compatible = "xunlong,orangepi-zero3", "allwinner,sun50i-h618"; -+}; -+ -+&emac0 { -+ phy-supply = <®_dldo1>; -+}; -+ -+&ext_rgmii_phy { -+ motorcomm,clk-out-frequency-hz = <125000000>; -+}; -+ -+&mmc0 { -+ /* -+ * The schematic shows the card detect pin wired up to PF6, via an -+ * inverter, but it just doesn't work. -+ */ -+ broken-cd; -+ vmmc-supply = <®_dldo1>; -+}; -+ -+&r_i2c { -+ status = "okay"; -+ -+ axp313: pmic@36 { -+ compatible = "x-powers,axp313a"; -+ reg = <0x36>; -+ #interrupt-cells = <1>; -+ interrupt-controller; -+ interrupt-parent = <&pio>; -+ interrupts = <2 9 IRQ_TYPE_LEVEL_LOW>; /* PC9 */ -+ -+ vin1-supply = <®_vcc5v>; -+ vin2-supply = <®_vcc5v>; -+ vin3-supply = <®_vcc5v>; -+ -+ regulators { -+ /* Supplies VCC-PLL, so needs to be always on. */ -+ reg_aldo1: aldo1 { -+ regulator-always-on; -+ regulator-min-microvolt = <1800000>; -+ regulator-max-microvolt = <1800000>; -+ regulator-name = "vcc1v8"; -+ }; -+ -+ /* Supplies VCC-IO, so needs to be always on. */ -+ reg_dldo1: dldo1 { -+ regulator-always-on; -+ regulator-min-microvolt = <3300000>; -+ regulator-max-microvolt = <3300000>; -+ regulator-name = "vcc3v3"; -+ }; -+ -+ reg_dcdc1: dcdc1 { -+ regulator-always-on; -+ regulator-min-microvolt = <810000>; -+ regulator-max-microvolt = <990000>; -+ regulator-name = "vdd-gpu-sys"; -+ }; -+ -+ reg_dcdc2: dcdc2 { -+ regulator-always-on; -+ regulator-min-microvolt = <810000>; -+ regulator-max-microvolt = <1100000>; -+ regulator-name = "vdd-cpu"; -+ }; -+ -+ reg_dcdc3: dcdc3 { -+ regulator-always-on; -+ regulator-min-microvolt = <1100000>; -+ regulator-max-microvolt = <1100000>; -+ regulator-name = "vdd-dram"; -+ }; -+ }; -+ }; -+}; -+ -+&pio { -+ vcc-pc-supply = <®_dldo1>; -+ vcc-pf-supply = <®_dldo1>; -+ vcc-pg-supply = <®_aldo1>; -+ vcc-ph-supply = <®_dldo1>; -+ vcc-pi-supply = <®_dldo1>; -+}; diff --git a/lede/target/linux/sunxi/patches-6.1/007-v6.7-arm64-dts-allwinner-h616-update-emac-for-Orange-Pi.patch b/lede/target/linux/sunxi/patches-6.1/007-v6.7-arm64-dts-allwinner-h616-update-emac-for-Orange-Pi.patch deleted file mode 100644 index fe32cfc3e6..0000000000 --- a/lede/target/linux/sunxi/patches-6.1/007-v6.7-arm64-dts-allwinner-h616-update-emac-for-Orange-Pi.patch +++ /dev/null @@ -1,36 +0,0 @@ ---- a/arch/arm64/boot/dts/allwinner/sun50i-h616-orangepi-zero.dtsi -+++ b/arch/arm64/boot/dts/allwinner/sun50i-h616-orangepi-zero.dtsi -@@ -68,10 +68,7 @@ - &emac0 { - pinctrl-names = "default"; - pinctrl-0 = <&ext_rgmii_pins>; -- phy-mode = "rgmii"; - phy-handle = <&ext_rgmii_phy>; -- allwinner,rx-delay-ps = <3100>; -- allwinner,tx-delay-ps = <700>; - status = "okay"; - }; - ---- a/arch/arm64/boot/dts/allwinner/sun50i-h616-orangepi-zero2.dts -+++ b/arch/arm64/boot/dts/allwinner/sun50i-h616-orangepi-zero2.dts -@@ -13,6 +13,9 @@ - }; - - &emac0 { -+ allwinner,rx-delay-ps = <3100>; -+ allwinner,tx-delay-ps = <700>; -+ phy-mode = "rgmii"; - phy-supply = <®_dcdce>; - }; - ---- a/arch/arm64/boot/dts/allwinner/sun50i-h618-orangepi-zero3.dts -+++ b/arch/arm64/boot/dts/allwinner/sun50i-h618-orangepi-zero3.dts -@@ -13,6 +13,8 @@ - }; - - &emac0 { -+ allwinner,tx-delay-ps = <700>; -+ phy-mode = "rgmii-rxid"; - phy-supply = <®_dldo1>; - }; - diff --git a/lede/target/linux/sunxi/patches-6.1/008-v6.7-arm64-dts-allwinner-h616-Add-SID-controller-node.patch b/lede/target/linux/sunxi/patches-6.1/008-v6.7-arm64-dts-allwinner-h616-Add-SID-controller-node.patch deleted file mode 100644 index ce8add18ab..0000000000 --- a/lede/target/linux/sunxi/patches-6.1/008-v6.7-arm64-dts-allwinner-h616-Add-SID-controller-node.patch +++ /dev/null @@ -1,31 +0,0 @@ -From 951992797378a2177946400438f4d23c9fceae5b Mon Sep 17 00:00:00 2001 -From: Martin Botka -Date: Tue, 12 Sep 2023 14:25:13 +0200 -Subject: [PATCH] arm64: dts: allwinner: h616: Add SID controller node - -Add node for the H616 SID controller - -Signed-off-by: Martin Botka -Acked-by: Jernej Skrabec -Link: https://lore.kernel.org/r/20230912-sid-h616-v3-2-ee18e1c5bbb5@somainline.org -Signed-off-by: Jernej Skrabec ---- - arch/arm64/boot/dts/allwinner/sun50i-h616.dtsi | 7 +++++++ - 1 file changed, 7 insertions(+) - ---- a/arch/arm64/boot/dts/allwinner/sun50i-h616.dtsi -+++ b/arch/arm64/boot/dts/allwinner/sun50i-h616.dtsi -@@ -133,6 +133,13 @@ - #reset-cells = <1>; - }; - -+ sid: efuse@3006000 { -+ compatible = "allwinner,sun50i-h616-sid", "allwinner,sun50i-a64-sid"; -+ reg = <0x03006000 0x1000>; -+ #address-cells = <1>; -+ #size-cells = <1>; -+ }; -+ - watchdog: watchdog@30090a0 { - compatible = "allwinner,sun50i-h616-wdt", - "allwinner,sun6i-a31-wdt"; diff --git a/lede/target/linux/sunxi/patches-6.1/009-v6.9-soc-sunxi-sram-export-register-0-for-THS-on-H616.patch b/lede/target/linux/sunxi/patches-6.1/009-v6.9-soc-sunxi-sram-export-register-0-for-THS-on-H616.patch deleted file mode 100644 index 3453e2aa53..0000000000 --- a/lede/target/linux/sunxi/patches-6.1/009-v6.9-soc-sunxi-sram-export-register-0-for-THS-on-H616.patch +++ /dev/null @@ -1,98 +0,0 @@ -From 898d96c5464b69af44f6407c5de81ebc349d574b Mon Sep 17 00:00:00 2001 -From: Andre Przywara -Date: Mon, 19 Feb 2024 15:36:33 +0000 -Subject: [PATCH] soc: sunxi: sram: export register 0 for THS on H616 - -The Allwinner H616 SoC contains a mysterious bit at register offset 0x0 -in the SRAM control block. If bit 16 is set (the reset value), the -temperature readings of the THS are way off, leading to reports about -200C, at normal ambient temperatures. Clearing this bits brings the -reported values down to the expected values. -The BSP code clears this bit in firmware (U-Boot), and has an explicit -comment about this, but offers no real explanation. - -Experiments in U-Boot show that register 0x0 has no effect on the SRAM C -visibility: all tested bit settings still allow full read and write -access by the CPU to the whole of SRAM C. Only bit 24 of the register at -offset 0x4 makes all of SRAM C inaccessible by the CPU. So modelling -the THS switch functionality as an SRAM region would not reflect reality. - -Since we should not rely on firmware settings, allow other code (the THS -driver) to access this register, by exporting it through the already -existing regmap. This mimics what we already do for the LDO control and -the EMAC register. - -To avoid concurrent accesses to the same register at the same time, by -the SRAM switch code and the regmap code, use the same lock to protect -the access. The regmap subsystem allows to use an existing lock, so we -just need to hook in there. - -Signed-off-by: Andre Przywara -Reviewed-by: Jernej Skrabec -Signed-off-by: Daniel Lezcano -Link: https://lore.kernel.org/r/20240219153639.179814-2-andre.przywara@arm.com ---- - drivers/soc/sunxi/sunxi_sram.c | 22 ++++++++++++++++++++++ - 1 file changed, 22 insertions(+) - ---- a/drivers/soc/sunxi/sunxi_sram.c -+++ b/drivers/soc/sunxi/sunxi_sram.c -@@ -284,6 +284,7 @@ EXPORT_SYMBOL(sunxi_sram_release); - struct sunxi_sramc_variant { - int num_emac_clocks; - bool has_ldo_ctrl; -+ bool has_ths_offset; - }; - - static const struct sunxi_sramc_variant sun4i_a10_sramc_variant = { -@@ -305,8 +306,10 @@ static const struct sunxi_sramc_variant - - static const struct sunxi_sramc_variant sun50i_h616_sramc_variant = { - .num_emac_clocks = 2, -+ .has_ths_offset = true, - }; - -+#define SUNXI_SRAM_THS_OFFSET_REG 0x0 - #define SUNXI_SRAM_EMAC_CLOCK_REG 0x30 - #define SUNXI_SYS_LDO_CTRL_REG 0x150 - -@@ -315,6 +318,8 @@ static bool sunxi_sram_regmap_accessible - { - const struct sunxi_sramc_variant *variant = dev_get_drvdata(dev); - -+ if (reg == SUNXI_SRAM_THS_OFFSET_REG && variant->has_ths_offset) -+ return true; - if (reg >= SUNXI_SRAM_EMAC_CLOCK_REG && - reg < SUNXI_SRAM_EMAC_CLOCK_REG + variant->num_emac_clocks * 4) - return true; -@@ -324,6 +329,20 @@ static bool sunxi_sram_regmap_accessible - return false; - } - -+static void sunxi_sram_lock(void *_lock) -+{ -+ spinlock_t *lock = _lock; -+ -+ spin_lock(lock); -+} -+ -+static void sunxi_sram_unlock(void *_lock) -+{ -+ spinlock_t *lock = _lock; -+ -+ spin_unlock(lock); -+} -+ - static struct regmap_config sunxi_sram_regmap_config = { - .reg_bits = 32, - .val_bits = 32, -@@ -333,6 +352,9 @@ static struct regmap_config sunxi_sram_r - /* other devices have no business accessing other registers */ - .readable_reg = sunxi_sram_regmap_accessible_reg, - .writeable_reg = sunxi_sram_regmap_accessible_reg, -+ .lock = sunxi_sram_lock, -+ .unlock = sunxi_sram_unlock, -+ .lock_arg = &sram_lock, - }; - - static int __init sunxi_sram_probe(struct platform_device *pdev) diff --git a/lede/target/linux/sunxi/patches-6.1/010-v6.8-thermal-drivers-sun8i-Add-D1-T113s-THS-controller-support.patch b/lede/target/linux/sunxi/patches-6.1/010-v6.8-thermal-drivers-sun8i-Add-D1-T113s-THS-controller-support.patch deleted file mode 100644 index 8b19989118..0000000000 --- a/lede/target/linux/sunxi/patches-6.1/010-v6.8-thermal-drivers-sun8i-Add-D1-T113s-THS-controller-support.patch +++ /dev/null @@ -1,47 +0,0 @@ -From ebbf19e36d021f253425344b4d4b987f3b7d9be5 Mon Sep 17 00:00:00 2001 -From: Maxim Kiselev -Date: Mon, 18 Dec 2023 00:06:23 +0300 -Subject: [PATCH] thermal/drivers/sun8i: Add D1/T113s THS controller support - -This patch adds a thermal sensor controller support for the D1/T113s, -which is similar to the one on H6, but with only one sensor and -different scale and offset values. - -Signed-off-by: Maxim Kiselev -Acked-by: Jernej Skrabec -Reviewed-by: Andre Przywara -Signed-off-by: Daniel Lezcano -Link: https://lore.kernel.org/r/20231217210629.131486-3-bigunclemax@gmail.com ---- - drivers/thermal/sun8i_thermal.c | 13 +++++++++++++ - 1 file changed, 13 insertions(+) - ---- a/drivers/thermal/sun8i_thermal.c -+++ b/drivers/thermal/sun8i_thermal.c -@@ -610,6 +610,18 @@ static const struct ths_thermal_chip sun - .calc_temp = sun8i_ths_calc_temp, - }; - -+static const struct ths_thermal_chip sun20i_d1_ths = { -+ .sensor_num = 1, -+ .has_bus_clk_reset = true, -+ .offset = 188552, -+ .scale = 673, -+ .temp_data_base = SUN50I_H6_THS_TEMP_DATA, -+ .calibrate = sun50i_h6_ths_calibrate, -+ .init = sun50i_h6_thermal_init, -+ .irq_ack = sun50i_h6_irq_ack, -+ .calc_temp = sun8i_ths_calc_temp, -+}; -+ - static const struct of_device_id of_ths_match[] = { - { .compatible = "allwinner,sun8i-a83t-ths", .data = &sun8i_a83t_ths }, - { .compatible = "allwinner,sun8i-h3-ths", .data = &sun8i_h3_ths }, -@@ -618,6 +630,7 @@ static const struct of_device_id of_ths_ - { .compatible = "allwinner,sun50i-a100-ths", .data = &sun50i_a100_ths }, - { .compatible = "allwinner,sun50i-h5-ths", .data = &sun50i_h5_ths }, - { .compatible = "allwinner,sun50i-h6-ths", .data = &sun50i_h6_ths }, -+ { .compatible = "allwinner,sun20i-d1-ths", .data = &sun20i_d1_ths }, - { /* sentinel */ }, - }; - MODULE_DEVICE_TABLE(of, of_ths_match); diff --git a/lede/target/linux/sunxi/patches-6.1/011-v6.9-thermal-drivers-sun8i-Explain-unknown-H6-register-value.patch b/lede/target/linux/sunxi/patches-6.1/011-v6.9-thermal-drivers-sun8i-Explain-unknown-H6-register-value.patch deleted file mode 100644 index b8138a3870..0000000000 --- a/lede/target/linux/sunxi/patches-6.1/011-v6.9-thermal-drivers-sun8i-Explain-unknown-H6-register-value.patch +++ /dev/null @@ -1,79 +0,0 @@ -From 14f118aa50fe7c7c7330f56d007ecacca487cea8 Mon Sep 17 00:00:00 2001 -From: Andre Przywara -Date: Mon, 19 Feb 2024 15:36:35 +0000 -Subject: [PATCH] thermal/drivers/sun8i: Explain unknown H6 register value - -So far we were ORing in some "unknown" value into the THS control -register on the Allwinner H6. This part of the register is not explained -in the H6 manual, but the H616 manual details those bits, and on closer -inspection the THS IP blocks in both SoCs seem very close: -- The BSP code for both SoCs writes the same values into THS_CTRL. -- The reset values of at least the first three registers are the same. - -Replace the "unknown" value with its proper meaning: "acquire time", -most probably the sample part of the sample & hold circuit of the ADC, -according to its explanation in the H616 manual. - -No functional change, just a macro rename and adjustment. - -Signed-off-by: Andre Przywara -Reviewed-by: Jernej Skrabec -Acked-by: Vasily Khoruzhick -Signed-off-by: Daniel Lezcano -Link: https://lore.kernel.org/r/20240219153639.179814-4-andre.przywara@arm.com ---- - drivers/thermal/sun8i_thermal.c | 29 ++++++++++++++++------------- - 1 file changed, 16 insertions(+), 13 deletions(-) - ---- a/drivers/thermal/sun8i_thermal.c -+++ b/drivers/thermal/sun8i_thermal.c -@@ -50,7 +50,8 @@ - #define SUN8I_THS_CTRL2_T_ACQ1(x) ((GENMASK(15, 0) & (x)) << 16) - #define SUN8I_THS_DATA_IRQ_STS(x) BIT(x + 8) - --#define SUN50I_THS_CTRL0_T_ACQ(x) ((GENMASK(15, 0) & (x)) << 16) -+#define SUN50I_THS_CTRL0_T_ACQ(x) (GENMASK(15, 0) & ((x) - 1)) -+#define SUN50I_THS_CTRL0_T_SAMPLE_PER(x) ((GENMASK(15, 0) & ((x) - 1)) << 16) - #define SUN50I_THS_FILTER_EN BIT(2) - #define SUN50I_THS_FILTER_TYPE(x) (GENMASK(1, 0) & (x)) - #define SUN50I_H6_THS_PC_TEMP_PERIOD(x) ((GENMASK(19, 0) & (x)) << 12) -@@ -410,25 +411,27 @@ static int sun8i_h3_thermal_init(struct - return 0; - } - --/* -- * Without this undocumented value, the returned temperatures would -- * be higher than real ones by about 20C. -- */ --#define SUN50I_H6_CTRL0_UNK 0x0000002f -- - static int sun50i_h6_thermal_init(struct ths_device *tmdev) - { - int val; - - /* -- * T_acq = 20us -- * clkin = 24MHz -- * -- * x = T_acq * clkin - 1 -- * = 479 -+ * The manual recommends an overall sample frequency of 50 KHz (20us, -+ * 480 cycles at 24 MHz), which provides plenty of time for both the -+ * acquisition time (>24 cycles) and the actual conversion time -+ * (>14 cycles). -+ * The lower half of the CTRL register holds the "acquire time", in -+ * clock cycles, which the manual recommends to be 2us: -+ * 24MHz * 2us = 48 cycles. -+ * The high half of THS_CTRL encodes the sample frequency, in clock -+ * cycles: 24MHz * 20us = 480 cycles. -+ * This is explained in the H616 manual, but apparently wrongly -+ * described in the H6 manual, although the BSP code does the same -+ * for both SoCs. - */ - regmap_write(tmdev->regmap, SUN50I_THS_CTRL0, -- SUN50I_H6_CTRL0_UNK | SUN50I_THS_CTRL0_T_ACQ(479)); -+ SUN50I_THS_CTRL0_T_ACQ(48) | -+ SUN50I_THS_CTRL0_T_SAMPLE_PER(480)); - /* average over 4 samples */ - regmap_write(tmdev->regmap, SUN50I_H6_THS_MFC, - SUN50I_THS_FILTER_EN | diff --git a/lede/target/linux/sunxi/patches-6.1/012-v6.9-thermal-drivers-sun8i-Extend-H6-calibration-to-support-4.patch b/lede/target/linux/sunxi/patches-6.1/012-v6.9-thermal-drivers-sun8i-Extend-H6-calibration-to-support-4.patch deleted file mode 100644 index 3d01a507fa..0000000000 --- a/lede/target/linux/sunxi/patches-6.1/012-v6.9-thermal-drivers-sun8i-Extend-H6-calibration-to-support-4.patch +++ /dev/null @@ -1,74 +0,0 @@ -From 6c04a419a4c5fb18edefc44dd676fb95c7f6c55d Mon Sep 17 00:00:00 2001 -From: Maksim Kiselev -Date: Mon, 19 Feb 2024 15:36:36 +0000 -Subject: [PATCH] thermal/drivers/sun8i: Extend H6 calibration to support 4 - sensors - -The H616 SoC resembles the H6 thermal sensor controller, with a few -changes like four sensors. - -Extend sun50i_h6_ths_calibrate() function to support calibration of -these sensors. - -Co-developed-by: Martin Botka -Signed-off-by: Martin Botka -Signed-off-by: Maksim Kiselev -Reviewed-by: Andre Przywara -Signed-off-by: Andre Przywara -Reviewed-by: Jernej Skrabec -Acked-by: Vasily Khoruzhick -Signed-off-by: Daniel Lezcano -Link: https://lore.kernel.org/r/20240219153639.179814-5-andre.przywara@arm.com ---- - drivers/thermal/sun8i_thermal.c | 28 ++++++++++++++++++++-------- - 1 file changed, 20 insertions(+), 8 deletions(-) - ---- a/drivers/thermal/sun8i_thermal.c -+++ b/drivers/thermal/sun8i_thermal.c -@@ -224,16 +224,21 @@ static int sun50i_h6_ths_calibrate(struc - struct device *dev = tmdev->dev; - int i, ft_temp; - -- if (!caldata[0] || callen < 2 + 2 * tmdev->chip->sensor_num) -+ if (!caldata[0]) - return -EINVAL; - - /* - * efuse layout: - * -- * 0 11 16 32 -- * +-------+-------+-------+ -- * |temp| |sensor0|sensor1| -- * +-------+-------+-------+ -+ * 0 11 16 27 32 43 48 57 -+ * +----------+-----------+-----------+-----------+ -+ * | temp | |sensor0| |sensor1| |sensor2| | -+ * +----------+-----------+-----------+-----------+ -+ * ^ ^ ^ -+ * | | | -+ * | | sensor3[11:8] -+ * | sensor3[7:4] -+ * sensor3[3:0] - * - * The calibration data on the H6 is the ambient temperature and - * sensor values that are filled during the factory test stage. -@@ -246,9 +251,16 @@ static int sun50i_h6_ths_calibrate(struc - ft_temp = (caldata[0] & FT_TEMP_MASK) * 100; - - for (i = 0; i < tmdev->chip->sensor_num; i++) { -- int sensor_reg = caldata[i + 1] & TEMP_CALIB_MASK; -- int cdata, offset; -- int sensor_temp = tmdev->chip->calc_temp(tmdev, i, sensor_reg); -+ int sensor_reg, sensor_temp, cdata, offset; -+ -+ if (i == 3) -+ sensor_reg = (caldata[1] >> 12) -+ | ((caldata[2] >> 12) << 4) -+ | ((caldata[3] >> 12) << 8); -+ else -+ sensor_reg = caldata[i + 1] & TEMP_CALIB_MASK; -+ -+ sensor_temp = tmdev->chip->calc_temp(tmdev, i, sensor_reg); - - /* - * Calibration data is CALIBRATE_DEFAULT - (calculated diff --git a/lede/target/linux/sunxi/patches-6.1/013-v6.9-thermal-drivers-sun8i-Add-SRAM-register-access-code.patch b/lede/target/linux/sunxi/patches-6.1/013-v6.9-thermal-drivers-sun8i-Add-SRAM-register-access-code.patch deleted file mode 100644 index 6db1e32cfb..0000000000 --- a/lede/target/linux/sunxi/patches-6.1/013-v6.9-thermal-drivers-sun8i-Add-SRAM-register-access-code.patch +++ /dev/null @@ -1,126 +0,0 @@ -From f8b54d1120b81ed57bed96cc8e814ba08886d1e5 Mon Sep 17 00:00:00 2001 -From: Andre Przywara -Date: Mon, 19 Feb 2024 15:36:37 +0000 -Subject: [PATCH] thermal/drivers/sun8i: Add SRAM register access code - -The Allwinner H616 SoC needs to clear a bit in one register in the SRAM -controller, to report reasonable temperature values. On reset, bit 16 in -register 0x3000000 is set, which leads to the driver reporting -temperatures around 200C. Clearing this bit brings the values down to the -expected range. The BSP code does a one-time write in U-Boot, with a -comment just mentioning the effect on the THS, but offering no further -explanation. - -To not rely on firmware to set things up for us, add code that queries -the SRAM controller device via a DT phandle link, then clear just this -single bit. - -Signed-off-by: Andre Przywara -Acked-by: Vasily Khoruzhick -Signed-off-by: Daniel Lezcano -Link: https://lore.kernel.org/r/20240219153639.179814-6-andre.przywara@arm.com ---- - drivers/thermal/sun8i_thermal.c | 51 +++++++++++++++++++++++++++++++++ - 1 file changed, 51 insertions(+) - ---- a/drivers/thermal/sun8i_thermal.c -+++ b/drivers/thermal/sun8i_thermal.c -@@ -15,6 +15,7 @@ - #include - #include - #include -+#include - #include - #include - #include -@@ -68,6 +69,7 @@ struct tsensor { - struct ths_thermal_chip { - bool has_mod_clk; - bool has_bus_clk_reset; -+ bool needs_sram; - int sensor_num; - int offset; - int scale; -@@ -85,12 +87,16 @@ struct ths_device { - const struct ths_thermal_chip *chip; - struct device *dev; - struct regmap *regmap; -+ struct regmap_field *sram_regmap_field; - struct reset_control *reset; - struct clk *bus_clk; - struct clk *mod_clk; - struct tsensor sensor[MAX_SENSOR_NUM]; - }; - -+/* The H616 needs to have a bit 16 in the SRAM control register cleared. */ -+static const struct reg_field sun8i_ths_sram_reg_field = REG_FIELD(0x0, 16, 16); -+ - /* Temp Unit: millidegree Celsius */ - static int sun8i_ths_calc_temp(struct ths_device *tmdev, - int id, int reg) -@@ -337,6 +343,34 @@ static void sun8i_ths_reset_control_asse - reset_control_assert(data); - } - -+static struct regmap *sun8i_ths_get_sram_regmap(struct device_node *node) -+{ -+ struct device_node *sram_node; -+ struct platform_device *sram_pdev; -+ struct regmap *regmap = NULL; -+ -+ sram_node = of_parse_phandle(node, "allwinner,sram", 0); -+ if (!sram_node) -+ return ERR_PTR(-ENODEV); -+ -+ sram_pdev = of_find_device_by_node(sram_node); -+ if (!sram_pdev) { -+ /* platform device might not be probed yet */ -+ regmap = ERR_PTR(-EPROBE_DEFER); -+ goto out_put_node; -+ } -+ -+ /* If no regmap is found then the other device driver is at fault */ -+ regmap = dev_get_regmap(&sram_pdev->dev, NULL); -+ if (!regmap) -+ regmap = ERR_PTR(-EINVAL); -+ -+ platform_device_put(sram_pdev); -+out_put_node: -+ of_node_put(sram_node); -+ return regmap; -+} -+ - static int sun8i_ths_resource_init(struct ths_device *tmdev) - { - struct device *dev = tmdev->dev; -@@ -381,6 +415,19 @@ static int sun8i_ths_resource_init(struc - if (ret) - return ret; - -+ if (tmdev->chip->needs_sram) { -+ struct regmap *regmap; -+ -+ regmap = sun8i_ths_get_sram_regmap(dev->of_node); -+ if (IS_ERR(regmap)) -+ return PTR_ERR(regmap); -+ tmdev->sram_regmap_field = devm_regmap_field_alloc(dev, -+ regmap, -+ sun8i_ths_sram_reg_field); -+ if (IS_ERR(tmdev->sram_regmap_field)) -+ return PTR_ERR(tmdev->sram_regmap_field); -+ } -+ - ret = sun8i_ths_calibrate(tmdev); - if (ret) - return ret; -@@ -427,6 +474,10 @@ static int sun50i_h6_thermal_init(struct - { - int val; - -+ /* The H616 needs to have a bit in the SRAM control register cleared. */ -+ if (tmdev->sram_regmap_field) -+ regmap_field_write(tmdev->sram_regmap_field, 0); -+ - /* - * The manual recommends an overall sample frequency of 50 KHz (20us, - * 480 cycles at 24 MHz), which provides plenty of time for both the diff --git a/lede/target/linux/sunxi/patches-6.1/014-v6.9-thermal-drivers-sun8i-Add-support-for-H616-THS-controller.patch b/lede/target/linux/sunxi/patches-6.1/014-v6.9-thermal-drivers-sun8i-Add-support-for-H616-THS-controller.patch deleted file mode 100644 index e743d344c6..0000000000 --- a/lede/target/linux/sunxi/patches-6.1/014-v6.9-thermal-drivers-sun8i-Add-support-for-H616-THS-controller.patch +++ /dev/null @@ -1,50 +0,0 @@ -From e7dbfa19572a1440a2e67ef70f94ff204849a0a8 Mon Sep 17 00:00:00 2001 -From: Martin Botka -Date: Mon, 19 Feb 2024 15:36:38 +0000 -Subject: [PATCH] thermal/drivers/sun8i: Add support for H616 THS controller - -Add support for the thermal sensor found in H616 SoCs, is the same as -the H6 thermal sensor controller, but with four sensors. -Also the registers readings are wrong, unless a bit in the first SYS_CFG -register cleared, so set exercise the SRAM regmap to take care of that. - -Signed-off-by: Martin Botka -Signed-off-by: Andre Przywara -Acked-by: Vasily Khoruzhick -Signed-off-by: Daniel Lezcano -Link: https://lore.kernel.org/r/20240219153639.179814-7-andre.przywara@arm.com ---- - drivers/thermal/sun8i_thermal.c | 15 +++++++++++++++ - 1 file changed, 15 insertions(+) - ---- a/drivers/thermal/sun8i_thermal.c -+++ b/drivers/thermal/sun8i_thermal.c -@@ -688,6 +688,20 @@ static const struct ths_thermal_chip sun - .calc_temp = sun8i_ths_calc_temp, - }; - -+static const struct ths_thermal_chip sun50i_h616_ths = { -+ .sensor_num = 4, -+ .has_bus_clk_reset = true, -+ .needs_sram = true, -+ .ft_deviation = 8000, -+ .offset = 263655, -+ .scale = 810, -+ .temp_data_base = SUN50I_H6_THS_TEMP_DATA, -+ .calibrate = sun50i_h6_ths_calibrate, -+ .init = sun50i_h6_thermal_init, -+ .irq_ack = sun50i_h6_irq_ack, -+ .calc_temp = sun8i_ths_calc_temp, -+}; -+ - static const struct of_device_id of_ths_match[] = { - { .compatible = "allwinner,sun8i-a83t-ths", .data = &sun8i_a83t_ths }, - { .compatible = "allwinner,sun8i-h3-ths", .data = &sun8i_h3_ths }, -@@ -697,6 +711,7 @@ static const struct of_device_id of_ths_ - { .compatible = "allwinner,sun50i-h5-ths", .data = &sun50i_h5_ths }, - { .compatible = "allwinner,sun50i-h6-ths", .data = &sun50i_h6_ths }, - { .compatible = "allwinner,sun20i-d1-ths", .data = &sun20i_d1_ths }, -+ { .compatible = "allwinner,sun50i-h616-ths", .data = &sun50i_h616_ths }, - { /* sentinel */ }, - }; - MODULE_DEVICE_TABLE(of, of_ths_match); diff --git a/lede/target/linux/sunxi/patches-6.1/015-v6.9-thermal-drivers-sun8i-Dont-fail-probe-due-to-zone-registra.patch b/lede/target/linux/sunxi/patches-6.1/015-v6.9-thermal-drivers-sun8i-Dont-fail-probe-due-to-zone-registra.patch deleted file mode 100644 index 384bf55084..0000000000 --- a/lede/target/linux/sunxi/patches-6.1/015-v6.9-thermal-drivers-sun8i-Dont-fail-probe-due-to-zone-registra.patch +++ /dev/null @@ -1,68 +0,0 @@ -From 9ac53d5532cc4bb595bbee86ccba2172ccc336c3 Mon Sep 17 00:00:00 2001 -From: Mark Brown -Date: Tue, 23 Jan 2024 23:33:07 +0000 -Subject: [PATCH] thermal/drivers/sun8i: Don't fail probe due to zone - registration failure - -Currently the sun8i thermal driver will fail to probe if any of the -thermal zones it is registering fails to register with the thermal core. -Since we currently do not define any trip points for the GPU thermal -zones on at least A64 or H5 this means that we have no thermal support -on these platforms: - -[ 1.698703] thermal_sys: Failed to find 'trips' node -[ 1.698707] thermal_sys: Failed to find trip points for thermal-sensor id=1 - -even though the main CPU thermal zone on both SoCs is fully configured. -This does not seem ideal, while we may not be able to use all the zones -it seems better to have those zones which are usable be operational. -Instead just carry on registering zones if we get any non-deferral -error, allowing use of those zones which are usable. - -This means that we also need to update the interrupt handler to not -attempt to notify the core for events on zones which we have not -registered, I didn't see an ability to mask individual interrupts and -I would expect that interrupts would still be indicated in the ISR even -if they were masked. - -Reviewed-by: Vasily Khoruzhick -Acked-by: Jernej Skrabec -Signed-off-by: Mark Brown -Signed-off-by: Daniel Lezcano -Link: https://lore.kernel.org/r/20240123-thermal-sun8i-registration-v3-1-3e5771b1bbdd@kernel.org ---- - drivers/thermal/sun8i_thermal.c | 16 ++++++++++++++-- - 1 file changed, 14 insertions(+), 2 deletions(-) - ---- a/drivers/thermal/sun8i_thermal.c -+++ b/drivers/thermal/sun8i_thermal.c -@@ -197,6 +197,9 @@ static irqreturn_t sun8i_irq_thread(int - int i; - - for_each_set_bit(i, &irq_bitmap, tmdev->chip->sensor_num) { -+ /* We allow some zones to not register. */ -+ if (IS_ERR(tmdev->sensor[i].tzd)) -+ continue; - thermal_zone_device_update(tmdev->sensor[i].tzd, - THERMAL_EVENT_UNSPECIFIED); - } -@@ -531,8 +534,17 @@ static int sun8i_ths_register(struct ths - i, - &tmdev->sensor[i], - &ths_ops); -- if (IS_ERR(tmdev->sensor[i].tzd)) -- return PTR_ERR(tmdev->sensor[i].tzd); -+ -+ /* -+ * If an individual zone fails to register for reasons -+ * other than probe deferral (eg, a bad DT) then carry -+ * on, other zones might register successfully. -+ */ -+ if (IS_ERR(tmdev->sensor[i].tzd)) { -+ if (PTR_ERR(tmdev->sensor[i].tzd) == -EPROBE_DEFER) -+ return PTR_ERR(tmdev->sensor[i].tzd); -+ continue; -+ } - - if (devm_thermal_add_hwmon_sysfs(tmdev->sensor[i].tzd)) - dev_warn(tmdev->dev, diff --git a/lede/target/linux/sunxi/patches-6.1/016-v6.9-arm64-dts-allwinner-h616-Add-thermal-sensor-and-zones.patch b/lede/target/linux/sunxi/patches-6.1/016-v6.9-arm64-dts-allwinner-h616-Add-thermal-sensor-and-zones.patch deleted file mode 100644 index cd6542bf14..0000000000 --- a/lede/target/linux/sunxi/patches-6.1/016-v6.9-arm64-dts-allwinner-h616-Add-thermal-sensor-and-zones.patch +++ /dev/null @@ -1,138 +0,0 @@ -From f4318af40544b8e7ff5a6b667ede60e6cf808262 Mon Sep 17 00:00:00 2001 -From: Martin Botka -Date: Mon, 19 Feb 2024 15:36:39 +0000 -Subject: [PATCH] arm64: dts: allwinner: h616: Add thermal sensor and zones - -There are four thermal sensors: -- CPU -- GPU -- VE -- DRAM - -Add the thermal sensor configuration and the thermal zones. - -Signed-off-by: Martin Botka -Signed-off-by: Andre Przywara -Reviewed-by: Jernej Skrabec -Link: https://lore.kernel.org/r/20240219153639.179814-8-andre.przywara@arm.com -Signed-off-by: Jernej Skrabec ---- - .../arm64/boot/dts/allwinner/sun50i-h616.dtsi | 88 +++++++++++++++++++ - 1 file changed, 88 insertions(+) - ---- a/arch/arm64/boot/dts/allwinner/sun50i-h616.dtsi -+++ b/arch/arm64/boot/dts/allwinner/sun50i-h616.dtsi -@@ -9,6 +9,7 @@ - #include - #include - #include -+#include - - / { - interrupt-parent = <&gic>; -@@ -138,6 +139,10 @@ - reg = <0x03006000 0x1000>; - #address-cells = <1>; - #size-cells = <1>; -+ -+ ths_calibration: thermal-sensor-calibration@14 { -+ reg = <0x14 0x8>; -+ }; - }; - - watchdog: watchdog@30090a0 { -@@ -511,6 +516,19 @@ - }; - }; - -+ ths: thermal-sensor@5070400 { -+ compatible = "allwinner,sun50i-h616-ths"; -+ reg = <0x05070400 0x400>; -+ interrupts = ; -+ clocks = <&ccu CLK_BUS_THS>; -+ clock-names = "bus"; -+ resets = <&ccu RST_BUS_THS>; -+ nvmem-cells = <&ths_calibration>; -+ nvmem-cell-names = "calibration"; -+ allwinner,sram = <&syscon>; -+ #thermal-sensor-cells = <1>; -+ }; -+ - usbotg: usb@5100000 { - compatible = "allwinner,sun50i-h616-musb", - "allwinner,sun8i-h3-musb"; -@@ -755,4 +773,74 @@ - #size-cells = <0>; - }; - }; -+ -+ thermal-zones { -+ cpu-thermal { -+ polling-delay-passive = <500>; -+ polling-delay = <1000>; -+ thermal-sensors = <&ths 2>; -+ sustainable-power = <1000>; -+ -+ trips { -+ cpu_threshold: cpu-trip-0 { -+ temperature = <60000>; -+ type = "passive"; -+ hysteresis = <0>; -+ }; -+ cpu_target: cpu-trip-1 { -+ temperature = <70000>; -+ type = "passive"; -+ hysteresis = <0>; -+ }; -+ cpu_critical: cpu-trip-2 { -+ temperature = <110000>; -+ type = "critical"; -+ hysteresis = <0>; -+ }; -+ }; -+ }; -+ -+ gpu-thermal { -+ polling-delay-passive = <500>; -+ polling-delay = <1000>; -+ thermal-sensors = <&ths 0>; -+ sustainable-power = <1100>; -+ -+ trips { -+ gpu_temp_critical: gpu-trip-0 { -+ temperature = <110000>; -+ type = "critical"; -+ hysteresis = <0>; -+ }; -+ }; -+ }; -+ -+ ve-thermal { -+ polling-delay-passive = <0>; -+ polling-delay = <0>; -+ thermal-sensors = <&ths 1>; -+ -+ trips { -+ ve_temp_critical: ve-trip-0 { -+ temperature = <110000>; -+ type = "critical"; -+ hysteresis = <0>; -+ }; -+ }; -+ }; -+ -+ ddr-thermal { -+ polling-delay-passive = <0>; -+ polling-delay = <0>; -+ thermal-sensors = <&ths 3>; -+ -+ trips { -+ ddr_temp_critical: ddr-trip-0 { -+ temperature = <110000>; -+ type = "critical"; -+ hysteresis = <0>; -+ }; -+ }; -+ }; -+ }; - }; diff --git a/lede/target/linux/sunxi/patches-6.1/017-v6.10-firmware-smccc-Export-revision-soc_id-function.patch b/lede/target/linux/sunxi/patches-6.1/017-v6.10-firmware-smccc-Export-revision-soc_id-function.patch deleted file mode 100644 index aacd0ba906..0000000000 --- a/lede/target/linux/sunxi/patches-6.1/017-v6.10-firmware-smccc-Export-revision-soc_id-function.patch +++ /dev/null @@ -1,32 +0,0 @@ -From 9cf3415ade2d7598d78d2ce6d35d6d6d06132201 Mon Sep 17 00:00:00 2001 -From: Martin Botka -Date: Thu, 18 Apr 2024 16:44:01 +0100 -Subject: [PATCH] firmware: smccc: Export revision soc_id function - -The "SoC ID revision" as provided via the SMCCC SOCID interface can be -valuable information for drivers, when certain functionality depends -on a die revision, for instance. -One example is the sun50i-cpufreq-nvmem driver, which needs this -information to determine the speed bin of the SoC. - -Export the arm_smccc_get_soc_id_revision() function so that it can be -called by any driver. - -Signed-off-by: Martin Botka -Signed-off-by: Andre Przywara -Acked-by: Sudeep Holla -Signed-off-by: Viresh Kumar ---- - drivers/firmware/smccc/smccc.c | 1 + - 1 file changed, 1 insertion(+) - ---- a/drivers/firmware/smccc/smccc.c -+++ b/drivers/firmware/smccc/smccc.c -@@ -65,6 +65,7 @@ s32 arm_smccc_get_soc_id_revision(void) - { - return smccc_soc_id_revision; - } -+EXPORT_SYMBOL_GPL(arm_smccc_get_soc_id_revision); - - static int __init smccc_devices_init(void) - { diff --git a/lede/target/linux/sunxi/patches-6.1/018-v6.10-cpufreq-dt-platdev-Blocklist-Allwinner-H616-618-SoCs.patch b/lede/target/linux/sunxi/patches-6.1/018-v6.10-cpufreq-dt-platdev-Blocklist-Allwinner-H616-618-SoCs.patch deleted file mode 100644 index d021aef753..0000000000 --- a/lede/target/linux/sunxi/patches-6.1/018-v6.10-cpufreq-dt-platdev-Blocklist-Allwinner-H616-618-SoCs.patch +++ /dev/null @@ -1,29 +0,0 @@ -From 6ae07744cf334b750762ba881492c0cfba524b38 Mon Sep 17 00:00:00 2001 -From: Martin Botka -Date: Thu, 18 Apr 2024 16:44:02 +0100 -Subject: [PATCH] cpufreq: dt-platdev: Blocklist Allwinner H616/618 SoCs - -The AllWinner H616 SoC will use the (extended) H6 OPP driver, so add -them to the cpufreq-dt blocklist, to not create the device twice. -This also affects the closely related sibling SoCs H618 and H700. - -Signed-off-by: Martin Botka -Signed-off-by: Andre Przywara -Reviewed-by: Jernej Skrabec -Signed-off-by: Viresh Kumar ---- - drivers/cpufreq/cpufreq-dt-platdev.c | 3 +++ - 1 file changed, 3 insertions(+) - ---- a/drivers/cpufreq/cpufreq-dt-platdev.c -+++ b/drivers/cpufreq/cpufreq-dt-platdev.c -@@ -102,6 +102,9 @@ static const struct of_device_id allowli - */ - static const struct of_device_id blocklist[] __initconst = { - { .compatible = "allwinner,sun50i-h6", }, -+ { .compatible = "allwinner,sun50i-h616", }, -+ { .compatible = "allwinner,sun50i-h618", }, -+ { .compatible = "allwinner,sun50i-h700", }, - - { .compatible = "arm,vexpress", }, - diff --git a/lede/target/linux/sunxi/patches-6.1/019-v6.10-cpufreq-sun50i-Refactor-speed-bin-decoding.patch b/lede/target/linux/sunxi/patches-6.1/019-v6.10-cpufreq-sun50i-Refactor-speed-bin-decoding.patch deleted file mode 100644 index 393dd51009..0000000000 --- a/lede/target/linux/sunxi/patches-6.1/019-v6.10-cpufreq-sun50i-Refactor-speed-bin-decoding.patch +++ /dev/null @@ -1,149 +0,0 @@ -From 6cc4bcceff9af0e6be9738096d95e4ba75e75123 Mon Sep 17 00:00:00 2001 -From: Brandon Cheo Fusi -Date: Thu, 18 Apr 2024 16:44:04 +0100 -Subject: [PATCH] cpufreq: sun50i: Refactor speed bin decoding - -Make converting the speed bin value into a speed grade generic and -determined by a platform specific callback. Also change the prototypes -involved to encode the speed bin directly in the return value. - -This allows to extend the driver more easily to support more SoCs. - -Signed-off-by: Brandon Cheo Fusi -[Andre: merge output into return value] -Signed-off-by: Andre Przywara -Reviewed-by: Jernej Skrabec -Signed-off-by: Viresh Kumar ---- - drivers/cpufreq/sun50i-cpufreq-nvmem.c | 74 +++++++++++++++++--------- - 1 file changed, 49 insertions(+), 25 deletions(-) - ---- a/drivers/cpufreq/sun50i-cpufreq-nvmem.c -+++ b/drivers/cpufreq/sun50i-cpufreq-nvmem.c -@@ -24,19 +24,52 @@ - - static struct platform_device *cpufreq_dt_pdev, *sun50i_cpufreq_pdev; - -+struct sunxi_cpufreq_data { -+ u32 (*efuse_xlate)(u32 speedbin); -+}; -+ -+static u32 sun50i_h6_efuse_xlate(u32 speedbin) -+{ -+ u32 efuse_value; -+ -+ efuse_value = (speedbin >> NVMEM_SHIFT) & NVMEM_MASK; -+ -+ /* -+ * We treat unexpected efuse values as if the SoC was from -+ * the slowest bin. Expected efuse values are 1-3, slowest -+ * to fastest. -+ */ -+ if (efuse_value >= 1 && efuse_value <= 3) -+ return efuse_value - 1; -+ else -+ return 0; -+} -+ -+static struct sunxi_cpufreq_data sun50i_h6_cpufreq_data = { -+ .efuse_xlate = sun50i_h6_efuse_xlate, -+}; -+ -+static const struct of_device_id cpu_opp_match_list[] = { -+ { .compatible = "allwinner,sun50i-h6-operating-points", -+ .data = &sun50i_h6_cpufreq_data, -+ }, -+ {} -+}; -+ - /** - * sun50i_cpufreq_get_efuse() - Determine speed grade from efuse value -- * @versions: Set to the value parsed from efuse - * -- * Returns 0 if success. -+ * Returns non-negative speed bin index on success, a negative error -+ * value otherwise. - */ --static int sun50i_cpufreq_get_efuse(u32 *versions) -+static int sun50i_cpufreq_get_efuse(void) - { -+ const struct sunxi_cpufreq_data *opp_data; - struct nvmem_cell *speedbin_nvmem; -+ const struct of_device_id *match; - struct device_node *np; - struct device *cpu_dev; -- u32 *speedbin, efuse_value; -- size_t len; -+ u32 *speedbin; - int ret; - - cpu_dev = get_cpu_device(0); -@@ -47,12 +80,12 @@ static int sun50i_cpufreq_get_efuse(u32 - if (!np) - return -ENOENT; - -- ret = of_device_is_compatible(np, -- "allwinner,sun50i-h6-operating-points"); -- if (!ret) { -+ match = of_match_node(cpu_opp_match_list, np); -+ if (!match) { - of_node_put(np); - return -ENOENT; - } -+ opp_data = match->data; - - speedbin_nvmem = of_nvmem_cell_get(np, NULL); - of_node_put(np); -@@ -60,25 +93,16 @@ static int sun50i_cpufreq_get_efuse(u32 - return dev_err_probe(cpu_dev, PTR_ERR(speedbin_nvmem), - "Could not get nvmem cell\n"); - -- speedbin = nvmem_cell_read(speedbin_nvmem, &len); -+ speedbin = nvmem_cell_read(speedbin_nvmem, NULL); - nvmem_cell_put(speedbin_nvmem); - if (IS_ERR(speedbin)) - return PTR_ERR(speedbin); - -- efuse_value = (*speedbin >> NVMEM_SHIFT) & NVMEM_MASK; -- -- /* -- * We treat unexpected efuse values as if the SoC was from -- * the slowest bin. Expected efuse values are 1-3, slowest -- * to fastest. -- */ -- if (efuse_value >= 1 && efuse_value <= 3) -- *versions = efuse_value - 1; -- else -- *versions = 0; -+ ret = opp_data->efuse_xlate(*speedbin); - - kfree(speedbin); -- return 0; -+ -+ return ret; - }; - - static int sun50i_cpufreq_nvmem_probe(struct platform_device *pdev) -@@ -86,7 +110,7 @@ static int sun50i_cpufreq_nvmem_probe(st - int *opp_tokens; - char name[MAX_NAME_LEN]; - unsigned int cpu; -- u32 speed = 0; -+ int speed; - int ret; - - opp_tokens = kcalloc(num_possible_cpus(), sizeof(*opp_tokens), -@@ -94,10 +118,10 @@ static int sun50i_cpufreq_nvmem_probe(st - if (!opp_tokens) - return -ENOMEM; - -- ret = sun50i_cpufreq_get_efuse(&speed); -- if (ret) { -+ speed = sun50i_cpufreq_get_efuse(); -+ if (speed < 0) { - kfree(opp_tokens); -- return ret; -+ return speed; - } - - snprintf(name, MAX_NAME_LEN, "speed%d", speed); diff --git a/lede/target/linux/sunxi/patches-6.1/020-v6.10-cpufreq-sun50i-Add-support-for-opp_supported_hw.patch b/lede/target/linux/sunxi/patches-6.1/020-v6.10-cpufreq-sun50i-Add-support-for-opp_supported_hw.patch deleted file mode 100644 index e5541593f2..0000000000 --- a/lede/target/linux/sunxi/patches-6.1/020-v6.10-cpufreq-sun50i-Add-support-for-opp_supported_hw.patch +++ /dev/null @@ -1,132 +0,0 @@ -From fa5aec9561cfc4f4370983ca5818c90227c9d90e Mon Sep 17 00:00:00 2001 -From: Andre Przywara -Date: Thu, 18 Apr 2024 16:44:05 +0100 -Subject: [PATCH] cpufreq: sun50i: Add support for opp_supported_hw - -The opp_supported_hw DT property allows the DT to specify a mask of chip -revisions that a certain OPP is eligible for. This allows for easy -limiting of maximum frequencies, for instance. - -Add support for that in the sun50i-cpufreq-nvmem driver. We support both -the existing opp-microvolt suffix properties as well as the -opp-supported-hw property, the generic code figures out which is needed -automatically. -However if none of the DT OPP nodes contain an opp-supported-hw -property, the core code will ignore all OPPs and the driver will fail -probing. So check the DT's eligibility first before using that feature. - -Signed-off-by: Andre Przywara -Reviewed-by: Jernej Skrabec -Signed-off-by: Viresh Kumar ---- - drivers/cpufreq/sun50i-cpufreq-nvmem.c | 62 ++++++++++++++++++++++---- - 1 file changed, 54 insertions(+), 8 deletions(-) - ---- a/drivers/cpufreq/sun50i-cpufreq-nvmem.c -+++ b/drivers/cpufreq/sun50i-cpufreq-nvmem.c -@@ -57,6 +57,41 @@ static const struct of_device_id cpu_opp - }; - - /** -+ * dt_has_supported_hw() - Check if any OPPs use opp-supported-hw -+ * -+ * If we ask the cpufreq framework to use the opp-supported-hw feature, it -+ * will ignore every OPP node without that DT property. If none of the OPPs -+ * have it, the driver will fail probing, due to the lack of OPPs. -+ * -+ * Returns true if we have at least one OPP with the opp-supported-hw property. -+ */ -+static bool dt_has_supported_hw(void) -+{ -+ bool has_opp_supported_hw = false; -+ struct device_node *np, *opp; -+ struct device *cpu_dev; -+ -+ cpu_dev = get_cpu_device(0); -+ if (!cpu_dev) -+ return -ENODEV; -+ -+ np = dev_pm_opp_of_get_opp_desc_node(cpu_dev); -+ if (!np) -+ return -ENOENT; -+ -+ for_each_child_of_node(np, opp) { -+ if (of_find_property(opp, "opp-supported-hw", NULL)) { -+ has_opp_supported_hw = true; -+ break; -+ } -+ } -+ -+ of_node_put(np); -+ -+ return has_opp_supported_hw; -+} -+ -+/** - * sun50i_cpufreq_get_efuse() - Determine speed grade from efuse value - * - * Returns non-negative speed bin index on success, a negative error -@@ -109,7 +144,8 @@ static int sun50i_cpufreq_nvmem_probe(st - { - int *opp_tokens; - char name[MAX_NAME_LEN]; -- unsigned int cpu; -+ unsigned int cpu, supported_hw; -+ struct dev_pm_opp_config config = {}; - int speed; - int ret; - -@@ -124,7 +160,18 @@ static int sun50i_cpufreq_nvmem_probe(st - return speed; - } - -+ /* -+ * We need at least one OPP with the "opp-supported-hw" property, -+ * or else the upper layers will ignore every OPP and will bail out. -+ */ -+ if (dt_has_supported_hw()) { -+ supported_hw = 1U << speed; -+ config.supported_hw = &supported_hw; -+ config.supported_hw_count = 1; -+ } -+ - snprintf(name, MAX_NAME_LEN, "speed%d", speed); -+ config.prop_name = name; - - for_each_possible_cpu(cpu) { - struct device *cpu_dev = get_cpu_device(cpu); -@@ -134,12 +181,11 @@ static int sun50i_cpufreq_nvmem_probe(st - goto free_opp; - } - -- opp_tokens[cpu] = dev_pm_opp_set_prop_name(cpu_dev, name); -- if (opp_tokens[cpu] < 0) { -- ret = opp_tokens[cpu]; -- pr_err("Failed to set prop name\n"); -+ ret = dev_pm_opp_set_config(cpu_dev, &config); -+ if (ret < 0) - goto free_opp; -- } -+ -+ opp_tokens[cpu] = ret; - } - - cpufreq_dt_pdev = platform_device_register_simple("cpufreq-dt", -1, -@@ -154,7 +200,7 @@ static int sun50i_cpufreq_nvmem_probe(st - - free_opp: - for_each_possible_cpu(cpu) -- dev_pm_opp_put_prop_name(opp_tokens[cpu]); -+ dev_pm_opp_clear_config(opp_tokens[cpu]); - kfree(opp_tokens); - - return ret; -@@ -168,7 +214,7 @@ static int sun50i_cpufreq_nvmem_remove(s - platform_device_unregister(cpufreq_dt_pdev); - - for_each_possible_cpu(cpu) -- dev_pm_opp_put_prop_name(opp_tokens[cpu]); -+ dev_pm_opp_clear_config(opp_tokens[cpu]); - - kfree(opp_tokens); - diff --git a/lede/target/linux/sunxi/patches-6.1/021-v6.10-cpufreq-sun50i-Add-H616-support.patch b/lede/target/linux/sunxi/patches-6.1/021-v6.10-cpufreq-sun50i-Add-H616-support.patch deleted file mode 100644 index 4d463fccd1..0000000000 --- a/lede/target/linux/sunxi/patches-6.1/021-v6.10-cpufreq-sun50i-Add-H616-support.patch +++ /dev/null @@ -1,122 +0,0 @@ -From e2e2dcd2e944fe6167cb731864f8a1343f1bbee7 Mon Sep 17 00:00:00 2001 -From: Martin Botka -Date: Thu, 18 Apr 2024 16:44:06 +0100 -Subject: [PATCH] cpufreq: sun50i: Add H616 support - -The Allwinner H616/H618 SoCs have different OPP tables per SoC version -and die revision. The SoC version is stored in NVMEM, as before, though -encoded differently. The die revision is in a different register, in the -SRAM controller. Firmware already exports that value in a standardised -way, through the SMCCC SoCID mechanism. We need both values, as some chips -have the same SoC version, but they don't support the same frequencies and -they get differentiated by the die revision. - -Add the new compatible string and tie the new translation function to -it. This mechanism not only covers the original H616 SoC, but also its -very close sibling SoCs H618 and H700, so add them to the list as well. - -Signed-off-by: Martin Botka -Signed-off-by: Andre Przywara -Signed-off-by: Viresh Kumar ---- - drivers/cpufreq/sun50i-cpufreq-nvmem.c | 67 ++++++++++++++++++++++++++ - 1 file changed, 67 insertions(+) - ---- a/drivers/cpufreq/sun50i-cpufreq-nvmem.c -+++ b/drivers/cpufreq/sun50i-cpufreq-nvmem.c -@@ -10,6 +10,7 @@ - - #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt - -+#include - #include - #include - #include -@@ -45,14 +46,77 @@ static u32 sun50i_h6_efuse_xlate(u32 spe - return 0; - } - -+static int get_soc_id_revision(void) -+{ -+#ifdef CONFIG_HAVE_ARM_SMCCC_DISCOVERY -+ return arm_smccc_get_soc_id_revision(); -+#else -+ return SMCCC_RET_NOT_SUPPORTED; -+#endif -+} -+ -+/* -+ * Judging by the OPP tables in the vendor BSP, the quality order of the -+ * returned speedbin index is 4 -> 0/2 -> 3 -> 1, from worst to best. -+ * 0 and 2 seem identical from the OPP tables' point of view. -+ */ -+static u32 sun50i_h616_efuse_xlate(u32 speedbin) -+{ -+ int ver_bits = get_soc_id_revision(); -+ u32 value = 0; -+ -+ switch (speedbin & 0xffff) { -+ case 0x2000: -+ value = 0; -+ break; -+ case 0x2400: -+ case 0x7400: -+ case 0x2c00: -+ case 0x7c00: -+ if (ver_bits != SMCCC_RET_NOT_SUPPORTED && ver_bits <= 1) { -+ /* ic version A/B */ -+ value = 1; -+ } else { -+ /* ic version C and later version */ -+ value = 2; -+ } -+ break; -+ case 0x5000: -+ case 0x5400: -+ case 0x6000: -+ value = 3; -+ break; -+ case 0x5c00: -+ value = 4; -+ break; -+ case 0x5d00: -+ value = 0; -+ break; -+ default: -+ pr_warn("sun50i-cpufreq-nvmem: unknown speed bin 0x%x, using default bin 0\n", -+ speedbin & 0xffff); -+ value = 0; -+ break; -+ } -+ -+ return value; -+} -+ - static struct sunxi_cpufreq_data sun50i_h6_cpufreq_data = { - .efuse_xlate = sun50i_h6_efuse_xlate, - }; - -+static struct sunxi_cpufreq_data sun50i_h616_cpufreq_data = { -+ .efuse_xlate = sun50i_h616_efuse_xlate, -+}; -+ - static const struct of_device_id cpu_opp_match_list[] = { - { .compatible = "allwinner,sun50i-h6-operating-points", - .data = &sun50i_h6_cpufreq_data, - }, -+ { .compatible = "allwinner,sun50i-h616-operating-points", -+ .data = &sun50i_h616_cpufreq_data, -+ }, - {} - }; - -@@ -231,6 +295,9 @@ static struct platform_driver sun50i_cpu - - static const struct of_device_id sun50i_cpufreq_match_list[] = { - { .compatible = "allwinner,sun50i-h6" }, -+ { .compatible = "allwinner,sun50i-h616" }, -+ { .compatible = "allwinner,sun50i-h618" }, -+ { .compatible = "allwinner,sun50i-h700" }, - {} - }; - MODULE_DEVICE_TABLE(of, sun50i_cpufreq_match_list); diff --git a/lede/target/linux/sunxi/patches-6.1/022-v6.10-arm64-dts-allwinner-h616-Add-CPU-OPPs-table.patch b/lede/target/linux/sunxi/patches-6.1/022-v6.10-arm64-dts-allwinner-h616-Add-CPU-OPPs-table.patch deleted file mode 100644 index 4665286d0f..0000000000 --- a/lede/target/linux/sunxi/patches-6.1/022-v6.10-arm64-dts-allwinner-h616-Add-CPU-OPPs-table.patch +++ /dev/null @@ -1,188 +0,0 @@ -From 3e057e05b3b281bcc29db573eb51f87ee6b5afc0 Mon Sep 17 00:00:00 2001 -From: Martin Botka -Date: Thu, 18 Apr 2024 16:44:07 +0100 -Subject: [PATCH] arm64: dts: allwinner: h616: Add CPU OPPs table - -Add an Operating Performance Points table for the CPU cores to enable -Dynamic Voltage & Frequency Scaling (DVFS) on the H616. -The values were taken from the BSP sources. There is a separate OPP set -seen on some H700 devices, but they didn't really work out in testing, so -they are not included for now. - -Also add the needed cpu_speed_grade nvmem cell and the cooling cells -properties, to enable passive cooling. - -Signed-off-by: Martin Botka -[Andre: rework to minimise opp-microvolt properties] -Signed-off-by: Andre Przywara -Acked-by: Jernej Skrabec -Signed-off-by: Viresh Kumar ---- - .../dts/allwinner/sun50i-h616-cpu-opp.dtsi | 115 ++++++++++++++++++ - .../arm64/boot/dts/allwinner/sun50i-h616.dtsi | 8 ++ - 2 files changed, 123 insertions(+) - create mode 100644 arch/arm64/boot/dts/allwinner/sun50i-h616-cpu-opp.dtsi - ---- /dev/null -+++ b/arch/arm64/boot/dts/allwinner/sun50i-h616-cpu-opp.dtsi -@@ -0,0 +1,115 @@ -+// SPDX-License-Identifier: (GPL-2.0+ OR MIT) -+// Copyright (C) 2023 Martin Botka -+ -+/ { -+ cpu_opp_table: opp-table-cpu { -+ compatible = "allwinner,sun50i-h616-operating-points"; -+ nvmem-cells = <&cpu_speed_grade>; -+ opp-shared; -+ -+ opp-480000000 { -+ opp-hz = /bits/ 64 <480000000>; -+ opp-microvolt = <900000>; -+ clock-latency-ns = <244144>; /* 8 32k periods */ -+ opp-supported-hw = <0x1f>; -+ }; -+ -+ opp-600000000 { -+ opp-hz = /bits/ 64 <600000000>; -+ opp-microvolt = <900000>; -+ clock-latency-ns = <244144>; /* 8 32k periods */ -+ opp-supported-hw = <0x12>; -+ }; -+ -+ opp-720000000 { -+ opp-hz = /bits/ 64 <720000000>; -+ opp-microvolt = <900000>; -+ clock-latency-ns = <244144>; /* 8 32k periods */ -+ opp-supported-hw = <0x0d>; -+ }; -+ -+ opp-792000000 { -+ opp-hz = /bits/ 64 <792000000>; -+ opp-microvolt-speed1 = <900000>; -+ opp-microvolt-speed4 = <940000>; -+ clock-latency-ns = <244144>; /* 8 32k periods */ -+ opp-supported-hw = <0x12>; -+ }; -+ -+ opp-936000000 { -+ opp-hz = /bits/ 64 <936000000>; -+ opp-microvolt = <900000>; -+ clock-latency-ns = <244144>; /* 8 32k periods */ -+ opp-supported-hw = <0x0d>; -+ }; -+ -+ opp-1008000000 { -+ opp-hz = /bits/ 64 <1008000000>; -+ opp-microvolt-speed0 = <950000>; -+ opp-microvolt-speed1 = <940000>; -+ opp-microvolt-speed2 = <950000>; -+ opp-microvolt-speed3 = <950000>; -+ opp-microvolt-speed4 = <1020000>; -+ clock-latency-ns = <244144>; /* 8 32k periods */ -+ opp-supported-hw = <0x1f>; -+ }; -+ -+ opp-1104000000 { -+ opp-hz = /bits/ 64 <1104000000>; -+ opp-microvolt-speed0 = <1000000>; -+ opp-microvolt-speed2 = <1000000>; -+ opp-microvolt-speed3 = <1000000>; -+ clock-latency-ns = <244144>; /* 8 32k periods */ -+ opp-supported-hw = <0x0d>; -+ }; -+ -+ opp-1200000000 { -+ opp-hz = /bits/ 64 <1200000000>; -+ opp-microvolt-speed0 = <1050000>; -+ opp-microvolt-speed1 = <1020000>; -+ opp-microvolt-speed2 = <1050000>; -+ opp-microvolt-speed3 = <1050000>; -+ opp-microvolt-speed4 = <1100000>; -+ clock-latency-ns = <244144>; /* 8 32k periods */ -+ opp-supported-hw = <0x1f>; -+ }; -+ -+ opp-1320000000 { -+ opp-hz = /bits/ 64 <1320000000>; -+ opp-microvolt = <1100000>; -+ clock-latency-ns = <244144>; /* 8 32k periods */ -+ opp-supported-hw = <0x1d>; -+ }; -+ -+ opp-1416000000 { -+ opp-hz = /bits/ 64 <1416000000>; -+ opp-microvolt = <1100000>; -+ clock-latency-ns = <244144>; /* 8 32k periods */ -+ opp-supported-hw = <0x0d>; -+ }; -+ -+ opp-1512000000 { -+ opp-hz = /bits/ 64 <1512000000>; -+ opp-microvolt-speed1 = <1100000>; -+ opp-microvolt-speed3 = <1100000>; -+ clock-latency-ns = <244144>; /* 8 32k periods */ -+ opp-supported-hw = <0x0a>; -+ }; -+ }; -+}; -+ -+&cpu0 { -+ operating-points-v2 = <&cpu_opp_table>; -+}; -+ -+&cpu1 { -+ operating-points-v2 = <&cpu_opp_table>; -+}; -+ -+&cpu2 { -+ operating-points-v2 = <&cpu_opp_table>; -+}; -+ -+&cpu3 { -+ operating-points-v2 = <&cpu_opp_table>; -+}; ---- a/arch/arm64/boot/dts/allwinner/sun50i-h616.dtsi -+++ b/arch/arm64/boot/dts/allwinner/sun50i-h616.dtsi -@@ -26,6 +26,7 @@ - reg = <0>; - enable-method = "psci"; - clocks = <&ccu CLK_CPUX>; -+ #cooling-cells = <2>; - }; - - cpu1: cpu@1 { -@@ -34,6 +35,7 @@ - reg = <1>; - enable-method = "psci"; - clocks = <&ccu CLK_CPUX>; -+ #cooling-cells = <2>; - }; - - cpu2: cpu@2 { -@@ -42,6 +44,7 @@ - reg = <2>; - enable-method = "psci"; - clocks = <&ccu CLK_CPUX>; -+ #cooling-cells = <2>; - }; - - cpu3: cpu@3 { -@@ -50,6 +53,7 @@ - reg = <3>; - enable-method = "psci"; - clocks = <&ccu CLK_CPUX>; -+ #cooling-cells = <2>; - }; - }; - -@@ -143,6 +147,10 @@ - ths_calibration: thermal-sensor-calibration@14 { - reg = <0x14 0x8>; - }; -+ -+ cpu_speed_grade: cpu-speed-grade@0 { -+ reg = <0x0 2>; -+ }; - }; - - watchdog: watchdog@30090a0 { diff --git a/lede/target/linux/sunxi/patches-6.1/023-v6.10-arm64-dts-allwinner-h616-enable-DVFS-for-all-boards.patch b/lede/target/linux/sunxi/patches-6.1/023-v6.10-arm64-dts-allwinner-h616-enable-DVFS-for-all-boards.patch deleted file mode 100644 index 677b5f07b2..0000000000 --- a/lede/target/linux/sunxi/patches-6.1/023-v6.10-arm64-dts-allwinner-h616-enable-DVFS-for-all-boards.patch +++ /dev/null @@ -1,86 +0,0 @@ -From 09d0aaa0ae9c80ff9569393b206226c1008801b1 Mon Sep 17 00:00:00 2001 -From: Andre Przywara -Date: Thu, 18 Apr 2024 16:44:08 +0100 -Subject: [PATCH] arm64: dts: allwinner: h616: enable DVFS for all boards - -With the DT bindings now describing the format of the CPU OPP tables, we -can include the OPP table in each board's .dts file, and specify the CPU -power supply. -This allows to enable DVFS, and get up to 50% of performance benefit in -the highest OPP, or up to 60% power savings in the lowest OPP, compared -to the fixed 1GHz @ 1.0V OPP we are running in by default at the moment. - -Signed-off-by: Andre Przywara -Acked-by: Jernej Skrabec -Signed-off-by: Viresh Kumar ---- - .../boot/dts/allwinner/sun50i-h616-bigtreetech-cb1.dtsi | 5 +++++ - arch/arm64/boot/dts/allwinner/sun50i-h616-orangepi-zero2.dts | 5 +++++ - arch/arm64/boot/dts/allwinner/sun50i-h616-x96-mate.dts | 5 +++++ - .../boot/dts/allwinner/sun50i-h618-longan-module-3h.dtsi | 5 +++++ - .../arm64/boot/dts/allwinner/sun50i-h618-orangepi-zero2w.dts | 5 +++++ - arch/arm64/boot/dts/allwinner/sun50i-h618-orangepi-zero3.dts | 5 +++++ - .../boot/dts/allwinner/sun50i-h618-transpeed-8k618-t.dts | 5 +++++ - 7 files changed, 35 insertions(+) - ---- a/arch/arm64/boot/dts/allwinner/sun50i-h616-orangepi-zero2.dts -+++ b/arch/arm64/boot/dts/allwinner/sun50i-h616-orangepi-zero2.dts -@@ -6,12 +6,17 @@ - /dts-v1/; - - #include "sun50i-h616-orangepi-zero.dtsi" -+#include "sun50i-h616-cpu-opp.dtsi" - - / { - model = "OrangePi Zero2"; - compatible = "xunlong,orangepi-zero2", "allwinner,sun50i-h616"; - }; - -+&cpu0 { -+ cpu-supply = <®_dcdca>; -+}; -+ - &emac0 { - allwinner,rx-delay-ps = <3100>; - allwinner,tx-delay-ps = <700>; ---- a/arch/arm64/boot/dts/allwinner/sun50i-h616-x96-mate.dts -+++ b/arch/arm64/boot/dts/allwinner/sun50i-h616-x96-mate.dts -@@ -6,6 +6,7 @@ - /dts-v1/; - - #include "sun50i-h616.dtsi" -+#include "sun50i-h616-cpu-opp.dtsi" - - #include - #include -@@ -32,6 +33,10 @@ - }; - }; - -+&cpu0 { -+ cpu-supply = <®_dcdca>; -+}; -+ - &ir { - status = "okay"; - }; ---- a/arch/arm64/boot/dts/allwinner/sun50i-h618-orangepi-zero3.dts -+++ b/arch/arm64/boot/dts/allwinner/sun50i-h618-orangepi-zero3.dts -@@ -6,12 +6,17 @@ - /dts-v1/; - - #include "sun50i-h616-orangepi-zero.dtsi" -+#include "sun50i-h616-cpu-opp.dtsi" - - / { - model = "OrangePi Zero3"; - compatible = "xunlong,orangepi-zero3", "allwinner,sun50i-h618"; - }; - -+&cpu0 { -+ cpu-supply = <®_dcdc2>; -+}; -+ - &emac0 { - allwinner,tx-delay-ps = <700>; - phy-mode = "rgmii-rxid"; diff --git a/lede/target/linux/sunxi/patches-6.1/024-v6.10-cpufreq-sun50i-Fix-build-warning-around-snprint.patch b/lede/target/linux/sunxi/patches-6.1/024-v6.10-cpufreq-sun50i-Fix-build-warning-around-snprint.patch deleted file mode 100644 index e6ec888779..0000000000 --- a/lede/target/linux/sunxi/patches-6.1/024-v6.10-cpufreq-sun50i-Fix-build-warning-around-snprint.patch +++ /dev/null @@ -1,51 +0,0 @@ -From d2059d3b548409905b20b4f52495bffbd7c8da8b Mon Sep 17 00:00:00 2001 -From: Viresh Kumar -Date: Mon, 22 Apr 2024 08:58:51 +0530 -Subject: [PATCH] cpufreq: sun50i: Fix build warning around snprint() - -The Sun50i driver generates a warning with W=1: - -warning: '%d' directive output may be truncated writing between 1 and 10 bytes into a region of size 2 [-Wformat-truncation=] - -Fix it by allocating a big enough array to print an integer. - -Reported-by: kernel test robot -Closes: https://lore.kernel.org/oe-kbuild-all/202404191715.LDwMm2gP-lkp@intel.com/ -Signed-off-by: Viresh Kumar -Acked-by: Chen-Yu Tsai -Reviewed-by: Andre Przywara -Tested-by: Andre Przywara -Reviewed-by: Julian Calaby ---- - drivers/cpufreq/sun50i-cpufreq-nvmem.c | 6 ++---- - 1 file changed, 2 insertions(+), 4 deletions(-) - ---- a/drivers/cpufreq/sun50i-cpufreq-nvmem.c -+++ b/drivers/cpufreq/sun50i-cpufreq-nvmem.c -@@ -18,8 +18,6 @@ - #include - #include - --#define MAX_NAME_LEN 7 -- - #define NVMEM_MASK 0x7 - #define NVMEM_SHIFT 5 - -@@ -207,7 +205,7 @@ static int sun50i_cpufreq_get_efuse(void - static int sun50i_cpufreq_nvmem_probe(struct platform_device *pdev) - { - int *opp_tokens; -- char name[MAX_NAME_LEN]; -+ char name[] = "speedXXXXXXXXXXX"; /* Integers can take 11 chars max */ - unsigned int cpu, supported_hw; - struct dev_pm_opp_config config = {}; - int speed; -@@ -234,7 +232,7 @@ static int sun50i_cpufreq_nvmem_probe(st - config.supported_hw_count = 1; - } - -- snprintf(name, MAX_NAME_LEN, "speed%d", speed); -+ snprintf(name, sizeof(name), "speed%d", speed); - config.prop_name = name; - - for_each_possible_cpu(cpu) { diff --git a/lede/target/linux/sunxi/patches-6.1/025-v6.10-cpufreq-sun50i-fix-error-returns-in-dt_has_supported_hw.patch b/lede/target/linux/sunxi/patches-6.1/025-v6.10-cpufreq-sun50i-fix-error-returns-in-dt_has_supported_hw.patch deleted file mode 100644 index 65cc1fde4f..0000000000 --- a/lede/target/linux/sunxi/patches-6.1/025-v6.10-cpufreq-sun50i-fix-error-returns-in-dt_has_supported_hw.patch +++ /dev/null @@ -1,34 +0,0 @@ -From 76a6fc5644b2a1c70868bec24a078f784600ef2a Mon Sep 17 00:00:00 2001 -From: Dan Carpenter -Date: Wed, 24 Apr 2024 14:40:11 +0300 -Subject: [PATCH] cpufreq: sun50i: fix error returns in dt_has_supported_hw() - -The dt_has_supported_hw() function returns type bool. That means these -negative error codes are cast to true but the function should return -false instead. - -Fixes: fa5aec9561cf ("cpufreq: sun50i: Add support for opp_supported_hw") -Signed-off-by: Dan Carpenter -Reviewed-by: Andre Przywara -Reviewed-by: Jernej Skrabec -Signed-off-by: Viresh Kumar ---- - drivers/cpufreq/sun50i-cpufreq-nvmem.c | 4 ++-- - 1 file changed, 2 insertions(+), 2 deletions(-) - ---- a/drivers/cpufreq/sun50i-cpufreq-nvmem.c -+++ b/drivers/cpufreq/sun50i-cpufreq-nvmem.c -@@ -135,11 +135,11 @@ static bool dt_has_supported_hw(void) - - cpu_dev = get_cpu_device(0); - if (!cpu_dev) -- return -ENODEV; -+ return false; - - np = dev_pm_opp_of_get_opp_desc_node(cpu_dev); - if (!np) -- return -ENOENT; -+ return false; - - for_each_child_of_node(np, opp) { - if (of_find_property(opp, "opp-supported-hw", NULL)) { diff --git a/lede/target/linux/sunxi/patches-6.1/101-sunxi-add-get_soc_chipid-and-sunxi_get_serial.patch b/lede/target/linux/sunxi/patches-6.1/101-sunxi-add-get_soc_chipid-and-sunxi_get_serial.patch deleted file mode 100644 index dcba61ba97..0000000000 --- a/lede/target/linux/sunxi/patches-6.1/101-sunxi-add-get_soc_chipid-and-sunxi_get_serial.patch +++ /dev/null @@ -1,53 +0,0 @@ -From caaa7def76801cbe9937602603f6b471f776e6f6 Mon Sep 17 00:00:00 2001 -From: The-going <48602507+The-going@users.noreply.github.com> -Date: Sat, 16 Apr 2022 11:19:05 +0300 -Subject: [PATCH] nvmem: sunxi_sid: add sunxi_get_soc_chipid, sunxi_get_serial - ---- - drivers/nvmem/sunxi_sid.c | 28 ++++++++++++++++++++++++++++ - 1 file changed, 28 insertions(+) - ---- a/drivers/nvmem/sunxi_sid.c -+++ b/drivers/nvmem/sunxi_sid.c -@@ -37,6 +37,25 @@ struct sunxi_sid { - u32 value_offset; - }; - -+static unsigned int sunxi_soc_chipid[4]; -+static unsigned int sunxi_serial[4]; -+ -+int sunxi_get_soc_chipid(unsigned char *chipid) -+{ -+ memcpy(chipid, sunxi_soc_chipid, 16); -+ -+ return 0; -+} -+EXPORT_SYMBOL(sunxi_get_soc_chipid); -+ -+int sunxi_get_serial(unsigned char *serial) -+{ -+ memcpy(serial, sunxi_serial, 16); -+ -+ return 0; -+} -+EXPORT_SYMBOL(sunxi_get_serial); -+ - static int sunxi_sid_read(void *context, unsigned int offset, - void *val, size_t bytes) - { -@@ -179,6 +198,15 @@ static int sunxi_sid_probe(struct platfo - - platform_set_drvdata(pdev, nvmem); - -+ nvmem_cfg->reg_read(sid, 0, &sunxi_soc_chipid[0], sizeof(int)); -+ nvmem_cfg->reg_read(sid, 4, &sunxi_soc_chipid[1], sizeof(int)); -+ nvmem_cfg->reg_read(sid, 8, &sunxi_soc_chipid[2], sizeof(int)); -+ nvmem_cfg->reg_read(sid, 12, &sunxi_soc_chipid[3], sizeof(int)); -+ -+ sunxi_serial[0] = sunxi_soc_chipid[3]; -+ sunxi_serial[1] = sunxi_soc_chipid[2]; -+ sunxi_serial[2] = (sunxi_soc_chipid[1] >> 16) & 0x0ffff; -+ - return 0; - } - diff --git a/lede/target/linux/sunxi/patches-6.1/460-ARM-dts-suniv-add-USB-related-device-nodes.patch b/lede/target/linux/sunxi/patches-6.1/460-ARM-dts-suniv-add-USB-related-device-nodes.patch deleted file mode 100644 index 86bc2e25f5..0000000000 --- a/lede/target/linux/sunxi/patches-6.1/460-ARM-dts-suniv-add-USB-related-device-nodes.patch +++ /dev/null @@ -1,35 +0,0 @@ ---- a/arch/arm/boot/dts/suniv-f1c100s.dtsi -+++ b/arch/arm/boot/dts/suniv-f1c100s.dtsi -@@ -133,6 +133,32 @@ - #size-cells = <0>; - }; - -+ usb_otg: usb@1c13000 { -+ compatible = "allwinner,suniv-f1c100s-musb"; -+ reg = <0x01c13000 0x0400>; -+ clocks = <&ccu CLK_BUS_OTG>; -+ resets = <&ccu RST_BUS_OTG>; -+ interrupts = <26>; -+ interrupt-names = "mc"; -+ phys = <&usbphy 0>; -+ phy-names = "usb"; -+ extcon = <&usbphy 0>; -+ allwinner,sram = <&otg_sram 1>; -+ status = "disabled"; -+ }; -+ -+ usbphy: phy@1c13400 { -+ compatible = "allwinner,suniv-f1c100s-usb-phy"; -+ reg = <0x01c13400 0x10>; -+ reg-names = "phy_ctrl"; -+ clocks = <&ccu CLK_USB_PHY0>; -+ clock-names = "usb0_phy"; -+ resets = <&ccu RST_USB_PHY0>; -+ reset-names = "usb0_reset"; -+ #phy-cells = <1>; -+ status = "disabled"; -+ }; -+ - ccu: clock@1c20000 { - compatible = "allwinner,suniv-f1c100s-ccu"; - reg = <0x01c20000 0x400>; diff --git a/lede/target/linux/sunxi/patches-6.1/461-ARM-dts-suniv-add-device-tree-for-PopStick-v1_1.patch b/lede/target/linux/sunxi/patches-6.1/461-ARM-dts-suniv-add-device-tree-for-PopStick-v1_1.patch deleted file mode 100644 index 1030494cee..0000000000 --- a/lede/target/linux/sunxi/patches-6.1/461-ARM-dts-suniv-add-device-tree-for-PopStick-v1_1.patch +++ /dev/null @@ -1,123 +0,0 @@ -From 7452d4799c5b352d6987cff3db8b1e415466586e Mon Sep 17 00:00:00 2001 -From: Icenowy Zheng -Date: Sun, 19 Mar 2023 21:29:35 +0000 -Subject: ARM: dts: suniv: add device tree for PopStick v1.1 - -PopStick is a minimal Allwinner F1C200s dongle, with its USB controller -wired to a USB Type-A plug, a SD slot and a SPI NAND flash on board, and -an on-board CH340 USB-UART converted connected to F1C200s's UART0. - -Add a device tree for it. As F1C200s is just F1C100s with a different -DRAM chip co-packaged, directly use F1C100s DTSI here. - -This commit covers the v1.1 version of this board, which is now shipped. -v1.0 is some internal sample that have not been shipped at all. - -Signed-off-by: Icenowy Zheng -Signed-off-by: Andre Przywara -Acked-by: Jernej Skrabec -Link: https://lore.kernel.org/r/20230319212936.26649-6-andre.przywara@arm.com -Signed-off-by: Jernej Skrabec ---- - arch/arm/boot/dts/suniv-f1c200s-popstick-v1.1.dts | 81 +++++++++++++++++++++++ - 1 file changed, 81 insertions(+) - create mode 100644 arch/arm/boot/dts/suniv-f1c200s-popstick-v1.1.dts - -(limited to 'arch/arm/boot/dts/suniv-f1c200s-popstick-v1.1.dts') - ---- /dev/null -+++ b/arch/arm/boot/dts/suniv-f1c200s-popstick-v1.1.dts -@@ -0,0 +1,81 @@ -+// SPDX-License-Identifier: (GPL-2.0+ OR MIT) -+/* -+ * Copyright 2022 Icenowy Zheng -+ */ -+ -+/dts-v1/; -+#include "suniv-f1c100s.dtsi" -+ -+#include -+#include -+ -+/ { -+ model = "Popcorn Computer PopStick v1.1"; -+ compatible = "sourceparts,popstick-v1.1", "sourceparts,popstick", -+ "allwinner,suniv-f1c200s", "allwinner,suniv-f1c100s"; -+ -+ aliases { -+ serial0 = &uart0; -+ }; -+ -+ chosen { -+ stdout-path = "serial0:115200n8"; -+ }; -+ -+ leds { -+ compatible = "gpio-leds"; -+ -+ led { -+ function = LED_FUNCTION_STATUS; -+ color = ; -+ gpios = <&pio 4 6 GPIO_ACTIVE_HIGH>; /* PE6 */ -+ linux,default-trigger = "heartbeat"; -+ }; -+ }; -+ -+ reg_vcc3v3: regulator-3v3 { -+ compatible = "regulator-fixed"; -+ regulator-name = "vcc3v3"; -+ regulator-min-microvolt = <3300000>; -+ regulator-max-microvolt = <3300000>; -+ }; -+}; -+ -+&mmc0 { -+ cd-gpios = <&pio 4 3 GPIO_ACTIVE_LOW>; /* PE3 */ -+ bus-width = <4>; -+ disable-wp; -+ vmmc-supply = <®_vcc3v3>; -+ status = "okay"; -+}; -+ -+&otg_sram { -+ status = "okay"; -+}; -+ -+&spi0 { -+ pinctrl-names = "default"; -+ pinctrl-0 = <&spi0_pc_pins>; -+ status = "okay"; -+ -+ flash@0 { -+ compatible = "spi-nand"; -+ reg = <0>; -+ spi-max-frequency = <40000000>; -+ }; -+}; -+ -+&uart0 { -+ pinctrl-names = "default"; -+ pinctrl-0 = <&uart0_pe_pins>; -+ status = "okay"; -+}; -+ -+&usb_otg { -+ dr_mode = "peripheral"; -+ status = "okay"; -+}; -+ -+&usbphy { -+ status = "okay"; -+}; ---- a/arch/arm/boot/dts/Makefile -+++ b/arch/arm/boot/dts/Makefile -@@ -1396,7 +1396,8 @@ dtb-$(CONFIG_MACH_SUN9I) += \ - sun9i-a80-optimus.dtb \ - sun9i-a80-cubieboard4.dtb - dtb-$(CONFIG_MACH_SUNIV) += \ -- suniv-f1c100s-licheepi-nano.dtb -+ suniv-f1c100s-licheepi-nano.dtb \ -+ suniv-f1c200s-popstick-v1.1.dtb - dtb-$(CONFIG_ARCH_TEGRA_2x_SOC) += \ - tegra20-acer-a500-picasso.dtb \ - tegra20-asus-tf101.dtb \ diff --git a/lede/target/linux/sunxi/patches-6.1/462-ARM-dts-suniv-licheepi-nano-enable-USB.patch b/lede/target/linux/sunxi/patches-6.1/462-ARM-dts-suniv-licheepi-nano-enable-USB.patch deleted file mode 100644 index f925d6de38..0000000000 --- a/lede/target/linux/sunxi/patches-6.1/462-ARM-dts-suniv-licheepi-nano-enable-USB.patch +++ /dev/null @@ -1,55 +0,0 @@ -From bedc7c5490fce4e57b55e025b4adfbd31f25623d Mon Sep 17 00:00:00 2001 -From: Icenowy Zheng -Date: Sun, 19 Mar 2023 21:29:32 +0000 -Subject: ARM: dts: suniv: licheepi-nano: enable USB - -Lichee Pi Nano has a Micro-USB connector, with its D+, D- pins connected -to the USB pins of the SoC and ID pin connected to PE2 GPIO. - -Enable the USB functionality. - -Signed-off-by: Icenowy Zheng -Acked-by: Jernej Skrabec -Signed-off-by: Andre Przywara -Link: https://lore.kernel.org/r/20230319212936.26649-3-andre.przywara@arm.com -Signed-off-by: Jernej Skrabec ---- - arch/arm/boot/dts/suniv-f1c100s-licheepi-nano.dts | 16 ++++++++++++++++ - 1 file changed, 16 insertions(+) - -(limited to 'arch/arm/boot/dts/suniv-f1c100s-licheepi-nano.dts') - ---- a/arch/arm/boot/dts/suniv-f1c100s-licheepi-nano.dts -+++ b/arch/arm/boot/dts/suniv-f1c100s-licheepi-nano.dts -@@ -6,6 +6,8 @@ - /dts-v1/; - #include "suniv-f1c100s.dtsi" - -+#include -+ - / { - model = "Lichee Pi Nano"; - compatible = "licheepi,licheepi-nano", "allwinner,suniv-f1c100s"; -@@ -50,8 +52,22 @@ - }; - }; - -+&otg_sram { -+ status = "okay"; -+}; -+ - &uart0 { - pinctrl-names = "default"; - pinctrl-0 = <&uart0_pe_pins>; - status = "okay"; - }; -+ -+&usb_otg { -+ dr_mode = "otg"; -+ status = "okay"; -+}; -+ -+&usbphy { -+ usb0_id_det-gpios = <&pio 4 2 GPIO_ACTIVE_HIGH>; /* PE2 */ -+ status = "okay"; -+}; diff --git a/lede/target/linux/sunxi/patches-6.1/463-f1c100s-sram-driver.patch b/lede/target/linux/sunxi/patches-6.1/463-f1c100s-sram-driver.patch deleted file mode 100644 index 5a6750cd00..0000000000 --- a/lede/target/linux/sunxi/patches-6.1/463-f1c100s-sram-driver.patch +++ /dev/null @@ -1,33 +0,0 @@ -Allwinner ARMv5 F1C100s has similar sram controller to sun4i A10 -Add compatible strings for it. - -Signed-off-by: Mesih Kilinc -Acked-by: Maxime Ripard ---- - drivers/soc/sunxi/sunxi_sram.c | 8 ++++++++ - 1 file changed, 8 insertions(+) - ---- a/drivers/soc/sunxi/sunxi_sram.c -+++ b/drivers/soc/sunxi/sunxi_sram.c -@@ -99,6 +99,10 @@ static const struct of_device_id sunxi_s - .compatible = "allwinner,sun50i-a64-sram-c", - .data = &sun50i_a64_sram_c.data, - }, -+ { -+ .compatible = "allwinner,suniv-f1c100s-sram-d", -+ .data = &sun4i_a10_sram_d.data, -+ }, - {} - }; - -@@ -429,6 +433,10 @@ static const struct of_device_id sunxi_s - .compatible = "allwinner,sun50i-h616-system-control", - .data = &sun50i_h616_sramc_variant, - }, -+ { -+ .compatible = "allwinner,suniv-f1c100s-system-control", -+ .data = &sun4i_a10_sramc_variant, -+ }, - { }, - }; - MODULE_DEVICE_TABLE(of, sunxi_sram_dt_match); diff --git a/lede/target/linux/sunxi/patches-6.1/464-f1c100s-watchdog-compat.patch b/lede/target/linux/sunxi/patches-6.1/464-f1c100s-watchdog-compat.patch deleted file mode 100644 index 0bd090636c..0000000000 --- a/lede/target/linux/sunxi/patches-6.1/464-f1c100s-watchdog-compat.patch +++ /dev/null @@ -1,18 +0,0 @@ -Allwinner ARMv5 F1C100s has similar watchdog timer to sun6i A31. -Add compatible string for it. - -Signed-off-by: Mesih Kilinc ---- - drivers/watchdog/sunxi_wdt.c | 1 + - 1 file changed, 1 insertion(+) - ---- a/drivers/watchdog/sunxi_wdt.c -+++ b/drivers/watchdog/sunxi_wdt.c -@@ -241,6 +241,7 @@ static const struct of_device_id sunxi_w - { .compatible = "allwinner,sun4i-a10-wdt", .data = &sun4i_wdt_reg }, - { .compatible = "allwinner,sun6i-a31-wdt", .data = &sun6i_wdt_reg }, - { .compatible = "allwinner,sun20i-d1-wdt", .data = &sun20i_wdt_reg }, -+ { .compatible = "allwinner,suniv-f1c100s-wdt", .data = &sun6i_wdt_reg }, - { /* sentinel */ } - }; - MODULE_DEVICE_TABLE(of, sunxi_wdt_dt_ids); diff --git a/lede/target/linux/sunxi/patches-6.1/102-sunxi-add-OF-node-for-USB-eth-on-NanoPi-R1S-H5.patch b/lede/target/linux/sunxi/patches-6.12/102-sunxi-add-OF-node-for-USB-eth-on-NanoPi-R1S-H5.patch similarity index 100% rename from lede/target/linux/sunxi/patches-6.1/102-sunxi-add-OF-node-for-USB-eth-on-NanoPi-R1S-H5.patch rename to lede/target/linux/sunxi/patches-6.12/102-sunxi-add-OF-node-for-USB-eth-on-NanoPi-R1S-H5.patch diff --git a/lede/target/linux/sunxi/patches-6.1/301-orangepi_pc2_usb_otg_to_host_key_power.patch b/lede/target/linux/sunxi/patches-6.12/301-orangepi_pc2_usb_otg_to_host_key_power.patch similarity index 90% rename from lede/target/linux/sunxi/patches-6.1/301-orangepi_pc2_usb_otg_to_host_key_power.patch rename to lede/target/linux/sunxi/patches-6.12/301-orangepi_pc2_usb_otg_to_host_key_power.patch index 2c5ccd7d96..eea47737fa 100644 --- a/lede/target/linux/sunxi/patches-6.1/301-orangepi_pc2_usb_otg_to_host_key_power.patch +++ b/lede/target/linux/sunxi/patches-6.12/301-orangepi_pc2_usb_otg_to_host_key_power.patch @@ -1,6 +1,6 @@ --- a/arch/arm64/boot/dts/allwinner/sun50i-h5-orangepi-pc2.dts +++ b/arch/arm64/boot/dts/allwinner/sun50i-h5-orangepi-pc2.dts -@@ -59,7 +59,7 @@ +@@ -60,7 +60,7 @@ key-sw4 { label = "sw4"; @@ -9,7 +9,7 @@ gpios = <&r_pio 0 3 GPIO_ACTIVE_LOW>; wakeup-source; }; -@@ -220,7 +220,7 @@ +@@ -221,7 +221,7 @@ }; &usb_otg { diff --git a/lede/target/linux/sunxi/patches-6.1/400-arm64-allwinner-a64-sopine-Add-Sopine-flash-partitio.patch b/lede/target/linux/sunxi/patches-6.12/400-arm64-allwinner-a64-sopine-Add-Sopine-flash-partitio.patch similarity index 100% rename from lede/target/linux/sunxi/patches-6.1/400-arm64-allwinner-a64-sopine-Add-Sopine-flash-partitio.patch rename to lede/target/linux/sunxi/patches-6.12/400-arm64-allwinner-a64-sopine-Add-Sopine-flash-partitio.patch diff --git a/lede/target/linux/sunxi/patches-6.1/410-sunxi-add-bananapi-p2-zero.patch b/lede/target/linux/sunxi/patches-6.12/410-sunxi-add-bananapi-p2-zero.patch similarity index 95% rename from lede/target/linux/sunxi/patches-6.1/410-sunxi-add-bananapi-p2-zero.patch rename to lede/target/linux/sunxi/patches-6.12/410-sunxi-add-bananapi-p2-zero.patch index 5b8dd170c5..eed2f0feff 100644 --- a/lede/target/linux/sunxi/patches-6.1/410-sunxi-add-bananapi-p2-zero.patch +++ b/lede/target/linux/sunxi/patches-6.12/410-sunxi-add-bananapi-p2-zero.patch @@ -1,6 +1,6 @@ ---- a/arch/arm/boot/dts/Makefile -+++ b/arch/arm/boot/dts/Makefile -@@ -1352,6 +1352,7 @@ dtb-$(CONFIG_MACH_SUN8I) += \ +--- a/arch/arm/boot/dts/allwinner/Makefile ++++ b/arch/arm/boot/dts/allwinner/Makefile +@@ -220,6 +220,7 @@ dtb-$(CONFIG_MACH_SUN8I) += \ sun8i-a83t-cubietruck-plus.dtb \ sun8i-a83t-tbs-a711.dtb \ sun8i-h2-plus-bananapi-m2-zero.dtb \ @@ -9,7 +9,7 @@ sun8i-h2-plus-orangepi-r1.dtb \ sun8i-h2-plus-orangepi-zero.dtb \ --- /dev/null -+++ b/arch/arm/boot/dts/sun8i-h2-plus-bananapi-p2-zero.dts ++++ b/arch/arm/boot/dts/allwinner/sun8i-h2-plus-bananapi-p2-zero.dts @@ -0,0 +1,279 @@ +// SPDX-License-Identifier: (GPL-2.0+ OR MIT) +/* @@ -94,7 +94,7 @@ + regulator-always-on; + regulator-boot-on; + enable-active-high; -+ gpio = <&r_pio 0 9 GPIO_ACTIVE_HIGH>; /* PL9 */ ++ gpios = <&r_pio 0 9 GPIO_ACTIVE_HIGH>; /* PL9 */ + vin-supply = <®_vcc5v0>; + }; + @@ -106,7 +106,7 @@ + regulator-always-on; + regulator-boot-on; + enable-active-high; -+ gpio = <&r_pio 0 8 GPIO_ACTIVE_HIGH>; /* PL8 */ ++ gpios = <&r_pio 0 8 GPIO_ACTIVE_HIGH>; /* PL8 */ + vin-supply = <®_vcc5v0>; + }; + diff --git a/lede/target/linux/sunxi/patches-6.1/430-arm64-dts-allwinner-a64-olinuxino-add-status-LED-ali.patch b/lede/target/linux/sunxi/patches-6.12/430-arm64-dts-allwinner-a64-olinuxino-add-status-LED-ali.patch similarity index 100% rename from lede/target/linux/sunxi/patches-6.1/430-arm64-dts-allwinner-a64-olinuxino-add-status-LED-ali.patch rename to lede/target/linux/sunxi/patches-6.12/430-arm64-dts-allwinner-a64-olinuxino-add-status-LED-ali.patch diff --git a/lede/target/linux/sunxi/patches-6.12/431-arm64-dts-allwinner-nanopi-r1s-h5-add-status-LED.patch b/lede/target/linux/sunxi/patches-6.12/431-arm64-dts-allwinner-nanopi-r1s-h5-add-status-LED.patch new file mode 100644 index 0000000000..ac28108304 --- /dev/null +++ b/lede/target/linux/sunxi/patches-6.12/431-arm64-dts-allwinner-nanopi-r1s-h5-add-status-LED.patch @@ -0,0 +1,23 @@ +--- a/arch/arm64/boot/dts/allwinner/sun50i-h5-nanopi-r1s-h5.dts ++++ b/arch/arm64/boot/dts/allwinner/sun50i-h5-nanopi-r1s-h5.dts +@@ -23,6 +23,11 @@ + ethernet0 = &emac; + ethernet1 = &rtl8189etv; + serial0 = &uart0; ++ ++ led-boot = &led_sys; ++ led-failsafe = &led_sys; ++ led-running = &led_sys; ++ led-upgrade = &led_sys; + }; + + chosen { +@@ -38,7 +43,7 @@ + gpios = <&pio 0 9 GPIO_ACTIVE_HIGH>; + }; + +- led-1 { ++ led_sys: led-1 { + function = LED_FUNCTION_STATUS; + color = ; + gpios = <&pio 0 10 GPIO_ACTIVE_HIGH>; diff --git a/lede/target/linux/sunxi/patches-6.1/440-arm64-dts-allwinner-h616-fix-cpu-max-freq.patch b/lede/target/linux/sunxi/patches-6.12/440-arm64-dts-allwinner-h616-fix-cpu-max-freq.patch similarity index 74% rename from lede/target/linux/sunxi/patches-6.1/440-arm64-dts-allwinner-h616-fix-cpu-max-freq.patch rename to lede/target/linux/sunxi/patches-6.12/440-arm64-dts-allwinner-h616-fix-cpu-max-freq.patch index cba21954ee..e572c363b4 100644 --- a/lede/target/linux/sunxi/patches-6.1/440-arm64-dts-allwinner-h616-fix-cpu-max-freq.patch +++ b/lede/target/linux/sunxi/patches-6.12/440-arm64-dts-allwinner-h616-fix-cpu-max-freq.patch @@ -1,15 +1,16 @@ --- a/arch/arm64/boot/dts/allwinner/sun50i-h616-cpu-opp.dtsi +++ b/arch/arm64/boot/dts/allwinner/sun50i-h616-cpu-opp.dtsi -@@ -90,10 +90,9 @@ +@@ -100,11 +100,9 @@ opp-1512000000 { opp-hz = /bits/ 64 <1512000000>; - opp-microvolt-speed1 = <1100000>; - opp-microvolt-speed3 = <1100000>; +- opp-microvolt-speed5 = <1160000>; + opp-microvolt = <1100000>; clock-latency-ns = <244144>; /* 8 32k periods */ -- opp-supported-hw = <0x0a>; -+ opp-supported-hw = <0x09>; +- opp-supported-hw = <0x2a>; ++ opp-supported-hw = <0x2b>; }; }; }; diff --git a/lede/target/linux/sunxi/patches-6.1/442-arm64-dts-orangepi-one-plus-enable-PWM.patch b/lede/target/linux/sunxi/patches-6.12/442-arm64-dts-orangepi-one-plus-enable-PWM.patch similarity index 100% rename from lede/target/linux/sunxi/patches-6.1/442-arm64-dts-orangepi-one-plus-enable-PWM.patch rename to lede/target/linux/sunxi/patches-6.12/442-arm64-dts-orangepi-one-plus-enable-PWM.patch diff --git a/lede/target/linux/sunxi/patches-6.1/450-arm64-dts-enable-wifi-on-pine64-boards.patch b/lede/target/linux/sunxi/patches-6.12/450-arm64-dts-enable-wifi-on-pine64-boards.patch similarity index 100% rename from lede/target/linux/sunxi/patches-6.1/450-arm64-dts-enable-wifi-on-pine64-boards.patch rename to lede/target/linux/sunxi/patches-6.12/450-arm64-dts-enable-wifi-on-pine64-boards.patch diff --git a/lede/target/linux/sunxi/patches-6.12/451-sunxi-add-csi-video-support-for-nanopi-neo-air.patch b/lede/target/linux/sunxi/patches-6.12/451-sunxi-add-csi-video-support-for-nanopi-neo-air.patch new file mode 100644 index 0000000000..c17d28c691 --- /dev/null +++ b/lede/target/linux/sunxi/patches-6.12/451-sunxi-add-csi-video-support-for-nanopi-neo-air.patch @@ -0,0 +1,107 @@ +From 4c3a3af679bd59660ac80889b560bddaf475ba81 Mon Sep 17 00:00:00 2001 +From: Michel Promonet +Date: Sun, 21 Jul 2024 19:04:19 +0200 +Subject: [PATCH] sunxi: add csi video support for nanopi-neo-air + +--- + .../dts/allwinner/sun8i-h3-nanopi-neo-air.dts | 85 +++++++++++++++++++ + 1 file changed, 85 insertions(+) + +--- a/arch/arm/boot/dts/allwinner/sun8i-h3-nanopi-neo-air.dts ++++ b/arch/arm/boot/dts/allwinner/sun8i-h3-nanopi-neo-air.dts +@@ -77,6 +77,39 @@ + compatible = "mmc-pwrseq-simple"; + reset-gpios = <&r_pio 0 7 GPIO_ACTIVE_LOW>; /* PL7 */ + }; ++ ++ cam_xclk: cam-xclk { ++ #clock-cells = <0>; ++ compatible = "fixed-clock"; ++ clock-frequency = <24000000>; ++ clock-output-names = "cam-xclk"; ++ }; ++ ++ reg_cam_avdd: cam-avdd { ++ compatible = "regulator-fixed"; ++ regulator-name = "cam-avdd"; ++ regulator-min-microvolt = <2800000>; ++ regulator-max-microvolt = <2800000>; ++ vin-supply = <®_vcc3v3>; ++ }; ++ ++ reg_cam_dovdd: cam-dovdd { ++ compatible = "regulator-fixed"; ++ regulator-name = "cam-dovdd"; ++ regulator-min-microvolt = <1800000>; ++ regulator-max-microvolt = <1800000>; ++ vin-supply = <®_vcc3v3>; ++ }; ++ ++ reg_cam_dvdd: cam-dvdd { ++ compatible = "regulator-fixed"; ++ regulator-name = "cam-dvdd"; ++ regulator-min-microvolt = <1500000>; ++ regulator-max-microvolt = <1500000>; ++ vin-supply = <®_vcc3v3>; ++ }; ++ ++ + }; + + &mmc0 { +@@ -141,3 +174,55 @@ + /* USB VBUS is always on */ + status = "okay"; + }; ++ ++&csi { ++ status = "okay"; ++ ++ port { ++ #address-cells = <1>; ++ #size-cells = <0>; ++ ++ /* Parallel bus endpoint */ ++ csi_from_ov5640: endpoint { ++ remote-endpoint = <&ov5640_to_csi>; ++ bus-width = <8>; ++ data-shift = <2>; ++ hsync-active = <1>; /* Active high */ ++ vsync-active = <0>; /* Active low */ ++ data-active = <1>; /* Active high */ ++ pclk-sample = <1>; /* Rising */ ++ }; ++ }; ++}; ++ ++&i2c2 { ++ status = "okay"; ++ ++ ov5640: camera@3c { ++ compatible = "ovti,ov5640"; ++ reg = <0x3c>; ++ clocks = <&cam_xclk>; ++ clock-names = "xclk"; ++ ++ reset-gpios = <&pio 4 14 GPIO_ACTIVE_LOW>; ++ powerdown-gpios = <&pio 4 15 GPIO_ACTIVE_HIGH>; ++ AVDD-supply = <®_cam_avdd>; ++ DOVDD-supply = <®_cam_dovdd>; ++ DVDD-supply = <®_cam_dvdd>; ++ ++ port { ++ ov5640_to_csi: endpoint { ++ remote-endpoint = <&csi_from_ov5640>; ++ bus-width = <8>; ++ data-shift = <2>; ++ hsync-active = <1>; /* Active high */ ++ vsync-active = <0>; /* Active low */ ++ data-active = <1>; /* Active high */ ++ pclk-sample = <1>; /* Rising */ ++ }; ++ }; ++ }; ++}; ++&i2c2_pins { ++ bias-pull-up; ++}; diff --git a/shadowsocks-rust/Cargo.lock b/shadowsocks-rust/Cargo.lock index 3b2990c057..5cdb959dcc 100644 --- a/shadowsocks-rust/Cargo.lock +++ b/shadowsocks-rust/Cargo.lock @@ -1088,9 +1088,9 @@ dependencies = [ [[package]] name = "flate2" -version = "1.1.1" +version = "1.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7ced92e76e966ca2fd84c8f7aa01a4aea65b0eb6648d72f7c8f3e2764a67fece" +checksum = "4a3d7db9596fecd151c5f638c0ee5d5bd487b6e0ea232e5dc96d5250f6f94b1d" dependencies = [ "crc32fast", "miniz_oxide", diff --git a/shadowsocks-rust/crates/shadowsocks-service/src/acl/mod.rs b/shadowsocks-rust/crates/shadowsocks-service/src/acl/mod.rs index c803ac26fb..3327cf1864 100644 --- a/shadowsocks-rust/crates/shadowsocks-service/src/acl/mod.rs +++ b/shadowsocks-rust/crates/shadowsocks-service/src/acl/mod.rs @@ -91,12 +91,12 @@ impl Rules { rule_regex: RegexSet, rule_set: HashSet, rule_tree: SubDomainsTree, - ) -> Rules { + ) -> Self { // Optimization, merging networks ipv4.simplify(); ipv6.simplify(); - Rules { + Self { ipv4, ipv6, rule_regex, @@ -167,7 +167,7 @@ struct ParsingRules { impl ParsingRules { fn new(name: &'static str) -> Self { - ParsingRules { + Self { name, ipv4: IpRange::new(), ipv6: IpRange::new(), @@ -342,7 +342,7 @@ pub struct AccessControl { impl AccessControl { /// Load ACL rules from a file - pub fn load_from_file>(p: P) -> io::Result { + pub fn load_from_file>(p: P) -> io::Result { trace!("ACL loading from {:?}", p.as_ref()); let file_path_ref = p.as_ref(); @@ -436,7 +436,7 @@ impl AccessControl { } } - Ok(AccessControl { + Ok(Self { outbound_block: outbound_block.into_rules()?, black_list: bypass.into_rules()?, white_list: proxy.into_rules()?, diff --git a/shadowsocks-rust/crates/shadowsocks-service/src/acl/sub_domains_tree.rs b/shadowsocks-rust/crates/shadowsocks-service/src/acl/sub_domains_tree.rs index 021ea16ec4..203d0efde9 100644 --- a/shadowsocks-rust/crates/shadowsocks-service/src/acl/sub_domains_tree.rs +++ b/shadowsocks-rust/crates/shadowsocks-service/src/acl/sub_domains_tree.rs @@ -11,7 +11,7 @@ struct DomainPart { impl DomainPart { fn new() -> Self { - DomainPart { + Self { included: false, children: HashMap::new(), } @@ -29,7 +29,7 @@ impl Debug for SubDomainsTree { impl SubDomainsTree { pub fn new() -> Self { - SubDomainsTree(HashMap::new()) + Self(HashMap::new()) } pub fn insert(&mut self, value: &str) { diff --git a/shadowsocks-rust/crates/shadowsocks-service/src/config.rs b/shadowsocks-rust/crates/shadowsocks-service/src/config.rs index 9a07e25c95..65aec145e5 100644 --- a/shadowsocks-rust/crates/shadowsocks-service/src/config.rs +++ b/shadowsocks-rust/crates/shadowsocks-service/src/config.rs @@ -444,23 +444,23 @@ pub enum ConfigType { impl ConfigType { /// Check if it is local server type pub fn is_local(self) -> bool { - self == ConfigType::Local + self == Self::Local } /// Check if it is remote server type pub fn is_server(self) -> bool { - self == ConfigType::Server + self == Self::Server } /// Check if it is manager server type pub fn is_manager(self) -> bool { - self == ConfigType::Manager + self == Self::Manager } /// Check if it is online config type (SIP008) #[cfg(feature = "local-online-config")] pub fn is_online_config(self) -> bool { - self == ConfigType::OnlineConfig + self == Self::OnlineConfig } } @@ -512,8 +512,8 @@ cfg_if! { cfg_if! { if #[cfg(any(target_os = "linux", target_os = "android"))] { /// Default TCP transparent proxy solution on this platform - pub const fn tcp_default() -> RedirType { - RedirType::Redirect + pub const fn tcp_default() -> Self { + Self::Redirect } /// Available TCP transparent proxy types @@ -524,8 +524,8 @@ cfg_if! { } /// Default UDP transparent proxy solution on this platform - pub const fn udp_default() -> RedirType { - RedirType::TProxy + pub const fn udp_default() -> Self { + Self::TProxy } /// Available UDP transparent proxy types @@ -635,20 +635,20 @@ cfg_if! { /// Check if transparent proxy is supported on this platform pub fn is_supported(self) -> bool { - self != RedirType::NotSupported + self != Self::NotSupported } /// Name of redirect type (transparent proxy type) pub const fn name(self) -> &'static str { match self { // Dummy, shouldn't be used in any useful situations - RedirType::NotSupported => "not_supported", + Self::NotSupported => "not_supported", #[cfg(any(target_os = "linux", target_os = "android"))] - RedirType::Redirect => "redirect", + Self::Redirect => "redirect", #[cfg(any(target_os = "linux", target_os = "android"))] - RedirType::TProxy => "tproxy", + Self::TProxy => "tproxy", #[cfg(any( target_os = "freebsd", @@ -683,13 +683,13 @@ cfg_if! { impl FromStr for RedirType { type Err = InvalidRedirType; - fn from_str(s: &str) -> Result { + fn from_str(s: &str) -> Result { match s { #[cfg(any(target_os = "linux", target_os = "android"))] - "redirect" => Ok(RedirType::Redirect), + "redirect" => Ok(Self::Redirect), #[cfg(any(target_os = "linux", target_os = "android"))] - "tproxy" => Ok(RedirType::TProxy), + "tproxy" => Ok(Self::TProxy), #[cfg(any( target_os = "freebsd", @@ -725,8 +725,8 @@ pub enum ManagerServerHost { } impl Default for ManagerServerHost { - fn default() -> ManagerServerHost { - ManagerServerHost::Ip(Ipv4Addr::UNSPECIFIED.into()) + fn default() -> Self { + Self::Ip(Ipv4Addr::UNSPECIFIED.into()) } } @@ -735,8 +735,8 @@ impl FromStr for ManagerServerHost { fn from_str(s: &str) -> Result { match s.parse::() { - Ok(s) => Ok(ManagerServerHost::Ip(s)), - Err(..) => Ok(ManagerServerHost::Domain(s.to_owned())), + Ok(s) => Ok(Self::Ip(s)), + Err(..) => Ok(Self::Domain(s.to_owned())), } } } @@ -766,11 +766,11 @@ impl Display for ManagerServerModeError { impl FromStr for ManagerServerMode { type Err = ManagerServerModeError; - fn from_str(s: &str) -> Result { + fn from_str(s: &str) -> Result { match s { - "builtin" => Ok(ManagerServerMode::Builtin), + "builtin" => Ok(Self::Builtin), #[cfg(unix)] - "standalone" => Ok(ManagerServerMode::Standalone), + "standalone" => Ok(Self::Standalone), _ => Err(ManagerServerModeError), } } @@ -779,9 +779,9 @@ impl FromStr for ManagerServerMode { impl Display for ManagerServerMode { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { match *self { - ManagerServerMode::Builtin => f.write_str("builtin"), + Self::Builtin => f.write_str("builtin"), #[cfg(unix)] - ManagerServerMode::Standalone => f.write_str("standalone"), + Self::Standalone => f.write_str("standalone"), } } } @@ -815,8 +815,8 @@ pub struct ManagerConfig { impl ManagerConfig { /// Create a ManagerConfig with default options - pub fn new(addr: ManagerAddr) -> ManagerConfig { - ManagerConfig { + pub fn new(addr: ManagerAddr) -> Self { + Self { addr, method: None, plugin: None, @@ -858,19 +858,19 @@ impl ProtocolType { /// As string representation pub fn as_str(&self) -> &'static str { match *self { - ProtocolType::Socks => "socks", + Self::Socks => "socks", #[cfg(feature = "local-http")] - ProtocolType::Http => "http", + Self::Http => "http", #[cfg(feature = "local-tunnel")] - ProtocolType::Tunnel => "tunnel", + Self::Tunnel => "tunnel", #[cfg(feature = "local-redir")] - ProtocolType::Redir => "redir", + Self::Redir => "redir", #[cfg(feature = "local-dns")] - ProtocolType::Dns => "dns", + Self::Dns => "dns", #[cfg(feature = "local-tun")] - ProtocolType::Tun => "tun", + Self::Tun => "tun", #[cfg(feature = "local-fake-dns")] - ProtocolType::FakeDns => "fake-dns", + Self::FakeDns => "fake-dns", } } @@ -909,19 +909,19 @@ impl FromStr for ProtocolType { fn from_str(s: &str) -> Result { match s { - "socks" => Ok(ProtocolType::Socks), + "socks" => Ok(Self::Socks), #[cfg(feature = "local-http")] - "http" => Ok(ProtocolType::Http), + "http" => Ok(Self::Http), #[cfg(feature = "local-tunnel")] - "tunnel" => Ok(ProtocolType::Tunnel), + "tunnel" => Ok(Self::Tunnel), #[cfg(feature = "local-redir")] - "redir" => Ok(ProtocolType::Redir), + "redir" => Ok(Self::Redir), #[cfg(feature = "local-dns")] - "dns" => Ok(ProtocolType::Dns), + "dns" => Ok(Self::Dns), #[cfg(feature = "local-tun")] - "tun" => Ok(ProtocolType::Tun), + "tun" => Ok(Self::Tun), #[cfg(feature = "local-fake-dns")] - "fake-dns" => Ok(ProtocolType::FakeDns), + "fake-dns" => Ok(Self::FakeDns), _ => Err(ProtocolTypeError), } } @@ -1054,7 +1054,7 @@ pub struct LocalConfig { impl LocalConfig { /// Create a new `LocalConfig` - pub fn new(protocol: ProtocolType) -> LocalConfig { + pub fn new(protocol: ProtocolType) -> Self { // DNS server runs in `TcpAndUdp` mode by default to maintain backwards compatibility // see https://github.com/shadowsocks/shadowsocks-rust/issues/1281 let mode = match protocol { @@ -1063,7 +1063,7 @@ impl LocalConfig { _ => Mode::TcpOnly, }; - LocalConfig { + Self { addr: None, protocol, @@ -1120,8 +1120,8 @@ impl LocalConfig { } /// Create a new `LocalConfig` with listen address - pub fn new_with_addr(addr: ServerAddr, protocol: ProtocolType) -> LocalConfig { - let mut config = LocalConfig::new(protocol); + pub fn new_with_addr(addr: ServerAddr, protocol: ProtocolType) -> Self { + let mut config = Self::new(protocol); config.addr = Some(addr); config } @@ -1260,8 +1260,8 @@ pub struct ServerInstanceConfig { impl ServerInstanceConfig { /// Create with `ServerConfig` - pub fn with_server_config(config: ServerConfig) -> ServerInstanceConfig { - ServerInstanceConfig { + pub fn with_server_config(config: ServerConfig) -> Self { + Self { config, acl: None, #[cfg(any(target_os = "linux", target_os = "android"))] @@ -1286,8 +1286,8 @@ pub struct LocalInstanceConfig { impl LocalInstanceConfig { /// Create with `LocalConfig` - pub fn with_local_config(config: LocalConfig) -> LocalInstanceConfig { - LocalInstanceConfig { config, acl: None } + pub fn with_local_config(config: LocalConfig) -> Self { + Self { config, acl: None } } } @@ -1435,8 +1435,8 @@ pub struct Error { } impl Error { - pub fn new(kind: ErrorKind, desc: &'static str, detail: Option) -> Error { - Error { kind, desc, detail } + pub fn new(kind: ErrorKind, desc: &'static str, detail: Option) -> Self { + Self { kind, desc, detail } } } @@ -1479,8 +1479,8 @@ impl Display for Error { impl Config { /// Creates an empty configuration - pub fn new(config_type: ConfigType) -> Config { - Config { + pub fn new(config_type: ConfigType) -> Self { + Self { server: Vec::new(), local: Vec::new(), @@ -1536,8 +1536,8 @@ impl Config { } } - fn load_from_ssconfig(config: SSConfig, config_type: ConfigType) -> Result { - let mut nconfig = Config::new(config_type); + fn load_from_ssconfig(config: SSConfig, config_type: ConfigType) -> Result { + let mut nconfig = Self::new(config_type); // Client // @@ -2495,11 +2495,11 @@ impl Config { impl DnsProtocol { fn enable_tcp(&self) -> bool { - matches!(*self, DnsProtocol::Tcp | DnsProtocol::Both) + matches!(*self, Self::Tcp | Self::Both) } fn enable_udp(&self) -> bool { - matches!(*self, DnsProtocol::Udp | DnsProtocol::Both) + matches!(*self, Self::Udp | Self::Both) } } @@ -2563,20 +2563,20 @@ impl Config { } /// Load Config from a `str` - pub fn load_from_str(s: &str, config_type: ConfigType) -> Result { + pub fn load_from_str(s: &str, config_type: ConfigType) -> Result { let c = json5::from_str::(s)?; - Config::load_from_ssconfig(c, config_type) + Self::load_from_ssconfig(c, config_type) } /// Load Config from a File - pub fn load_from_file>(filename: P, config_type: ConfigType) -> Result { + pub fn load_from_file>(filename: P, config_type: ConfigType) -> Result { let filename = filename.as_ref(); let mut reader = OpenOptions::new().read(true).open(filename)?; let mut content = String::new(); reader.read_to_string(&mut content)?; - let mut config = Config::load_from_str(&content[..], config_type)?; + let mut config = Self::load_from_str(&content[..], config_type)?; // Record the path of the configuration for auto-reloading config.config_path = Some(filename.to_owned()); diff --git a/shadowsocks-rust/crates/shadowsocks-service/src/local/context.rs b/shadowsocks-rust/crates/shadowsocks-service/src/local/context.rs index 18aff4c7fc..65307cae59 100644 --- a/shadowsocks-rust/crates/shadowsocks-service/src/local/context.rs +++ b/shadowsocks-rust/crates/shadowsocks-service/src/local/context.rs @@ -46,14 +46,14 @@ pub struct ServiceContext { impl Default for ServiceContext { fn default() -> Self { - ServiceContext::new() + Self::new() } } impl ServiceContext { /// Create a new `ServiceContext` - pub fn new() -> ServiceContext { - ServiceContext { + pub fn new() -> Self { + Self { context: Context::new_shared(ServerType::Local), connect_opts: ConnectOpts::default(), accept_opts: AcceptOpts::default(), diff --git a/shadowsocks-rust/crates/shadowsocks-service/src/local/dns/client_cache.rs b/shadowsocks-rust/crates/shadowsocks-service/src/local/dns/client_cache.rs index 72215f3af8..ef5f0e3a29 100644 --- a/shadowsocks-rust/crates/shadowsocks-service/src/local/dns/client_cache.rs +++ b/shadowsocks-rust/crates/shadowsocks-service/src/local/dns/client_cache.rs @@ -36,8 +36,8 @@ pub struct DnsClientCache { } impl DnsClientCache { - pub fn new(max_client_per_addr: usize) -> DnsClientCache { - DnsClientCache { + pub fn new(max_client_per_addr: usize) -> Self { + Self { cache: Mutex::new(HashMap::new()), timeout: Duration::from_secs(5), retry_count: 1, diff --git a/shadowsocks-rust/crates/shadowsocks-service/src/local/dns/config.rs b/shadowsocks-rust/crates/shadowsocks-service/src/local/dns/config.rs index b0eed8b972..ac74a6a21e 100644 --- a/shadowsocks-rust/crates/shadowsocks-service/src/local/dns/config.rs +++ b/shadowsocks-rust/crates/shadowsocks-service/src/local/dns/config.rs @@ -32,13 +32,13 @@ impl FromStr for NameServerAddr { fn from_str(s: &str) -> Result { if let Ok(ip) = s.parse::() { - return Ok(NameServerAddr::SocketAddr(SocketAddr::new(ip, 53))); + return Ok(Self::SocketAddr(SocketAddr::new(ip, 53))); } match s.parse::() { - Ok(addr) => Ok(NameServerAddr::SocketAddr(addr)), + Ok(addr) => Ok(Self::SocketAddr(addr)), #[cfg(unix)] - Err(..) => Ok(NameServerAddr::UnixSocketAddr(PathBuf::from(s))), + Err(..) => Ok(Self::UnixSocketAddr(PathBuf::from(s))), #[cfg(not(unix))] Err(err) => Err(err), } @@ -48,9 +48,9 @@ impl FromStr for NameServerAddr { impl Display for NameServerAddr { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { match *self { - NameServerAddr::SocketAddr(ref sa) => Display::fmt(sa, f), + Self::SocketAddr(ref sa) => Display::fmt(sa, f), #[cfg(unix)] - NameServerAddr::UnixSocketAddr(ref p) => write!(f, "{}", p.display()), + Self::UnixSocketAddr(ref p) => write!(f, "{}", p.display()), } } } diff --git a/shadowsocks-rust/crates/shadowsocks-service/src/local/dns/dns_resolver.rs b/shadowsocks-rust/crates/shadowsocks-service/src/local/dns/dns_resolver.rs index 6831578ecc..e328fd9947 100644 --- a/shadowsocks-rust/crates/shadowsocks-service/src/local/dns/dns_resolver.rs +++ b/shadowsocks-rust/crates/shadowsocks-service/src/local/dns/dns_resolver.rs @@ -26,8 +26,8 @@ pub struct DnsResolver { } impl DnsResolver { - pub fn new(ns: NameServerAddr) -> DnsResolver { - DnsResolver { + pub fn new(ns: NameServerAddr) -> Self { + Self { ns, client_cache: DnsClientCache::new(5), mode: Mode::UdpOnly, diff --git a/shadowsocks-rust/crates/shadowsocks-service/src/local/dns/server.rs b/shadowsocks-rust/crates/shadowsocks-service/src/local/dns/server.rs index 1a16b5d4a2..8429bf031c 100644 --- a/shadowsocks-rust/crates/shadowsocks-service/src/local/dns/server.rs +++ b/shadowsocks-rust/crates/shadowsocks-service/src/local/dns/server.rs @@ -70,9 +70,9 @@ impl DnsBuilder { remote_addr: Address, balancer: PingBalancer, client_cache_size: usize, - ) -> DnsBuilder { + ) -> Self { let context = ServiceContext::new(); - DnsBuilder::with_context( + Self::with_context( Arc::new(context), bind_addr, local_addr, @@ -90,8 +90,8 @@ impl DnsBuilder { remote_addr: Address, balancer: PingBalancer, client_cache_size: usize, - ) -> DnsBuilder { - DnsBuilder { + ) -> Self { + Self { context, mode: Mode::UdpOnly, local_addr, @@ -190,8 +190,8 @@ impl DnsTcpServerBuilder { local_addr: Arc, remote_addr: Arc
, client: Arc, - ) -> DnsTcpServerBuilder { - DnsTcpServerBuilder { + ) -> Self { + Self { context, bind_addr, local_addr, @@ -270,7 +270,7 @@ impl DnsTcpServer { } }; - tokio::spawn(DnsTcpServer::handle_tcp_stream( + tokio::spawn(Self::handle_tcp_stream( self.client.clone(), stream, peer_addr, @@ -365,8 +365,8 @@ impl DnsUdpServerBuilder { local_addr: Arc, remote_addr: Arc
, client: Arc, - ) -> DnsUdpServerBuilder { - DnsUdpServerBuilder { + ) -> Self { + Self { context, bind_addr, local_addr, @@ -453,7 +453,7 @@ impl DnsUdpServer { } }; - tokio::spawn(DnsUdpServer::handle_udp_packet( + tokio::spawn(Self::handle_udp_packet( self.client.clone(), self.listener.clone(), peer_addr, @@ -720,8 +720,8 @@ struct DnsClient { } impl DnsClient { - fn new(context: Arc, balancer: PingBalancer, mode: Mode, client_cache_size: usize) -> DnsClient { - DnsClient { + fn new(context: Arc, balancer: PingBalancer, mode: Mode, client_cache_size: usize) -> Self { + Self { context, client_cache: DnsClientCache::new(client_cache_size), mode, diff --git a/shadowsocks-rust/crates/shadowsocks-service/src/local/dns/upstream.rs b/shadowsocks-rust/crates/shadowsocks-service/src/local/dns/upstream.rs index e069ab9e0a..fc67330a45 100644 --- a/shadowsocks-rust/crates/shadowsocks-service/src/local/dns/upstream.rs +++ b/shadowsocks-rust/crates/shadowsocks-service/src/local/dns/upstream.rs @@ -66,22 +66,22 @@ pub enum DnsClient { impl DnsClient { /// Connect to local provided TCP DNS server - pub async fn connect_tcp_local(ns: SocketAddr, connect_opts: &ConnectOpts) -> io::Result { + pub async fn connect_tcp_local(ns: SocketAddr, connect_opts: &ConnectOpts) -> io::Result { let stream = ShadowTcpStream::connect_with_opts(&ns, connect_opts).await?; - Ok(DnsClient::TcpLocal { stream }) + Ok(Self::TcpLocal { stream }) } /// Connect to local provided UDP DNS server - pub async fn connect_udp_local(ns: SocketAddr, connect_opts: &ConnectOpts) -> io::Result { + pub async fn connect_udp_local(ns: SocketAddr, connect_opts: &ConnectOpts) -> io::Result { let socket = ShadowUdpSocket::connect_with_opts(&ns, connect_opts).await?.into(); - Ok(DnsClient::UdpLocal { socket }) + Ok(Self::UdpLocal { socket }) } #[cfg(unix)] /// Connect to local provided Unix Domain Socket DNS server, in TCP-like protocol - pub async fn connect_unix_stream>(path: &P) -> io::Result { + pub async fn connect_unix_stream>(path: &P) -> io::Result { let stream = UnixStream::connect(path).await?; - Ok(DnsClient::UnixStream { stream }) + Ok(Self::UnixStream { stream }) } /// Connect to remote DNS server through proxy in TCP @@ -91,12 +91,12 @@ impl DnsClient { ns: &Address, connect_opts: &ConnectOpts, flow_stat: Arc, - ) -> io::Result { + ) -> io::Result { let stream = ProxyClientStream::connect_with_opts_map(context, svr_cfg, ns, connect_opts, |s| { MonProxyStream::from_stream(s, flow_stat) }) .await?; - Ok(DnsClient::TcpRemote { stream }) + Ok(Self::TcpRemote { stream }) } /// Connect to remote DNS server through proxy in UDP @@ -106,13 +106,13 @@ impl DnsClient { ns: Address, connect_opts: &ConnectOpts, flow_stat: Arc, - ) -> io::Result { + ) -> io::Result { let socket = ProxySocket::connect_with_opts(context.clone(), svr_cfg, connect_opts).await?; let socket = MonProxySocket::from_socket(socket, flow_stat.clone()); let mut control = UdpSocketControlData::default(); control.client_session_id = generate_client_session_id(); control.packet_id = 0; // AEAD-2022 Packet ID starts from 1 - Ok(DnsClient::UdpRemote { + Ok(Self::UdpRemote { socket, ns, control, @@ -143,8 +143,8 @@ impl DnsClient { trace!("DNS lookup {:?}", msg); match *self { - DnsClient::TcpLocal { ref mut stream } => stream_query(stream, msg).await, - DnsClient::UdpLocal { ref socket } => { + Self::TcpLocal { ref mut stream } => stream_query(stream, msg).await, + Self::UdpLocal { ref socket } => { let bytes = msg.to_vec()?; socket.send(&bytes).await?; @@ -154,9 +154,9 @@ impl DnsClient { Message::from_vec(&recv_buf[..n]) } #[cfg(unix)] - DnsClient::UnixStream { ref mut stream } => stream_query(stream, msg).await, - DnsClient::TcpRemote { ref mut stream } => stream_query(stream, msg).await, - DnsClient::UdpRemote { + Self::UnixStream { ref mut stream } => stream_query(stream, msg).await, + Self::TcpRemote { ref mut stream } => stream_query(stream, msg).await, + Self::UdpRemote { ref mut socket, ref ns, ref mut control, @@ -258,12 +258,12 @@ impl DnsClient { } match *self { - DnsClient::TcpLocal { ref mut stream } => check_peekable(stream), - DnsClient::UdpLocal { .. } => true, + Self::TcpLocal { ref mut stream } => check_peekable(stream), + Self::UdpLocal { .. } => true, #[cfg(unix)] - DnsClient::UnixStream { ref mut stream } => check_peekable(stream), - DnsClient::TcpRemote { ref mut stream } => check_peekable(stream.get_mut().get_mut()), - DnsClient::UdpRemote { .. } => true, + Self::UnixStream { ref mut stream } => check_peekable(stream), + Self::TcpRemote { ref mut stream } => check_peekable(stream.get_mut().get_mut()), + Self::UdpRemote { .. } => true, } } } diff --git a/shadowsocks-rust/crates/shadowsocks-service/src/local/fake_dns/manager.rs b/shadowsocks-rust/crates/shadowsocks-service/src/local/fake_dns/manager.rs index 5dd00d7d20..0792defb34 100644 --- a/shadowsocks-rust/crates/shadowsocks-service/src/local/fake_dns/manager.rs +++ b/shadowsocks-rust/crates/shadowsocks-service/src/local/fake_dns/manager.rs @@ -33,7 +33,7 @@ impl From for io::Error { fn from(value: FakeDnsError) -> Self { match value { FakeDnsError::IoError(e) => e, - FakeDnsError::RocksDBError(e) => io::Error::other(e), + FakeDnsError::RocksDBError(e) => Self::other(e), } } } @@ -152,7 +152,7 @@ impl FakeDnsManager { ipv4_network: Ipv4Net, ipv6_network: Ipv6Net, expire_duration: Duration, - ) -> FakeDnsResult { + ) -> FakeDnsResult { let db_path = db_path.as_ref(); // https://github.com/facebook/rocksdb/wiki/Setup-Options-and-Basic-Tuning @@ -238,7 +238,7 @@ impl FakeDnsManager { trace!("FakeDNS database created. {:?}", c); } - Ok(FakeDnsManager { + Ok(Self { db: Mutex::new(db), ipv4_network: Mutex::new(ipv4_network.hosts().cycle()), ipv6_network: Mutex::new(ipv6_network.hosts().cycle()), @@ -279,14 +279,14 @@ impl FakeDnsManager { let db = self.db.lock().await; // ip -> domain_name - let ip2name_key = FakeDnsManager::get_ip2name_key(ip); + let ip2name_key = Self::get_ip2name_key(ip); match db.get(&ip2name_key)? { None => Ok(None), Some(v) => { // Got ip -> domain_name let mut ip_mapping = proto::IpAddrMapping::decode(&v)?; - let now = FakeDnsManager::get_current_timestamp(); + let now = Self::get_current_timestamp(); if ip_mapping.expire_time >= now { // Ok. It is not expired yet. Try to extend its expire time. ip_mapping.expire_time = now + self.expire_duration.as_secs() as i64; @@ -301,7 +301,7 @@ impl FakeDnsManager { }; { - let name2ip_key = FakeDnsManager::get_name2ip_key(&name); + let name2ip_key = Self::get_name2ip_key(&name); match db.get(&name2ip_key)? { Some(v) => { let mut domain_name_mapping = proto::DomainNameMapping::decode(&v)?; diff --git a/shadowsocks-rust/crates/shadowsocks-service/src/local/fake_dns/proto.rs b/shadowsocks-rust/crates/shadowsocks-service/src/local/fake_dns/proto.rs index 5313679748..92db0e56e4 100644 --- a/shadowsocks-rust/crates/shadowsocks-service/src/local/fake_dns/proto.rs +++ b/shadowsocks-rust/crates/shadowsocks-service/src/local/fake_dns/proto.rs @@ -12,7 +12,7 @@ pub struct StorageMeta { } impl StorageMeta { - pub fn decode(v: &[u8]) -> io::Result { + pub fn decode(v: &[u8]) -> io::Result { bson::from_slice(v).map_err(io::Error::other) } @@ -28,7 +28,7 @@ pub struct IpAddrMapping { } impl IpAddrMapping { - pub fn decode(v: &[u8]) -> io::Result { + pub fn decode(v: &[u8]) -> io::Result { bson::from_slice(v).map_err(io::Error::other) } @@ -45,7 +45,7 @@ pub struct DomainNameMapping { } impl DomainNameMapping { - pub fn decode(v: &[u8]) -> io::Result { + pub fn decode(v: &[u8]) -> io::Result { bson::from_slice(v).map_err(io::Error::other) } diff --git a/shadowsocks-rust/crates/shadowsocks-service/src/local/fake_dns/server.rs b/shadowsocks-rust/crates/shadowsocks-service/src/local/fake_dns/server.rs index 8086a3dc65..6ca4665baf 100644 --- a/shadowsocks-rust/crates/shadowsocks-service/src/local/fake_dns/server.rs +++ b/shadowsocks-rust/crates/shadowsocks-service/src/local/fake_dns/server.rs @@ -29,14 +29,14 @@ pub struct FakeDnsBuilder { impl FakeDnsBuilder { /// Create a new Fake DNS server - pub fn new(client_addr: ServerAddr) -> FakeDnsBuilder { + pub fn new(client_addr: ServerAddr) -> Self { let context = ServiceContext::new(); - FakeDnsBuilder::with_context(Arc::new(context), client_addr) + Self::with_context(Arc::new(context), client_addr) } /// Create a new Fake DNS server with context - pub fn with_context(context: Arc, client_addr: ServerAddr) -> FakeDnsBuilder { - FakeDnsBuilder { + pub fn with_context(context: Arc, client_addr: ServerAddr) -> Self { + Self { context, mode: Mode::TcpAndUdp, client_addr, diff --git a/shadowsocks-rust/crates/shadowsocks-service/src/local/fake_dns/tcp_server.rs b/shadowsocks-rust/crates/shadowsocks-service/src/local/fake_dns/tcp_server.rs index 943f855fb7..25115e15af 100644 --- a/shadowsocks-rust/crates/shadowsocks-service/src/local/fake_dns/tcp_server.rs +++ b/shadowsocks-rust/crates/shadowsocks-service/src/local/fake_dns/tcp_server.rs @@ -37,7 +37,7 @@ impl FakeDnsTcpServer { context: Arc, client_config: &ServerAddr, manager: Arc, - ) -> io::Result { + ) -> io::Result { let listener = match *client_config { ServerAddr::SocketAddr(ref saddr) => { ShadowTcpListener::bind_with_opts(saddr, context.accept_opts()).await? @@ -50,7 +50,7 @@ impl FakeDnsTcpServer { } }; - Ok(FakeDnsTcpServer { + Ok(Self { context, listener, manager, @@ -79,7 +79,7 @@ impl FakeDnsTcpServer { let context = self.context.clone(); let manager = self.manager.clone(); tokio::spawn(async move { - if let Err(err) = FakeDnsTcpServer::handle_client(context, peer_addr, stream, manager).await { + if let Err(err) = Self::handle_client(context, peer_addr, stream, manager).await { error!( "failed to handle Fake DNS tcp client, peer: {}, err: {}", peer_addr, err diff --git a/shadowsocks-rust/crates/shadowsocks-service/src/local/fake_dns/udp_server.rs b/shadowsocks-rust/crates/shadowsocks-service/src/local/fake_dns/udp_server.rs index d6ace3f3f2..68b59ac217 100644 --- a/shadowsocks-rust/crates/shadowsocks-service/src/local/fake_dns/udp_server.rs +++ b/shadowsocks-rust/crates/shadowsocks-service/src/local/fake_dns/udp_server.rs @@ -22,7 +22,7 @@ impl FakeDnsUdpServer { context: Arc, client_config: &ServerAddr, manager: Arc, - ) -> io::Result { + ) -> io::Result { let listener = match *client_config { ServerAddr::SocketAddr(ref saddr) => { ShadowUdpSocket::listen_with_opts(saddr, context.accept_opts()).await? @@ -35,7 +35,7 @@ impl FakeDnsUdpServer { } }; - Ok(FakeDnsUdpServer { listener, manager }) + Ok(Self { listener, manager }) } /// Get UDP local address diff --git a/shadowsocks-rust/crates/shadowsocks-service/src/local/http/http_client.rs b/shadowsocks-rust/crates/shadowsocks-service/src/local/http/http_client.rs index 83fd591f9e..1a4e1bc6b1 100644 --- a/shadowsocks-rust/crates/shadowsocks-service/src/local/http/http_client.rs +++ b/shadowsocks-rust/crates/shadowsocks-service/src/local/http/http_client.rs @@ -106,7 +106,7 @@ pub struct HttpClient { impl Clone for HttpClient { fn clone(&self) -> Self { - HttpClient { + Self { cache_conn: self.cache_conn.clone(), } } @@ -119,7 +119,7 @@ where B::Error: Into>, { fn default() -> Self { - HttpClient::new() + Self::new() } } @@ -130,8 +130,8 @@ where B::Error: Into>, { /// Create a new HttpClient - pub fn new() -> HttpClient { - HttpClient { + pub fn new() -> Self { + Self { cache_conn: Arc::new(Mutex::new(LruCache::with_expiry_duration(CONNECTION_EXPIRE_DURATION))), } } @@ -260,7 +260,7 @@ where host: Address, domain: &str, balancer: Option<&PingBalancer>, - ) -> io::Result> { + ) -> io::Result { if *scheme != Scheme::HTTP && *scheme != Scheme::HTTPS { return Err(io::Error::new(ErrorKind::InvalidInput, "invalid scheme")); } @@ -268,9 +268,9 @@ where let (stream, _) = connect_host(context, &host, balancer).await?; if *scheme == Scheme::HTTP { - HttpConnection::connect_http_http1(scheme, host, stream).await + Self::connect_http_http1(scheme, host, stream).await } else if *scheme == Scheme::HTTPS { - HttpConnection::connect_https(scheme, host, domain, stream).await + Self::connect_https(scheme, host, domain, stream).await } else { unreachable!() } @@ -280,7 +280,7 @@ where scheme: &Scheme, host: Address, stream: AutoProxyClientStream, - ) -> io::Result> { + ) -> io::Result { trace!( "HTTP making new HTTP/1.1 connection to host: {}, scheme: {}", host, scheme @@ -305,7 +305,7 @@ where } }); - Ok(HttpConnection::Http1(send_request)) + Ok(Self::Http1(send_request)) } async fn connect_https( @@ -313,7 +313,7 @@ where host: Address, domain: &str, stream: AutoProxyClientStream, - ) -> io::Result> { + ) -> io::Result { trace!("HTTP making new TLS connection to host: {}, scheme: {}", host, scheme); // TLS handshake, check alpn for h2 support. @@ -337,7 +337,7 @@ where } }); - Ok(HttpConnection::Http2(send_request)) + Ok(Self::Http2(send_request)) } else { // HTTP/1.x TLS let (send_request, connection) = match http1::Builder::new() @@ -356,14 +356,14 @@ where } }); - Ok(HttpConnection::Http1(send_request)) + Ok(Self::Http1(send_request)) } } #[inline] pub async fn send_request(&mut self, mut req: Request) -> Result, HttpClientError> { match self { - HttpConnection::Http1(r) => { + Self::Http1(r) => { if !matches!( req.version(), HttpVersion::HTTP_09 | HttpVersion::HTTP_10 | HttpVersion::HTTP_11 @@ -394,7 +394,7 @@ where r.send_request(req).await.map_err(Into::into) } - HttpConnection::Http2(r) => { + Self::Http2(r) => { if !matches!(req.version(), HttpVersion::HTTP_2) { trace!("HTTP client changed Request.version to HTTP/2 from {:?}", req.version()); @@ -408,8 +408,8 @@ where pub fn is_closed(&self) -> bool { match self { - HttpConnection::Http1(r) => r.is_closed(), - HttpConnection::Http2(r) => r.is_closed(), + Self::Http1(r) => r.is_closed(), + Self::Http2(r) => r.is_closed(), } } } diff --git a/shadowsocks-rust/crates/shadowsocks-service/src/local/http/http_service.rs b/shadowsocks-rust/crates/shadowsocks-service/src/local/http/http_service.rs index a048108fdb..441f2fe941 100644 --- a/shadowsocks-rust/crates/shadowsocks-service/src/local/http/http_service.rs +++ b/shadowsocks-rust/crates/shadowsocks-service/src/local/http/http_service.rs @@ -38,8 +38,8 @@ impl HttpService { peer_addr: SocketAddr, http_client: HttpClient, balancer: PingBalancer, - ) -> HttpService { - HttpService { + ) -> Self { + Self { context, peer_addr, http_client, diff --git a/shadowsocks-rust/crates/shadowsocks-service/src/local/http/http_stream.rs b/shadowsocks-rust/crates/shadowsocks-service/src/local/http/http_stream.rs index 1503d745c8..dc1df35586 100644 --- a/shadowsocks-rust/crates/shadowsocks-service/src/local/http/http_stream.rs +++ b/shadowsocks-rust/crates/shadowsocks-service/src/local/http/http_stream.rs @@ -22,8 +22,8 @@ pub enum ProxyHttpStream { } impl ProxyHttpStream { - pub fn connect_http(stream: AutoProxyClientStream) -> ProxyHttpStream { - ProxyHttpStream::Http(stream) + pub fn connect_http(stream: AutoProxyClientStream) -> Self { + Self::Http(stream) } #[cfg(feature = "local-http-native-tls")] @@ -59,7 +59,7 @@ impl ProxyHttpStream { } #[cfg(feature = "local-http-rustls")] - pub async fn connect_https(stream: AutoProxyClientStream, domain: &str) -> io::Result { + pub async fn connect_https(stream: AutoProxyClientStream, domain: &str) -> io::Result { use log::warn; use rustls_native_certs::CertificateResult; use std::sync::{Arc, LazyLock}; @@ -114,7 +114,7 @@ impl ProxyHttpStream { let (_, session) = tls_stream.get_ref(); let negotiated_http2 = matches!(session.alpn_protocol(), Some(b"h2")); - Ok(ProxyHttpStream::Https(tls_stream, negotiated_http2)) + Ok(Self::Https(tls_stream, negotiated_http2)) } #[cfg(not(any(feature = "local-http-native-tls", feature = "local-http-rustls")))] @@ -127,9 +127,9 @@ impl ProxyHttpStream { pub fn negotiated_http2(&self) -> bool { match *self { - ProxyHttpStream::Http(..) => false, + Self::Http(..) => false, #[cfg(any(feature = "local-http-native-tls", feature = "local-http-rustls"))] - ProxyHttpStream::Https(_, n) => n, + Self::Https(_, n) => n, } } } diff --git a/shadowsocks-rust/crates/shadowsocks-service/src/local/http/server.rs b/shadowsocks-rust/crates/shadowsocks-service/src/local/http/server.rs index 067297a4f2..0cb8f1bfc4 100644 --- a/shadowsocks-rust/crates/shadowsocks-service/src/local/http/server.rs +++ b/shadowsocks-rust/crates/shadowsocks-service/src/local/http/server.rs @@ -29,9 +29,9 @@ pub struct HttpBuilder { impl HttpBuilder { /// Create a new HTTP Local server builder - pub fn new(client_config: ServerAddr, balancer: PingBalancer) -> HttpBuilder { + pub fn new(client_config: ServerAddr, balancer: PingBalancer) -> Self { let context = ServiceContext::new(); - HttpBuilder::with_context(Arc::new(context), client_config, balancer) + Self::with_context(Arc::new(context), client_config, balancer) } /// Create with an existed context @@ -39,8 +39,8 @@ impl HttpBuilder { context: Arc, client_config: ServerAddr, balancer: PingBalancer, - ) -> HttpBuilder { - HttpBuilder { + ) -> Self { + Self { context, client_config, balancer, @@ -143,8 +143,8 @@ pub struct HttpConnectionHandler { impl HttpConnectionHandler { /// Create a new Handler - pub fn new(context: Arc, balancer: PingBalancer) -> HttpConnectionHandler { - HttpConnectionHandler { + pub fn new(context: Arc, balancer: PingBalancer) -> Self { + Self { context, balancer, http_client: HttpClient::new(), @@ -156,7 +156,7 @@ impl HttpConnectionHandler { where S: AsyncRead + AsyncWrite + Unpin + Send + 'static, { - let HttpConnectionHandler { + let Self { context, balancer, http_client, diff --git a/shadowsocks-rust/crates/shadowsocks-service/src/local/loadbalancing/ping_balancer.rs b/shadowsocks-rust/crates/shadowsocks-service/src/local/loadbalancing/ping_balancer.rs index f365064df1..7fab8b3c63 100644 --- a/shadowsocks-rust/crates/shadowsocks-service/src/local/loadbalancing/ping_balancer.rs +++ b/shadowsocks-rust/crates/shadowsocks-service/src/local/loadbalancing/ping_balancer.rs @@ -54,8 +54,8 @@ pub enum ServerType { impl fmt::Display for ServerType { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { match *self { - ServerType::Tcp => f.write_str("TCP"), - ServerType::Udp => f.write_str("UDP"), + Self::Tcp => f.write_str("TCP"), + Self::Udp => f.write_str("UDP"), } } } @@ -71,8 +71,8 @@ pub struct PingBalancerBuilder { } impl PingBalancerBuilder { - pub fn new(context: Arc, mode: Mode) -> PingBalancerBuilder { - PingBalancerBuilder { + pub fn new(context: Arc, mode: Mode) -> Self { + Self { servers: Vec::new(), context, mode, @@ -241,7 +241,7 @@ impl PingBalancerContext { max_server_rtt: Duration, check_interval: Duration, check_best_interval: Option, - ) -> io::Result<(Arc, PingBalancerContextTask)> { + ) -> io::Result<(Arc, PingBalancerContextTask)> { let plugin_abortable = { // Start plugins for TCP proxies @@ -305,7 +305,7 @@ impl PingBalancerContext { let (best_tcp_idx, best_udp_idx) = PingBalancerBuilder::find_best_idx(&servers, mode); - let balancer_context = PingBalancerContext { + let balancer_context = Self { servers, best_tcp_idx: AtomicUsize::new(best_tcp_idx), best_udp_idx: AtomicUsize::new(best_udp_idx), @@ -360,10 +360,10 @@ impl PingBalancerContext { for server in self.servers.iter() { let svr_cfg = server.server_config(); - if self.mode.enable_tcp() && PingBalancerContext::check_server_tcp_enabled(svr_cfg) { + if self.mode.enable_tcp() && Self::check_server_tcp_enabled(svr_cfg) { tcp_count += 1; } - if self.mode.enable_udp() && PingBalancerContext::check_server_udp_enabled(svr_cfg) { + if self.mode.enable_udp() && Self::check_server_udp_enabled(svr_cfg) { udp_count += 1; } } @@ -397,7 +397,7 @@ impl PingBalancerContext { for server in servers.iter() { let svr_cfg = server.server_config(); - if self.mode.enable_tcp() && PingBalancerContext::check_server_tcp_enabled(svr_cfg) { + if self.mode.enable_tcp() && Self::check_server_tcp_enabled(svr_cfg) { let checker = PingChecker { server: server.clone(), server_type: ServerType::Tcp, @@ -407,7 +407,7 @@ impl PingBalancerContext { vfut_tcp.push(checker.check_update_score()); } - if self.mode.enable_udp() && PingBalancerContext::check_server_udp_enabled(svr_cfg) { + if self.mode.enable_udp() && Self::check_server_udp_enabled(svr_cfg) { let checker = PingChecker { server: server.clone(), server_type: ServerType::Udp, @@ -523,7 +523,7 @@ impl PingBalancerContext { let mut check_tcp = false; let mut check_udp = false; - if self.mode.enable_tcp() && PingBalancerContext::check_server_tcp_enabled(best_tcp_svr_cfg) { + if self.mode.enable_tcp() && Self::check_server_tcp_enabled(best_tcp_svr_cfg) { let checker = PingChecker { server: best_tcp_server.clone(), server_type: ServerType::Tcp, @@ -534,7 +534,7 @@ impl PingBalancerContext { check_tcp = true; } - if self.mode.enable_udp() && PingBalancerContext::check_server_udp_enabled(best_udp_svr_cfg) { + if self.mode.enable_udp() && Self::check_server_udp_enabled(best_udp_svr_cfg) { let checker = PingChecker { server: best_udp_server.clone(), server_type: ServerType::Udp, @@ -1032,7 +1032,7 @@ struct ServerConfigFormatter<'a> { } impl<'a> ServerConfigFormatter<'a> { - fn new(server_config: &'a ServerConfig) -> ServerConfigFormatter<'a> { + fn new(server_config: &'a ServerConfig) -> Self { ServerConfigFormatter { server_config } } } diff --git a/shadowsocks-rust/crates/shadowsocks-service/src/local/loadbalancing/server_data.rs b/shadowsocks-rust/crates/shadowsocks-service/src/local/loadbalancing/server_data.rs index 76cb6f5473..0a9a2dbe26 100644 --- a/shadowsocks-rust/crates/shadowsocks-service/src/local/loadbalancing/server_data.rs +++ b/shadowsocks-rust/crates/shadowsocks-service/src/local/loadbalancing/server_data.rs @@ -25,11 +25,11 @@ pub struct ServerScore { impl ServerScore { /// Create a `ServerScore` - pub fn new(user_weight: f32, max_server_rtt: Duration, check_window: Duration) -> ServerScore { + pub fn new(user_weight: f32, max_server_rtt: Duration, check_window: Duration) -> Self { let max_server_rtt = max_server_rtt.as_millis() as u32; assert!(max_server_rtt > 0); - ServerScore { + Self { stat_data: Mutex::new(ServerStat::new(user_weight, max_server_rtt, check_window)), score: AtomicU32::new(u32::MAX), } @@ -93,7 +93,7 @@ impl ServerIdent { svr_cfg: ServerInstanceConfig, max_server_rtt: Duration, check_window: Duration, - ) -> ServerIdent { + ) -> Self { let mut connect_opts = context.connect_opts_ref().clone(); #[cfg(any(target_os = "linux", target_os = "android"))] @@ -114,7 +114,7 @@ impl ServerIdent { connect_opts.bind_interface = Some(bind_interface.clone()); } - ServerIdent { + Self { tcp_score: ServerScore::new(svr_cfg.config.weight().tcp_weight(), max_server_rtt, check_window), udp_score: ServerScore::new(svr_cfg.config.weight().udp_weight(), max_server_rtt, check_window), svr_cfg, diff --git a/shadowsocks-rust/crates/shadowsocks-service/src/local/loadbalancing/server_stat.rs b/shadowsocks-rust/crates/shadowsocks-service/src/local/loadbalancing/server_stat.rs index a81d2e7165..dd80cd7a09 100644 --- a/shadowsocks-rust/crates/shadowsocks-service/src/local/loadbalancing/server_stat.rs +++ b/shadowsocks-rust/crates/shadowsocks-service/src/local/loadbalancing/server_stat.rs @@ -64,11 +64,11 @@ fn max_latency_stdev(max_server_rtt: u32) -> f64 { } impl ServerStat { - pub fn new(user_weight: f32, max_server_rtt: u32, check_window: Duration) -> ServerStat { + pub fn new(user_weight: f32, max_server_rtt: u32, check_window: Duration) -> Self { assert!((0.0..=1.0).contains(&user_weight)); let max_latency_stdev = max_latency_stdev(max_server_rtt); - ServerStat { + Self { max_server_rtt, latency_queue: VecDeque::new(), max_latency_stdev, diff --git a/shadowsocks-rust/crates/shadowsocks-service/src/local/mod.rs b/shadowsocks-rust/crates/shadowsocks-service/src/local/mod.rs index e6447fe0e7..96698ed1bf 100644 --- a/shadowsocks-rust/crates/shadowsocks-service/src/local/mod.rs +++ b/shadowsocks-rust/crates/shadowsocks-service/src/local/mod.rs @@ -94,7 +94,7 @@ pub struct Server { impl Server { /// Create a shadowsocks local server - pub async fn new(config: Config) -> io::Result { + pub async fn new(config: Config) -> io::Result { assert!(config.config_type == ConfigType::Local && !config.local.is_empty()); trace!("{:?}", config); @@ -223,7 +223,7 @@ impl Server { balancer_builder.build().await? }; - let mut local_server = Server { + let mut local_server = Self { balancer: balancer.clone(), socks_servers: Vec::new(), #[cfg(feature = "local-tunnel")] diff --git a/shadowsocks-rust/crates/shadowsocks-service/src/local/net/tcp/auto_proxy_stream.rs b/shadowsocks-rust/crates/shadowsocks-service/src/local/net/tcp/auto_proxy_stream.rs index 36fea6b32e..580bb01ee5 100644 --- a/shadowsocks-rust/crates/shadowsocks-service/src/local/net/tcp/auto_proxy_stream.rs +++ b/shadowsocks-rust/crates/shadowsocks-service/src/local/net/tcp/auto_proxy_stream.rs @@ -36,11 +36,11 @@ impl AutoProxyClientStream { context: Arc, server: &ServerIdent, addr: A, - ) -> io::Result + ) -> io::Result where A: Into
, { - AutoProxyClientStream::connect_with_opts(context.clone(), server, addr, context.connect_opts_ref()).await + Self::connect_with_opts(context.clone(), server, addr, context.connect_opts_ref()).await } /// Connect to target `addr` via shadowsocks' server configured by `svr_cfg` @@ -49,24 +49,24 @@ impl AutoProxyClientStream { server: &ServerIdent, addr: A, opts: &ConnectOpts, - ) -> io::Result + ) -> io::Result where A: Into
, { let addr = addr.into(); if context.check_target_bypassed(&addr).await { - AutoProxyClientStream::connect_bypassed_with_opts(context, addr, opts).await + Self::connect_bypassed_with_opts(context, addr, opts).await } else { - AutoProxyClientStream::connect_proxied_with_opts(context, server, addr, opts).await + Self::connect_proxied_with_opts(context, server, addr, opts).await } } /// Connect directly to target `addr` - pub async fn connect_bypassed(context: Arc, addr: A) -> io::Result + pub async fn connect_bypassed(context: Arc, addr: A) -> io::Result where A: Into
, { - AutoProxyClientStream::connect_bypassed_with_opts(context.clone(), addr, context.connect_opts_ref()).await + Self::connect_bypassed_with_opts(context.clone(), addr, context.connect_opts_ref()).await } /// Connect directly to target `addr` @@ -74,7 +74,7 @@ impl AutoProxyClientStream { context: Arc, addr: A, connect_opts: &ConnectOpts, - ) -> io::Result + ) -> io::Result where A: Into
, { @@ -86,7 +86,7 @@ impl AutoProxyClientStream { addr = mapped_addr; } let stream = TcpStream::connect_remote_with_opts(context.context_ref(), &addr, connect_opts).await?; - Ok(AutoProxyClientStream::Bypassed(stream)) + Ok(Self::Bypassed(stream)) } /// Connect to target `addr` via shadowsocks' server configured by `svr_cfg` @@ -94,11 +94,11 @@ impl AutoProxyClientStream { context: Arc, server: &ServerIdent, addr: A, - ) -> io::Result + ) -> io::Result where A: Into
, { - AutoProxyClientStream::connect_proxied_with_opts(context.clone(), server, addr, context.connect_opts_ref()) + Self::connect_proxied_with_opts(context.clone(), server, addr, context.connect_opts_ref()) .await } @@ -108,7 +108,7 @@ impl AutoProxyClientStream { server: &ServerIdent, addr: A, connect_opts: &ConnectOpts, - ) -> io::Result + ) -> io::Result where A: Into
, { @@ -134,27 +134,27 @@ impl AutoProxyClientStream { return Err(err); } }; - Ok(AutoProxyClientStream::Proxied(stream)) + Ok(Self::Proxied(stream)) } pub fn local_addr(&self) -> io::Result { match *self { - AutoProxyClientStream::Proxied(ref s) => s.get_ref().get_ref().local_addr(), - AutoProxyClientStream::Bypassed(ref s) => s.local_addr(), + Self::Proxied(ref s) => s.get_ref().get_ref().local_addr(), + Self::Bypassed(ref s) => s.local_addr(), } } pub fn set_nodelay(&self, nodelay: bool) -> io::Result<()> { match *self { - AutoProxyClientStream::Proxied(ref s) => s.get_ref().get_ref().set_nodelay(nodelay), - AutoProxyClientStream::Bypassed(ref s) => s.set_nodelay(nodelay), + Self::Proxied(ref s) => s.get_ref().get_ref().set_nodelay(nodelay), + Self::Bypassed(ref s) => s.set_nodelay(nodelay), } } } impl AutoProxyIo for AutoProxyClientStream { fn is_proxied(&self) -> bool { - matches!(*self, AutoProxyClientStream::Proxied(..)) + matches!(*self, Self::Proxied(..)) } } @@ -203,6 +203,6 @@ impl AsyncWrite for AutoProxyClientStream { impl From>> for AutoProxyClientStream { fn from(s: ProxyClientStream>) -> Self { - AutoProxyClientStream::Proxied(s) + Self::Proxied(s) } } diff --git a/shadowsocks-rust/crates/shadowsocks-service/src/local/net/udp/association.rs b/shadowsocks-rust/crates/shadowsocks-service/src/local/net/udp/association.rs index e80c0a4ed5..a2f4648266 100644 --- a/shadowsocks-rust/crates/shadowsocks-service/src/local/net/udp/association.rs +++ b/shadowsocks-rust/crates/shadowsocks-service/src/local/net/udp/association.rs @@ -68,7 +68,7 @@ where time_to_live: Option, capacity: Option, balancer: PingBalancer, - ) -> (UdpAssociationManager, Duration, mpsc::Receiver) { + ) -> (Self, Duration, mpsc::Receiver) { let time_to_live = time_to_live.unwrap_or(crate::DEFAULT_UDP_EXPIRY_DURATION); let assoc_map = match capacity { Some(capacity) => LruCache::with_expiry_duration_and_capacity(time_to_live, capacity), @@ -78,7 +78,7 @@ where let (keepalive_tx, keepalive_rx) = mpsc::channel(UDP_ASSOCIATION_KEEP_ALIVE_CHANNEL_SIZE); ( - UdpAssociationManager { + Self { respond_writer, context, assoc_map, @@ -162,7 +162,7 @@ where balancer: PingBalancer, respond_writer: W, server_session_expire_duration: Duration, - ) -> UdpAssociation { + ) -> Self { let (assoc_handle, sender) = UdpAssociationContext::create( context, peer_addr, @@ -171,7 +171,7 @@ where respond_writer, server_session_expire_duration, ); - UdpAssociation { + Self { assoc_handle, sender, writer: PhantomData, @@ -198,8 +198,8 @@ struct ServerSessionContext { } impl ServerSessionContext { - fn new(session_expire_duration: Duration) -> ServerSessionContext { - ServerSessionContext { + fn new(session_expire_duration: Duration) -> Self { + Self { server_session_map: LruCache::with_expiry_duration(session_expire_duration), } } @@ -265,7 +265,7 @@ where // being OOM. let (sender, receiver) = mpsc::channel(UDP_ASSOCIATION_SEND_CHANNEL_SIZE); - let mut assoc = UdpAssociationContext { + let mut assoc = Self { context, peer_addr, bypassed_ipv4_socket: None, diff --git a/shadowsocks-rust/crates/shadowsocks-service/src/local/online_config/content_encoding.rs b/shadowsocks-rust/crates/shadowsocks-service/src/local/online_config/content_encoding.rs index 64a4c86470..a3959d63a0 100644 --- a/shadowsocks-rust/crates/shadowsocks-service/src/local/online_config/content_encoding.rs +++ b/shadowsocks-rust/crates/shadowsocks-service/src/local/online_config/content_encoding.rs @@ -26,15 +26,15 @@ impl<'a> TryFrom<&'a HeaderValue> for ContentEncoding { fn try_from(value: &'a HeaderValue) -> Result { if value == HeaderValue::from_static("identity") { - Ok(ContentEncoding::Identity) + Ok(Self::Identity) } else if value == HeaderValue::from_static("deflate") { - Ok(ContentEncoding::Deflate) + Ok(Self::Deflate) } else if value == HeaderValue::from_static("gzip") { - Ok(ContentEncoding::Gzip) + Ok(Self::Gzip) } else if value == HeaderValue::from_static("br") { - Ok(ContentEncoding::Br) + Ok(Self::Br) } else if value == HeaderValue::from_static("zstd") { - Ok(ContentEncoding::Zstd) + Ok(Self::Zstd) } else { Err(ContentEncodingError) } diff --git a/shadowsocks-rust/crates/shadowsocks-service/src/local/online_config/mod.rs b/shadowsocks-rust/crates/shadowsocks-service/src/local/online_config/mod.rs index 433e0e3420..b8191ec185 100644 --- a/shadowsocks-rust/crates/shadowsocks-service/src/local/online_config/mod.rs +++ b/shadowsocks-rust/crates/shadowsocks-service/src/local/online_config/mod.rs @@ -35,8 +35,8 @@ pub struct OnlineConfigServiceBuilder { impl OnlineConfigServiceBuilder { /// Create a Builder - pub fn new(context: Arc, config_url: String, balancer: PingBalancer) -> OnlineConfigServiceBuilder { - OnlineConfigServiceBuilder { + pub fn new(context: Arc, config_url: String, balancer: PingBalancer) -> Self { + Self { context, config_url, balancer, diff --git a/shadowsocks-rust/crates/shadowsocks-service/src/local/redir/server.rs b/shadowsocks-rust/crates/shadowsocks-service/src/local/redir/server.rs index bdac16e6be..7f4d537b79 100644 --- a/shadowsocks-rust/crates/shadowsocks-service/src/local/redir/server.rs +++ b/shadowsocks-rust/crates/shadowsocks-service/src/local/redir/server.rs @@ -27,14 +27,14 @@ pub struct RedirBuilder { impl RedirBuilder { /// Create a new transparent proxy server with default configuration - pub fn new(client_addr: ServerAddr, balancer: PingBalancer) -> RedirBuilder { + pub fn new(client_addr: ServerAddr, balancer: PingBalancer) -> Self { let context = ServiceContext::new(); - RedirBuilder::with_context(Arc::new(context), client_addr, balancer) + Self::with_context(Arc::new(context), client_addr, balancer) } /// Create a new transparent proxy server with context - pub fn with_context(context: Arc, client_addr: ServerAddr, balancer: PingBalancer) -> RedirBuilder { - RedirBuilder { + pub fn with_context(context: Arc, client_addr: ServerAddr, balancer: PingBalancer) -> Self { + Self { context, mode: Mode::TcpOnly, udp_expiry_duration: None, diff --git a/shadowsocks-rust/crates/shadowsocks-service/src/local/redir/tcprelay/mod.rs b/shadowsocks-rust/crates/shadowsocks-service/src/local/redir/tcprelay/mod.rs index b42c919db8..9a844ffd94 100644 --- a/shadowsocks-rust/crates/shadowsocks-service/src/local/redir/tcprelay/mod.rs +++ b/shadowsocks-rust/crates/shadowsocks-service/src/local/redir/tcprelay/mod.rs @@ -86,7 +86,7 @@ impl RedirTcpServer { client_config: &ServerAddr, balancer: PingBalancer, redir_ty: RedirType, - ) -> io::Result { + ) -> io::Result { let listener = match *client_config { ServerAddr::SocketAddr(ref saddr) => { TcpListener::bind_redir(redir_ty, *saddr, context.accept_opts()).await? @@ -99,7 +99,7 @@ impl RedirTcpServer { } }; - Ok(RedirTcpServer { + Ok(Self { context, listener, balancer, diff --git a/shadowsocks-rust/crates/shadowsocks-service/src/local/redir/tcprelay/sys/unix/linux.rs b/shadowsocks-rust/crates/shadowsocks-service/src/local/redir/tcprelay/sys/unix/linux.rs index 3fa008d770..b42a8d16a2 100644 --- a/shadowsocks-rust/crates/shadowsocks-service/src/local/redir/tcprelay/sys/unix/linux.rs +++ b/shadowsocks-rust/crates/shadowsocks-service/src/local/redir/tcprelay/sys/unix/linux.rs @@ -19,7 +19,7 @@ use crate::{ }; impl TcpListenerRedirExt for TcpListener { - async fn bind_redir(ty: RedirType, addr: SocketAddr, accept_opts: AcceptOpts) -> io::Result { + async fn bind_redir(ty: RedirType, addr: SocketAddr, accept_opts: AcceptOpts) -> io::Result { match ty { RedirType::Redirect => { // REDIRECT rule doesn't need to set IP_TRANSPARENT diff --git a/shadowsocks-rust/crates/shadowsocks-service/src/local/redir/udprelay/mod.rs b/shadowsocks-rust/crates/shadowsocks-service/src/local/redir/udprelay/mod.rs index 7a62658ba7..a6135377ea 100644 --- a/shadowsocks-rust/crates/shadowsocks-service/src/local/redir/udprelay/mod.rs +++ b/shadowsocks-rust/crates/shadowsocks-service/src/local/redir/udprelay/mod.rs @@ -46,7 +46,7 @@ impl Drop for UdpRedirInboundCache { } impl UdpRedirInboundCache { - fn new() -> UdpRedirInboundCache { + fn new() -> Self { let cache = Arc::new(Mutex::new(LruCache::with_expiry_duration_and_capacity( INBOUND_SOCKET_CACHE_EXPIRATION, INBOUND_SOCKET_CACHE_CAPACITY, @@ -62,7 +62,7 @@ impl UdpRedirInboundCache { }) }; - UdpRedirInboundCache { cache, watcher } + Self { cache, watcher } } } @@ -75,8 +75,8 @@ struct UdpRedirInboundWriter { impl UdpRedirInboundWriter { #[allow(unused_variables, clippy::needless_update)] - fn new(redir_ty: RedirType, opts: &ConnectOpts) -> UdpRedirInboundWriter { - UdpRedirInboundWriter { + fn new(redir_ty: RedirType, opts: &ConnectOpts) -> Self { + Self { redir_ty, socket_opts: RedirSocketOpts { #[cfg(any(target_os = "linux", target_os = "android"))] @@ -212,7 +212,7 @@ impl RedirUdpServer { time_to_live: Option, capacity: Option, balancer: PingBalancer, - ) -> io::Result { + ) -> io::Result { let listener = match *client_config { ServerAddr::SocketAddr(ref saddr) => UdpRedirSocket::listen(redir_ty, *saddr)?, ServerAddr::DomainName(ref dname, port) => { @@ -223,7 +223,7 @@ impl RedirUdpServer { } }; - Ok(RedirUdpServer { + Ok(Self { context, redir_ty, time_to_live, diff --git a/shadowsocks-rust/crates/shadowsocks-service/src/local/redir/udprelay/sys/unix/linux.rs b/shadowsocks-rust/crates/shadowsocks-service/src/local/redir/udprelay/sys/unix/linux.rs index ef84f3fac5..a54ab75858 100644 --- a/shadowsocks-rust/crates/shadowsocks-service/src/local/redir/udprelay/sys/unix/linux.rs +++ b/shadowsocks-rust/crates/shadowsocks-service/src/local/redir/udprelay/sys/unix/linux.rs @@ -30,15 +30,15 @@ impl UdpRedirSocket { /// Create a new UDP socket binded to `addr` /// /// This will allow listening to `addr` that is not in local host - pub fn listen(ty: RedirType, addr: SocketAddr) -> io::Result { - UdpRedirSocket::bind(ty, addr, false) + pub fn listen(ty: RedirType, addr: SocketAddr) -> io::Result { + Self::bind(ty, addr, false) } /// Create a new UDP socket binded to `addr` /// /// This will allow binding to `addr` that is not in local host - pub fn bind_nonlocal(ty: RedirType, addr: SocketAddr, redir_opts: &RedirSocketOpts) -> io::Result { - let socket = UdpRedirSocket::bind(ty, addr, true)?; + pub fn bind_nonlocal(ty: RedirType, addr: SocketAddr, redir_opts: &RedirSocketOpts) -> io::Result { + let socket = Self::bind(ty, addr, true)?; if let Some(mark) = redir_opts.fwmark { let ret = unsafe { @@ -58,7 +58,7 @@ impl UdpRedirSocket { Ok(socket) } - fn bind(ty: RedirType, addr: SocketAddr, reuse_port: bool) -> io::Result { + fn bind(ty: RedirType, addr: SocketAddr, reuse_port: bool) -> io::Result { if ty != RedirType::TProxy { return Err(Error::new( ErrorKind::InvalidInput, @@ -123,7 +123,7 @@ impl UdpRedirSocket { } let io = AsyncFd::new(socket.into())?; - Ok(UdpRedirSocket { io }) + Ok(Self { io }) } /// Send data to the socket to the given target address diff --git a/shadowsocks-rust/crates/shadowsocks-service/src/local/socks/client/socks4/tcp_client.rs b/shadowsocks-rust/crates/shadowsocks-service/src/local/socks/client/socks4/tcp_client.rs index ea5fae2c27..998248807e 100644 --- a/shadowsocks-rust/crates/shadowsocks-service/src/local/socks/client/socks4/tcp_client.rs +++ b/shadowsocks-rust/crates/shadowsocks-service/src/local/socks/client/socks4/tcp_client.rs @@ -24,7 +24,7 @@ pub struct Socks4TcpClient { impl Socks4TcpClient { /// Connects to `addr` via `proxy` - pub async fn connect(addr: A, proxy: P, user_id: U) -> Result + pub async fn connect(addr: A, proxy: P, user_id: U) -> Result where A: Into
, P: ToSocketAddrs, @@ -51,7 +51,7 @@ impl Socks4TcpClient { return Err(Error::Result(hsp.cd)); } - Ok(Socks4TcpClient { stream: s }) + Ok(Self { stream: s }) } } diff --git a/shadowsocks-rust/crates/shadowsocks-service/src/local/socks/client/socks5/tcp_client.rs b/shadowsocks-rust/crates/shadowsocks-service/src/local/socks/client/socks5/tcp_client.rs index 4d7a86862f..fc89b1e4a7 100644 --- a/shadowsocks-rust/crates/shadowsocks-service/src/local/socks/client/socks5/tcp_client.rs +++ b/shadowsocks-rust/crates/shadowsocks-service/src/local/socks/client/socks5/tcp_client.rs @@ -25,7 +25,7 @@ pub struct Socks5TcpClient { impl Socks5TcpClient { /// Connects to `addr` via `proxy` - pub async fn connect(addr: A, proxy: P) -> Result + pub async fn connect(addr: A, proxy: P) -> Result where A: Into
, P: ToSocketAddrs, @@ -56,13 +56,13 @@ impl Socks5TcpClient { r => return Err(Error::Reply(r)), } - Ok(Socks5TcpClient { stream: s }) + Ok(Self { stream: s }) } /// UDP Associate `addr` via `proxy` /// /// According to RFC, `addr` is the address that your UDP socket binds to - pub async fn udp_associate(addr: A, proxy: P) -> Result<(Socks5TcpClient, Address), Error> + pub async fn udp_associate(addr: A, proxy: P) -> Result<(Self, Address), Error> where A: Into
, P: ToSocketAddrs, @@ -93,7 +93,7 @@ impl Socks5TcpClient { r => return Err(Error::Reply(r)), } - Ok((Socks5TcpClient { stream: s }, hp.address)) + Ok((Self { stream: s }, hp.address)) } } diff --git a/shadowsocks-rust/crates/shadowsocks-service/src/local/socks/client/socks5/udp_client.rs b/shadowsocks-rust/crates/shadowsocks-service/src/local/socks/client/socks5/udp_client.rs index 16c3bdf811..32a55c5956 100644 --- a/shadowsocks-rust/crates/shadowsocks-service/src/local/socks/client/socks5/udp_client.rs +++ b/shadowsocks-rust/crates/shadowsocks-service/src/local/socks/client/socks5/udp_client.rs @@ -20,11 +20,11 @@ pub struct Socks5UdpClient { impl Socks5UdpClient { /// Create a new UDP associate client binds to a specific address - pub async fn bind(addrs: A) -> io::Result + pub async fn bind(addrs: A) -> io::Result where A: ToSocketAddrs, { - Ok(Socks5UdpClient { + Ok(Self { socket: UdpSocket::bind(addrs).await?, assoc_client: None, }) diff --git a/shadowsocks-rust/crates/shadowsocks-service/src/local/socks/config.rs b/shadowsocks-rust/crates/shadowsocks-service/src/local/socks/config.rs index 81a05a91d6..5378fac980 100644 --- a/shadowsocks-rust/crates/shadowsocks-service/src/local/socks/config.rs +++ b/shadowsocks-rust/crates/shadowsocks-service/src/local/socks/config.rs @@ -35,8 +35,8 @@ pub struct Socks5AuthConfig { impl Socks5AuthConfig { /// Create a new SOCKS5 Authentication configuration - pub fn new() -> Socks5AuthConfig { - Socks5AuthConfig { + pub fn new() -> Self { + Self { passwd: Socks5AuthPasswdConfig::new(), } } @@ -54,7 +54,7 @@ impl Socks5AuthConfig { /// ] /// } /// } - pub fn load_from_file + ?Sized>(filename: &P) -> io::Result { + pub fn load_from_file + ?Sized>(filename: &P) -> io::Result { let filename = filename.as_ref(); trace!( @@ -78,7 +78,7 @@ impl Socks5AuthConfig { } } - Ok(Socks5AuthConfig { passwd }) + Ok(Self { passwd }) } /// Check if authentication is required @@ -88,8 +88,8 @@ impl Socks5AuthConfig { } impl Default for Socks5AuthConfig { - fn default() -> Socks5AuthConfig { - Socks5AuthConfig::new() + fn default() -> Self { + Self::new() } } @@ -103,8 +103,8 @@ pub struct Socks5AuthPasswdConfig { impl Socks5AuthPasswdConfig { /// Create an empty `Passwd` configuration - pub fn new() -> Socks5AuthPasswdConfig { - Socks5AuthPasswdConfig { passwd: HashMap::new() } + pub fn new() -> Self { + Self { passwd: HashMap::new() } } /// Add a user with password @@ -135,7 +135,7 @@ impl Socks5AuthPasswdConfig { } impl Default for Socks5AuthPasswdConfig { - fn default() -> Socks5AuthPasswdConfig { - Socks5AuthPasswdConfig::new() + fn default() -> Self { + Self::new() } } diff --git a/shadowsocks-rust/crates/shadowsocks-service/src/local/socks/server/mod.rs b/shadowsocks-rust/crates/shadowsocks-service/src/local/socks/server/mod.rs index 0e060a3b1c..03c1583839 100644 --- a/shadowsocks-rust/crates/shadowsocks-service/src/local/socks/server/mod.rs +++ b/shadowsocks-rust/crates/shadowsocks-service/src/local/socks/server/mod.rs @@ -37,9 +37,9 @@ pub struct SocksBuilder { impl SocksBuilder { /// Create a new SOCKS server with default configuration - pub fn new(client_config: ServerAddr, balancer: PingBalancer) -> SocksBuilder { + pub fn new(client_config: ServerAddr, balancer: PingBalancer) -> Self { let context = ServiceContext::new(); - SocksBuilder::with_context(Arc::new(context), client_config, balancer) + Self::with_context(Arc::new(context), client_config, balancer) } /// Create a new SOCKS server with context @@ -47,8 +47,8 @@ impl SocksBuilder { context: Arc, client_config: ServerAddr, balancer: PingBalancer, - ) -> SocksBuilder { - SocksBuilder { + ) -> Self { + Self { context, mode: Mode::TcpOnly, udp_expiry_duration: None, diff --git a/shadowsocks-rust/crates/shadowsocks-service/src/local/socks/server/server.rs b/shadowsocks-rust/crates/shadowsocks-service/src/local/socks/server/server.rs index f264fe29dd..31f2640953 100644 --- a/shadowsocks-rust/crates/shadowsocks-service/src/local/socks/server/server.rs +++ b/shadowsocks-rust/crates/shadowsocks-service/src/local/socks/server/server.rs @@ -34,8 +34,8 @@ impl SocksTcpServerBuilder { balancer: PingBalancer, mode: Mode, socks5_auth: Socks5AuthConfig, - ) -> SocksTcpServerBuilder { - SocksTcpServerBuilder { + ) -> Self { + Self { context, client_config, udp_associate_addr, diff --git a/shadowsocks-rust/crates/shadowsocks-service/src/local/socks/server/socks4/tcprelay.rs b/shadowsocks-rust/crates/shadowsocks-service/src/local/socks/server/socks4/tcprelay.rs index 34dc2900c7..534eac9ac0 100644 --- a/shadowsocks-rust/crates/shadowsocks-service/src/local/socks/server/socks4/tcprelay.rs +++ b/shadowsocks-rust/crates/shadowsocks-service/src/local/socks/server/socks4/tcprelay.rs @@ -31,8 +31,8 @@ pub struct Socks4TcpHandler { } impl Socks4TcpHandler { - pub fn new(context: Arc, balancer: PingBalancer, mode: Mode) -> Socks4TcpHandler { - Socks4TcpHandler { + pub fn new(context: Arc, balancer: PingBalancer, mode: Mode) -> Self { + Self { context, balancer, mode, diff --git a/shadowsocks-rust/crates/shadowsocks-service/src/local/socks/server/socks5/tcprelay.rs b/shadowsocks-rust/crates/shadowsocks-service/src/local/socks/server/socks5/tcprelay.rs index e377e3f17b..f359acfaba 100644 --- a/shadowsocks-rust/crates/shadowsocks-service/src/local/socks/server/socks5/tcprelay.rs +++ b/shadowsocks-rust/crates/shadowsocks-service/src/local/socks/server/socks5/tcprelay.rs @@ -44,8 +44,8 @@ impl Socks5TcpHandler { balancer: PingBalancer, mode: Mode, auth: Arc, - ) -> Socks5TcpHandler { - Socks5TcpHandler { + ) -> Self { + Self { context, udp_associate_addr, balancer, diff --git a/shadowsocks-rust/crates/shadowsocks-service/src/local/socks/server/socks5/udprelay.rs b/shadowsocks-rust/crates/shadowsocks-service/src/local/socks/server/socks5/udprelay.rs index 54e5234617..d0c95d81a9 100644 --- a/shadowsocks-rust/crates/shadowsocks-service/src/local/socks/server/socks5/udprelay.rs +++ b/shadowsocks-rust/crates/shadowsocks-service/src/local/socks/server/socks5/udprelay.rs @@ -45,8 +45,8 @@ impl Socks5UdpServerBuilder { time_to_live: Option, capacity: Option, balancer: PingBalancer, - ) -> Socks5UdpServerBuilder { - Socks5UdpServerBuilder { + ) -> Self { + Self { context, client_config, time_to_live, diff --git a/shadowsocks-rust/crates/shadowsocks-service/src/local/socks/socks4.rs b/shadowsocks-rust/crates/shadowsocks-service/src/local/socks/socks4.rs index 11c1bedf75..0fc7138d47 100644 --- a/shadowsocks-rust/crates/shadowsocks-service/src/local/socks/socks4.rs +++ b/shadowsocks-rust/crates/shadowsocks-service/src/local/socks/socks4.rs @@ -43,16 +43,16 @@ impl Command { #[inline] fn as_u8(self) -> u8 { match self { - Command::Connect => consts::SOCKS4_COMMAND_CONNECT, - Command::Bind => consts::SOCKS4_COMMAND_BIND, + Self::Connect => consts::SOCKS4_COMMAND_CONNECT, + Self::Bind => consts::SOCKS4_COMMAND_BIND, } } #[inline] - fn from_u8(code: u8) -> Option { + fn from_u8(code: u8) -> Option { match code { - consts::SOCKS4_COMMAND_CONNECT => Some(Command::Connect), - consts::SOCKS4_COMMAND_BIND => Some(Command::Bind), + consts::SOCKS4_COMMAND_CONNECT => Some(Self::Connect), + consts::SOCKS4_COMMAND_BIND => Some(Self::Bind), _ => None, } } @@ -77,22 +77,22 @@ impl ResultCode { #[inline] fn as_u8(self) -> u8 { match self { - ResultCode::RequestGranted => consts::SOCKS4_RESULT_REQUEST_GRANTED, - ResultCode::RequestRejectedOrFailed => consts::SOCKS4_RESULT_REQUEST_REJECTED_OR_FAILED, - ResultCode::RequestRejectedCannotConnect => consts::SOCKS4_RESULT_REQUEST_REJECTED_CANNOT_CONNECT, - ResultCode::RequestRejectedDifferentUserId => consts::SOCKS4_RESULT_REQUEST_REJECTED_DIFFERENT_USER_ID, - ResultCode::Other(c) => c, + Self::RequestGranted => consts::SOCKS4_RESULT_REQUEST_GRANTED, + Self::RequestRejectedOrFailed => consts::SOCKS4_RESULT_REQUEST_REJECTED_OR_FAILED, + Self::RequestRejectedCannotConnect => consts::SOCKS4_RESULT_REQUEST_REJECTED_CANNOT_CONNECT, + Self::RequestRejectedDifferentUserId => consts::SOCKS4_RESULT_REQUEST_REJECTED_DIFFERENT_USER_ID, + Self::Other(c) => c, } } #[inline] - fn from_u8(code: u8) -> ResultCode { + fn from_u8(code: u8) -> Self { match code { - consts::SOCKS4_RESULT_REQUEST_GRANTED => ResultCode::RequestGranted, - consts::SOCKS4_RESULT_REQUEST_REJECTED_OR_FAILED => ResultCode::RequestRejectedOrFailed, - consts::SOCKS4_RESULT_REQUEST_REJECTED_CANNOT_CONNECT => ResultCode::RequestRejectedCannotConnect, - consts::SOCKS4_RESULT_REQUEST_REJECTED_DIFFERENT_USER_ID => ResultCode::RequestRejectedDifferentUserId, - code => ResultCode::Other(code), + consts::SOCKS4_RESULT_REQUEST_GRANTED => Self::RequestGranted, + consts::SOCKS4_RESULT_REQUEST_REJECTED_OR_FAILED => Self::RequestRejectedOrFailed, + consts::SOCKS4_RESULT_REQUEST_REJECTED_CANNOT_CONNECT => Self::RequestRejectedCannotConnect, + consts::SOCKS4_RESULT_REQUEST_REJECTED_DIFFERENT_USER_ID => Self::RequestRejectedDifferentUserId, + code => Self::Other(code), } } } @@ -100,15 +100,15 @@ impl ResultCode { impl fmt::Display for ResultCode { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { match *self { - ResultCode::RequestGranted => f.write_str("request granted"), - ResultCode::RequestRejectedOrFailed => f.write_str("request rejected or failed"), - ResultCode::RequestRejectedCannotConnect => { + Self::RequestGranted => f.write_str("request granted"), + Self::RequestRejectedOrFailed => f.write_str("request rejected or failed"), + Self::RequestRejectedCannotConnect => { f.write_str("request rejected because SOCKS server cannot connect to identd on the client") } - ResultCode::RequestRejectedDifferentUserId => { + Self::RequestRejectedDifferentUserId => { f.write_str("request rejected because the client program and identd report different user-ids") } - ResultCode::Other(code) => write!(f, "other result code {code}"), + Self::Other(code) => write!(f, "other result code {code}"), } } } @@ -126,8 +126,8 @@ impl fmt::Debug for Address { #[inline] fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { match *self { - Address::SocketAddress(ref addr) => write!(f, "{addr}"), - Address::DomainNameAddress(ref addr, ref port) => write!(f, "{addr}:{port}"), + Self::SocketAddress(ref addr) => write!(f, "{addr}"), + Self::DomainNameAddress(ref addr, ref port) => write!(f, "{addr}:{port}"), } } } @@ -136,41 +136,41 @@ impl fmt::Display for Address { #[inline] fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { match *self { - Address::SocketAddress(ref addr) => write!(f, "{addr}"), - Address::DomainNameAddress(ref addr, ref port) => write!(f, "{addr}:{port}"), + Self::SocketAddress(ref addr) => write!(f, "{addr}"), + Self::DomainNameAddress(ref addr, ref port) => write!(f, "{addr}:{port}"), } } } impl From for Address { - fn from(s: SocketAddrV4) -> Address { - Address::SocketAddress(s) + fn from(s: SocketAddrV4) -> Self { + Self::SocketAddress(s) } } impl From<(String, u16)> for Address { - fn from((dn, port): (String, u16)) -> Address { - Address::DomainNameAddress(dn, port) + fn from((dn, port): (String, u16)) -> Self { + Self::DomainNameAddress(dn, port) } } impl From<(&str, u16)> for Address { - fn from((dn, port): (&str, u16)) -> Address { - Address::DomainNameAddress(dn.to_owned(), port) + fn from((dn, port): (&str, u16)) -> Self { + Self::DomainNameAddress(dn.to_owned(), port) } } -impl From<&Address> for Address { - fn from(addr: &Address) -> Address { +impl From<&Self> for Address { + fn from(addr: &Self) -> Self { addr.clone() } } impl From
for socks5::Address { - fn from(addr: Address) -> socks5::Address { + fn from(addr: Address) -> Self { match addr { - Address::SocketAddress(a) => socks5::Address::SocketAddress(SocketAddr::V4(a)), - Address::DomainNameAddress(d, p) => socks5::Address::DomainNameAddress(d, p), + Address::SocketAddress(a) => Self::SocketAddress(SocketAddr::V4(a)), + Address::DomainNameAddress(d, p) => Self::DomainNameAddress(d, p), } } } @@ -201,7 +201,7 @@ pub struct HandshakeRequest { impl HandshakeRequest { /// Read from a reader - pub async fn read_from(r: &mut R) -> Result + pub async fn read_from(r: &mut R) -> Result where R: AsyncBufRead + Unpin, { @@ -250,7 +250,7 @@ impl HandshakeRequest { Address::SocketAddress(SocketAddrV4::new(ip, port)) }; - Ok(HandshakeRequest { + Ok(Self { cd: command, dst, user_id, @@ -327,12 +327,12 @@ pub struct HandshakeResponse { impl HandshakeResponse { /// Create a response with code - pub fn new(code: ResultCode) -> HandshakeResponse { - HandshakeResponse { cd: code } + pub fn new(code: ResultCode) -> Self { + Self { cd: code } } /// Read from a reader - pub async fn read_from(r: &mut R) -> Result + pub async fn read_from(r: &mut R) -> Result where R: AsyncRead + Unpin, { @@ -349,7 +349,7 @@ impl HandshakeResponse { // DSTPORT, DSTIP are ignored - Ok(HandshakeResponse { cd: result_code }) + Ok(Self { cd: result_code }) } /// Write data into a writer @@ -364,7 +364,7 @@ impl HandshakeResponse { /// Writes to buffer pub fn write_to_buf(&self, buf: &mut B) { - let HandshakeResponse { ref cd } = *self; + let Self { ref cd } = *self; buf.put_slice(&[ // VN: Result Code's version, must be 0 @@ -406,10 +406,10 @@ pub enum Error { } impl From for io::Error { - fn from(err: Error) -> io::Error { + fn from(err: Error) -> Self { match err { Error::IoError(err) => err, - e => io::Error::other(e), + e => Self::other(e), } } } diff --git a/shadowsocks-rust/crates/shadowsocks-service/src/local/tun/ip_packet.rs b/shadowsocks-rust/crates/shadowsocks-service/src/local/tun/ip_packet.rs index 1ec076f126..fdfa5a82b5 100644 --- a/shadowsocks-rust/crates/shadowsocks-service/src/local/tun/ip_packet.rs +++ b/shadowsocks-rust/crates/shadowsocks-service/src/local/tun/ip_packet.rs @@ -11,32 +11,32 @@ pub enum IpPacket> { } impl + Copy> IpPacket { - pub fn new_checked(packet: T) -> smoltcp::wire::Result>> { + pub fn new_checked(packet: T) -> smoltcp::wire::Result> { let buffer = packet.as_ref(); match IpVersion::of_packet(buffer)? { - IpVersion::Ipv4 => Ok(Some(IpPacket::Ipv4(Ipv4Packet::new_checked(packet)?))), - IpVersion::Ipv6 => Ok(Some(IpPacket::Ipv6(Ipv6Packet::new_checked(packet)?))), + IpVersion::Ipv4 => Ok(Some(Self::Ipv4(Ipv4Packet::new_checked(packet)?))), + IpVersion::Ipv6 => Ok(Some(Self::Ipv6(Ipv6Packet::new_checked(packet)?))), } } pub fn src_addr(&self) -> IpAddr { match *self { - IpPacket::Ipv4(ref packet) => IpAddr::from(packet.src_addr()), - IpPacket::Ipv6(ref packet) => IpAddr::from(packet.src_addr()), + Self::Ipv4(ref packet) => IpAddr::from(packet.src_addr()), + Self::Ipv6(ref packet) => IpAddr::from(packet.src_addr()), } } pub fn dst_addr(&self) -> IpAddr { match *self { - IpPacket::Ipv4(ref packet) => IpAddr::from(packet.dst_addr()), - IpPacket::Ipv6(ref packet) => IpAddr::from(packet.dst_addr()), + Self::Ipv4(ref packet) => IpAddr::from(packet.dst_addr()), + Self::Ipv6(ref packet) => IpAddr::from(packet.dst_addr()), } } pub fn protocol(&self) -> IpProtocol { match *self { - IpPacket::Ipv4(ref packet) => packet.next_header(), - IpPacket::Ipv6(ref packet) => packet.next_header(), + Self::Ipv4(ref packet) => packet.next_header(), + Self::Ipv6(ref packet) => packet.next_header(), } } } diff --git a/shadowsocks-rust/crates/shadowsocks-service/src/local/tun/mod.rs b/shadowsocks-rust/crates/shadowsocks-service/src/local/tun/mod.rs index d5abfd11e6..34e51ccfa4 100644 --- a/shadowsocks-rust/crates/shadowsocks-service/src/local/tun/mod.rs +++ b/shadowsocks-rust/crates/shadowsocks-service/src/local/tun/mod.rs @@ -64,8 +64,8 @@ unsafe impl Send for TunBuilder {} impl TunBuilder { /// Create a Tun service builder - pub fn new(context: Arc, balancer: PingBalancer) -> TunBuilder { - TunBuilder { + pub fn new(context: Arc, balancer: PingBalancer) -> Self { + Self { context, balancer, tun_config: TunConfiguration::default(), diff --git a/shadowsocks-rust/crates/shadowsocks-service/src/local/tun/tcp.rs b/shadowsocks-rust/crates/shadowsocks-service/src/local/tun/tcp.rs index ab6a746f4a..eb491a08af 100644 --- a/shadowsocks-rust/crates/shadowsocks-service/src/local/tun/tcp.rs +++ b/shadowsocks-rust/crates/shadowsocks-service/src/local/tun/tcp.rs @@ -68,8 +68,8 @@ struct ManagerNotify { } impl ManagerNotify { - fn new(thread: Thread) -> ManagerNotify { - ManagerNotify { thread } + fn new(thread: Thread) -> Self { + Self { thread } } fn notify(&self) { @@ -119,7 +119,7 @@ impl TcpConnection { socket_creation_tx: &mpsc::UnboundedSender, manager_notify: Arc, tcp_opts: &TcpSocketOpts, - ) -> impl Future + use<> { + ) -> impl Future + use<> { let send_buffer_size = tcp_opts.send_buffer_size.unwrap_or(DEFAULT_TCP_SEND_BUFFER_SIZE); let recv_buffer_size = tcp_opts.recv_buffer_size.unwrap_or(DEFAULT_TCP_RECV_BUFFER_SIZE); @@ -140,7 +140,7 @@ impl TcpConnection { async move { // waiting socket add to SocketSet let _ = rx.await; - TcpConnection { + Self { control, manager_notify, } @@ -257,7 +257,7 @@ impl Drop for TcpTun { } impl TcpTun { - pub fn new(context: Arc, balancer: PingBalancer, mtu: u32) -> TcpTun { + pub fn new(context: Arc, balancer: PingBalancer, mtu: u32) -> Self { let mut capabilities = DeviceCapabilities::default(); capabilities.medium = Medium::Ip; capabilities.max_transmission_unit = mtu as usize; @@ -486,7 +486,7 @@ impl TcpTun { let manager_notify = Arc::new(ManagerNotify::new(manager_handle.thread().clone())); - TcpTun { + Self { context, manager_handle: Some(manager_handle), manager_notify, diff --git a/shadowsocks-rust/crates/shadowsocks-service/src/local/tun/udp.rs b/shadowsocks-rust/crates/shadowsocks-service/src/local/tun/udp.rs index 2a25ba9de0..6eae9facb3 100644 --- a/shadowsocks-rust/crates/shadowsocks-service/src/local/tun/udp.rs +++ b/shadowsocks-rust/crates/shadowsocks-service/src/local/tun/udp.rs @@ -31,7 +31,7 @@ impl UdpTun { balancer: PingBalancer, time_to_live: Option, capacity: Option, - ) -> (UdpTun, Duration, mpsc::Receiver) { + ) -> (Self, Duration, mpsc::Receiver) { let (tun_tx, tun_rx) = mpsc::channel(64); let (manager, cleanup_interval, keepalive_rx) = UdpAssociationManager::new( context, @@ -41,7 +41,7 @@ impl UdpTun { balancer, ); - (UdpTun { tun_rx, manager }, cleanup_interval, keepalive_rx) + (Self { tun_rx, manager }, cleanup_interval, keepalive_rx) } pub async fn handle_packet( @@ -87,8 +87,8 @@ struct UdpTunInboundWriter { } impl UdpTunInboundWriter { - fn new(tun_tx: mpsc::Sender) -> UdpTunInboundWriter { - UdpTunInboundWriter { tun_tx } + fn new(tun_tx: mpsc::Sender) -> Self { + Self { tun_tx } } } diff --git a/shadowsocks-rust/crates/shadowsocks-service/src/local/tun/virt_device.rs b/shadowsocks-rust/crates/shadowsocks-service/src/local/tun/virt_device.rs index 22ee37c342..bca9a20fe0 100644 --- a/shadowsocks-rust/crates/shadowsocks-service/src/local/tun/virt_device.rs +++ b/shadowsocks-rust/crates/shadowsocks-service/src/local/tun/virt_device.rs @@ -141,13 +141,13 @@ impl Drop for TokenBuffer { } impl TokenBuffer { - pub fn with_capacity(cap: usize) -> TokenBuffer { + pub fn with_capacity(cap: usize) -> Self { let mut list = TOKEN_BUFFER_LIST.lock().unwrap(); if let Some(mut buffer) = list.pop() { buffer.reserve(cap); - return TokenBuffer { buffer }; + return Self { buffer }; } - TokenBuffer { + Self { buffer: BytesMut::with_capacity(cap), } } diff --git a/shadowsocks-rust/crates/shadowsocks-service/src/local/tunnel/server.rs b/shadowsocks-rust/crates/shadowsocks-service/src/local/tunnel/server.rs index 4b853ef9f0..f25b276eec 100644 --- a/shadowsocks-rust/crates/shadowsocks-service/src/local/tunnel/server.rs +++ b/shadowsocks-rust/crates/shadowsocks-service/src/local/tunnel/server.rs @@ -29,9 +29,9 @@ pub struct TunnelBuilder { impl TunnelBuilder { /// Create a new Tunnel server forwarding to `forward_addr` - pub fn new(forward_addr: Address, client_addr: ServerAddr, balancer: PingBalancer) -> TunnelBuilder { + pub fn new(forward_addr: Address, client_addr: ServerAddr, balancer: PingBalancer) -> Self { let context = ServiceContext::new(); - TunnelBuilder::with_context(Arc::new(context), forward_addr, client_addr, balancer) + Self::with_context(Arc::new(context), forward_addr, client_addr, balancer) } /// Create a new Tunnel server with context @@ -40,8 +40,8 @@ impl TunnelBuilder { forward_addr: Address, client_addr: ServerAddr, balancer: PingBalancer, - ) -> TunnelBuilder { - TunnelBuilder { + ) -> Self { + Self { context, forward_addr, mode: Mode::TcpOnly, diff --git a/shadowsocks-rust/crates/shadowsocks-service/src/local/tunnel/tcprelay.rs b/shadowsocks-rust/crates/shadowsocks-service/src/local/tunnel/tcprelay.rs index 59f5d435a1..c387125f25 100644 --- a/shadowsocks-rust/crates/shadowsocks-service/src/local/tunnel/tcprelay.rs +++ b/shadowsocks-rust/crates/shadowsocks-service/src/local/tunnel/tcprelay.rs @@ -28,8 +28,8 @@ impl TunnelTcpServerBuilder { client_config: ServerAddr, balancer: PingBalancer, forward_addr: Address, - ) -> TunnelTcpServerBuilder { - TunnelTcpServerBuilder { + ) -> Self { + Self { context, client_config, balancer, diff --git a/shadowsocks-rust/crates/shadowsocks-service/src/local/tunnel/udprelay.rs b/shadowsocks-rust/crates/shadowsocks-service/src/local/tunnel/udprelay.rs index e9ced6dd24..bbc6a31a3e 100644 --- a/shadowsocks-rust/crates/shadowsocks-service/src/local/tunnel/udprelay.rs +++ b/shadowsocks-rust/crates/shadowsocks-service/src/local/tunnel/udprelay.rs @@ -34,8 +34,8 @@ impl TunnelUdpServerBuilder { capacity: Option, balancer: PingBalancer, forward_addr: Address, - ) -> TunnelUdpServerBuilder { - TunnelUdpServerBuilder { + ) -> Self { + Self { context, client_config, time_to_live, diff --git a/shadowsocks-rust/crates/shadowsocks-service/src/manager/server.rs b/shadowsocks-rust/crates/shadowsocks-service/src/manager/server.rs index 2c0793ee7c..29ca40cd88 100644 --- a/shadowsocks-rust/crates/shadowsocks-service/src/manager/server.rs +++ b/shadowsocks-rust/crates/shadowsocks-service/src/manager/server.rs @@ -79,13 +79,13 @@ pub struct ManagerBuilder { impl ManagerBuilder { /// Create a new manager server builder from configuration - pub fn new(svr_cfg: ManagerConfig) -> ManagerBuilder { - ManagerBuilder::with_context(svr_cfg, Context::new_shared(ServerType::Server)) + pub fn new(svr_cfg: ManagerConfig) -> Self { + Self::with_context(svr_cfg, Context::new_shared(ServerType::Server)) } /// Create a new manager server builder with context and configuration - pub(crate) fn with_context(svr_cfg: ManagerConfig, context: SharedContext) -> ManagerBuilder { - ManagerBuilder { + pub(crate) fn with_context(svr_cfg: ManagerConfig, context: SharedContext) -> Self { + Self { context, svr_cfg, connect_opts: ConnectOpts::default(), diff --git a/shadowsocks-rust/crates/shadowsocks-service/src/net/flow.rs b/shadowsocks-rust/crates/shadowsocks-service/src/net/flow.rs index ef0d9e71b1..5cc57ef16c 100644 --- a/shadowsocks-rust/crates/shadowsocks-service/src/net/flow.rs +++ b/shadowsocks-rust/crates/shadowsocks-service/src/net/flow.rs @@ -15,7 +15,7 @@ pub struct FlowStat { impl Default for FlowStat { fn default() -> Self { - FlowStat { + Self { tx: FlowCounter::new(0), rx: FlowCounter::new(0), } @@ -24,8 +24,8 @@ impl Default for FlowStat { impl FlowStat { /// Create an empty flow statistic - pub fn new() -> FlowStat { - FlowStat::default() + pub fn new() -> Self { + Self::default() } /// Transmitted bytes count diff --git a/shadowsocks-rust/crates/shadowsocks-service/src/net/mon_socket.rs b/shadowsocks-rust/crates/shadowsocks-service/src/net/mon_socket.rs index 28553a78dc..a2d421659e 100644 --- a/shadowsocks-rust/crates/shadowsocks-service/src/net/mon_socket.rs +++ b/shadowsocks-rust/crates/shadowsocks-service/src/net/mon_socket.rs @@ -20,8 +20,8 @@ pub struct MonProxySocket { impl MonProxySocket { /// Create a new socket with flow monitor - pub fn from_socket(socket: ProxySocket, flow_stat: Arc) -> MonProxySocket { - MonProxySocket { socket, flow_stat } + pub fn from_socket(socket: ProxySocket, flow_stat: Arc) -> Self { + Self { socket, flow_stat } } /// Get the underlying `ProxySocket` immutable reference diff --git a/shadowsocks-rust/crates/shadowsocks-service/src/net/mon_stream.rs b/shadowsocks-rust/crates/shadowsocks-service/src/net/mon_stream.rs index d889577d21..b901ebf620 100644 --- a/shadowsocks-rust/crates/shadowsocks-service/src/net/mon_stream.rs +++ b/shadowsocks-rust/crates/shadowsocks-service/src/net/mon_stream.rs @@ -22,8 +22,8 @@ pub struct MonProxyStream { impl MonProxyStream { #[inline] - pub fn from_stream(stream: S, flow_stat: Arc) -> MonProxyStream { - MonProxyStream { stream, flow_stat } + pub fn from_stream(stream: S, flow_stat: Arc) -> Self { + Self { stream, flow_stat } } #[inline] diff --git a/shadowsocks-rust/crates/shadowsocks-service/src/net/packet_window.rs b/shadowsocks-rust/crates/shadowsocks-service/src/net/packet_window.rs index 4ff8275c8e..500bfb28bc 100644 --- a/shadowsocks-rust/crates/shadowsocks-service/src/net/packet_window.rs +++ b/shadowsocks-rust/crates/shadowsocks-service/src/net/packet_window.rs @@ -21,15 +21,15 @@ pub struct PacketWindowFilter { } impl Default for PacketWindowFilter { - fn default() -> PacketWindowFilter { - PacketWindowFilter::new() + fn default() -> Self { + Self::new() } } impl PacketWindowFilter { /// Create an empty filter - pub fn new() -> PacketWindowFilter { - PacketWindowFilter { + pub fn new() -> Self { + Self { last_packet_id: 0, packet_ring: [0u64; RING_BLOCKS as usize], } diff --git a/shadowsocks-rust/crates/shadowsocks-service/src/server/context.rs b/shadowsocks-rust/crates/shadowsocks-service/src/server/context.rs index 0a89fde166..340ac5ff2e 100644 --- a/shadowsocks-rust/crates/shadowsocks-service/src/server/context.rs +++ b/shadowsocks-rust/crates/shadowsocks-service/src/server/context.rs @@ -27,7 +27,7 @@ pub struct ServiceContext { impl Default for ServiceContext { fn default() -> Self { - ServiceContext { + Self { context: Context::new_shared(ServerType::Server), connect_opts: ConnectOpts::default(), acl: None, @@ -38,8 +38,8 @@ impl Default for ServiceContext { impl ServiceContext { /// Create a new `ServiceContext` - pub fn new() -> ServiceContext { - ServiceContext::default() + pub fn new() -> Self { + Self::default() } /// Get cloned `shadowsocks` Context diff --git a/shadowsocks-rust/crates/shadowsocks-service/src/server/server.rs b/shadowsocks-rust/crates/shadowsocks-service/src/server/server.rs index 2ef4199fed..dfe6ca5d55 100644 --- a/shadowsocks-rust/crates/shadowsocks-service/src/server/server.rs +++ b/shadowsocks-rust/crates/shadowsocks-service/src/server/server.rs @@ -34,13 +34,13 @@ pub struct ServerBuilder { impl ServerBuilder { /// Create a new server builder from configuration - pub fn new(svr_cfg: ServerConfig) -> ServerBuilder { - ServerBuilder::with_context(ServiceContext::new(), svr_cfg) + pub fn new(svr_cfg: ServerConfig) -> Self { + Self::with_context(ServiceContext::new(), svr_cfg) } /// Create a new server builder with context - fn with_context(context: ServiceContext, svr_cfg: ServerConfig) -> ServerBuilder { - ServerBuilder { + fn with_context(context: ServiceContext, svr_cfg: ServerConfig) -> Self { + Self { context, svr_cfg, udp_expiry_duration: None, diff --git a/shadowsocks-rust/crates/shadowsocks-service/src/server/tcprelay.rs b/shadowsocks-rust/crates/shadowsocks-service/src/server/tcprelay.rs index 8f01a67877..9c7e938311 100644 --- a/shadowsocks-rust/crates/shadowsocks-service/src/server/tcprelay.rs +++ b/shadowsocks-rust/crates/shadowsocks-service/src/server/tcprelay.rs @@ -37,9 +37,9 @@ impl TcpServer { context: Arc, svr_cfg: ServerConfig, accept_opts: AcceptOpts, - ) -> io::Result { + ) -> io::Result { let listener = ProxyListener::bind_with_opts(context.context(), &svr_cfg, accept_opts).await?; - Ok(TcpServer { + Ok(Self { context, svr_cfg, listener, diff --git a/shadowsocks-rust/crates/shadowsocks-service/src/server/udprelay.rs b/shadowsocks-rust/crates/shadowsocks-service/src/server/udprelay.rs index cf80a61f84..0fb1b78b79 100644 --- a/shadowsocks-rust/crates/shadowsocks-service/src/server/udprelay.rs +++ b/shadowsocks-rust/crates/shadowsocks-service/src/server/udprelay.rs @@ -56,11 +56,11 @@ enum NatMap { impl NatMap { fn cleanup_expired(&mut self) { match *self { - NatMap::Association(ref mut m) => { + Self::Association(ref mut m) => { m.iter(); } #[cfg(feature = "aead-cipher-2022")] - NatMap::Session(ref mut m) => { + Self::Session(ref mut m) => { m.iter(); } } @@ -68,11 +68,11 @@ impl NatMap { fn keep_alive(&mut self, key: &NatKey) { match (self, key) { - (NatMap::Association(m), NatKey::PeerAddr(peer_addr)) => { + (Self::Association(m), NatKey::PeerAddr(peer_addr)) => { m.get(peer_addr); } #[cfg(feature = "aead-cipher-2022")] - (NatMap::Session(m), NatKey::SessionId(session_id)) => { + (Self::Session(m), NatKey::SessionId(session_id)) => { m.get(session_id); } #[allow(unreachable_patterns)] @@ -99,7 +99,7 @@ impl UdpServer { time_to_live: Option, capacity: Option, accept_opts: AcceptOpts, - ) -> io::Result { + ) -> io::Result { let time_to_live = time_to_live.unwrap_or(crate::DEFAULT_UDP_EXPIRY_DURATION); fn create_assoc_map(time_to_live: Duration, capacity: Option) -> LruCache @@ -128,7 +128,7 @@ impl UdpServer { let socket = MonProxySocket::from_socket(socket, context.flow_stat()); let listener = Arc::new(socket); - Ok(UdpServer { + Ok(Self { context, assoc_map, keepalive_tx, @@ -180,7 +180,7 @@ impl UdpServer { loop { let (n, peer_addr, target_addr, control) = - match UdpServer::recv_one_packet(&context, &listener, &mut buffer).await { + match Self::recv_one_packet(&context, &listener, &mut buffer).await { Some(s) => s, None => continue, }; @@ -242,7 +242,7 @@ impl UdpServer { self.assoc_map.keep_alive(&peer_addr); } - recv_result = UdpServer::recv_one_packet(&self.context, &listener, &mut buffer) => { + recv_result = Self::recv_one_packet(&self.context, &listener, &mut buffer) => { let (n, peer_addr, target_addr, control) = match recv_result { Some(s) => s, None => continue, @@ -398,9 +398,9 @@ impl UdpAssociation { inbound: Arc>, peer_addr: SocketAddr, keepalive_tx: mpsc::Sender, - ) -> UdpAssociation { + ) -> Self { let (assoc_handle, sender) = UdpAssociationContext::create(context, inbound, peer_addr, keepalive_tx, None); - UdpAssociation { assoc_handle, sender } + Self { assoc_handle, sender } } #[cfg(feature = "aead-cipher-2022")] @@ -410,10 +410,10 @@ impl UdpAssociation { peer_addr: SocketAddr, keepalive_tx: mpsc::Sender, client_session_id: u64, - ) -> UdpAssociation { + ) -> Self { let (assoc_handle, sender) = UdpAssociationContext::create(context, inbound, peer_addr, keepalive_tx, Some(client_session_id)); - UdpAssociation { assoc_handle, sender } + Self { assoc_handle, sender } } fn try_send(&self, data: UdpAssociationSendMessage) -> io::Result<()> { @@ -432,8 +432,8 @@ struct ClientSessionContext { } impl ClientSessionContext { - fn new(client_session_id: u64) -> ClientSessionContext { - ClientSessionContext { + fn new(client_session_id: u64) -> Self { + Self { client_session_id, packet_window_filter: PacketWindowFilter::new(), client_user: None, @@ -488,7 +488,7 @@ impl UdpAssociationContext { // being OOM. let (sender, receiver) = mpsc::channel(UDP_ASSOCIATION_SEND_CHANNEL_SIZE); - let mut assoc = UdpAssociationContext { + let mut assoc = Self { context, peer_addr, outbound_ipv4_socket: None, diff --git a/shadowsocks-rust/crates/shadowsocks/src/config.rs b/shadowsocks-rust/crates/shadowsocks/src/config.rs index 51d61b6bec..fb4b0ace7d 100644 --- a/shadowsocks-rust/crates/shadowsocks/src/config.rs +++ b/shadowsocks-rust/crates/shadowsocks/src/config.rs @@ -58,12 +58,12 @@ pub enum ServerType { impl ServerType { /// Check if it is `Local` pub fn is_local(self) -> bool { - self == ServerType::Local + self == Self::Local } /// Check if it is `Server` pub fn is_server(self) -> bool { - self == ServerType::Server + self == Self::Server } } @@ -78,22 +78,22 @@ pub enum Mode { impl Mode { /// Check if UDP is enabled pub fn enable_udp(self) -> bool { - matches!(self, Mode::UdpOnly | Mode::TcpAndUdp) + matches!(self, Self::UdpOnly | Self::TcpAndUdp) } /// Check if TCP is enabled pub fn enable_tcp(self) -> bool { - matches!(self, Mode::TcpOnly | Mode::TcpAndUdp) + matches!(self, Self::TcpOnly | Self::TcpAndUdp) } /// Merge with another Mode - pub fn merge(&self, mode: Mode) -> Mode { + pub fn merge(&self, mode: Self) -> Self { let me = *self as u8; let fm = mode as u8; match me | fm { - 0x01 => Mode::TcpOnly, - 0x02 => Mode::UdpOnly, - 0x03 => Mode::TcpAndUdp, + 0x01 => Self::TcpOnly, + 0x02 => Self::UdpOnly, + 0x03 => Self::TcpAndUdp, _ => unreachable!(), } } @@ -101,9 +101,9 @@ impl Mode { /// String representation of Mode pub fn as_str(&self) -> &'static str { match *self { - Mode::TcpOnly => "tcp_only", - Mode::TcpAndUdp => "tcp_and_udp", - Mode::UdpOnly => "udp_only", + Self::TcpOnly => "tcp_only", + Self::TcpAndUdp => "tcp_and_udp", + Self::UdpOnly => "udp_only", } } } @@ -119,9 +119,9 @@ impl FromStr for Mode { fn from_str(s: &str) -> Result { match s { - "tcp_only" => Ok(Mode::TcpOnly), - "tcp_and_udp" => Ok(Mode::TcpAndUdp), - "udp_only" => Ok(Mode::UdpOnly), + "tcp_only" => Ok(Self::TcpOnly), + "tcp_and_udp" => Ok(Self::TcpAndUdp), + "udp_only" => Ok(Self::UdpOnly), _ => Err(()), } } @@ -206,14 +206,14 @@ pub struct ServerWeight { impl Default for ServerWeight { fn default() -> Self { - ServerWeight::new() + Self::new() } } impl ServerWeight { /// Creates a default weight for server, which will have 1.0 for both TCP and UDP - pub fn new() -> ServerWeight { - ServerWeight { + pub fn new() -> Self { + Self { tcp_weight: 1.0, udp_weight: 1.0, } @@ -262,7 +262,7 @@ impl Debug for ServerUser { impl ServerUser { /// Create a user - pub fn new(name: N, key: K) -> ServerUser + pub fn new(name: N, key: K) -> Self where N: Into, K: Into, @@ -273,7 +273,7 @@ impl ServerUser { let hash = blake3::hash(&key); let identity_hash = Bytes::from(hash.as_bytes()[0..16].to_owned()); - ServerUser { + Self { name, key, identity_hash, @@ -281,12 +281,12 @@ impl ServerUser { } /// Create a user from encoded key - pub fn with_encoded_key(name: N, key: &str) -> Result + pub fn with_encoded_key(name: N, key: &str) -> Result where N: Into, { let key = USER_KEY_BASE64_ENGINE.decode(key)?; - Ok(ServerUser::new(name, key)) + Ok(Self::new(name, key)) } /// Name of the user @@ -335,8 +335,8 @@ pub struct ServerUserManager { impl ServerUserManager { /// Create a new manager - pub fn new() -> ServerUserManager { - ServerUserManager { users: HashMap::new() } + pub fn new() -> Self { + Self { users: HashMap::new() } } /// Add a new user @@ -366,8 +366,8 @@ impl ServerUserManager { } impl Default for ServerUserManager { - fn default() -> ServerUserManager { - ServerUserManager::new() + fn default() -> Self { + Self::new() } } @@ -579,14 +579,14 @@ where impl ServerConfig { /// Create a new `ServerConfig` - pub fn new(addr: A, password: P, method: CipherKind) -> Result + pub fn new(addr: A, password: P, method: CipherKind) -> Result where A: Into, P: Into, { let (password, enc_key, identity_keys) = password_to_keys(method, password)?; - Ok(ServerConfig { + Ok(Self { addr: addr.into(), password, method, @@ -834,7 +834,7 @@ impl ServerConfig { /// /// 1. QRCode URL supported by shadowsocks-android, https://github.com/shadowsocks/shadowsocks-android/issues/51 /// 2. Plain userinfo:password format supported by go2-shadowsocks2 - pub fn from_url(encoded: &str) -> Result { + pub fn from_url(encoded: &str) -> Result { let parsed = Url::parse(encoded).map_err(UrlParseError::from)?; if parsed.scheme() != "ss" { @@ -863,7 +863,7 @@ impl ServerConfig { decoded_body.insert_str(0, "ss://"); // Parse it like ss://method:password@host:port - return ServerConfig::from_url(&decoded_body); + return Self::from_url(&decoded_body); } let (method, pwd) = match parsed.password() { @@ -949,7 +949,7 @@ impl ServerConfig { return Err(UrlParseError::InvalidMethod); } }; - let mut svrconfig = ServerConfig::new(addr, pwd, method)?; + let mut svrconfig = Self::new(addr, pwd, method)?; if let Some(q) = parsed.query() { let query = match serde_urlencoded::from_bytes::>(q.as_bytes()) { @@ -1023,8 +1023,8 @@ pub enum UrlParseError { impl FromStr for ServerConfig { type Err = UrlParseError; - fn from_str(s: &str) -> Result { - ServerConfig::from_url(s) + fn from_str(s: &str) -> Result { + Self::from_url(s) } } @@ -1041,16 +1041,16 @@ impl ServerAddr { /// Get string representation of domain pub fn host(&self) -> String { match *self { - ServerAddr::SocketAddr(ref s) => s.ip().to_string(), - ServerAddr::DomainName(ref dm, _) => dm.clone(), + Self::SocketAddr(ref s) => s.ip().to_string(), + Self::DomainName(ref dm, _) => dm.clone(), } } /// Get port pub fn port(&self) -> u16 { match *self { - ServerAddr::SocketAddr(ref s) => s.port(), - ServerAddr::DomainName(_, p) => p, + Self::SocketAddr(ref s) => s.port(), + Self::DomainName(_, p) => p, } } } @@ -1068,9 +1068,9 @@ impl Display for ServerAddrError { impl FromStr for ServerAddr { type Err = ServerAddrError; - fn from_str(s: &str) -> Result { + fn from_str(s: &str) -> Result { match s.parse::() { - Ok(addr) => Ok(ServerAddr::SocketAddr(addr)), + Ok(addr) => Ok(Self::SocketAddr(addr)), Err(..) => { let mut sp = s.split(':'); match (sp.next(), sp.next()) { @@ -1079,7 +1079,7 @@ impl FromStr for ServerAddr { return Err(ServerAddrError); } match port.parse::() { - Ok(port) => Ok(ServerAddr::DomainName(dn.to_owned(), port)), + Ok(port) => Ok(Self::DomainName(dn.to_owned(), port)), Err(..) => Err(ServerAddrError), } } @@ -1093,8 +1093,8 @@ impl FromStr for ServerAddr { impl Display for ServerAddr { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { match *self { - ServerAddr::SocketAddr(ref a) => write!(f, "{a}"), - ServerAddr::DomainName(ref d, port) => write!(f, "{d}:{port}"), + Self::SocketAddr(ref a) => write!(f, "{a}"), + Self::DomainName(ref d, port) => write!(f, "{d}:{port}"), } } } @@ -1168,49 +1168,49 @@ impl serde::Serialize for ServerAddr { } impl From for ServerAddr { - fn from(addr: SocketAddr) -> ServerAddr { - ServerAddr::SocketAddr(addr) + fn from(addr: SocketAddr) -> Self { + Self::SocketAddr(addr) } } impl> From<(I, u16)> for ServerAddr { - fn from((dname, port): (I, u16)) -> ServerAddr { - ServerAddr::DomainName(dname.into(), port) + fn from((dname, port): (I, u16)) -> Self { + Self::DomainName(dname.into(), port) } } impl From
for ServerAddr { - fn from(addr: Address) -> ServerAddr { + fn from(addr: Address) -> Self { match addr { - Address::SocketAddress(sa) => ServerAddr::SocketAddr(sa), - Address::DomainNameAddress(dn, port) => ServerAddr::DomainName(dn, port), + Address::SocketAddress(sa) => Self::SocketAddr(sa), + Address::DomainNameAddress(dn, port) => Self::DomainName(dn, port), } } } impl From<&Address> for ServerAddr { - fn from(addr: &Address) -> ServerAddr { + fn from(addr: &Address) -> Self { match *addr { - Address::SocketAddress(sa) => ServerAddr::SocketAddr(sa), - Address::DomainNameAddress(ref dn, port) => ServerAddr::DomainName(dn.clone(), port), + Address::SocketAddress(sa) => Self::SocketAddr(sa), + Address::DomainNameAddress(ref dn, port) => Self::DomainName(dn.clone(), port), } } } impl From for Address { - fn from(addr: ServerAddr) -> Address { + fn from(addr: ServerAddr) -> Self { match addr { - ServerAddr::SocketAddr(sa) => Address::SocketAddress(sa), - ServerAddr::DomainName(dn, port) => Address::DomainNameAddress(dn, port), + ServerAddr::SocketAddr(sa) => Self::SocketAddress(sa), + ServerAddr::DomainName(dn, port) => Self::DomainNameAddress(dn, port), } } } impl From<&ServerAddr> for Address { - fn from(addr: &ServerAddr) -> Address { + fn from(addr: &ServerAddr) -> Self { match *addr { - ServerAddr::SocketAddr(sa) => Address::SocketAddress(sa), - ServerAddr::DomainName(ref dn, port) => Address::DomainNameAddress(dn.clone(), port), + ServerAddr::SocketAddr(sa) => Self::SocketAddress(sa), + ServerAddr::DomainName(ref dn, port) => Self::DomainNameAddress(dn.clone(), port), } } } @@ -1240,19 +1240,19 @@ impl Display for ManagerAddrError { impl FromStr for ManagerAddr { type Err = ManagerAddrError; - fn from_str(s: &str) -> Result { + fn from_str(s: &str) -> Result { match s.find(':') { Some(pos) => { // Contains a ':' in address, must be IP:Port or Domain:Port match s.parse::() { - Ok(saddr) => Ok(ManagerAddr::SocketAddr(saddr)), + Ok(saddr) => Ok(Self::SocketAddr(saddr)), Err(..) => { // Splits into Domain and Port let (sdomain, sport) = s.split_at(pos); let (sdomain, sport) = (sdomain.trim(), sport[1..].trim()); match sport.parse::() { - Ok(port) => Ok(ManagerAddr::DomainName(sdomain.to_owned(), port)), + Ok(port) => Ok(Self::DomainName(sdomain.to_owned(), port)), Err(..) => Err(ManagerAddrError), } } @@ -1261,7 +1261,7 @@ impl FromStr for ManagerAddr { #[cfg(unix)] None => { // Must be a unix socket path - Ok(ManagerAddr::UnixSocketAddr(PathBuf::from(s))) + Ok(Self::UnixSocketAddr(PathBuf::from(s))) } #[cfg(not(unix))] None => Err(ManagerAddrError), @@ -1272,10 +1272,10 @@ impl FromStr for ManagerAddr { impl Display for ManagerAddr { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { match *self { - ManagerAddr::SocketAddr(ref saddr) => fmt::Display::fmt(saddr, f), - ManagerAddr::DomainName(ref dname, port) => write!(f, "{dname}:{port}"), + Self::SocketAddr(ref saddr) => fmt::Display::fmt(saddr, f), + Self::DomainName(ref dname, port) => write!(f, "{dname}:{port}"), #[cfg(unix)] - ManagerAddr::UnixSocketAddr(ref path) => fmt::Display::fmt(&path.display(), f), + Self::UnixSocketAddr(ref path) => fmt::Display::fmt(&path.display(), f), } } } @@ -1349,27 +1349,27 @@ impl serde::Serialize for ManagerAddr { } impl From for ManagerAddr { - fn from(addr: SocketAddr) -> ManagerAddr { - ManagerAddr::SocketAddr(addr) + fn from(addr: SocketAddr) -> Self { + Self::SocketAddr(addr) } } impl<'a> From<(&'a str, u16)> for ManagerAddr { - fn from((dname, port): (&'a str, u16)) -> ManagerAddr { - ManagerAddr::DomainName(dname.to_owned(), port) + fn from((dname, port): (&'a str, u16)) -> Self { + Self::DomainName(dname.to_owned(), port) } } impl From<(String, u16)> for ManagerAddr { - fn from((dname, port): (String, u16)) -> ManagerAddr { - ManagerAddr::DomainName(dname, port) + fn from((dname, port): (String, u16)) -> Self { + Self::DomainName(dname, port) } } #[cfg(unix)] impl From for ManagerAddr { - fn from(p: PathBuf) -> ManagerAddr { - ManagerAddr::UnixSocketAddr(p) + fn from(p: PathBuf) -> Self { + Self::UnixSocketAddr(p) } } @@ -1394,10 +1394,10 @@ pub enum ReplayAttackPolicy { impl Display for ReplayAttackPolicy { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { match *self { - ReplayAttackPolicy::Default => f.write_str("default"), - ReplayAttackPolicy::Ignore => f.write_str("ignore"), - ReplayAttackPolicy::Detect => f.write_str("detect"), - ReplayAttackPolicy::Reject => f.write_str("reject"), + Self::Default => f.write_str("default"), + Self::Ignore => f.write_str("ignore"), + Self::Detect => f.write_str("detect"), + Self::Reject => f.write_str("reject"), } } } @@ -1417,10 +1417,10 @@ impl FromStr for ReplayAttackPolicy { fn from_str(s: &str) -> Result { match s { - "default" => Ok(ReplayAttackPolicy::Default), - "ignore" => Ok(ReplayAttackPolicy::Ignore), - "detect" => Ok(ReplayAttackPolicy::Detect), - "reject" => Ok(ReplayAttackPolicy::Reject), + "default" => Ok(Self::Default), + "ignore" => Ok(Self::Ignore), + "detect" => Ok(Self::Detect), + "reject" => Ok(Self::Reject), _ => Err(ReplayAttackPolicyError), } } diff --git a/shadowsocks-rust/crates/shadowsocks/src/context.rs b/shadowsocks-rust/crates/shadowsocks/src/context.rs index 9a48834105..fcc6a576bb 100644 --- a/shadowsocks-rust/crates/shadowsocks/src/context.rs +++ b/shadowsocks-rust/crates/shadowsocks/src/context.rs @@ -33,8 +33,8 @@ pub type SharedContext = Arc; impl Context { /// Create a new `Context` for `Client` or `Server` - pub fn new(config_type: ServerType) -> Context { - Context { + pub fn new(config_type: ServerType) -> Self { + Self { replay_protector: ReplayProtector::new(config_type), replay_policy: ReplayAttackPolicy::Default, dns_resolver: Arc::new(DnsResolver::system_resolver()), @@ -44,7 +44,7 @@ impl Context { /// Create a new `Context` shared pub fn new_shared(config_type: ServerType) -> SharedContext { - SharedContext::new(Context::new(config_type)) + SharedContext::new(Self::new(config_type)) } /// Check if nonce exist or not diff --git a/shadowsocks-rust/crates/shadowsocks/src/dns_resolver/hickory_dns_resolver.rs b/shadowsocks-rust/crates/shadowsocks/src/dns_resolver/hickory_dns_resolver.rs index 9c5b69d7f8..88d0301856 100644 --- a/shadowsocks-rust/crates/shadowsocks/src/dns_resolver/hickory_dns_resolver.rs +++ b/shadowsocks-rust/crates/shadowsocks/src/dns_resolver/hickory_dns_resolver.rs @@ -33,8 +33,8 @@ pub struct ShadowDnsRuntimeProvider { } impl ShadowDnsRuntimeProvider { - fn new(connect_opts: ConnectOpts) -> ShadowDnsRuntimeProvider { - ShadowDnsRuntimeProvider { + fn new(connect_opts: ConnectOpts) -> Self { + Self { handle: TokioHandle::default(), connect_opts, } @@ -85,6 +85,11 @@ impl RuntimeProvider for ShadowDnsRuntimeProvider { let wait_for = wait_for.unwrap_or_else(|| Duration::from_secs(5)); Box::pin(async move { + trace!( + "hickory-dns RuntimeProvider tcp connecting to {} with {:?}", + server_addr, connect_opts + ); + let tcp = match tokio::time::timeout( wait_for, ShadowTcpStream::connect_with_opts(&server_addr, &connect_opts), @@ -95,6 +100,11 @@ impl RuntimeProvider for ShadowDnsRuntimeProvider { Ok(Err(err)) => return Err(err), Err(_) => return Err(io::ErrorKind::TimedOut.into()), }; + + trace!( + "hickory-dns RuntimeProvider tcp connected to {}, {:?}", + server_addr, connect_opts + ); Ok(AsyncIoTokioAsStd(tcp)) }) } @@ -106,7 +116,15 @@ impl RuntimeProvider for ShadowDnsRuntimeProvider { ) -> Pin>>> { let connect_opts = self.connect_opts.clone(); Box::pin(async move { + trace!( + "hickory-dns RuntimeProvider udp binding to {} with {:?}", + local_addr, connect_opts + ); let udp = ShadowUdpSocket::bind_with_opts(&local_addr, &connect_opts).await?; + trace!( + "hickory-dns RuntimeProvider udp bound to {}, {:?}", + local_addr, connect_opts + ); Ok(udp) }) } diff --git a/shadowsocks-rust/crates/shadowsocks/src/dns_resolver/resolver.rs b/shadowsocks-rust/crates/shadowsocks/src/dns_resolver/resolver.rs index 1101a9d404..75a11abc84 100644 --- a/shadowsocks-rust/crates/shadowsocks/src/dns_resolver/resolver.rs +++ b/shadowsocks-rust/crates/shadowsocks/src/dns_resolver/resolver.rs @@ -71,20 +71,20 @@ pub enum DnsResolver { } impl Default for DnsResolver { - fn default() -> DnsResolver { - DnsResolver::system_resolver() + fn default() -> Self { + Self::system_resolver() } } impl Debug for DnsResolver { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { match *self { - DnsResolver::System => f.write_str("System"), + Self::System => f.write_str("System"), #[cfg(feature = "hickory-dns")] - DnsResolver::HickoryDnsSystem { .. } => f.write_str("HickoryDnsSystem(..)"), + Self::HickoryDnsSystem { .. } => f.write_str("HickoryDnsSystem(..)"), #[cfg(feature = "hickory-dns")] - DnsResolver::HickoryDns(..) => f.write_str("HickoryDns(..)"), - DnsResolver::Custom(..) => f.write_str("Custom(..)"), + Self::HickoryDns(..) => f.write_str("HickoryDns(..)"), + Self::Custom(..) => f.write_str("Custom(..)"), } } } @@ -93,7 +93,7 @@ impl Debug for DnsResolver { impl Drop for DnsResolver { fn drop(&mut self) { #[cfg(all(feature = "hickory-dns", unix, not(target_os = "android")))] - if let DnsResolver::HickoryDnsSystem { ref abortable, .. } = *self { + if let Self::HickoryDnsSystem { ref abortable, .. } = *self { abortable.abort(); } } @@ -120,10 +120,10 @@ cfg_if! { fn next(&mut self) -> Option { match *self { - EitherResolved::Tokio(ref mut a) => a.next(), - EitherResolved::HickoryDnsSystem(ref mut b) => b.next(), - EitherResolved::HickoryDns(ref mut c) => c.next(), - EitherResolved::Custom(ref mut d) => d.next(), + Self::Tokio(ref mut a) => a.next(), + Self::HickoryDnsSystem(ref mut b) => b.next(), + Self::HickoryDns(ref mut c) => c.next(), + Self::Custom(ref mut d) => d.next(), } } } @@ -228,8 +228,8 @@ async fn hickory_dns_notify_update_dns(resolver: Arc) impl DnsResolver { /// Use system DNS resolver. Tokio will call `getaddrinfo` in blocking pool. - pub fn system_resolver() -> DnsResolver { - DnsResolver::System + pub fn system_resolver() -> Self { + Self::System } /// Use hickory-dns DNS system resolver (with DNS cache) @@ -239,7 +239,7 @@ impl DnsResolver { pub async fn hickory_dns_system_resolver( opts: Option, connect_opts: ConnectOpts, - ) -> io::Result { + ) -> io::Result { use super::hickory_dns_resolver::create_resolver; let resolver = create_resolver(None, opts.clone(), connect_opts.clone()).await?; @@ -261,7 +261,7 @@ impl DnsResolver { }) }; - Ok(DnsResolver::HickoryDnsSystem { inner, abortable }) + Ok(Self::HickoryDnsSystem { inner, abortable }) } else { Ok(DnsResolver::HickoryDnsSystem { inner }) } @@ -274,19 +274,19 @@ impl DnsResolver { dns: ResolverConfig, opts: Option, connect_opts: ConnectOpts, - ) -> io::Result { + ) -> io::Result { use super::hickory_dns_resolver::create_resolver; - Ok(DnsResolver::HickoryDns( + Ok(Self::HickoryDns( create_resolver(Some(dns), opts, connect_opts).await?, )) } /// Custom DNS resolver - pub fn custom_resolver(custom: R) -> DnsResolver + pub fn custom_resolver(custom: R) -> Self where R: DnsResolve + Send + Sync + 'static, { - DnsResolver::Custom(DynDnsResolve::boxed(custom)) + Self::Custom(DynDnsResolve::boxed(custom)) } /// Resolve address into `SocketAddr`s @@ -303,7 +303,7 @@ impl DnsResolver { } impl<'x, 'y> ResolverLogger<'x, 'y> { - fn new(resolver: &'x DnsResolver, addr: &'y str, port: u16) -> ResolverLogger<'x, 'y> { + fn new(resolver: &'x DnsResolver, addr: &'y str, port: u16) -> Self { let start_time = if log_enabled!(Level::Trace) { Some(Instant::now()) } else { @@ -373,7 +373,7 @@ impl DnsResolver { let _log_guard = ResolverLogger::new(self, addr, port); match *self { - DnsResolver::System => match lookup_host((addr, port)).await { + Self::System => match lookup_host((addr, port)).await { Ok(v) => Ok(EitherResolved::Tokio(v)), Err(err) => { let err = Error::other(format!("dns resolve {addr}:{port} error: {err}")); @@ -381,7 +381,7 @@ impl DnsResolver { } }, #[cfg(feature = "hickory-dns")] - DnsResolver::HickoryDnsSystem { ref inner, .. } => match inner.resolver.load().lookup_ip(addr).await { + Self::HickoryDnsSystem { ref inner, .. } => match inner.resolver.load().lookup_ip(addr).await { Ok(lookup_result) => Ok(EitherResolved::HickoryDnsSystem( lookup_result.into_iter().map(move |ip| SocketAddr::new(ip, port)), )), @@ -391,7 +391,7 @@ impl DnsResolver { } }, #[cfg(feature = "hickory-dns")] - DnsResolver::HickoryDns(ref resolver) => match resolver.lookup_ip(addr).await { + Self::HickoryDns(ref resolver) => match resolver.lookup_ip(addr).await { Ok(lookup_result) => Ok(EitherResolved::HickoryDns( lookup_result.into_iter().map(move |ip| SocketAddr::new(ip, port)), )), @@ -400,7 +400,7 @@ impl DnsResolver { Err(err) } }, - DnsResolver::Custom(ref resolver) => match resolver.resolve(addr, port).await { + Self::Custom(ref resolver) => match resolver.resolve(addr, port).await { Ok(v) => Ok(EitherResolved::Custom(v.into_iter())), Err(err) => { let err = Error::other(format!("dns resolve {addr}:{port} error: {err}")); @@ -412,6 +412,6 @@ impl DnsResolver { /// Check if currently using system resolver pub fn is_system_resolver(&self) -> bool { - matches!(*self, DnsResolver::System) + matches!(*self, Self::System) } } diff --git a/shadowsocks-rust/crates/shadowsocks/src/manager/client.rs b/shadowsocks-rust/crates/shadowsocks/src/manager/client.rs index f3fc96955b..193d716d1d 100644 --- a/shadowsocks-rust/crates/shadowsocks/src/manager/client.rs +++ b/shadowsocks-rust/crates/shadowsocks/src/manager/client.rs @@ -41,10 +41,10 @@ impl ManagerClient { context: &Context, bind_addr: &ManagerAddr, connect_opts: &ConnectOpts, - ) -> Result { + ) -> Result { ManagerDatagram::connect(context, bind_addr, connect_opts) .await - .map(|socket| ManagerClient { socket }) + .map(|socket| Self { socket }) .map_err(Into::into) } diff --git a/shadowsocks-rust/crates/shadowsocks/src/manager/datagram.rs b/shadowsocks-rust/crates/shadowsocks/src/manager/datagram.rs index f50186c6aa..7939b8d6c3 100644 --- a/shadowsocks-rust/crates/shadowsocks/src/manager/datagram.rs +++ b/shadowsocks-rust/crates/shadowsocks/src/manager/datagram.rs @@ -26,9 +26,9 @@ impl ManagerSocketAddr { /// Check if it is unnamed (not binded to any valid address), only valid for `UnixSocketAddr` pub fn is_unnamed(&self) -> bool { match *self { - ManagerSocketAddr::SocketAddr(..) => false, + Self::SocketAddr(..) => false, #[cfg(unix)] - ManagerSocketAddr::UnixSocketAddr(ref s) => s.is_unnamed(), + Self::UnixSocketAddr(ref s) => s.is_unnamed(), } } } @@ -36,9 +36,9 @@ impl ManagerSocketAddr { impl fmt::Display for ManagerSocketAddr { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { match *self { - ManagerSocketAddr::SocketAddr(ref saddr) => fmt::Display::fmt(saddr, f), + Self::SocketAddr(ref saddr) => fmt::Display::fmt(saddr, f), #[cfg(unix)] - ManagerSocketAddr::UnixSocketAddr(ref saddr) => fmt::Debug::fmt(saddr, f), + Self::UnixSocketAddr(ref saddr) => fmt::Debug::fmt(saddr, f), } } } @@ -55,16 +55,16 @@ pub enum ManagerDatagram { impl ManagerDatagram { /// Create a `ManagerDatagram` binding to requested `bind_addr` - pub async fn bind(context: &Context, bind_addr: &ManagerAddr) -> io::Result { + pub async fn bind(context: &Context, bind_addr: &ManagerAddr) -> io::Result { match *bind_addr { - ManagerAddr::SocketAddr(ref saddr) => Ok(ManagerDatagram::UdpDatagram( + ManagerAddr::SocketAddr(ref saddr) => Ok(Self::UdpDatagram( ShadowUdpSocket::listen(saddr).await?.into(), )), ManagerAddr::DomainName(ref dname, port) => { let (_, socket) = lookup_then!(context, dname, port, |saddr| { ShadowUdpSocket::listen(&saddr).await })?; - Ok(ManagerDatagram::UdpDatagram(socket.into())) + Ok(Self::UdpDatagram(socket.into())) } #[cfg(unix)] ManagerAddr::UnixSocketAddr(ref path) => { @@ -73,7 +73,7 @@ impl ManagerDatagram { // Remove it first incase it is already exists let _ = fs::remove_file(path); - Ok(ManagerDatagram::UnixDatagram(UnixDatagram::bind(path)?)) + Ok(Self::UnixDatagram(UnixDatagram::bind(path)?)) } } } @@ -83,14 +83,14 @@ impl ManagerDatagram { context: &Context, bind_addr: &ManagerAddr, connect_opts: &ConnectOpts, - ) -> io::Result { + ) -> io::Result { match *bind_addr { - ManagerAddr::SocketAddr(sa) => ManagerDatagram::connect_socket_addr(sa, connect_opts).await, + ManagerAddr::SocketAddr(sa) => Self::connect_socket_addr(sa, connect_opts).await, ManagerAddr::DomainName(ref dname, port) => { // Try connect to all socket addresses lookup_then!(context, dname, port, |addr| { - ManagerDatagram::connect_socket_addr(addr, connect_opts).await + Self::connect_socket_addr(addr, connect_opts).await }) .map(|(_, d)| d) } @@ -101,34 +101,34 @@ impl ManagerDatagram { ManagerAddr::UnixSocketAddr(ref path) => { let dgram = UnixDatagram::unbound()?; dgram.connect(path)?; - Ok(ManagerDatagram::UnixDatagram(dgram)) + Ok(Self::UnixDatagram(dgram)) } } } - async fn connect_socket_addr(sa: SocketAddr, connect_opts: &ConnectOpts) -> io::Result { + async fn connect_socket_addr(sa: SocketAddr, connect_opts: &ConnectOpts) -> io::Result { let socket = ShadowUdpSocket::connect_with_opts(&sa, connect_opts).await?; - Ok(ManagerDatagram::UdpDatagram(socket.into())) + Ok(Self::UdpDatagram(socket.into())) } /// Receives data from the socket. pub async fn recv(&mut self, buf: &mut [u8]) -> io::Result { match *self { - ManagerDatagram::UdpDatagram(ref mut udp) => udp.recv(buf).await, + Self::UdpDatagram(ref mut udp) => udp.recv(buf).await, #[cfg(unix)] - ManagerDatagram::UnixDatagram(ref mut unix) => unix.recv(buf).await, + Self::UnixDatagram(ref mut unix) => unix.recv(buf).await, } } /// Receives data from the socket. pub async fn recv_from(&mut self, buf: &mut [u8]) -> io::Result<(usize, ManagerSocketAddr)> { match *self { - ManagerDatagram::UdpDatagram(ref mut udp) => { + Self::UdpDatagram(ref mut udp) => { let (s, addr) = udp.recv_from(buf).await?; Ok((s, ManagerSocketAddr::SocketAddr(addr))) } #[cfg(unix)] - ManagerDatagram::UnixDatagram(ref mut unix) => { + Self::UnixDatagram(ref mut unix) => { let (s, addr) = unix.recv_from(buf).await?; Ok((s, ManagerSocketAddr::UnixSocketAddr(addr))) } @@ -138,16 +138,16 @@ impl ManagerDatagram { /// Sends data to the socket pub async fn send(&mut self, buf: &[u8]) -> io::Result { match *self { - ManagerDatagram::UdpDatagram(ref mut udp) => udp.send(buf).await, + Self::UdpDatagram(ref mut udp) => udp.send(buf).await, #[cfg(unix)] - ManagerDatagram::UnixDatagram(ref mut unix) => unix.send(buf).await, + Self::UnixDatagram(ref mut unix) => unix.send(buf).await, } } /// Sends data to the socket to the specified address. pub async fn send_to(&mut self, buf: &[u8], target: &ManagerSocketAddr) -> io::Result { match *self { - ManagerDatagram::UdpDatagram(ref mut udp) => match *target { + Self::UdpDatagram(ref mut udp) => match *target { ManagerSocketAddr::SocketAddr(ref saddr) => udp.send_to(buf, saddr).await, #[cfg(unix)] ManagerSocketAddr::UnixSocketAddr(..) => { @@ -156,7 +156,7 @@ impl ManagerDatagram { } }, #[cfg(unix)] - ManagerDatagram::UnixDatagram(ref mut unix) => match *target { + Self::UnixDatagram(ref mut unix) => match *target { ManagerSocketAddr::UnixSocketAddr(ref saddr) => match saddr.as_pathname() { Some(paddr) => unix.send_to(buf, paddr).await, None => { @@ -175,7 +175,7 @@ impl ManagerDatagram { /// Sends data on the socket to the specified manager address pub async fn send_to_manager(&mut self, buf: &[u8], context: &Context, target: &ManagerAddr) -> io::Result { match *self { - ManagerDatagram::UdpDatagram(ref mut udp) => match *target { + Self::UdpDatagram(ref mut udp) => match *target { ManagerAddr::SocketAddr(ref saddr) => udp.send_to(buf, saddr).await, ManagerAddr::DomainName(ref dname, port) => { let (_, n) = lookup_then!(context, dname, port, |saddr| { udp.send_to(buf, saddr).await })?; @@ -188,7 +188,7 @@ impl ManagerDatagram { } }, #[cfg(unix)] - ManagerDatagram::UnixDatagram(ref mut unix) => match *target { + Self::UnixDatagram(ref mut unix) => match *target { ManagerAddr::UnixSocketAddr(ref paddr) => unix.send_to(buf, paddr).await, ManagerAddr::SocketAddr(..) | ManagerAddr::DomainName(..) => { let err = io::Error::new(ErrorKind::InvalidInput, "unix datagram requires path address target"); @@ -201,9 +201,9 @@ impl ManagerDatagram { /// Returns the local address that this socket is bound to. pub fn local_addr(&self) -> io::Result { match *self { - ManagerDatagram::UdpDatagram(ref socket) => socket.local_addr().map(ManagerSocketAddr::SocketAddr), + Self::UdpDatagram(ref socket) => socket.local_addr().map(ManagerSocketAddr::SocketAddr), #[cfg(unix)] - ManagerDatagram::UnixDatagram(ref dgram) => dgram.local_addr().map(ManagerSocketAddr::UnixSocketAddr), + Self::UnixDatagram(ref dgram) => dgram.local_addr().map(ManagerSocketAddr::UnixSocketAddr), } } } diff --git a/shadowsocks-rust/crates/shadowsocks/src/manager/error.rs b/shadowsocks-rust/crates/shadowsocks/src/manager/error.rs index 81d90b2aad..b66339ae30 100644 --- a/shadowsocks-rust/crates/shadowsocks/src/manager/error.rs +++ b/shadowsocks-rust/crates/shadowsocks/src/manager/error.rs @@ -16,7 +16,7 @@ pub enum Error { } impl From for io::Error { - fn from(e: Error) -> io::Error { + fn from(e: Error) -> Self { match e { Error::IoError(e) => e, Error::ProtocolError(e) => From::from(e), diff --git a/shadowsocks-rust/crates/shadowsocks/src/manager/listener.rs b/shadowsocks-rust/crates/shadowsocks/src/manager/listener.rs index 6f79d9d60b..6a5f72ec55 100644 --- a/shadowsocks-rust/crates/shadowsocks/src/manager/listener.rs +++ b/shadowsocks-rust/crates/shadowsocks/src/manager/listener.rs @@ -20,10 +20,10 @@ pub struct ManagerListener { impl ManagerListener { /// Create a `ManagerDatagram` binding to requested `bind_addr` - pub async fn bind(context: &Context, bind_addr: &ManagerAddr) -> io::Result { + pub async fn bind(context: &Context, bind_addr: &ManagerAddr) -> io::Result { ManagerDatagram::bind(context, bind_addr) .await - .map(|socket| ManagerListener { socket }) + .map(|socket| Self { socket }) } pub async fn recv_from(&mut self) -> Result<(ManagerRequest, ManagerSocketAddr), Error> { diff --git a/shadowsocks-rust/crates/shadowsocks/src/manager/protocol.rs b/shadowsocks-rust/crates/shadowsocks/src/manager/protocol.rs index ec33d061ad..336658c044 100644 --- a/shadowsocks-rust/crates/shadowsocks/src/manager/protocol.rs +++ b/shadowsocks-rust/crates/shadowsocks/src/manager/protocol.rs @@ -80,7 +80,7 @@ pub struct AddResponse(pub String); impl ManagerProtocol for AddResponse { fn from_bytes(buf: &[u8]) -> Result { - Ok(AddResponse(str::from_utf8(buf)?.trim().to_owned())) + Ok(Self(str::from_utf8(buf)?.trim().to_owned())) } fn to_bytes(&self) -> Result, Error> { @@ -129,7 +129,7 @@ pub struct RemoveResponse(pub String); impl ManagerProtocol for RemoveResponse { fn from_bytes(buf: &[u8]) -> Result { - Ok(RemoveResponse(str::from_utf8(buf)?.trim().to_owned())) + Ok(Self(str::from_utf8(buf)?.trim().to_owned())) } fn to_bytes(&self) -> Result, Error> { @@ -150,7 +150,7 @@ impl ManagerProtocol for ListRequest { return Err(Error::UnrecognizedCommand(cmd.to_owned())); } - Ok(ListRequest) + Ok(Self) } fn to_bytes(&self) -> Result, Error> { @@ -189,7 +189,7 @@ impl ManagerProtocol for PingRequest { return Err(Error::UnrecognizedCommand(cmd.to_owned())); } - Ok(PingRequest) + Ok(Self) } fn to_bytes(&self) -> Result, Error> { @@ -295,11 +295,11 @@ impl ManagerRequest { /// Command key pub fn command(&self) -> &'static str { match *self { - ManagerRequest::Add(..) => "add", - ManagerRequest::Remove(..) => "remove", - ManagerRequest::List(..) => "list", - ManagerRequest::Ping(..) => "ping", - ManagerRequest::Stat(..) => "stat", + Self::Add(..) => "add", + Self::Remove(..) => "remove", + Self::List(..) => "list", + Self::Ping(..) => "ping", + Self::Stat(..) => "stat", } } } @@ -307,15 +307,15 @@ impl ManagerRequest { impl ManagerProtocol for ManagerRequest { fn to_bytes(&self) -> Result, Error> { match *self { - ManagerRequest::Add(ref req) => req.to_bytes(), - ManagerRequest::Remove(ref req) => req.to_bytes(), - ManagerRequest::List(ref req) => req.to_bytes(), - ManagerRequest::Ping(ref req) => req.to_bytes(), - ManagerRequest::Stat(ref req) => req.to_bytes(), + Self::Add(ref req) => req.to_bytes(), + Self::Remove(ref req) => req.to_bytes(), + Self::List(ref req) => req.to_bytes(), + Self::Ping(ref req) => req.to_bytes(), + Self::Stat(ref req) => req.to_bytes(), } } - fn from_bytes(buf: &[u8]) -> Result { + fn from_bytes(buf: &[u8]) -> Result { let mut nsplit = buf.splitn(2, |b| *b == b':'); let cmd = nsplit.next().expect("first element shouldn't be None"); @@ -324,33 +324,33 @@ impl ManagerProtocol for ManagerRequest { None => Err(Error::MissingParameter), Some(param) => { let req = serde_json::from_slice(param)?; - Ok(ManagerRequest::Add(req)) + Ok(Self::Add(req)) } }, "remove" => match nsplit.next() { None => Err(Error::MissingParameter), Some(param) => { let req = serde_json::from_slice(param)?; - Ok(ManagerRequest::Remove(req)) + Ok(Self::Remove(req)) } }, "list" => { if nsplit.next().is_some() { return Err(Error::RedundantParameter); } - Ok(ManagerRequest::List(ListRequest)) + Ok(Self::List(ListRequest)) } "ping" => { if nsplit.next().is_some() { return Err(Error::RedundantParameter); } - Ok(ManagerRequest::Ping(PingRequest)) + Ok(Self::Ping(PingRequest)) } "stat" => match nsplit.next() { None => Err(Error::MissingParameter), Some(param) => { let req = serde_json::from_slice(param)?; - Ok(ManagerRequest::Stat(req)) + Ok(Self::Stat(req)) } }, cmd => Err(Error::UnrecognizedCommand(cmd.to_owned())), @@ -374,7 +374,7 @@ pub enum Error { } impl From for io::Error { - fn from(err: Error) -> io::Error { - io::Error::other(err.to_string()) + fn from(err: Error) -> Self { + Self::other(err.to_string()) } } diff --git a/shadowsocks-rust/crates/shadowsocks/src/net/mod.rs b/shadowsocks-rust/crates/shadowsocks/src/net/mod.rs index 6b69fbcd71..c8c824b864 100644 --- a/shadowsocks-rust/crates/shadowsocks/src/net/mod.rs +++ b/shadowsocks-rust/crates/shadowsocks/src/net/mod.rs @@ -26,19 +26,19 @@ pub enum AddrFamily { } impl From<&SocketAddr> for AddrFamily { - fn from(addr: &SocketAddr) -> AddrFamily { + fn from(addr: &SocketAddr) -> Self { match *addr { - SocketAddr::V4(..) => AddrFamily::Ipv4, - SocketAddr::V6(..) => AddrFamily::Ipv6, + SocketAddr::V4(..) => Self::Ipv4, + SocketAddr::V6(..) => Self::Ipv6, } } } impl From for AddrFamily { - fn from(addr: SocketAddr) -> AddrFamily { + fn from(addr: SocketAddr) -> Self { match addr { - SocketAddr::V4(..) => AddrFamily::Ipv4, - SocketAddr::V6(..) => AddrFamily::Ipv6, + SocketAddr::V4(..) => Self::Ipv4, + SocketAddr::V6(..) => Self::Ipv6, } } } diff --git a/shadowsocks-rust/crates/shadowsocks/src/net/sys/unix/linux/mod.rs b/shadowsocks-rust/crates/shadowsocks/src/net/sys/unix/linux/mod.rs index ee6c1070b1..76ca4cc8f8 100644 --- a/shadowsocks-rust/crates/shadowsocks/src/net/sys/unix/linux/mod.rs +++ b/shadowsocks-rust/crates/shadowsocks/src/net/sys/unix/linux/mod.rs @@ -33,9 +33,9 @@ pub enum TcpStream { } impl TcpStream { - pub async fn connect(addr: SocketAddr, opts: &ConnectOpts) -> io::Result { + pub async fn connect(addr: SocketAddr, opts: &ConnectOpts) -> io::Result { if opts.tcp.mptcp { - return TcpStream::connect_mptcp(addr, opts).await; + return Self::connect_mptcp(addr, opts).await; } let socket = match addr { @@ -43,15 +43,15 @@ impl TcpStream { SocketAddr::V6(..) => TcpSocket::new_v6()?, }; - TcpStream::connect_with_socket(socket, addr, opts).await + Self::connect_with_socket(socket, addr, opts).await } - async fn connect_mptcp(addr: SocketAddr, opts: &ConnectOpts) -> io::Result { + async fn connect_mptcp(addr: SocketAddr, opts: &ConnectOpts) -> io::Result { let socket = create_mptcp_socket(&addr)?; - TcpStream::connect_with_socket(socket, addr, opts).await + Self::connect_with_socket(socket, addr, opts).await } - async fn connect_with_socket(socket: TcpSocket, addr: SocketAddr, opts: &ConnectOpts) -> io::Result { + async fn connect_with_socket(socket: TcpSocket, addr: SocketAddr, opts: &ConnectOpts) -> io::Result { // Any traffic to localhost should not be protected // This is a workaround for VPNService #[cfg(target_os = "android")] @@ -101,40 +101,40 @@ impl TcpStream { let stream = socket.connect(addr).await?; set_common_sockopt_after_connect(&stream, opts)?; - return Ok(TcpStream::Standard(stream)); + return Ok(Self::Standard(stream)); } let stream = TfoStream::connect_with_socket(socket, addr).await?; set_common_sockopt_after_connect(&stream, opts)?; - Ok(TcpStream::FastOpen(stream)) + Ok(Self::FastOpen(stream)) } pub fn local_addr(&self) -> io::Result { match *self { - TcpStream::Standard(ref s) => s.local_addr(), - TcpStream::FastOpen(ref s) => s.local_addr(), + Self::Standard(ref s) => s.local_addr(), + Self::FastOpen(ref s) => s.local_addr(), } } pub fn peer_addr(&self) -> io::Result { match *self { - TcpStream::Standard(ref s) => s.peer_addr(), - TcpStream::FastOpen(ref s) => s.peer_addr(), + Self::Standard(ref s) => s.peer_addr(), + Self::FastOpen(ref s) => s.peer_addr(), } } pub fn nodelay(&self) -> io::Result { match *self { - TcpStream::Standard(ref s) => s.nodelay(), - TcpStream::FastOpen(ref s) => s.nodelay(), + Self::Standard(ref s) => s.nodelay(), + Self::FastOpen(ref s) => s.nodelay(), } } pub fn set_nodelay(&self, nodelay: bool) -> io::Result<()> { match *self { - TcpStream::Standard(ref s) => s.set_nodelay(nodelay), - TcpStream::FastOpen(ref s) => s.set_nodelay(nodelay), + Self::Standard(ref s) => s.set_nodelay(nodelay), + Self::FastOpen(ref s) => s.set_nodelay(nodelay), } } } @@ -142,8 +142,8 @@ impl TcpStream { impl AsRawFd for TcpStream { fn as_raw_fd(&self) -> RawFd { match *self { - TcpStream::Standard(ref s) => s.as_raw_fd(), - TcpStream::FastOpen(ref s) => s.as_raw_fd(), + Self::Standard(ref s) => s.as_raw_fd(), + Self::FastOpen(ref s) => s.as_raw_fd(), } } } diff --git a/shadowsocks-rust/crates/shadowsocks/src/net/sys/unix/uds.rs b/shadowsocks-rust/crates/shadowsocks/src/net/sys/unix/uds.rs index e8eba2bcd3..09a41d62ea 100644 --- a/shadowsocks-rust/crates/shadowsocks/src/net/sys/unix/uds.rs +++ b/shadowsocks-rust/crates/shadowsocks/src/net/sys/unix/uds.rs @@ -25,8 +25,8 @@ pub struct UnixStream { impl UnixStream { /// Connects to the socket named by `path`. - pub async fn connect>(path: P) -> io::Result { - TokioUnixStream::connect(path).await.map(|io| UnixStream { io }) + pub async fn connect>(path: P) -> io::Result { + TokioUnixStream::connect(path).await.map(|io| Self { io }) } fn poll_send_with_fd(&self, cx: &mut Context, buf: &[u8], fds: &[RawFd]) -> Poll> { @@ -100,8 +100,8 @@ pub struct UnixListener { impl UnixListener { /// Creates a new `UnixListener` bound to the specified socket. - pub fn bind>(path: P) -> io::Result { - TokioUnixListener::bind(path).map(|io| UnixListener { io }) + pub fn bind>(path: P) -> io::Result { + TokioUnixListener::bind(path).map(|io| Self { io }) } /// Accepts a new incoming connection to this listener. diff --git a/shadowsocks-rust/crates/shadowsocks/src/net/tcp.rs b/shadowsocks-rust/crates/shadowsocks/src/net/tcp.rs index d0f7ebc3db..58aef66cad 100644 --- a/shadowsocks-rust/crates/shadowsocks/src/net/tcp.rs +++ b/shadowsocks-rust/crates/shadowsocks/src/net/tcp.rs @@ -35,7 +35,7 @@ pub struct TcpStream(#[pin] SysTcpStream); impl TcpStream { /// Connects to address - pub async fn connect_with_opts(addr: &SocketAddr, opts: &ConnectOpts) -> io::Result { + pub async fn connect_with_opts(addr: &SocketAddr, opts: &ConnectOpts) -> io::Result { // tcp_stream_connect(addr, opts).await.map(TcpStream) SysTcpStream::connect(*addr, opts).await.map(TcpStream) } @@ -45,7 +45,7 @@ impl TcpStream { context: &Context, addr: &ServerAddr, opts: &ConnectOpts, - ) -> io::Result { + ) -> io::Result { let stream = match *addr { ServerAddr::SocketAddr(ref addr) => SysTcpStream::connect(*addr, opts).await?, ServerAddr::DomainName(ref domain, port) => { @@ -56,7 +56,7 @@ impl TcpStream { } }; - Ok(TcpStream(stream)) + Ok(Self(stream)) } /// Connects proxy remote target @@ -64,7 +64,7 @@ impl TcpStream { context: &Context, addr: &Address, opts: &ConnectOpts, - ) -> io::Result { + ) -> io::Result { let stream = match *addr { Address::SocketAddress(ref addr) => SysTcpStream::connect(*addr, opts).await?, Address::DomainNameAddress(ref domain, port) => { @@ -75,7 +75,7 @@ impl TcpStream { } }; - Ok(TcpStream(stream)) + Ok(Self(stream)) } /// Returns the local address that this stream is bound to. @@ -128,7 +128,7 @@ pub struct TcpListener { impl TcpListener { /// Creates a new TcpListener, which will be bound to the specified address. - pub async fn bind_with_opts(addr: &SocketAddr, accept_opts: AcceptOpts) -> io::Result { + pub async fn bind_with_opts(addr: &SocketAddr, accept_opts: AcceptOpts) -> io::Result { let socket = create_inbound_tcp_socket(addr, &accept_opts).await?; if let Some(size) = accept_opts.tcp.send_buffer_size { @@ -166,18 +166,18 @@ impl TcpListener { set_tcp_fastopen(&inner)?; } - Ok(TcpListener { inner, accept_opts }) + Ok(Self { inner, accept_opts }) } /// Create a `TcpListener` from tokio's `TcpListener` - pub fn from_listener(listener: TokioTcpListener, accept_opts: AcceptOpts) -> io::Result { + pub fn from_listener(listener: TokioTcpListener, accept_opts: AcceptOpts) -> io::Result { // Enable TFO if supported // macos requires TCP_FASTOPEN to be set after listen(), but other platform doesn't have this constraint if accept_opts.tcp.fastopen { set_tcp_fastopen(&listener)?; } - Ok(TcpListener { + Ok(Self { inner: listener, accept_opts, }) @@ -216,7 +216,7 @@ impl DerefMut for TcpListener { } impl From for TokioTcpListener { - fn from(listener: TcpListener) -> TokioTcpListener { + fn from(listener: TcpListener) -> Self { listener.inner } } diff --git a/shadowsocks-rust/crates/shadowsocks/src/net/udp.rs b/shadowsocks-rust/crates/shadowsocks/src/net/udp.rs index b33b4f8750..41c6ec7183 100644 --- a/shadowsocks-rust/crates/shadowsocks/src/net/udp.rs +++ b/shadowsocks-rust/crates/shadowsocks/src/net/udp.rs @@ -96,7 +96,7 @@ impl UdpSocket { context: &Context, addr: &ServerAddr, opts: &ConnectOpts, - ) -> io::Result { + ) -> io::Result { let socket = match *addr { ServerAddr::SocketAddr(ref remote_addr) => { let socket = create_outbound_udp_socket(From::from(remote_addr), opts).await?; @@ -112,7 +112,7 @@ impl UdpSocket { } }; - Ok(UdpSocket { + Ok(Self { socket, mtu: opts.udp.mtu, }) @@ -123,7 +123,7 @@ impl UdpSocket { context: &Context, addr: &Address, opts: &ConnectOpts, - ) -> io::Result { + ) -> io::Result { let socket = match *addr { Address::SocketAddress(ref remote_addr) => { let socket = create_outbound_udp_socket(From::from(remote_addr), opts).await?; @@ -139,27 +139,27 @@ impl UdpSocket { } }; - Ok(UdpSocket { + Ok(Self { socket, mtu: opts.udp.mtu, }) } /// Connects to shadowsocks server - pub async fn connect_with_opts(addr: &SocketAddr, opts: &ConnectOpts) -> io::Result { + pub async fn connect_with_opts(addr: &SocketAddr, opts: &ConnectOpts) -> io::Result { let socket = create_outbound_udp_socket(From::from(addr), opts).await?; socket.connect(addr).await?; - Ok(UdpSocket { + Ok(Self { socket, mtu: opts.udp.mtu, }) } /// Binds to a specific address with opts - pub async fn connect_any_with_opts>(af: AF, opts: &ConnectOpts) -> io::Result { + pub async fn connect_any_with_opts>(af: AF, opts: &ConnectOpts) -> io::Result { create_outbound_udp_socket(af.into(), opts) .await - .map(|socket| UdpSocket { + .map(|socket| Self { socket, mtu: opts.udp.mtu, }) @@ -167,13 +167,13 @@ impl UdpSocket { /// Binds to a specific address as an outbound socket #[inline] - pub async fn bind(addr: &SocketAddr) -> io::Result { - UdpSocket::bind_with_opts(addr, &ConnectOpts::default()).await + pub async fn bind(addr: &SocketAddr) -> io::Result { + Self::bind_with_opts(addr, &ConnectOpts::default()).await } /// Binds to a specific address with opts as an outbound socket - pub async fn bind_with_opts(addr: &SocketAddr, opts: &ConnectOpts) -> io::Result { - bind_outbound_udp_socket(addr, opts).await.map(|socket| UdpSocket { + pub async fn bind_with_opts(addr: &SocketAddr, opts: &ConnectOpts) -> io::Result { + bind_outbound_udp_socket(addr, opts).await.map(|socket| Self { socket, mtu: opts.udp.mtu, }) @@ -181,14 +181,14 @@ impl UdpSocket { /// Binds to a specific address (inbound) #[inline] - pub async fn listen(addr: &SocketAddr) -> io::Result { - UdpSocket::listen_with_opts(addr, AcceptOpts::default()).await + pub async fn listen(addr: &SocketAddr) -> io::Result { + Self::listen_with_opts(addr, AcceptOpts::default()).await } /// Binds to a specific address (inbound) - pub async fn listen_with_opts(addr: &SocketAddr, opts: AcceptOpts) -> io::Result { + pub async fn listen_with_opts(addr: &SocketAddr, opts: AcceptOpts) -> io::Result { let socket = create_inbound_udp_socket(addr, opts.ipv6_only).await?; - Ok(UdpSocket { + Ok(Self { socket, mtu: opts.udp.mtu, }) @@ -399,12 +399,12 @@ impl DerefMut for UdpSocket { impl From for UdpSocket { fn from(socket: tokio::net::UdpSocket) -> Self { - UdpSocket { socket, mtu: None } + Self { socket, mtu: None } } } impl From for tokio::net::UdpSocket { - fn from(s: UdpSocket) -> tokio::net::UdpSocket { + fn from(s: UdpSocket) -> Self { s.socket } } diff --git a/shadowsocks-rust/crates/shadowsocks/src/plugin/mod.rs b/shadowsocks-rust/crates/shadowsocks/src/plugin/mod.rs index 379052f7c3..065f9b5f35 100644 --- a/shadowsocks-rust/crates/shadowsocks/src/plugin/mod.rs +++ b/shadowsocks-rust/crates/shadowsocks/src/plugin/mod.rs @@ -70,7 +70,7 @@ impl Plugin { /// /// `PluginMode::Client`: Plugin listens to `local_addr` and send data to `remote_addr`, client should send data to `local_addr` /// `PluginMode::Server`: Plugin listens to `remote_addr` and send data to `local_addr`, server should listen to `local_addr` - pub fn start(c: &PluginConfig, remote_addr: &ServerAddr, mode: PluginMode) -> io::Result { + pub fn start(c: &PluginConfig, remote_addr: &ServerAddr, mode: PluginMode) -> io::Result { let loop_ip = match remote_addr { ServerAddr::SocketAddr(sa) => match sa.ip() { IpAddr::V4(..) => Ipv4Addr::LOCALHOST.into(), @@ -113,7 +113,7 @@ impl Plugin { } } - Ok(Plugin { + Ok(Self { process, local_addr, mode: c.plugin_mode, diff --git a/shadowsocks-rust/crates/shadowsocks/src/relay/socks5.rs b/shadowsocks-rust/crates/shadowsocks/src/relay/socks5.rs index c1c4889f0b..56b62b1b98 100644 --- a/shadowsocks-rust/crates/shadowsocks/src/relay/socks5.rs +++ b/shadowsocks-rust/crates/shadowsocks/src/relay/socks5.rs @@ -63,19 +63,19 @@ impl Command { #[rustfmt::skip] fn as_u8(self) -> u8 { match self { - Command::TcpConnect => consts::SOCKS5_CMD_TCP_CONNECT, - Command::TcpBind => consts::SOCKS5_CMD_TCP_BIND, - Command::UdpAssociate => consts::SOCKS5_CMD_UDP_ASSOCIATE, + Self::TcpConnect => consts::SOCKS5_CMD_TCP_CONNECT, + Self::TcpBind => consts::SOCKS5_CMD_TCP_BIND, + Self::UdpAssociate => consts::SOCKS5_CMD_UDP_ASSOCIATE, } } #[inline] #[rustfmt::skip] - fn from_u8(code: u8) -> Option { + fn from_u8(code: u8) -> Option { match code { - consts::SOCKS5_CMD_TCP_CONNECT => Some(Command::TcpConnect), - consts::SOCKS5_CMD_TCP_BIND => Some(Command::TcpBind), - consts::SOCKS5_CMD_UDP_ASSOCIATE => Some(Command::UdpAssociate), + consts::SOCKS5_CMD_TCP_CONNECT => Some(Self::TcpConnect), + consts::SOCKS5_CMD_TCP_BIND => Some(Self::TcpBind), + consts::SOCKS5_CMD_UDP_ASSOCIATE => Some(Self::UdpAssociate), _ => None, } } @@ -102,33 +102,33 @@ impl Reply { #[rustfmt::skip] pub fn as_u8(self) -> u8 { match self { - Reply::Succeeded => consts::SOCKS5_REPLY_SUCCEEDED, - Reply::GeneralFailure => consts::SOCKS5_REPLY_GENERAL_FAILURE, - Reply::ConnectionNotAllowed => consts::SOCKS5_REPLY_CONNECTION_NOT_ALLOWED, - Reply::NetworkUnreachable => consts::SOCKS5_REPLY_NETWORK_UNREACHABLE, - Reply::HostUnreachable => consts::SOCKS5_REPLY_HOST_UNREACHABLE, - Reply::ConnectionRefused => consts::SOCKS5_REPLY_CONNECTION_REFUSED, - Reply::TtlExpired => consts::SOCKS5_REPLY_TTL_EXPIRED, - Reply::CommandNotSupported => consts::SOCKS5_REPLY_COMMAND_NOT_SUPPORTED, - Reply::AddressTypeNotSupported => consts::SOCKS5_REPLY_ADDRESS_TYPE_NOT_SUPPORTED, - Reply::OtherReply(c) => c, + Self::Succeeded => consts::SOCKS5_REPLY_SUCCEEDED, + Self::GeneralFailure => consts::SOCKS5_REPLY_GENERAL_FAILURE, + Self::ConnectionNotAllowed => consts::SOCKS5_REPLY_CONNECTION_NOT_ALLOWED, + Self::NetworkUnreachable => consts::SOCKS5_REPLY_NETWORK_UNREACHABLE, + Self::HostUnreachable => consts::SOCKS5_REPLY_HOST_UNREACHABLE, + Self::ConnectionRefused => consts::SOCKS5_REPLY_CONNECTION_REFUSED, + Self::TtlExpired => consts::SOCKS5_REPLY_TTL_EXPIRED, + Self::CommandNotSupported => consts::SOCKS5_REPLY_COMMAND_NOT_SUPPORTED, + Self::AddressTypeNotSupported => consts::SOCKS5_REPLY_ADDRESS_TYPE_NOT_SUPPORTED, + Self::OtherReply(c) => c, } } #[inline] #[rustfmt::skip] - pub fn from_u8(code: u8) -> Reply { + pub fn from_u8(code: u8) -> Self { match code { - consts::SOCKS5_REPLY_SUCCEEDED => Reply::Succeeded, - consts::SOCKS5_REPLY_GENERAL_FAILURE => Reply::GeneralFailure, - consts::SOCKS5_REPLY_CONNECTION_NOT_ALLOWED => Reply::ConnectionNotAllowed, - consts::SOCKS5_REPLY_NETWORK_UNREACHABLE => Reply::NetworkUnreachable, - consts::SOCKS5_REPLY_HOST_UNREACHABLE => Reply::HostUnreachable, - consts::SOCKS5_REPLY_CONNECTION_REFUSED => Reply::ConnectionRefused, - consts::SOCKS5_REPLY_TTL_EXPIRED => Reply::TtlExpired, - consts::SOCKS5_REPLY_COMMAND_NOT_SUPPORTED => Reply::CommandNotSupported, - consts::SOCKS5_REPLY_ADDRESS_TYPE_NOT_SUPPORTED => Reply::AddressTypeNotSupported, - _ => Reply::OtherReply(code), + consts::SOCKS5_REPLY_SUCCEEDED => Self::Succeeded, + consts::SOCKS5_REPLY_GENERAL_FAILURE => Self::GeneralFailure, + consts::SOCKS5_REPLY_CONNECTION_NOT_ALLOWED => Self::ConnectionNotAllowed, + consts::SOCKS5_REPLY_NETWORK_UNREACHABLE => Self::NetworkUnreachable, + consts::SOCKS5_REPLY_HOST_UNREACHABLE => Self::HostUnreachable, + consts::SOCKS5_REPLY_CONNECTION_REFUSED => Self::ConnectionRefused, + consts::SOCKS5_REPLY_TTL_EXPIRED => Self::TtlExpired, + consts::SOCKS5_REPLY_COMMAND_NOT_SUPPORTED => Self::CommandNotSupported, + consts::SOCKS5_REPLY_ADDRESS_TYPE_NOT_SUPPORTED => Self::AddressTypeNotSupported, + _ => Self::OtherReply(code), } } } @@ -137,16 +137,16 @@ impl fmt::Display for Reply { #[rustfmt::skip] fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { match *self { - Reply::Succeeded => write!(f, "Succeeded"), - Reply::AddressTypeNotSupported => write!(f, "Address type not supported"), - Reply::CommandNotSupported => write!(f, "Command not supported"), - Reply::ConnectionNotAllowed => write!(f, "Connection not allowed"), - Reply::ConnectionRefused => write!(f, "Connection refused"), - Reply::GeneralFailure => write!(f, "General failure"), - Reply::HostUnreachable => write!(f, "Host unreachable"), - Reply::NetworkUnreachable => write!(f, "Network unreachable"), - Reply::OtherReply(u) => write!(f, "Other reply ({u})"), - Reply::TtlExpired => write!(f, "TTL expired"), + Self::Succeeded => write!(f, "Succeeded"), + Self::AddressTypeNotSupported => write!(f, "Address type not supported"), + Self::CommandNotSupported => write!(f, "Command not supported"), + Self::ConnectionNotAllowed => write!(f, "Connection not allowed"), + Self::ConnectionRefused => write!(f, "Connection refused"), + Self::GeneralFailure => write!(f, "General failure"), + Self::HostUnreachable => write!(f, "Host unreachable"), + Self::NetworkUnreachable => write!(f, "Network unreachable"), + Self::OtherReply(u) => write!(f, "Other reply ({u})"), + Self::TtlExpired => write!(f, "TTL expired"), } } } @@ -173,10 +173,10 @@ pub enum Error { } impl From for io::Error { - fn from(err: Error) -> io::Error { + fn from(err: Error) -> Self { match err { Error::IoError(err) => err, - e => io::Error::other(e), + e => Self::other(e), } } } @@ -185,17 +185,17 @@ impl Error { /// Convert to `Reply` for responding pub fn as_reply(&self) -> Reply { match *self { - Error::IoError(ref err) => match err.kind() { + Self::IoError(ref err) => match err.kind() { ErrorKind::ConnectionRefused => Reply::ConnectionRefused, _ => Reply::GeneralFailure, }, - Error::AddressTypeNotSupported(..) => Reply::AddressTypeNotSupported, - Error::AddressDomainInvalidEncoding => Reply::GeneralFailure, - Error::UnsupportedSocksVersion(..) => Reply::GeneralFailure, - Error::UnsupportedCommand(..) => Reply::CommandNotSupported, - Error::UnsupportedPasswdAuthVersion(..) => Reply::GeneralFailure, - Error::PasswdAuthInvalidRequest => Reply::GeneralFailure, - Error::Reply(r) => r, + Self::AddressTypeNotSupported(..) => Reply::AddressTypeNotSupported, + Self::AddressDomainInvalidEncoding => Reply::GeneralFailure, + Self::UnsupportedSocksVersion(..) => Reply::GeneralFailure, + Self::UnsupportedCommand(..) => Reply::CommandNotSupported, + Self::UnsupportedPasswdAuthVersion(..) => Reply::GeneralFailure, + Self::PasswdAuthInvalidRequest => Reply::GeneralFailure, + Self::Reply(r) => r, } } } @@ -211,7 +211,7 @@ pub enum Address { impl Address { /// read from a cursor - pub fn read_cursor>(cur: &mut io::Cursor) -> Result { + pub fn read_cursor>(cur: &mut io::Cursor) -> Result { if cur.remaining() < 2 { return Err(io::Error::other("invalid buf").into()); } @@ -224,7 +224,7 @@ impl Address { } let addr = Ipv4Addr::from(cur.get_u32()); let port = cur.get_u16(); - Ok(Address::SocketAddress(SocketAddr::V4(SocketAddrV4::new(addr, port)))) + Ok(Self::SocketAddress(SocketAddr::V4(SocketAddrV4::new(addr, port)))) } consts::SOCKS5_ADDR_TYPE_IPV6 => { if cur.remaining() < 16 + 2 { @@ -232,7 +232,7 @@ impl Address { } let addr = Ipv6Addr::from(cur.get_u128()); let port = cur.get_u16(); - Ok(Address::SocketAddress(SocketAddr::V6(SocketAddrV6::new( + Ok(Self::SocketAddress(SocketAddr::V6(SocketAddrV6::new( addr, port, 0, 0, )))) } @@ -245,14 +245,14 @@ impl Address { cur.copy_to_slice(&mut buf); let port = cur.get_u16(); let addr = String::from_utf8(buf).map_err(|_| Error::AddressDomainInvalidEncoding)?; - Ok(Address::DomainNameAddress(addr, port)) + Ok(Self::DomainNameAddress(addr, port)) } _ => Err(Error::AddressTypeNotSupported(atyp)), } } /// Parse from a `AsyncRead` - pub async fn read_from(stream: &mut R) -> Result + pub async fn read_from(stream: &mut R) -> Result where R: AsyncRead + Unpin, { @@ -267,7 +267,7 @@ impl Address { let v4addr = Ipv4Addr::new(buf[0], buf[1], buf[2], buf[3]); let port = u16::from_be_bytes([buf[4], buf[5]]); - Ok(Address::SocketAddress(SocketAddr::V4(SocketAddrV4::new(v4addr, port)))) + Ok(Self::SocketAddress(SocketAddr::V4(SocketAddrV4::new(v4addr, port)))) } consts::SOCKS5_ADDR_TYPE_IPV6 => { let mut buf = [0u16; 9]; @@ -287,7 +287,7 @@ impl Address { ); let port = u16::from_be(buf[8]); - Ok(Address::SocketAddress(SocketAddr::V6(SocketAddrV6::new( + Ok(Self::SocketAddress(SocketAddr::V6(SocketAddrV6::new( v6addr, port, 0, 0, )))) } @@ -312,7 +312,7 @@ impl Address { Err(..) => return Err(Error::AddressDomainInvalidEncoding), }; - Ok(Address::DomainNameAddress(addr, port)) + Ok(Self::DomainNameAddress(addr, port)) } _ => { // Wrong Address Type . Socks5 only supports ipv4, ipv6 and domain name @@ -356,16 +356,16 @@ impl Address { /// Get associated port number pub fn port(&self) -> u16 { match *self { - Address::SocketAddress(addr) => addr.port(), - Address::DomainNameAddress(.., port) => port, + Self::SocketAddress(addr) => addr.port(), + Self::DomainNameAddress(.., port) => port, } } /// Get host address string pub fn host(&self) -> String { match *self { - Address::SocketAddress(ref addr) => addr.ip().to_string(), - Address::DomainNameAddress(ref domain, ..) => domain.to_owned(), + Self::SocketAddress(ref addr) => addr.ip().to_string(), + Self::DomainNameAddress(ref domain, ..) => domain.to_owned(), } } } @@ -374,8 +374,8 @@ impl Debug for Address { #[inline] fn fmt(&self, f: &mut Formatter) -> fmt::Result { match *self { - Address::SocketAddress(ref addr) => write!(f, "{addr}"), - Address::DomainNameAddress(ref addr, ref port) => write!(f, "{addr}:{port}"), + Self::SocketAddress(ref addr) => write!(f, "{addr}"), + Self::DomainNameAddress(ref addr, ref port) => write!(f, "{addr}:{port}"), } } } @@ -384,8 +384,8 @@ impl fmt::Display for Address { #[inline] fn fmt(&self, f: &mut Formatter) -> fmt::Result { match *self { - Address::SocketAddress(ref addr) => write!(f, "{addr}"), - Address::DomainNameAddress(ref addr, ref port) => write!(f, "{addr}:{port}"), + Self::SocketAddress(ref addr) => write!(f, "{addr}"), + Self::DomainNameAddress(ref addr, ref port) => write!(f, "{addr}:{port}"), } } } @@ -395,26 +395,26 @@ impl ToSocketAddrs for Address { fn to_socket_addrs(&self) -> io::Result> { match self.clone() { - Address::SocketAddress(addr) => Ok(vec![addr].into_iter()), - Address::DomainNameAddress(addr, port) => (&addr[..], port).to_socket_addrs(), + Self::SocketAddress(addr) => Ok(vec![addr].into_iter()), + Self::DomainNameAddress(addr, port) => (&addr[..], port).to_socket_addrs(), } } } impl From for Address { - fn from(s: SocketAddr) -> Address { - Address::SocketAddress(s) + fn from(s: SocketAddr) -> Self { + Self::SocketAddress(s) } } impl From<(String, u16)> for Address { - fn from((dn, port): (String, u16)) -> Address { - Address::DomainNameAddress(dn, port) + fn from((dn, port): (String, u16)) -> Self { + Self::DomainNameAddress(dn, port) } } -impl From<&Address> for Address { - fn from(addr: &Address) -> Address { +impl From<&Self> for Address { + fn from(addr: &Self) -> Self { addr.clone() } } @@ -434,19 +434,19 @@ impl std::error::Error for AddressError {} impl FromStr for Address { type Err = AddressError; - fn from_str(s: &str) -> Result { + fn from_str(s: &str) -> Result { match s.parse::() { - Ok(addr) => Ok(Address::SocketAddress(addr)), + Ok(addr) => Ok(Self::SocketAddress(addr)), Err(..) => { let mut sp = s.split(':'); match (sp.next(), sp.next()) { (Some(dn), Some(port)) => match port.parse::() { - Ok(port) => Ok(Address::DomainNameAddress(dn.to_owned(), port)), + Ok(port) => Ok(Self::DomainNameAddress(dn.to_owned(), port)), Err(..) => Err(AddressError), }, (Some(dn), None) => { // Assume it is 80 (http's default port) - Ok(Address::DomainNameAddress(dn.to_owned(), 80)) + Ok(Self::DomainNameAddress(dn.to_owned(), 80)) } _ => Err(AddressError), } @@ -524,15 +524,15 @@ pub struct TcpRequestHeader { impl TcpRequestHeader { /// Creates a request header - pub fn new(cmd: Command, addr: Address) -> TcpRequestHeader { - TcpRequestHeader { + pub fn new(cmd: Command, addr: Address) -> Self { + Self { command: cmd, address: addr, } } /// Read from a reader - pub async fn read_from(r: &mut R) -> Result + pub async fn read_from(r: &mut R) -> Result where R: AsyncRead + Unpin, { @@ -551,7 +551,7 @@ impl TcpRequestHeader { }; let address = Address::read_from(r).await?; - Ok(TcpRequestHeader { command, address }) + Ok(Self { command, address }) } /// Write data into a writer @@ -566,7 +566,7 @@ impl TcpRequestHeader { /// Writes to buffer pub fn write_to_buf(&self, buf: &mut B) { - let TcpRequestHeader { + let Self { ref address, ref command, } = *self; @@ -601,12 +601,12 @@ pub struct TcpResponseHeader { impl TcpResponseHeader { /// Creates a response header - pub fn new(reply: Reply, address: Address) -> TcpResponseHeader { - TcpResponseHeader { reply, address } + pub fn new(reply: Reply, address: Address) -> Self { + Self { reply, address } } /// Read from a reader - pub async fn read_from(r: &mut R) -> Result + pub async fn read_from(r: &mut R) -> Result where R: AsyncRead + Unpin, { @@ -622,7 +622,7 @@ impl TcpResponseHeader { let address = Address::read_from(r).await?; - Ok(TcpResponseHeader { + Ok(Self { reply: Reply::from_u8(reply_code), address, }) @@ -640,7 +640,7 @@ impl TcpResponseHeader { /// Writes to buffer pub fn write_to_buf(&self, buf: &mut B) { - let TcpResponseHeader { ref reply, ref address } = *self; + let Self { ref reply, ref address } = *self; buf.put_slice(&[consts::SOCKS5_VERSION, reply.as_u8(), 0x00]); address.write_to_buf(buf); } @@ -668,12 +668,12 @@ pub struct HandshakeRequest { impl HandshakeRequest { /// Creates a handshake request - pub fn new(methods: Vec) -> HandshakeRequest { - HandshakeRequest { methods } + pub fn new(methods: Vec) -> Self { + Self { methods } } /// Read from a reader - pub async fn read_from(r: &mut R) -> Result + pub async fn read_from(r: &mut R) -> Result where R: AsyncRead + Unpin, { @@ -690,7 +690,7 @@ impl HandshakeRequest { let mut methods = vec![0u8; nmet as usize]; let _ = r.read_exact(&mut methods).await?; - Ok(HandshakeRequest { methods }) + Ok(Self { methods }) } /// Write to a writer @@ -705,7 +705,7 @@ impl HandshakeRequest { /// Write to buffer pub fn write_to_buf(&self, buf: &mut B) { - let HandshakeRequest { ref methods } = *self; + let Self { ref methods } = *self; buf.put_slice(&[consts::SOCKS5_VERSION, methods.len() as u8]); buf.put_slice(methods); } @@ -732,12 +732,12 @@ pub struct HandshakeResponse { impl HandshakeResponse { /// Creates a handshake response - pub fn new(cm: u8) -> HandshakeResponse { - HandshakeResponse { chosen_method: cm } + pub fn new(cm: u8) -> Self { + Self { chosen_method: cm } } /// Read from a reader - pub async fn read_from(r: &mut R) -> Result + pub async fn read_from(r: &mut R) -> Result where R: AsyncRead + Unpin, { @@ -750,7 +750,7 @@ impl HandshakeResponse { if ver != consts::SOCKS5_VERSION { Err(Error::UnsupportedSocksVersion(ver)) } else { - Ok(HandshakeResponse { chosen_method: met }) + Ok(Self { chosen_method: met }) } } @@ -796,12 +796,12 @@ pub struct UdpAssociateHeader { impl UdpAssociateHeader { /// Creates a header - pub fn new(frag: u8, address: Address) -> UdpAssociateHeader { - UdpAssociateHeader { frag, address } + pub fn new(frag: u8, address: Address) -> Self { + Self { frag, address } } /// Read from a reader - pub async fn read_from(r: &mut R) -> Result + pub async fn read_from(r: &mut R) -> Result where R: AsyncRead + Unpin, { @@ -810,7 +810,7 @@ impl UdpAssociateHeader { let frag = buf[2]; let address = Address::read_from(r).await?; - Ok(UdpAssociateHeader::new(frag, address)) + Ok(Self::new(frag, address)) } /// Write to a writer @@ -825,7 +825,7 @@ impl UdpAssociateHeader { /// Write to buffer pub fn write_to_buf(&self, buf: &mut B) { - let UdpAssociateHeader { ref frag, ref address } = *self; + let Self { ref frag, ref address } = *self; buf.put_slice(&[0x00, 0x00, *frag]); address.write_to_buf(buf); } @@ -855,7 +855,7 @@ pub struct PasswdAuthRequest { impl PasswdAuthRequest { /// Create a Username/Password Authentication Request - pub fn new(uname: U, passwd: P) -> PasswdAuthRequest + pub fn new(uname: U, passwd: P) -> Self where U: Into>, P: Into>, @@ -869,11 +869,11 @@ impl PasswdAuthRequest { && passwd.len() <= u8::MAX as usize ); - PasswdAuthRequest { uname, passwd } + Self { uname, passwd } } /// Read from a reader - pub async fn read_from(r: &mut R) -> Result + pub async fn read_from(r: &mut R) -> Result where R: AsyncRead + Unpin, { @@ -911,7 +911,7 @@ impl PasswdAuthRequest { let _ = r.read_exact(&mut passwd).await?; } - Ok(PasswdAuthRequest { uname, passwd }) + Ok(Self { uname, passwd }) } /// Write to a writer @@ -945,12 +945,12 @@ pub struct PasswdAuthResponse { } impl PasswdAuthResponse { - pub fn new(status: u8) -> PasswdAuthResponse { - PasswdAuthResponse { status } + pub fn new(status: u8) -> Self { + Self { status } } /// Read from a reader - pub async fn read_from(r: &mut R) -> Result + pub async fn read_from(r: &mut R) -> Result where R: AsyncRead + Unpin, { @@ -961,7 +961,7 @@ impl PasswdAuthResponse { return Err(Error::UnsupportedPasswdAuthVersion(buf[0])); } - Ok(PasswdAuthResponse { status: buf[1] }) + Ok(Self { status: buf[1] }) } /// Write to a writer diff --git a/shadowsocks-rust/crates/shadowsocks/src/relay/tcprelay/aead.rs b/shadowsocks-rust/crates/shadowsocks/src/relay/tcprelay/aead.rs index f4c4647d81..271804cfba 100644 --- a/shadowsocks-rust/crates/shadowsocks/src/relay/tcprelay/aead.rs +++ b/shadowsocks-rust/crates/shadowsocks/src/relay/tcprelay/aead.rs @@ -74,10 +74,10 @@ pub enum ProtocolError { pub type ProtocolResult = Result; impl From for io::Error { - fn from(e: ProtocolError) -> io::Error { + fn from(e: ProtocolError) -> Self { match e { ProtocolError::IoError(err) => err, - _ => io::Error::other(e), + _ => Self::other(e), } } } @@ -101,9 +101,9 @@ pub struct DecryptedReader { } impl DecryptedReader { - pub fn new(method: CipherKind, key: &[u8]) -> DecryptedReader { + pub fn new(method: CipherKind, key: &[u8]) -> Self { if method.salt_len() > 0 { - DecryptedReader { + Self { state: DecryptReadState::WaitSalt { key: Bytes::copy_from_slice(key), }, @@ -114,7 +114,7 @@ impl DecryptedReader { has_handshaked: false, } } else { - DecryptedReader { + Self { state: DecryptReadState::ReadLength, cipher: Some(Cipher::new(method, key, &[])), buffer: BytesMut::with_capacity(2 + method.tag_len()), @@ -226,7 +226,7 @@ impl DecryptedReader { let cipher = self.cipher.as_mut().expect("cipher is None"); let m = &mut self.buffer[..length_len]; - let length = DecryptedReader::decrypt_length(cipher, m)?; + let length = Self::decrypt_length(cipher, m)?; Ok(Some(length)).into() } @@ -339,12 +339,12 @@ pub struct EncryptedWriter { impl EncryptedWriter { /// Creates a new EncryptedWriter - pub fn new(method: CipherKind, key: &[u8], nonce: &[u8]) -> EncryptedWriter { + pub fn new(method: CipherKind, key: &[u8], nonce: &[u8]) -> Self { // nonce should be sent with the first packet let mut buffer = BytesMut::with_capacity(nonce.len()); buffer.put(nonce); - EncryptedWriter { + Self { cipher: Cipher::new(method, key, nonce), buffer, state: EncryptWriteState::AssemblePacket, diff --git a/shadowsocks-rust/crates/shadowsocks/src/relay/tcprelay/aead_2022.rs b/shadowsocks-rust/crates/shadowsocks/src/relay/tcprelay/aead_2022.rs index 6d780d67e7..37371689a0 100644 --- a/shadowsocks-rust/crates/shadowsocks/src/relay/tcprelay/aead_2022.rs +++ b/shadowsocks-rust/crates/shadowsocks/src/relay/tcprelay/aead_2022.rs @@ -110,10 +110,10 @@ pub enum ProtocolError { pub type ProtocolResult = Result; impl From for io::Error { - fn from(e: ProtocolError) -> io::Error { + fn from(e: ProtocolError) -> Self { match e { ProtocolError::IoError(err) => err, - _ => io::Error::other(e), + _ => Self::other(e), } } } @@ -141,8 +141,8 @@ pub struct DecryptedReader { } impl DecryptedReader { - pub fn new(stream_ty: StreamType, method: CipherKind, key: &[u8]) -> DecryptedReader { - DecryptedReader::with_user_manager(stream_ty, method, key, None) + pub fn new(stream_ty: StreamType, method: CipherKind, key: &[u8]) -> Self { + Self::with_user_manager(stream_ty, method, key, None) } pub fn with_user_manager( @@ -150,9 +150,9 @@ impl DecryptedReader { method: CipherKind, key: &[u8], user_manager: Option>, - ) -> DecryptedReader { + ) -> Self { if method.salt_len() > 0 { - DecryptedReader { + Self { stream_ty, state: DecryptReadState::ReadHeader { key: Bytes::copy_from_slice(key), @@ -168,7 +168,7 @@ impl DecryptedReader { has_handshaked: false, } } else { - DecryptedReader { + Self { stream_ty, state: DecryptReadState::ReadHeader { key: Bytes::new(), // EMPTY SALT, no allocation @@ -419,7 +419,7 @@ impl DecryptedReader { let cipher = self.cipher.as_mut().expect("cipher is None"); let m = &mut self.buffer[..length_len]; - let length = DecryptedReader::decrypt_length(cipher, m)?; + let length = Self::decrypt_length(cipher, m)?; Ok(Some(length)).into() } @@ -531,9 +531,9 @@ pub struct EncryptedWriter { impl EncryptedWriter { /// Creates a new EncryptedWriter - pub fn new(stream_ty: StreamType, method: CipherKind, key: &[u8], nonce: &[u8]) -> EncryptedWriter { + pub fn new(stream_ty: StreamType, method: CipherKind, key: &[u8], nonce: &[u8]) -> Self { const EMPTY_IDENTITY: [Bytes; 0] = []; - EncryptedWriter::with_identity(stream_ty, method, key, nonce, &EMPTY_IDENTITY) + Self::with_identity(stream_ty, method, key, nonce, &EMPTY_IDENTITY) } /// Creates a new EncryptedWriter with identities @@ -543,7 +543,7 @@ impl EncryptedWriter { key: &[u8], nonce: &[u8], identity_keys: &[Bytes], - ) -> EncryptedWriter { + ) -> Self { // nonce should be sent with the first packet let mut buffer = BytesMut::with_capacity(nonce.len() + identity_keys.len() * 16); buffer.put(nonce); @@ -607,7 +607,7 @@ impl EncryptedWriter { } } - EncryptedWriter { + Self { stream_ty, cipher: TcpCipher::new(method, key, nonce), method, diff --git a/shadowsocks-rust/crates/shadowsocks/src/relay/tcprelay/crypto_io.rs b/shadowsocks-rust/crates/shadowsocks/src/relay/tcprelay/crypto_io.rs index f5046d354d..e7275cc2bf 100644 --- a/shadowsocks-rust/crates/shadowsocks/src/relay/tcprelay/crypto_io.rs +++ b/shadowsocks-rust/crates/shadowsocks/src/relay/tcprelay/crypto_io.rs @@ -49,7 +49,7 @@ pub enum ProtocolError { pub type ProtocolResult = Result; impl From for io::Error { - fn from(e: ProtocolError) -> io::Error { + fn from(e: ProtocolError) -> Self { match e { ProtocolError::IoError(err) => err, #[cfg(feature = "stream-cipher")] @@ -85,8 +85,8 @@ pub enum DecryptedReader { impl DecryptedReader { /// Create a new reader for reading encrypted data - pub fn new(stream_ty: StreamType, method: CipherKind, key: &[u8]) -> DecryptedReader { - DecryptedReader::with_user_manager(stream_ty, method, key, None) + pub fn new(stream_ty: StreamType, method: CipherKind, key: &[u8]) -> Self { + Self::with_user_manager(stream_ty, method, key, None) } /// Create a new reader for reading encrypted data @@ -95,7 +95,7 @@ impl DecryptedReader { method: CipherKind, key: &[u8], user_manager: Option>, - ) -> DecryptedReader { + ) -> Self { if cfg!(not(feature = "aead-cipher-2022")) { let _ = stream_ty; let _ = user_manager; @@ -103,16 +103,16 @@ impl DecryptedReader { match method.category() { #[cfg(feature = "stream-cipher")] - CipherCategory::Stream => DecryptedReader::Stream(StreamDecryptedReader::new(method, key)), + CipherCategory::Stream => Self::Stream(StreamDecryptedReader::new(method, key)), #[cfg(feature = "aead-cipher")] - CipherCategory::Aead => DecryptedReader::Aead(AeadDecryptedReader::new(method, key)), + CipherCategory::Aead => Self::Aead(AeadDecryptedReader::new(method, key)), CipherCategory::None => { let _ = method; let _ = key; - DecryptedReader::None + Self::None } #[cfg(feature = "aead-cipher-2022")] - CipherCategory::Aead2022 => DecryptedReader::Aead2022(Aead2022DecryptedReader::with_user_manager( + CipherCategory::Aead2022 => Self::Aead2022(Aead2022DecryptedReader::with_user_manager( stream_ty, method, key, @@ -135,19 +135,19 @@ impl DecryptedReader { { match *self { #[cfg(feature = "stream-cipher")] - DecryptedReader::Stream(ref mut reader) => { + Self::Stream(ref mut reader) => { reader.poll_read_decrypted(cx, context, stream, buf).map_err(Into::into) } #[cfg(feature = "aead-cipher")] - DecryptedReader::Aead(ref mut reader) => { + Self::Aead(ref mut reader) => { reader.poll_read_decrypted(cx, context, stream, buf).map_err(Into::into) } - DecryptedReader::None => { + Self::None => { let _ = context; Pin::new(stream).poll_read(cx, buf).map_err(Into::into) } #[cfg(feature = "aead-cipher-2022")] - DecryptedReader::Aead2022(ref mut reader) => { + Self::Aead2022(ref mut reader) => { reader.poll_read_decrypted(cx, context, stream, buf).map_err(Into::into) } } @@ -157,12 +157,12 @@ impl DecryptedReader { pub fn nonce(&self) -> Option<&[u8]> { match *self { #[cfg(feature = "stream-cipher")] - DecryptedReader::Stream(ref reader) => reader.iv(), + Self::Stream(ref reader) => reader.iv(), #[cfg(feature = "aead-cipher")] - DecryptedReader::Aead(ref reader) => reader.salt(), - DecryptedReader::None => None, + Self::Aead(ref reader) => reader.salt(), + Self::None => None, #[cfg(feature = "aead-cipher-2022")] - DecryptedReader::Aead2022(ref reader) => reader.salt(), + Self::Aead2022(ref reader) => reader.salt(), } } @@ -170,12 +170,12 @@ impl DecryptedReader { pub fn request_nonce(&self) -> Option<&[u8]> { match *self { #[cfg(feature = "stream-cipher")] - DecryptedReader::Stream(..) => None, + Self::Stream(..) => None, #[cfg(feature = "aead-cipher")] - DecryptedReader::Aead(..) => None, - DecryptedReader::None => None, + Self::Aead(..) => None, + Self::None => None, #[cfg(feature = "aead-cipher-2022")] - DecryptedReader::Aead2022(ref reader) => reader.request_salt(), + Self::Aead2022(ref reader) => reader.request_salt(), } } @@ -183,24 +183,24 @@ impl DecryptedReader { pub fn user_key(&self) -> Option<&[u8]> { match *self { #[cfg(feature = "stream-cipher")] - DecryptedReader::Stream(..) => None, + Self::Stream(..) => None, #[cfg(feature = "aead-cipher")] - DecryptedReader::Aead(..) => None, - DecryptedReader::None => None, + Self::Aead(..) => None, + Self::None => None, #[cfg(feature = "aead-cipher-2022")] - DecryptedReader::Aead2022(ref reader) => reader.user_key(), + Self::Aead2022(ref reader) => reader.user_key(), } } pub fn handshaked(&self) -> bool { match *self { #[cfg(feature = "stream-cipher")] - DecryptedReader::Stream(ref reader) => reader.handshaked(), + Self::Stream(ref reader) => reader.handshaked(), #[cfg(feature = "aead-cipher")] - DecryptedReader::Aead(ref reader) => reader.handshaked(), - DecryptedReader::None => true, + Self::Aead(ref reader) => reader.handshaked(), + Self::None => true, #[cfg(feature = "aead-cipher-2022")] - DecryptedReader::Aead2022(ref reader) => reader.handshaked(), + Self::Aead2022(ref reader) => reader.handshaked(), } } } @@ -219,24 +219,24 @@ pub enum EncryptedWriter { impl EncryptedWriter { /// Create a new writer for writing encrypted data - pub fn new(stream_ty: StreamType, method: CipherKind, key: &[u8], nonce: &[u8]) -> EncryptedWriter { + pub fn new(stream_ty: StreamType, method: CipherKind, key: &[u8], nonce: &[u8]) -> Self { if cfg!(not(feature = "aead-cipher-2022")) { let _ = stream_ty; } match method.category() { #[cfg(feature = "stream-cipher")] - CipherCategory::Stream => EncryptedWriter::Stream(StreamEncryptedWriter::new(method, key, nonce)), + CipherCategory::Stream => Self::Stream(StreamEncryptedWriter::new(method, key, nonce)), #[cfg(feature = "aead-cipher")] - CipherCategory::Aead => EncryptedWriter::Aead(AeadEncryptedWriter::new(method, key, nonce)), + CipherCategory::Aead => Self::Aead(AeadEncryptedWriter::new(method, key, nonce)), CipherCategory::None => { let _ = key; let _ = nonce; - EncryptedWriter::None + Self::None } #[cfg(feature = "aead-cipher-2022")] CipherCategory::Aead2022 => { - EncryptedWriter::Aead2022(Aead2022EncryptedWriter::new(stream_ty, method, key, nonce)) + Self::Aead2022(Aead2022EncryptedWriter::new(stream_ty, method, key, nonce)) } } } @@ -248,7 +248,7 @@ impl EncryptedWriter { key: &[u8], nonce: &[u8], identity_keys: &[Bytes], - ) -> EncryptedWriter { + ) -> Self { if cfg!(not(feature = "aead-cipher-2022")) { let _ = stream_ty; let _ = identity_keys; @@ -256,16 +256,16 @@ impl EncryptedWriter { match method.category() { #[cfg(feature = "stream-cipher")] - CipherCategory::Stream => EncryptedWriter::Stream(StreamEncryptedWriter::new(method, key, nonce)), + CipherCategory::Stream => Self::Stream(StreamEncryptedWriter::new(method, key, nonce)), #[cfg(feature = "aead-cipher")] - CipherCategory::Aead => EncryptedWriter::Aead(AeadEncryptedWriter::new(method, key, nonce)), + CipherCategory::Aead => Self::Aead(AeadEncryptedWriter::new(method, key, nonce)), CipherCategory::None => { let _ = key; let _ = nonce; - EncryptedWriter::None + Self::None } #[cfg(feature = "aead-cipher-2022")] - CipherCategory::Aead2022 => EncryptedWriter::Aead2022(Aead2022EncryptedWriter::with_identity( + CipherCategory::Aead2022 => Self::Aead2022(Aead2022EncryptedWriter::with_identity( stream_ty, method, key, @@ -288,12 +288,12 @@ impl EncryptedWriter { { match *self { #[cfg(feature = "stream-cipher")] - EncryptedWriter::Stream(ref mut writer) => writer.poll_write_encrypted(cx, stream, buf).map_err(Into::into), + Self::Stream(ref mut writer) => writer.poll_write_encrypted(cx, stream, buf).map_err(Into::into), #[cfg(feature = "aead-cipher")] - EncryptedWriter::Aead(ref mut writer) => writer.poll_write_encrypted(cx, stream, buf).map_err(Into::into), - EncryptedWriter::None => Pin::new(stream).poll_write(cx, buf).map_err(Into::into), + Self::Aead(ref mut writer) => writer.poll_write_encrypted(cx, stream, buf).map_err(Into::into), + Self::None => Pin::new(stream).poll_write(cx, buf).map_err(Into::into), #[cfg(feature = "aead-cipher-2022")] - EncryptedWriter::Aead2022(ref mut writer) => { + Self::Aead2022(ref mut writer) => { writer.poll_write_encrypted(cx, stream, buf).map_err(Into::into) } } @@ -303,12 +303,12 @@ impl EncryptedWriter { pub fn nonce(&self) -> &[u8] { match *self { #[cfg(feature = "stream-cipher")] - EncryptedWriter::Stream(ref writer) => writer.iv(), + Self::Stream(ref writer) => writer.iv(), #[cfg(feature = "aead-cipher")] - EncryptedWriter::Aead(ref writer) => writer.salt(), - EncryptedWriter::None => &[], + Self::Aead(ref writer) => writer.salt(), + Self::None => &[], #[cfg(feature = "aead-cipher-2022")] - EncryptedWriter::Aead2022(ref writer) => writer.salt(), + Self::Aead2022(ref writer) => writer.salt(), } } @@ -316,7 +316,7 @@ impl EncryptedWriter { pub fn set_request_nonce(&mut self, request_nonce: Bytes) { match *self { #[cfg(feature = "aead-cipher-2022")] - EncryptedWriter::Aead2022(ref mut writer) => writer.set_request_salt(request_nonce), + Self::Aead2022(ref mut writer) => writer.set_request_salt(request_nonce), _ => { let _ = request_nonce; panic!("only AEAD-2022 cipher could send request salt"); @@ -328,7 +328,7 @@ impl EncryptedWriter { pub fn reset_cipher_with_key(&mut self, key: &[u8]) { match *self { #[cfg(feature = "aead-cipher-2022")] - EncryptedWriter::Aead2022(ref mut writer) => writer.reset_cipher_with_key(key), + Self::Aead2022(ref mut writer) => writer.reset_cipher_with_key(key), _ => { let _ = key; panic!("only AEAD-2022 cipher could authenticate with multiple users"); @@ -363,9 +363,9 @@ impl CryptoStream { stream_ty: StreamType, method: CipherKind, key: &[u8], - ) -> CryptoStream { + ) -> Self { const EMPTY_IDENTITY: [Bytes; 0] = []; - CryptoStream::from_stream_with_identity(context, stream, stream_ty, method, key, &EMPTY_IDENTITY, None) + Self::from_stream_with_identity(context, stream, stream_ty, method, key, &EMPTY_IDENTITY, None) } /// Create a new CryptoStream with the underlying stream connection @@ -377,12 +377,12 @@ impl CryptoStream { key: &[u8], identity_keys: &[Bytes], user_manager: Option>, - ) -> CryptoStream { + ) -> Self { let category = method.category(); if category == CipherCategory::None { // Fast-path for none cipher - return CryptoStream::::new_none(stream, method); + return Self::new_none(stream, method); } let prev_len = match category { @@ -426,7 +426,7 @@ impl CryptoStream { } }; - CryptoStream { + Self { stream, dec: DecryptedReader::with_user_manager(stream_ty, method, key, user_manager), enc: EncryptedWriter::with_identity(stream_ty, method, key, &iv, identity_keys), @@ -435,8 +435,8 @@ impl CryptoStream { } } - fn new_none(stream: S, method: CipherKind) -> CryptoStream { - CryptoStream { + fn new_none(stream: S, method: CipherKind) -> Self { + Self { stream, dec: DecryptedReader::None, enc: EncryptedWriter::None, @@ -547,7 +547,7 @@ where context: &Context, buf: &mut ReadBuf<'_>, ) -> Poll> { - let CryptoStream { + let Self { ref mut dec, ref mut enc, ref mut stream, @@ -580,7 +580,7 @@ where cx: &mut task::Context<'_>, buf: &[u8], ) -> Poll> { - let CryptoStream { + let Self { ref mut enc, ref mut stream, .. diff --git a/shadowsocks-rust/crates/shadowsocks/src/relay/tcprelay/proxy_listener.rs b/shadowsocks-rust/crates/shadowsocks/src/relay/tcprelay/proxy_listener.rs index b76893725d..a8d061e6ee 100644 --- a/shadowsocks-rust/crates/shadowsocks/src/relay/tcprelay/proxy_listener.rs +++ b/shadowsocks-rust/crates/shadowsocks/src/relay/tcprelay/proxy_listener.rs @@ -33,8 +33,8 @@ static DEFAULT_ACCEPT_OPTS: LazyLock = LazyLock::new(Default::defaul impl ProxyListener { /// Create a `ProxyListener` binding to a specific address - pub async fn bind(context: SharedContext, svr_cfg: &ServerConfig) -> io::Result { - ProxyListener::bind_with_opts(context, svr_cfg, DEFAULT_ACCEPT_OPTS.clone()).await + pub async fn bind(context: SharedContext, svr_cfg: &ServerConfig) -> io::Result { + Self::bind_with_opts(context, svr_cfg, DEFAULT_ACCEPT_OPTS.clone()).await } /// Create a `ProxyListener` binding to a specific address with opts @@ -42,7 +42,7 @@ impl ProxyListener { context: SharedContext, svr_cfg: &ServerConfig, accept_opts: AcceptOpts, - ) -> io::Result { + ) -> io::Result { let listener = match svr_cfg.tcp_external_addr() { ServerAddr::SocketAddr(sa) => TcpListener::bind_with_opts(sa, accept_opts).await?, ServerAddr::DomainName(domain, port) => { @@ -52,12 +52,12 @@ impl ProxyListener { .1 } }; - Ok(ProxyListener::from_listener(context, listener, svr_cfg)) + Ok(Self::from_listener(context, listener, svr_cfg)) } /// Create a `ProxyListener` from a `TcpListener` - pub fn from_listener(context: SharedContext, listener: TcpListener, svr_cfg: &ServerConfig) -> ProxyListener { - ProxyListener { + pub fn from_listener(context: SharedContext, listener: TcpListener, svr_cfg: &ServerConfig) -> Self { + Self { listener, method: svr_cfg.method(), key: svr_cfg.key().to_vec().into_boxed_slice(), diff --git a/shadowsocks-rust/crates/shadowsocks/src/relay/tcprelay/proxy_stream/client.rs b/shadowsocks-rust/crates/shadowsocks/src/relay/tcprelay/proxy_stream/client.rs index a43531e7b5..1a93408fd6 100644 --- a/shadowsocks-rust/crates/shadowsocks/src/relay/tcprelay/proxy_stream/client.rs +++ b/shadowsocks-rust/crates/shadowsocks/src/relay/tcprelay/proxy_stream/client.rs @@ -63,11 +63,11 @@ impl ProxyClientStream { context: SharedContext, svr_cfg: &ServerConfig, addr: A, - ) -> io::Result> + ) -> io::Result where A: Into
, { - ProxyClientStream::connect_with_opts(context, svr_cfg, addr, &DEFAULT_CONNECT_OPTS).await + Self::connect_with_opts(context, svr_cfg, addr, &DEFAULT_CONNECT_OPTS).await } /// Connect to target `addr` via shadowsocks' server configured by `svr_cfg` @@ -76,11 +76,11 @@ impl ProxyClientStream { svr_cfg: &ServerConfig, addr: A, opts: &ConnectOpts, - ) -> io::Result> + ) -> io::Result where A: Into
, { - ProxyClientStream::connect_with_opts_map(context, svr_cfg, addr, opts, |s| s).await + Self::connect_with_opts_map(context, svr_cfg, addr, opts, |s| s).await } } @@ -94,12 +94,12 @@ where svr_cfg: &ServerConfig, addr: A, map_fn: F, - ) -> io::Result> + ) -> io::Result where A: Into
, F: FnOnce(OutboundTcpStream) -> S, { - ProxyClientStream::connect_with_opts_map(context, svr_cfg, addr, &DEFAULT_CONNECT_OPTS, map_fn).await + Self::connect_with_opts_map(context, svr_cfg, addr, &DEFAULT_CONNECT_OPTS, map_fn).await } /// Connect to target `addr` via shadowsocks' server configured by `svr_cfg`, maps `TcpStream` to customized stream with `map_fn` @@ -109,7 +109,7 @@ where addr: A, opts: &ConnectOpts, map_fn: F, - ) -> io::Result> + ) -> io::Result where A: Into
, F: FnOnce(OutboundTcpStream) -> S, @@ -142,13 +142,13 @@ where opts ); - Ok(ProxyClientStream::from_stream(context, map_fn(stream), svr_cfg, addr)) + Ok(Self::from_stream(context, map_fn(stream), svr_cfg, addr)) } /// Create a `ProxyClientStream` with a connected `stream` to a shadowsocks' server /// /// NOTE: `stream` must be connected to the server with the same configuration as `svr_cfg`, otherwise strange errors would occurs - pub fn from_stream(context: SharedContext, stream: S, svr_cfg: &ServerConfig, addr: A) -> ProxyClientStream + pub fn from_stream(context: SharedContext, stream: S, svr_cfg: &ServerConfig, addr: A) -> Self where A: Into
, { @@ -174,7 +174,7 @@ where ProxyClientStreamReadState::Established }; - ProxyClientStream { + Self { stream, writer_state: ProxyClientStreamWriteState::Connect(addr), reader_state, diff --git a/shadowsocks-rust/crates/shadowsocks/src/relay/tcprelay/proxy_stream/protocol/mod.rs b/shadowsocks-rust/crates/shadowsocks/src/relay/tcprelay/proxy_stream/protocol/mod.rs index 883986ae4f..7acaa393da 100644 --- a/shadowsocks-rust/crates/shadowsocks/src/relay/tcprelay/proxy_stream/protocol/mod.rs +++ b/shadowsocks-rust/crates/shadowsocks/src/relay/tcprelay/proxy_stream/protocol/mod.rs @@ -26,21 +26,21 @@ pub enum TcpRequestHeader { } impl TcpRequestHeader { - pub async fn read_from(method: CipherKind, reader: &mut R) -> io::Result { + pub async fn read_from(method: CipherKind, reader: &mut R) -> io::Result { match method.category() { - CipherCategory::None => Ok(TcpRequestHeader::Stream( + CipherCategory::None => Ok(Self::Stream( StreamTcpRequestHeader::read_from(reader).await?, )), #[cfg(feature = "aead-cipher")] - CipherCategory::Aead => Ok(TcpRequestHeader::Stream( + CipherCategory::Aead => Ok(Self::Stream( StreamTcpRequestHeader::read_from(reader).await?, )), #[cfg(feature = "stream-cipher")] - CipherCategory::Stream => Ok(TcpRequestHeader::Stream( + CipherCategory::Stream => Ok(Self::Stream( StreamTcpRequestHeader::read_from(reader).await?, )), #[cfg(feature = "aead-cipher-2022")] - CipherCategory::Aead2022 => Ok(TcpRequestHeader::Aead2022( + CipherCategory::Aead2022 => Ok(Self::Aead2022( Aead2022TcpRequestHeader::read_from(reader).await?, )), } @@ -48,33 +48,33 @@ impl TcpRequestHeader { pub fn write_to_buf(&self, buf: &mut B) { match *self { - TcpRequestHeader::Stream(ref h) => h.write_to_buf(buf), + Self::Stream(ref h) => h.write_to_buf(buf), #[cfg(feature = "aead-cipher-2022")] - TcpRequestHeader::Aead2022(ref h) => h.write_to_buf(buf), + Self::Aead2022(ref h) => h.write_to_buf(buf), } } pub fn addr(self) -> Address { match self { - TcpRequestHeader::Stream(h) => h.addr, + Self::Stream(h) => h.addr, #[cfg(feature = "aead-cipher-2022")] - TcpRequestHeader::Aead2022(h) => h.addr, + Self::Aead2022(h) => h.addr, } } pub fn addr_ref(&self) -> &Address { match *self { - TcpRequestHeader::Stream(ref h) => &h.addr, + Self::Stream(ref h) => &h.addr, #[cfg(feature = "aead-cipher-2022")] - TcpRequestHeader::Aead2022(ref h) => &h.addr, + Self::Aead2022(ref h) => &h.addr, } } pub fn serialized_len(&self) -> usize { match *self { - TcpRequestHeader::Stream(ref h) => h.serialized_len(), + Self::Stream(ref h) => h.serialized_len(), #[cfg(feature = "aead-cipher-2022")] - TcpRequestHeader::Aead2022(ref h) => h.serialized_len(), + Self::Aead2022(ref h) => h.serialized_len(), } } } diff --git a/shadowsocks-rust/crates/shadowsocks/src/relay/tcprelay/proxy_stream/protocol/v1.rs b/shadowsocks-rust/crates/shadowsocks/src/relay/tcprelay/proxy_stream/protocol/v1.rs index 2eaa81d345..87b7318537 100644 --- a/shadowsocks-rust/crates/shadowsocks/src/relay/tcprelay/proxy_stream/protocol/v1.rs +++ b/shadowsocks-rust/crates/shadowsocks/src/relay/tcprelay/proxy_stream/protocol/v1.rs @@ -13,8 +13,8 @@ pub struct StreamTcpRequestHeader { } impl StreamTcpRequestHeader { - pub async fn read_from(reader: &mut R) -> io::Result { - Ok(StreamTcpRequestHeader { + pub async fn read_from(reader: &mut R) -> io::Result { + Ok(Self { addr: Address::read_from(reader).await?, }) } diff --git a/shadowsocks-rust/crates/shadowsocks/src/relay/tcprelay/proxy_stream/protocol/v2.rs b/shadowsocks-rust/crates/shadowsocks/src/relay/tcprelay/proxy_stream/protocol/v2.rs index 656306d5f4..f55a3a0ec7 100644 --- a/shadowsocks-rust/crates/shadowsocks/src/relay/tcprelay/proxy_stream/protocol/v2.rs +++ b/shadowsocks-rust/crates/shadowsocks/src/relay/tcprelay/proxy_stream/protocol/v2.rs @@ -27,7 +27,7 @@ pub struct Aead2022TcpRequestHeader { } impl Aead2022TcpRequestHeader { - pub async fn read_from(reader: &mut R) -> io::Result { + pub async fn read_from(reader: &mut R) -> io::Result { let addr = Address::read_from(reader).await?; let mut padding_size_buffer = [0u8; 2]; @@ -46,7 +46,7 @@ impl Aead2022TcpRequestHeader { } } - Ok(Aead2022TcpRequestHeader { addr, padding_size }) + Ok(Self { addr, padding_size }) } pub fn write_to_buf(&self, buf: &mut B) { diff --git a/shadowsocks-rust/crates/shadowsocks/src/relay/tcprelay/proxy_stream/server.rs b/shadowsocks-rust/crates/shadowsocks/src/relay/tcprelay/proxy_stream/server.rs index 2a66038e68..a36c02ef29 100644 --- a/shadowsocks-rust/crates/shadowsocks/src/relay/tcprelay/proxy_stream/server.rs +++ b/shadowsocks-rust/crates/shadowsocks/src/relay/tcprelay/proxy_stream/server.rs @@ -45,8 +45,8 @@ pub struct ProxyServerStream { impl ProxyServerStream { /// Create a `ProxyServerStream` from a connection stream - pub fn from_stream(context: SharedContext, stream: S, method: CipherKind, key: &[u8]) -> ProxyServerStream { - ProxyServerStream::from_stream_with_user_manager(context, stream, method, key, None) + pub fn from_stream(context: SharedContext, stream: S, method: CipherKind, key: &[u8]) -> Self { + Self::from_stream_with_user_manager(context, stream, method, key, None) } /// Create a `ProxyServerStream` from a connection stream @@ -58,7 +58,7 @@ impl ProxyServerStream { method: CipherKind, key: &[u8], user_manager: Option>, - ) -> ProxyServerStream { + ) -> Self { #[cfg(feature = "aead-cipher-2022")] let writer_state = if method.is_aead_2022() { ProxyServerStreamWriteState::PrepareHeader(None) @@ -70,7 +70,7 @@ impl ProxyServerStream { let writer_state = ProxyServerStreamWriteState::Established; const EMPTY_IDENTITY: [Bytes; 0] = []; - ProxyServerStream { + Self { stream: CryptoStream::from_stream_with_identity( &context, stream, diff --git a/shadowsocks-rust/crates/shadowsocks/src/relay/tcprelay/stream.rs b/shadowsocks-rust/crates/shadowsocks/src/relay/tcprelay/stream.rs index aac4d7d522..58bc7e2b7a 100644 --- a/shadowsocks-rust/crates/shadowsocks/src/relay/tcprelay/stream.rs +++ b/shadowsocks-rust/crates/shadowsocks/src/relay/tcprelay/stream.rs @@ -31,10 +31,10 @@ pub enum ProtocolError { pub type ProtocolResult = Result; impl From for io::Error { - fn from(e: ProtocolError) -> io::Error { + fn from(e: ProtocolError) -> Self { match e { ProtocolError::IoError(err) => err, - _ => io::Error::other(e), + _ => Self::other(e), } } } @@ -55,9 +55,9 @@ pub struct DecryptedReader { } impl DecryptedReader { - pub fn new(method: CipherKind, key: &[u8]) -> DecryptedReader { + pub fn new(method: CipherKind, key: &[u8]) -> Self { if method.iv_len() > 0 { - DecryptedReader { + Self { state: DecryptReadState::WaitIv { key: Bytes::copy_from_slice(key), }, @@ -68,7 +68,7 @@ impl DecryptedReader { has_handshaked: false, } } else { - DecryptedReader { + Self { state: DecryptReadState::Read, cipher: Some(Cipher::new(method, key, &[])), buffer: BytesMut::new(), @@ -209,12 +209,12 @@ pub struct EncryptedWriter { impl EncryptedWriter { /// Creates a new EncryptedWriter - pub fn new(method: CipherKind, key: &[u8], nonce: &[u8]) -> EncryptedWriter { + pub fn new(method: CipherKind, key: &[u8], nonce: &[u8]) -> Self { // nonce should be sent with the first packet let mut buffer = BytesMut::with_capacity(nonce.len()); buffer.put(nonce); - EncryptedWriter { + Self { cipher: Cipher::new(method, key, nonce), buffer, state: EncryptWriteState::AssemblePacket, diff --git a/shadowsocks-rust/crates/shadowsocks/src/relay/udprelay/aead_2022.rs b/shadowsocks-rust/crates/shadowsocks/src/relay/udprelay/aead_2022.rs index 2e07346aa8..2514724eda 100644 --- a/shadowsocks-rust/crates/shadowsocks/src/relay/udprelay/aead_2022.rs +++ b/shadowsocks-rust/crates/shadowsocks/src/relay/udprelay/aead_2022.rs @@ -116,13 +116,13 @@ struct CipherKey { } impl PartialOrd for CipherKey { - fn partial_cmp(&self, other: &CipherKey) -> Option { + fn partial_cmp(&self, other: &Self) -> Option { Some(self.cmp(other)) } } impl Ord for CipherKey { - fn cmp(&self, other: &CipherKey) -> Ordering { + fn cmp(&self, other: &Self) -> Ordering { let hash1 = { let mut hasher = DefaultHasher::new(); self.hash(&mut hasher); diff --git a/shadowsocks-rust/crates/shadowsocks/src/relay/udprelay/compat.rs b/shadowsocks-rust/crates/shadowsocks/src/relay/udprelay/compat.rs index 8dec3e2958..d3cc13a096 100644 --- a/shadowsocks-rust/crates/shadowsocks/src/relay/udprelay/compat.rs +++ b/shadowsocks-rust/crates/shadowsocks/src/relay/udprelay/compat.rs @@ -47,11 +47,11 @@ impl DatagramSocket for UdpSocket { impl DatagramReceive for UdpSocket { fn poll_recv(&self, cx: &mut Context<'_>, buf: &mut ReadBuf<'_>) -> Poll> { - UdpSocket::poll_recv(self, cx, buf) + Self::poll_recv(self, cx, buf) } fn poll_recv_from(&self, cx: &mut Context<'_>, buf: &mut ReadBuf<'_>) -> Poll> { - UdpSocket::poll_recv_from(self, cx, buf) + Self::poll_recv_from(self, cx, buf) } fn poll_recv_ready(&self, cx: &mut Context<'_>) -> Poll> { @@ -61,11 +61,11 @@ impl DatagramReceive for UdpSocket { impl DatagramSend for UdpSocket { fn poll_send(&self, cx: &mut Context<'_>, buf: &[u8]) -> Poll> { - UdpSocket::poll_send(self, cx, buf) + Self::poll_send(self, cx, buf) } fn poll_send_to(&self, cx: &mut Context<'_>, buf: &[u8], target: SocketAddr) -> Poll> { - UdpSocket::poll_send_to(self, cx, buf, target) + Self::poll_send_to(self, cx, buf, target) } fn poll_send_ready(&self, cx: &mut Context<'_>) -> Poll> { diff --git a/shadowsocks-rust/crates/shadowsocks/src/relay/udprelay/proxy_socket.rs b/shadowsocks-rust/crates/shadowsocks/src/relay/udprelay/proxy_socket.rs index e1140246b7..642149ca49 100644 --- a/shadowsocks-rust/crates/shadowsocks/src/relay/udprelay/proxy_socket.rs +++ b/shadowsocks-rust/crates/shadowsocks/src/relay/udprelay/proxy_socket.rs @@ -60,10 +60,10 @@ pub enum ProxySocketError { } impl From for io::Error { - fn from(e: ProxySocketError) -> io::Error { + fn from(e: ProxySocketError) -> Self { match e { ProxySocketError::IoError(e) => e, - _ => io::Error::other(e), + _ => Self::other(e), } } } @@ -90,8 +90,8 @@ impl ProxySocket { pub async fn connect( context: SharedContext, svr_cfg: &ServerConfig, - ) -> ProxySocketResult> { - ProxySocket::connect_with_opts(context, svr_cfg, &DEFAULT_CONNECT_OPTS).await + ) -> ProxySocketResult { + Self::connect_with_opts(context, svr_cfg, &DEFAULT_CONNECT_OPTS).await } /// Create a client to communicate with Shadowsocks' UDP server (outbound) @@ -99,7 +99,7 @@ impl ProxySocket { context: SharedContext, svr_cfg: &ServerConfig, opts: &ConnectOpts, - ) -> ProxySocketResult> { + ) -> ProxySocketResult { // Note: Plugins doesn't support UDP relay let socket = ShadowUdpSocket::connect_server_with_opts(&context, svr_cfg.udp_external_addr(), opts).await?; @@ -111,7 +111,7 @@ impl ProxySocket { opts ); - Ok(ProxySocket::from_socket( + Ok(Self::from_socket( UdpSocketType::Client, context, svr_cfg, @@ -123,8 +123,8 @@ impl ProxySocket { pub async fn bind( context: SharedContext, svr_cfg: &ServerConfig, - ) -> ProxySocketResult> { - ProxySocket::bind_with_opts(context, svr_cfg, AcceptOpts::default()).await + ) -> ProxySocketResult { + Self::bind_with_opts(context, svr_cfg, AcceptOpts::default()).await } /// Create a `ProxySocket` binding to a specific address (inbound) @@ -132,7 +132,7 @@ impl ProxySocket { context: SharedContext, svr_cfg: &ServerConfig, opts: AcceptOpts, - ) -> ProxySocketResult> { + ) -> ProxySocketResult { // Plugins doesn't support UDP let socket = match svr_cfg.udp_external_addr() { ServerAddr::SocketAddr(sa) => ShadowUdpSocket::listen_with_opts(sa, opts).await?, @@ -143,7 +143,7 @@ impl ProxySocket { .1 } }; - Ok(ProxySocket::from_socket( + Ok(Self::from_socket( UdpSocketType::Server, context, svr_cfg, @@ -159,12 +159,12 @@ impl ProxySocket { context: SharedContext, svr_cfg: &ServerConfig, socket: S, - ) -> ProxySocket { + ) -> Self { let key = svr_cfg.key().to_vec().into_boxed_slice(); let method = svr_cfg.method(); // NOTE: svr_cfg.timeout() is not for this socket, but for associations. - ProxySocket { + Self { socket_type, io: socket, method, diff --git a/shadowsocks-rust/crates/shadowsocks/src/security/replay/mod.rs b/shadowsocks-rust/crates/shadowsocks/src/security/replay/mod.rs index 2848c56f65..7c22ca7095 100644 --- a/shadowsocks-rust/crates/shadowsocks/src/security/replay/mod.rs +++ b/shadowsocks-rust/crates/shadowsocks/src/security/replay/mod.rs @@ -40,8 +40,8 @@ impl fmt::Debug for ReplayProtector { impl ReplayProtector { /// Create a new ReplayProtector #[allow(unused_variables)] - pub fn new(config_type: ServerType) -> ReplayProtector { - ReplayProtector { + pub fn new(config_type: ServerType) -> Self { + Self { #[cfg(feature = "security-replay-attack-detect")] nonce_ppbloom: spin::Mutex::new(PingPongBloom::new(config_type)), #[cfg(feature = "aead-cipher-2022")] diff --git a/shadowsocks-rust/crates/shadowsocks/src/security/replay/ppbloom.rs b/shadowsocks-rust/crates/shadowsocks/src/security/replay/ppbloom.rs index 88dfa20d16..0b587c03ff 100644 --- a/shadowsocks-rust/crates/shadowsocks/src/security/replay/ppbloom.rs +++ b/shadowsocks-rust/crates/shadowsocks/src/security/replay/ppbloom.rs @@ -36,7 +36,7 @@ pub struct PingPongBloom { } impl PingPongBloom { - pub fn new(ty: ServerType) -> PingPongBloom { + pub fn new(ty: ServerType) -> Self { let (mut item_count, fp_p) = if ty.is_local() { (BF_NUM_ENTRIES_FOR_CLIENT, BF_ERROR_RATE_FOR_CLIENT) } else { @@ -45,7 +45,7 @@ impl PingPongBloom { item_count /= 2; - PingPongBloom { + Self { blooms: [ Bloom::new_for_fp_rate(item_count, fp_p).expect("BloomFilter1"), Bloom::new_for_fp_rate(item_count, fp_p).expect("BloomFilter2"), diff --git a/shadowsocks-rust/src/config.rs b/shadowsocks-rust/src/config.rs index 002ab65afa..1fef165510 100644 --- a/shadowsocks-rust/src/config.rs +++ b/shadowsocks-rust/src/config.rs @@ -108,24 +108,24 @@ pub struct Config { impl Config { /// Load `Config` from file - pub fn load_from_file>(filename: &P) -> Result { + pub fn load_from_file>(filename: &P) -> Result { let filename = filename.as_ref(); let mut reader = OpenOptions::new().read(true).open(filename)?; let mut content = String::new(); reader.read_to_string(&mut content)?; - Config::load_from_str(&content) + Self::load_from_str(&content) } /// Load `Config` from string - pub fn load_from_str(s: &str) -> Result { + pub fn load_from_str(s: &str) -> Result { let ssconfig = json5::from_str(s)?; - Config::load_from_ssconfig(ssconfig) + Self::load_from_ssconfig(ssconfig) } - fn load_from_ssconfig(ssconfig: SSConfig) -> Result { - let mut config = Config::default(); + fn load_from_ssconfig(ssconfig: SSConfig) -> Result { + let mut config = Self::default(); #[cfg(feature = "logging")] if let Some(log) = ssconfig.log { @@ -240,11 +240,11 @@ pub struct RuntimeModeError; impl FromStr for RuntimeMode { type Err = RuntimeModeError; - fn from_str(s: &str) -> Result { + fn from_str(s: &str) -> Result { match s { - "single_thread" => Ok(RuntimeMode::SingleThread), + "single_thread" => Ok(Self::SingleThread), #[cfg(feature = "multi-threaded")] - "multi_thread" => Ok(RuntimeMode::MultiThread), + "multi_thread" => Ok(Self::MultiThread), _ => Err(RuntimeModeError), } } diff --git a/shadowsocks-rust/src/service/local.rs b/shadowsocks-rust/src/service/local.rs index dc477186e1..cf01f37a3a 100644 --- a/shadowsocks-rust/src/service/local.rs +++ b/shadowsocks-rust/src/service/local.rs @@ -59,19 +59,19 @@ mod local_value_parser { impl FromStr for RemoteDnsAddress { type Err = AddressError; - fn from_str(a: &str) -> Result { + fn from_str(a: &str) -> Result { if let Ok(ip) = a.parse::() { - return Ok(RemoteDnsAddress(Address::SocketAddress(SocketAddr::new(ip, 53)))); + return Ok(Self(Address::SocketAddress(SocketAddr::new(ip, 53)))); } if let Ok(saddr) = a.parse::() { - return Ok(RemoteDnsAddress(Address::SocketAddress(saddr))); + return Ok(Self(Address::SocketAddress(saddr))); } if a.find(':').is_some() { a.parse::
().map(RemoteDnsAddress) } else { - Ok(RemoteDnsAddress(Address::DomainNameAddress(a.to_owned(), 53))) + Ok(Self(Address::DomainNameAddress(a.to_owned(), 53))) } } } diff --git a/shadowsocks-rust/tests/socks4.rs b/shadowsocks-rust/tests/socks4.rs index 9679982996..ffccffa6ac 100644 --- a/shadowsocks-rust/tests/socks4.rs +++ b/shadowsocks-rust/tests/socks4.rs @@ -27,7 +27,7 @@ pub struct Socks4TestServer { } impl Socks4TestServer { - pub fn new(svr_addr: S, local_addr: L, pwd: &str, method: CipherKind) -> Socks4TestServer + pub fn new(svr_addr: S, local_addr: L, pwd: &str, method: CipherKind) -> Self where S: ToSocketAddrs, L: ToSocketAddrs, @@ -35,7 +35,7 @@ impl Socks4TestServer { let svr_addr = svr_addr.to_socket_addrs().unwrap().next().unwrap(); let local_addr = local_addr.to_socket_addrs().unwrap().next().unwrap(); - Socks4TestServer { + Self { local_addr, svr_config: { let mut cfg = Config::new(ConfigType::Server); diff --git a/shadowsocks-rust/tests/socks5.rs b/shadowsocks-rust/tests/socks5.rs index 0075c0d043..ac62a73d69 100644 --- a/shadowsocks-rust/tests/socks5.rs +++ b/shadowsocks-rust/tests/socks5.rs @@ -28,7 +28,7 @@ pub struct Socks5TestServer { } impl Socks5TestServer { - pub fn new(svr_addr: S, local_addr: L, pwd: &str, method: CipherKind, enable_udp: bool) -> Socks5TestServer + pub fn new(svr_addr: S, local_addr: L, pwd: &str, method: CipherKind, enable_udp: bool) -> Self where S: ToSocketAddrs, L: ToSocketAddrs, @@ -36,7 +36,7 @@ impl Socks5TestServer { let svr_addr = svr_addr.to_socket_addrs().unwrap().next().unwrap(); let local_addr = local_addr.to_socket_addrs().unwrap().next().unwrap(); - Socks5TestServer { + Self { local_addr, svr_config: { let mut cfg = Config::new(ConfigType::Server); diff --git a/small/mihomo/Makefile b/small/mihomo/Makefile index 0dd5fb4288..80ea57c95d 100644 --- a/small/mihomo/Makefile +++ b/small/mihomo/Makefile @@ -5,12 +5,12 @@ include $(TOPDIR)/rules.mk PKG_NAME:=mihomo -PKG_VERSION:=1.19.9 +PKG_VERSION:=1.19.10 PKG_RELEASE:=1 PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz PKG_SOURCE_URL:=https://codeload.github.com/metacubex/mihomo/tar.gz/v$(PKG_VERSION)? -PKG_HASH:=900ddee847f4dc35f2298ca3fea451a9bbb582557ce390198d73a29f4586813f +PKG_HASH:=a0ca7bb23fcfa067e8a58a9618879a507881dbca321a8eb0550948b1d26296c0 PKG_MAINTAINER:=Anya Lin PKG_LICENSE:=GPL-2.0 diff --git a/v2rayng/V2rayNG/app/src/main/java/com/v2ray/ang/handler/SettingsManager.kt b/v2rayng/V2rayNG/app/src/main/java/com/v2ray/ang/handler/SettingsManager.kt index c528aeb272..a488e59326 100644 --- a/v2rayng/V2rayNG/app/src/main/java/com/v2ray/ang/handler/SettingsManager.kt +++ b/v2rayng/V2rayNG/app/src/main/java/com/v2ray/ang/handler/SettingsManager.kt @@ -159,7 +159,7 @@ object SettingsManager { * @return True if bypassing LAN, false otherwise. */ fun routingRulesetsBypassLan(): Boolean { - val vpnBypassLan = MmkvManager.decodeSettingsString(AppConfig.PREF_VPN_BYPASS_LAN) ?: "0" + val vpnBypassLan = MmkvManager.decodeSettingsString(AppConfig.PREF_VPN_BYPASS_LAN) ?: "1" if (vpnBypassLan == "1") { return true } else if (vpnBypassLan == "2") { diff --git a/v2rayng/V2rayNG/app/src/main/res/xml/pref_settings.xml b/v2rayng/V2rayNG/app/src/main/res/xml/pref_settings.xml index 75cad84855..cbfbb93233 100644 --- a/v2rayng/V2rayNG/app/src/main/res/xml/pref_settings.xml +++ b/v2rayng/V2rayNG/app/src/main/res/xml/pref_settings.xml @@ -56,7 +56,7 @@ android:title="@string/title_pref_vpn_dns" /> 0 { + ss.path = req.path[0] + } + if req.headers.host.count>0 { + ss.host = req.headers.host[0] + } + } + } + } else if self.v2ray.streamNetwork == "kcp" { + ss.headerType = self.v2ray.streamKcp.header.type + ss.netPath = self.v2ray.streamKcp.seed + } else if self.v2ray.streamNetwork == "quic" { + ss.headerType = self.v2ray.streamQuic.header.type + ss.netPath = self.v2ray.streamQuic.key + } else if self.v2ray.streamNetwork == "domainsocket" { + ss.netPath = self.v2ray.streamDs.path + } else if self.v2ray.streamNetwork == "h2" { + if self.v2ray.streamH2.host.count > 0 { + ss.netHost = self.v2ray.streamH2.host[0] + } + ss.netPath = self.v2ray.streamH2.path + } else if self.v2ray.streamNetwork == "ws" { + ss.netHost = self.v2ray.streamWs.headers.host + ss.netPath = self.v2ray.streamWs.path + } else if self.v2ray.streamNetwork == "grpc" { + ss.netPath = self.v2ray.streamGrpc.serviceName + } ss.fp = self.v2ray.securityTls.fingerprint ss.flow = self.v2ray.serverTrojan.flow ss.sni = self.v2ray.securityTls.serverName diff --git a/v2rayu/V2rayU/Uri.swift b/v2rayu/V2rayU/Uri.swift index 963345486e..b1e8f272a7 100644 --- a/v2rayu/V2rayU/Uri.swift +++ b/v2rayu/V2rayU/Uri.swift @@ -152,8 +152,64 @@ class VmessUri { break case "mode": self.grpcMode = param[1] + break case "seed": self.kcpSeed = param[1] + break + // 以下是 shadowrocket 的分享参数: + // remarks=vmess_ws&obfsParam=ws.host.domain&path=/vmwss&obfs=websocket&tls=1&peer=ws.sni.domain&alterId=64 + case "obfs": + // 这里是 ws 的 + if param[1] == "websocket" || param[1] == "ws" { + self.network = "ws" + } else if param[1] == "h2" { + self.network = "h2" + } else if param[1] == "http" { + self.network = "tcp" // + self.type = "http" // headerType + } else if param[1] == "grpc" { + self.network = "grpc" + } else if param[1] == "domainsocket" { + self.network = "domainsocket" + } else if param[1] == "quic" { + self.network = "quic" + } else if param[1] == "kcp" || param[1] == "mkcp" { + self.network = "kcp" + } else { + self.network = "tcp" + self.type = param[1] + } + break + case "alterId": + // 这里是 alterId + self.alterId = Int(param[1]) ?? 0 + break + case "obfsParam": + // 这里是 ws,h2 的 host + self.netHost = param[1] + // params的obfs=mkcp情况下, 获取 kcp seed: obfsParam=%7B%22seed%22:%22111%22,%22Host%22:%22xxx.xx%22%7D + if paramsStr.contains("obfs=mkcp") || paramsStr.contains("obfs=kcp") || paramsStr.contains("obfs=grpc") { + // 先 urldecode, 解析 kcp seed: {"seed":"111","Host":""} + if let decodedParam = param[1].removingPercentEncoding, let data = decodedParam.data(using: .utf8) { + if let json = try? JSON(data: data) { + self.kcpSeed = json["seed"].stringValue + self.netHost = json["Host"].stringValue + } + } + } + break + case "path": + // 这里是 ws,h2 的 path, tcp 的 header path + self.netPath = param[1] + break + case "remarks": + // 这里是备注 + self.remark = param[1].urlDecoded() + break + case "peer": + // 这里是 sni + self.sni = param[1] + break default: break } @@ -436,7 +492,7 @@ class TrojanUri { func encode() -> String { var uri = URLComponents() uri.scheme = "trojan" - uri.password = self.password + uri.user = self.password // 因没有 user,所以这里用 password, 不然会多一个 : uri.host = self.host uri.port = self.port uri.queryItems = [ @@ -462,10 +518,15 @@ class TrojanUri { self.error = "error:missing port" return } - guard let password = url.user else { + guard var password = url.user else { self.error = "error:missing password" return } + // shadowrocket trojan url: trojan://%3Apassword@host:port?query#remark + if url.absoluteString.contains("trojan://%3A") { + // 去掉前面的 %3A,即: + password = password.replacingOccurrences(of: "%3A", with: "").replacingOccurrences(of: ":", with: "") + } self.host = host self.port = Int(port) self.password = password @@ -499,6 +560,69 @@ class TrojanUri { case "headerType": self.headerType = item.value as! String break + // 以下是 shadowrocket 的分享参数: + // peer=sni.xx.xx&obfs=grpc&obfsParam=hjfjkdkdi&path=tekdjjd#yanue-trojan1 + // ?peer=sni.xx.xx&plugin=obfs-local;obfs=websocket;obfs-host=%7B%22Host%22:%22hjfjkdkdi%22%7D;obfs-uri=tekdjjd#trojan3 + case "plugin": + // 这里是 obfs-local 的参数: obfs-local;obfs=websocket;obfs-host={"Host":"hjfjkdkdi"};obfs-uri=tekdjjd + let value = item.value as! String + print("trojan plugin:", value) + // 按 ; 分割 + let plugins = value.components(separatedBy: ";") + for plugin in plugins { + let pluginParts = plugin.components(separatedBy: "=") + if pluginParts.count < 2 { + continue + } + switch pluginParts[0] { + case "obfs": + // 这里是 ws 的 + if pluginParts[1] == "websocket" || pluginParts[1] == "ws" { + self.network = "ws" + } else if pluginParts[1] == "h2" { + self.network = "h2" + } else if pluginParts[1] == "grpc" { + self.network = "grpc" + } else { + self.network = "tcp" + } + case "obfs-host": + // 这里是 ws,h2 的 host: {"Host":"hjfjkdkdi"} + if let hostValue = pluginParts[1].removingPercentEncoding,let data = hostValue.data(using: .utf8) { + if let json = try? JSON(data: data) { + self.netHost = json["Host"].stringValue + } + } + case "obfs-uri": + // 这里是 ws,h2 的 path + self.netPath = pluginParts[1] + default: + break + } + } + break + case "obfs": + let value = item.value as! String + print("trojan obfs:", value) + // 这里是 ws 的 + if value == "websocket" || value == "ws" { + self.network = "ws" + } else if value == "h2" { + self.network = "h2" + } else if value == "grpc" { + self.network = "grpc" + } else { + self.network = "tcp" + } + break + case "obfsParam": + // 这里是 ws,h2 的 host + self.netHost = item.value as! String + break + case "peer": + // 这里是 sni + self.sni = item.value as! String + break default: break } diff --git a/v2rayu/V2rayU/V2rayLaunch.swift b/v2rayu/V2rayU/V2rayLaunch.swift index 811b462f82..bcf403cab5 100644 --- a/v2rayu/V2rayU/V2rayLaunch.swift +++ b/v2rayu/V2rayU/V2rayLaunch.swift @@ -444,4 +444,44 @@ class V2rayLaunch: NSObject { NSLog("save json file fail: \(error)") } } + + // clear v2ray-core.log file + static func clearLogFile() { + let logFile = URL(fileURLWithPath: logFilePath) + do { + if FileManager.default.fileExists(atPath: logFilePath) { + try FileManager.default.removeItem(at: logFile) + } + // create new file + FileManager.default.createFile(atPath: logFilePath, contents: nil, attributes: nil) + } catch let error { + NSLog("clear log file fail: \(error)") + var title = "Clear log file failed" + var toast = "Error: \(error)" + if isMainland { + title = "清除日志文件失败" + toast = "错误: \(error)" + } + alertDialog(title: title, message: toast) + } + } + + static func truncateLogFile() { + let logFile = URL(fileURLWithPath: logFilePath) + do { + if FileManager.default.fileExists(atPath: logFilePath) { + // truncate log file, write empty string + try "".write(to: logFile, atomically: true, encoding: String.Encoding.utf8) + } + } catch let error { + NSLog("truncate log file fail: \(error)") + var title = "Truncate log file failed" + var toast = "Error: \(error)" + if isMainland { + title = "清除日志文件失败" + toast = "错误: \(error)" + } + alertDialog(title: title, message: toast) + } + } } diff --git a/xray-core/README.md b/xray-core/README.md index 26bd3fa1bd..622205533b 100644 --- a/xray-core/README.md +++ b/xray-core/README.md @@ -44,7 +44,7 @@ - [Hiddify](https://github.com/hiddify/Hiddify-Manager) - One Click - [Xray-REALITY](https://github.com/zxcvos/Xray-script), [xray-reality](https://github.com/sajjaddg/xray-reality), [reality-ezpz](https://github.com/aleskxyz/reality-ezpz) - - [Xray_bash_onekey](https://github.com/hello-yunshu/Xray_bash_onekey), [XTool](https://github.com/LordPenguin666/XTool) + - [Xray_bash_onekey](https://github.com/hello-yunshu/Xray_bash_onekey), [XTool](https://github.com/LordPenguin666/XTool), [VPainLess](https://github.com/vpainless/vpainless) - [v2ray-agent](https://github.com/mack-a/v2ray-agent), [Xray_onekey](https://github.com/wulabing/Xray_onekey), [ProxySU](https://github.com/proxysu/ProxySU) - Magisk - [Xray4Magisk](https://github.com/Asterisk4Magisk/Xray4Magisk) @@ -85,6 +85,7 @@ - [v2rayNG](https://github.com/2dust/v2rayNG) - [X-flutter](https://github.com/XTLS/X-flutter) - [SaeedDev94/Xray](https://github.com/SaeedDev94/Xray) + - [SimpleXray](https://github.com/lhear/SimpleXray) - iOS & macOS arm64 - [Happ](https://apps.apple.com/app/happ-proxy-utility/id6504287215) - [Streisand](https://apps.apple.com/app/streisand/id6450534064) diff --git a/xray-core/core/core.go b/xray-core/core/core.go index 03d0019123..15405bb812 100644 --- a/xray-core/core/core.go +++ b/xray-core/core/core.go @@ -18,8 +18,8 @@ import ( var ( Version_x byte = 25 - Version_y byte = 5 - Version_z byte = 16 + Version_y byte = 6 + Version_z byte = 7 ) var ( diff --git a/xray-core/go.mod b/xray-core/go.mod index f570b84da6..d10a5a54fb 100644 --- a/xray-core/go.mod +++ b/xray-core/go.mod @@ -20,7 +20,7 @@ require ( github.com/stretchr/testify v1.10.0 github.com/v2fly/ss-bloomring v0.0.0-20210312155135-28617310f63e github.com/vishvananda/netlink v1.3.1 - github.com/xtls/reality v0.0.0-20250527000105-e679ef7bb130 + github.com/xtls/reality v0.0.0-20250607105625-90e738a94c8c go4.org/netipx v0.0.0-20231129151722-fdeea329fbba golang.org/x/crypto v0.39.0 golang.org/x/net v0.41.0 diff --git a/xray-core/go.sum b/xray-core/go.sum index 50f1c1e7e7..28bf3ad97f 100644 --- a/xray-core/go.sum +++ b/xray-core/go.sum @@ -76,8 +76,8 @@ github.com/vishvananda/netlink v1.3.1 h1:3AEMt62VKqz90r0tmNhog0r/PpWKmrEShJU0wJW github.com/vishvananda/netlink v1.3.1/go.mod h1:ARtKouGSTGchR8aMwmkzC0qiNPrrWO5JS/XMVl45+b4= github.com/vishvananda/netns v0.0.5 h1:DfiHV+j8bA32MFM7bfEunvT8IAqQ/NzSJHtcmW5zdEY= github.com/vishvananda/netns v0.0.5/go.mod h1:SpkAiCQRtJ6TvvxPnOSyH3BMl6unz3xZlaprSwhNNJM= -github.com/xtls/reality v0.0.0-20250527000105-e679ef7bb130 h1:v/TVypWnLferyoaNHh6a8oyggj9APBUzfl1OOgXNbpw= -github.com/xtls/reality v0.0.0-20250527000105-e679ef7bb130/go.mod h1:bJdU3ExzfUlY40Xxfibq3THW9IHiE8mHu/tEzud5JWM= +github.com/xtls/reality v0.0.0-20250607105625-90e738a94c8c h1:GiY3/SynO0ujSH3rQDEIrE4MTTZM9KHufR3zx3JLD3c= +github.com/xtls/reality v0.0.0-20250607105625-90e738a94c8c/go.mod h1:Rkdcxe9Yd8SWQRRP+LSvX6wxk1m4lmNkyUZEHzbPDZw= github.com/yuin/goldmark v1.4.1/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k= go.opentelemetry.io/auto/sdk v1.1.0 h1:cH53jehLUN6UFLY71z+NDOiNJqDdPRaXzTel0sJySYA= go.opentelemetry.io/auto/sdk v1.1.0/go.mod h1:3wSPjt5PWp2RhlCcmmOial7AvC4DQqZb7a7wCow3W8A= diff --git a/xray-core/infra/conf/transport_internet.go b/xray-core/infra/conf/transport_internet.go index b4ae080108..1a4175d807 100644 --- a/xray-core/infra/conf/transport_internet.go +++ b/xray-core/infra/conf/transport_internet.go @@ -699,25 +699,50 @@ type CustomSockoptConfig struct { Type string `json:"type"` } +type HappyEyeballsConfig struct { + PrioritizeIPv6 bool `json:"prioritizeIPv6"` + TryDelayMs uint64 `json:"tryDelayMs"` + Interleave uint32 `json:"interleave"` + MaxConcurrentTry uint32 `json:"maxConcurrentTry"` +} + +func (h *HappyEyeballsConfig) UnmarshalJSON(data []byte) error { + var innerHappyEyeballsConfig = struct { + PrioritizeIPv6 bool `json:"prioritizeIPv6"` + TryDelayMs uint64 `json:"tryDelayMs"` + Interleave uint32 `json:"interleave"` + MaxConcurrentTry uint32 `json:"maxConcurrentTry"` + }{PrioritizeIPv6: false, Interleave: 1, TryDelayMs: 0, MaxConcurrentTry: 4} + if err := json.Unmarshal(data, &innerHappyEyeballsConfig); err != nil { + return err + } + h.PrioritizeIPv6 = innerHappyEyeballsConfig.PrioritizeIPv6 + h.TryDelayMs = innerHappyEyeballsConfig.TryDelayMs + h.Interleave = innerHappyEyeballsConfig.Interleave + h.MaxConcurrentTry = innerHappyEyeballsConfig.MaxConcurrentTry + return nil +} + type SocketConfig struct { - Mark int32 `json:"mark"` - TFO interface{} `json:"tcpFastOpen"` - TProxy string `json:"tproxy"` - AcceptProxyProtocol bool `json:"acceptProxyProtocol"` - DomainStrategy string `json:"domainStrategy"` - DialerProxy string `json:"dialerProxy"` - TCPKeepAliveInterval int32 `json:"tcpKeepAliveInterval"` - TCPKeepAliveIdle int32 `json:"tcpKeepAliveIdle"` - TCPCongestion string `json:"tcpCongestion"` - TCPWindowClamp int32 `json:"tcpWindowClamp"` - TCPMaxSeg int32 `json:"tcpMaxSeg"` - Penetrate bool `json:"penetrate"` - TCPUserTimeout int32 `json:"tcpUserTimeout"` - V6only bool `json:"v6only"` - Interface string `json:"interface"` - TcpMptcp bool `json:"tcpMptcp"` - CustomSockopt []*CustomSockoptConfig `json:"customSockopt"` - AddressPortStrategy string `json:"addressPortStrategy"` + Mark int32 `json:"mark"` + TFO interface{} `json:"tcpFastOpen"` + TProxy string `json:"tproxy"` + AcceptProxyProtocol bool `json:"acceptProxyProtocol"` + DomainStrategy string `json:"domainStrategy"` + DialerProxy string `json:"dialerProxy"` + TCPKeepAliveInterval int32 `json:"tcpKeepAliveInterval"` + TCPKeepAliveIdle int32 `json:"tcpKeepAliveIdle"` + TCPCongestion string `json:"tcpCongestion"` + TCPWindowClamp int32 `json:"tcpWindowClamp"` + TCPMaxSeg int32 `json:"tcpMaxSeg"` + Penetrate bool `json:"penetrate"` + TCPUserTimeout int32 `json:"tcpUserTimeout"` + V6only bool `json:"v6only"` + Interface string `json:"interface"` + TcpMptcp bool `json:"tcpMptcp"` + CustomSockopt []*CustomSockoptConfig `json:"customSockopt"` + AddressPortStrategy string `json:"addressPortStrategy"` + HappyEyeballsSettings *HappyEyeballsConfig `json:"happyEyeballs"` } // Build implements Buildable. @@ -809,6 +834,14 @@ func (c *SocketConfig) Build() (*internet.SocketConfig, error) { return nil, errors.New("unsupported address and port strategy: ", c.AddressPortStrategy) } + var happyEyeballs = &internet.HappyEyeballsConfig{Interleave: 1, PrioritizeIpv6: false, TryDelayMs: 0, MaxConcurrentTry: 4} + if c.HappyEyeballsSettings != nil { + happyEyeballs.PrioritizeIpv6 = c.HappyEyeballsSettings.PrioritizeIPv6 + happyEyeballs.Interleave = c.HappyEyeballsSettings.Interleave + happyEyeballs.TryDelayMs = c.HappyEyeballsSettings.TryDelayMs + happyEyeballs.MaxConcurrentTry = c.HappyEyeballsSettings.MaxConcurrentTry + } + return &internet.SocketConfig{ Mark: c.Mark, Tfo: tfo, @@ -828,6 +861,7 @@ func (c *SocketConfig) Build() (*internet.SocketConfig, error) { TcpMptcp: c.TcpMptcp, CustomSockopt: customSockopts, AddressPortStrategy: addressPortStrategy, + HappyEyeballs: happyEyeballs, }, nil } diff --git a/xray-core/infra/conf/transport_test.go b/xray-core/infra/conf/transport_test.go index e747008298..87e5f92091 100644 --- a/xray-core/infra/conf/transport_test.go +++ b/xray-core/infra/conf/transport_test.go @@ -26,6 +26,7 @@ func TestSocketConfig(t *testing.T) { Tfo: 256, DomainStrategy: internet.DomainStrategy_USE_IP, DialerProxy: "tag", + HappyEyeballs: &internet.HappyEyeballsConfig{Interleave: 1, TryDelayMs: 0, PrioritizeIpv6: false, MaxConcurrentTry: 4}, } runMultiTestCase(t, []TestCase{ { @@ -45,8 +46,9 @@ func TestSocketConfig(t *testing.T) { // test "tcpFastOpen": false, disabled TFO is expected expectedOutput = &internet.SocketConfig{ - Mark: 0, - Tfo: -1, + Mark: 0, + Tfo: -1, + HappyEyeballs: &internet.HappyEyeballsConfig{Interleave: 1, TryDelayMs: 0, PrioritizeIpv6: false, MaxConcurrentTry: 4}, } runMultiTestCase(t, []TestCase{ { @@ -63,8 +65,9 @@ func TestSocketConfig(t *testing.T) { // test "tcpFastOpen": 65535, queue length 65535 is expected expectedOutput = &internet.SocketConfig{ - Mark: 0, - Tfo: 65535, + Mark: 0, + Tfo: 65535, + HappyEyeballs: &internet.HappyEyeballsConfig{Interleave: 1, TryDelayMs: 0, PrioritizeIpv6: false, MaxConcurrentTry: 4}, } runMultiTestCase(t, []TestCase{ { @@ -81,8 +84,9 @@ func TestSocketConfig(t *testing.T) { // test "tcpFastOpen": -65535, disable TFO is expected expectedOutput = &internet.SocketConfig{ - Mark: 0, - Tfo: -65535, + Mark: 0, + Tfo: -65535, + HappyEyeballs: &internet.HappyEyeballsConfig{Interleave: 1, TryDelayMs: 0, PrioritizeIpv6: false, MaxConcurrentTry: 4}, } runMultiTestCase(t, []TestCase{ { @@ -99,8 +103,9 @@ func TestSocketConfig(t *testing.T) { // test "tcpFastOpen": 0, no operation is expected expectedOutput = &internet.SocketConfig{ - Mark: 0, - Tfo: 0, + Mark: 0, + Tfo: 0, + HappyEyeballs: &internet.HappyEyeballsConfig{Interleave: 1, TryDelayMs: 0, PrioritizeIpv6: false, MaxConcurrentTry: 4}, } runMultiTestCase(t, []TestCase{ { @@ -117,8 +122,9 @@ func TestSocketConfig(t *testing.T) { // test omit "tcpFastOpen", no operation is expected expectedOutput = &internet.SocketConfig{ - Mark: 0, - Tfo: 0, + Mark: 0, + Tfo: 0, + HappyEyeballs: &internet.HappyEyeballsConfig{Interleave: 1, TryDelayMs: 0, PrioritizeIpv6: false, MaxConcurrentTry: 4}, } runMultiTestCase(t, []TestCase{ { @@ -133,8 +139,9 @@ func TestSocketConfig(t *testing.T) { // test "tcpFastOpen": null, no operation is expected expectedOutput = &internet.SocketConfig{ - Mark: 0, - Tfo: 0, + Mark: 0, + Tfo: 0, + HappyEyeballs: &internet.HappyEyeballsConfig{Interleave: 1, TryDelayMs: 0, PrioritizeIpv6: false, MaxConcurrentTry: 4}, } runMultiTestCase(t, []TestCase{ { diff --git a/xray-core/infra/conf/xray.go b/xray-core/infra/conf/xray.go index 42b8fa4d9f..f1d9fb0803 100644 --- a/xray-core/infra/conf/xray.go +++ b/xray-core/infra/conf/xray.go @@ -69,10 +69,8 @@ func (c *SniffingConfig) Build() (*proxyman.SniffingConfig, error) { p = append(p, "tls") case "quic": p = append(p, "quic") - case "fakedns": + case "fakedns", "fakedns+others": p = append(p, "fakedns") - case "fakedns+others": - p = append(p, "fakedns+others") default: return nil, errors.New("unknown protocol: ", protocol) } diff --git a/xray-core/testing/scenarios/command_test.go b/xray-core/testing/scenarios/command_test.go index e562952b13..c7914752b3 100644 --- a/xray-core/testing/scenarios/command_test.go +++ b/xray-core/testing/scenarios/command_test.go @@ -286,8 +286,8 @@ func TestCommanderListHandlers(t *testing.T) { t.Error("unexpected nil response") } - if !cmp.Equal(inboundResp.Inbounds, clientConfig.Inbound, protocmp.Transform()) { - t.Fatal("inbound response doesn't match config") + if diff := cmp.Diff(inboundResp.Inbounds, clientConfig.Inbound, protocmp.Transform()); diff != "" { + t.Fatalf("inbound response doesn't match config (-want +got):\n%s", diff) } outboundResp, err := hsClient.ListOutbounds(context.Background(), &command.ListOutboundsRequest{}) @@ -296,8 +296,8 @@ func TestCommanderListHandlers(t *testing.T) { t.Error("unexpected nil response") } - if !cmp.Equal(outboundResp.Outbounds, clientConfig.Outbound, protocmp.Transform()) { - t.Fatal("outbound response doesn't match config") + if diff := cmp.Diff(outboundResp.Outbounds, clientConfig.Outbound, protocmp.Transform()); diff != "" { + t.Fatalf("outbound response doesn't match config (-want +got):\n%s", diff) } } diff --git a/xray-core/transport/internet/config.pb.go b/xray-core/transport/internet/config.pb.go index 6aa11b3e91..f974926ef6 100644 --- a/xray-core/transport/internet/config.pb.go +++ b/xray-core/transport/internet/config.pb.go @@ -511,24 +511,25 @@ type SocketConfig struct { Tproxy SocketConfig_TProxyMode `protobuf:"varint,3,opt,name=tproxy,proto3,enum=xray.transport.internet.SocketConfig_TProxyMode" json:"tproxy,omitempty"` // ReceiveOriginalDestAddress is for enabling IP_RECVORIGDSTADDR socket // option. This option is for UDP only. - ReceiveOriginalDestAddress bool `protobuf:"varint,4,opt,name=receive_original_dest_address,json=receiveOriginalDestAddress,proto3" json:"receive_original_dest_address,omitempty"` - BindAddress []byte `protobuf:"bytes,5,opt,name=bind_address,json=bindAddress,proto3" json:"bind_address,omitempty"` - BindPort uint32 `protobuf:"varint,6,opt,name=bind_port,json=bindPort,proto3" json:"bind_port,omitempty"` - AcceptProxyProtocol bool `protobuf:"varint,7,opt,name=accept_proxy_protocol,json=acceptProxyProtocol,proto3" json:"accept_proxy_protocol,omitempty"` - DomainStrategy DomainStrategy `protobuf:"varint,8,opt,name=domain_strategy,json=domainStrategy,proto3,enum=xray.transport.internet.DomainStrategy" json:"domain_strategy,omitempty"` - DialerProxy string `protobuf:"bytes,9,opt,name=dialer_proxy,json=dialerProxy,proto3" json:"dialer_proxy,omitempty"` - TcpKeepAliveInterval int32 `protobuf:"varint,10,opt,name=tcp_keep_alive_interval,json=tcpKeepAliveInterval,proto3" json:"tcp_keep_alive_interval,omitempty"` - TcpKeepAliveIdle int32 `protobuf:"varint,11,opt,name=tcp_keep_alive_idle,json=tcpKeepAliveIdle,proto3" json:"tcp_keep_alive_idle,omitempty"` - TcpCongestion string `protobuf:"bytes,12,opt,name=tcp_congestion,json=tcpCongestion,proto3" json:"tcp_congestion,omitempty"` - Interface string `protobuf:"bytes,13,opt,name=interface,proto3" json:"interface,omitempty"` - V6Only bool `protobuf:"varint,14,opt,name=v6only,proto3" json:"v6only,omitempty"` - TcpWindowClamp int32 `protobuf:"varint,15,opt,name=tcp_window_clamp,json=tcpWindowClamp,proto3" json:"tcp_window_clamp,omitempty"` - TcpUserTimeout int32 `protobuf:"varint,16,opt,name=tcp_user_timeout,json=tcpUserTimeout,proto3" json:"tcp_user_timeout,omitempty"` - TcpMaxSeg int32 `protobuf:"varint,17,opt,name=tcp_max_seg,json=tcpMaxSeg,proto3" json:"tcp_max_seg,omitempty"` - Penetrate bool `protobuf:"varint,18,opt,name=penetrate,proto3" json:"penetrate,omitempty"` - TcpMptcp bool `protobuf:"varint,19,opt,name=tcp_mptcp,json=tcpMptcp,proto3" json:"tcp_mptcp,omitempty"` - CustomSockopt []*CustomSockopt `protobuf:"bytes,20,rep,name=customSockopt,proto3" json:"customSockopt,omitempty"` - AddressPortStrategy AddressPortStrategy `protobuf:"varint,21,opt,name=address_port_strategy,json=addressPortStrategy,proto3,enum=xray.transport.internet.AddressPortStrategy" json:"address_port_strategy,omitempty"` + ReceiveOriginalDestAddress bool `protobuf:"varint,4,opt,name=receive_original_dest_address,json=receiveOriginalDestAddress,proto3" json:"receive_original_dest_address,omitempty"` + BindAddress []byte `protobuf:"bytes,5,opt,name=bind_address,json=bindAddress,proto3" json:"bind_address,omitempty"` + BindPort uint32 `protobuf:"varint,6,opt,name=bind_port,json=bindPort,proto3" json:"bind_port,omitempty"` + AcceptProxyProtocol bool `protobuf:"varint,7,opt,name=accept_proxy_protocol,json=acceptProxyProtocol,proto3" json:"accept_proxy_protocol,omitempty"` + DomainStrategy DomainStrategy `protobuf:"varint,8,opt,name=domain_strategy,json=domainStrategy,proto3,enum=xray.transport.internet.DomainStrategy" json:"domain_strategy,omitempty"` + DialerProxy string `protobuf:"bytes,9,opt,name=dialer_proxy,json=dialerProxy,proto3" json:"dialer_proxy,omitempty"` + TcpKeepAliveInterval int32 `protobuf:"varint,10,opt,name=tcp_keep_alive_interval,json=tcpKeepAliveInterval,proto3" json:"tcp_keep_alive_interval,omitempty"` + TcpKeepAliveIdle int32 `protobuf:"varint,11,opt,name=tcp_keep_alive_idle,json=tcpKeepAliveIdle,proto3" json:"tcp_keep_alive_idle,omitempty"` + TcpCongestion string `protobuf:"bytes,12,opt,name=tcp_congestion,json=tcpCongestion,proto3" json:"tcp_congestion,omitempty"` + Interface string `protobuf:"bytes,13,opt,name=interface,proto3" json:"interface,omitempty"` + V6Only bool `protobuf:"varint,14,opt,name=v6only,proto3" json:"v6only,omitempty"` + TcpWindowClamp int32 `protobuf:"varint,15,opt,name=tcp_window_clamp,json=tcpWindowClamp,proto3" json:"tcp_window_clamp,omitempty"` + TcpUserTimeout int32 `protobuf:"varint,16,opt,name=tcp_user_timeout,json=tcpUserTimeout,proto3" json:"tcp_user_timeout,omitempty"` + TcpMaxSeg int32 `protobuf:"varint,17,opt,name=tcp_max_seg,json=tcpMaxSeg,proto3" json:"tcp_max_seg,omitempty"` + Penetrate bool `protobuf:"varint,18,opt,name=penetrate,proto3" json:"penetrate,omitempty"` + TcpMptcp bool `protobuf:"varint,19,opt,name=tcp_mptcp,json=tcpMptcp,proto3" json:"tcp_mptcp,omitempty"` + CustomSockopt []*CustomSockopt `protobuf:"bytes,20,rep,name=customSockopt,proto3" json:"customSockopt,omitempty"` + AddressPortStrategy AddressPortStrategy `protobuf:"varint,21,opt,name=address_port_strategy,json=addressPortStrategy,proto3,enum=xray.transport.internet.AddressPortStrategy" json:"address_port_strategy,omitempty"` + HappyEyeballs *HappyEyeballsConfig `protobuf:"bytes,22,opt,name=happy_eyeballs,json=happyEyeballs,proto3" json:"happy_eyeballs,omitempty"` } func (x *SocketConfig) Reset() { @@ -708,6 +709,82 @@ func (x *SocketConfig) GetAddressPortStrategy() AddressPortStrategy { return AddressPortStrategy_None } +func (x *SocketConfig) GetHappyEyeballs() *HappyEyeballsConfig { + if x != nil { + return x.HappyEyeballs + } + return nil +} + +type HappyEyeballsConfig struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + PrioritizeIpv6 bool `protobuf:"varint,1,opt,name=prioritize_ipv6,json=prioritizeIpv6,proto3" json:"prioritize_ipv6,omitempty"` + Interleave uint32 `protobuf:"varint,2,opt,name=interleave,proto3" json:"interleave,omitempty"` + TryDelayMs uint64 `protobuf:"varint,3,opt,name=try_delayMs,json=tryDelayMs,proto3" json:"try_delayMs,omitempty"` + MaxConcurrentTry uint32 `protobuf:"varint,4,opt,name=max_concurrent_try,json=maxConcurrentTry,proto3" json:"max_concurrent_try,omitempty"` +} + +func (x *HappyEyeballsConfig) Reset() { + *x = HappyEyeballsConfig{} + mi := &file_transport_internet_config_proto_msgTypes[5] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *HappyEyeballsConfig) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*HappyEyeballsConfig) ProtoMessage() {} + +func (x *HappyEyeballsConfig) ProtoReflect() protoreflect.Message { + mi := &file_transport_internet_config_proto_msgTypes[5] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use HappyEyeballsConfig.ProtoReflect.Descriptor instead. +func (*HappyEyeballsConfig) Descriptor() ([]byte, []int) { + return file_transport_internet_config_proto_rawDescGZIP(), []int{5} +} + +func (x *HappyEyeballsConfig) GetPrioritizeIpv6() bool { + if x != nil { + return x.PrioritizeIpv6 + } + return false +} + +func (x *HappyEyeballsConfig) GetInterleave() uint32 { + if x != nil { + return x.Interleave + } + return 0 +} + +func (x *HappyEyeballsConfig) GetTryDelayMs() uint64 { + if x != nil { + return x.TryDelayMs + } + return 0 +} + +func (x *HappyEyeballsConfig) GetMaxConcurrentTry() uint32 { + if x != nil { + return x.MaxConcurrentTry + } + return 0 +} + var File_transport_internet_config_proto protoreflect.FileDescriptor var file_transport_internet_config_proto_rawDesc = []byte{ @@ -766,7 +843,7 @@ var file_transport_internet_config_proto_rawDesc = []byte{ 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x6f, 0x70, 0x74, 0x12, 0x14, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x05, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x12, 0x12, 0x0a, 0x04, 0x74, 0x79, 0x70, 0x65, 0x18, 0x06, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, - 0x74, 0x79, 0x70, 0x65, 0x22, 0xfd, 0x07, 0x0a, 0x0c, 0x53, 0x6f, 0x63, 0x6b, 0x65, 0x74, 0x43, + 0x74, 0x79, 0x70, 0x65, 0x22, 0xd2, 0x08, 0x0a, 0x0c, 0x53, 0x6f, 0x63, 0x6b, 0x65, 0x74, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x12, 0x12, 0x0a, 0x04, 0x6d, 0x61, 0x72, 0x6b, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, 0x52, 0x04, 0x6d, 0x61, 0x72, 0x6b, 0x12, 0x10, 0x0a, 0x03, 0x74, 0x66, 0x6f, 0x18, 0x02, 0x20, 0x01, 0x28, 0x05, 0x52, 0x03, 0x74, 0x66, 0x6f, 0x12, 0x48, 0x0a, 0x06, 0x74, @@ -827,37 +904,53 @@ var file_transport_internet_config_proto_rawDesc = []byte{ 0x74, 0x2e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x65, 0x74, 0x2e, 0x41, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x50, 0x6f, 0x72, 0x74, 0x53, 0x74, 0x72, 0x61, 0x74, 0x65, 0x67, 0x79, 0x52, 0x13, 0x61, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x50, 0x6f, 0x72, 0x74, 0x53, 0x74, 0x72, 0x61, 0x74, - 0x65, 0x67, 0x79, 0x22, 0x2f, 0x0a, 0x0a, 0x54, 0x50, 0x72, 0x6f, 0x78, 0x79, 0x4d, 0x6f, 0x64, - 0x65, 0x12, 0x07, 0x0a, 0x03, 0x4f, 0x66, 0x66, 0x10, 0x00, 0x12, 0x0a, 0x0a, 0x06, 0x54, 0x50, - 0x72, 0x6f, 0x78, 0x79, 0x10, 0x01, 0x12, 0x0c, 0x0a, 0x08, 0x52, 0x65, 0x64, 0x69, 0x72, 0x65, - 0x63, 0x74, 0x10, 0x02, 0x2a, 0xa9, 0x01, 0x0a, 0x0e, 0x44, 0x6f, 0x6d, 0x61, 0x69, 0x6e, 0x53, - 0x74, 0x72, 0x61, 0x74, 0x65, 0x67, 0x79, 0x12, 0x09, 0x0a, 0x05, 0x41, 0x53, 0x5f, 0x49, 0x53, - 0x10, 0x00, 0x12, 0x0a, 0x0a, 0x06, 0x55, 0x53, 0x45, 0x5f, 0x49, 0x50, 0x10, 0x01, 0x12, 0x0b, - 0x0a, 0x07, 0x55, 0x53, 0x45, 0x5f, 0x49, 0x50, 0x34, 0x10, 0x02, 0x12, 0x0b, 0x0a, 0x07, 0x55, - 0x53, 0x45, 0x5f, 0x49, 0x50, 0x36, 0x10, 0x03, 0x12, 0x0c, 0x0a, 0x08, 0x55, 0x53, 0x45, 0x5f, - 0x49, 0x50, 0x34, 0x36, 0x10, 0x04, 0x12, 0x0c, 0x0a, 0x08, 0x55, 0x53, 0x45, 0x5f, 0x49, 0x50, - 0x36, 0x34, 0x10, 0x05, 0x12, 0x0c, 0x0a, 0x08, 0x46, 0x4f, 0x52, 0x43, 0x45, 0x5f, 0x49, 0x50, - 0x10, 0x06, 0x12, 0x0d, 0x0a, 0x09, 0x46, 0x4f, 0x52, 0x43, 0x45, 0x5f, 0x49, 0x50, 0x34, 0x10, - 0x07, 0x12, 0x0d, 0x0a, 0x09, 0x46, 0x4f, 0x52, 0x43, 0x45, 0x5f, 0x49, 0x50, 0x36, 0x10, 0x08, - 0x12, 0x0e, 0x0a, 0x0a, 0x46, 0x4f, 0x52, 0x43, 0x45, 0x5f, 0x49, 0x50, 0x34, 0x36, 0x10, 0x09, - 0x12, 0x0e, 0x0a, 0x0a, 0x46, 0x4f, 0x52, 0x43, 0x45, 0x5f, 0x49, 0x50, 0x36, 0x34, 0x10, 0x0a, - 0x2a, 0x97, 0x01, 0x0a, 0x13, 0x41, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x50, 0x6f, 0x72, 0x74, - 0x53, 0x74, 0x72, 0x61, 0x74, 0x65, 0x67, 0x79, 0x12, 0x08, 0x0a, 0x04, 0x4e, 0x6f, 0x6e, 0x65, - 0x10, 0x00, 0x12, 0x0f, 0x0a, 0x0b, 0x53, 0x72, 0x76, 0x50, 0x6f, 0x72, 0x74, 0x4f, 0x6e, 0x6c, - 0x79, 0x10, 0x01, 0x12, 0x12, 0x0a, 0x0e, 0x53, 0x72, 0x76, 0x41, 0x64, 0x64, 0x72, 0x65, 0x73, - 0x73, 0x4f, 0x6e, 0x6c, 0x79, 0x10, 0x02, 0x12, 0x15, 0x0a, 0x11, 0x53, 0x72, 0x76, 0x50, 0x6f, - 0x72, 0x74, 0x41, 0x6e, 0x64, 0x41, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x10, 0x03, 0x12, 0x0f, - 0x0a, 0x0b, 0x54, 0x78, 0x74, 0x50, 0x6f, 0x72, 0x74, 0x4f, 0x6e, 0x6c, 0x79, 0x10, 0x04, 0x12, - 0x12, 0x0a, 0x0e, 0x54, 0x78, 0x74, 0x41, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x4f, 0x6e, 0x6c, - 0x79, 0x10, 0x05, 0x12, 0x15, 0x0a, 0x11, 0x54, 0x78, 0x74, 0x50, 0x6f, 0x72, 0x74, 0x41, 0x6e, - 0x64, 0x41, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x10, 0x06, 0x42, 0x67, 0x0a, 0x1b, 0x63, 0x6f, - 0x6d, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x74, 0x72, 0x61, 0x6e, 0x73, 0x70, 0x6f, 0x72, 0x74, - 0x2e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x65, 0x74, 0x50, 0x01, 0x5a, 0x2c, 0x67, 0x69, 0x74, - 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x78, 0x74, 0x6c, 0x73, 0x2f, 0x78, 0x72, 0x61, - 0x79, 0x2d, 0x63, 0x6f, 0x72, 0x65, 0x2f, 0x74, 0x72, 0x61, 0x6e, 0x73, 0x70, 0x6f, 0x72, 0x74, - 0x2f, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x65, 0x74, 0xaa, 0x02, 0x17, 0x58, 0x72, 0x61, 0x79, - 0x2e, 0x54, 0x72, 0x61, 0x6e, 0x73, 0x70, 0x6f, 0x72, 0x74, 0x2e, 0x49, 0x6e, 0x74, 0x65, 0x72, - 0x6e, 0x65, 0x74, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x65, 0x67, 0x79, 0x12, 0x53, 0x0a, 0x0e, 0x68, 0x61, 0x70, 0x70, 0x79, 0x5f, 0x65, 0x79, 0x65, + 0x62, 0x61, 0x6c, 0x6c, 0x73, 0x18, 0x16, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x2c, 0x2e, 0x78, 0x72, + 0x61, 0x79, 0x2e, 0x74, 0x72, 0x61, 0x6e, 0x73, 0x70, 0x6f, 0x72, 0x74, 0x2e, 0x69, 0x6e, 0x74, + 0x65, 0x72, 0x6e, 0x65, 0x74, 0x2e, 0x48, 0x61, 0x70, 0x70, 0x79, 0x45, 0x79, 0x65, 0x62, 0x61, + 0x6c, 0x6c, 0x73, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x52, 0x0d, 0x68, 0x61, 0x70, 0x70, 0x79, + 0x45, 0x79, 0x65, 0x62, 0x61, 0x6c, 0x6c, 0x73, 0x22, 0x2f, 0x0a, 0x0a, 0x54, 0x50, 0x72, 0x6f, + 0x78, 0x79, 0x4d, 0x6f, 0x64, 0x65, 0x12, 0x07, 0x0a, 0x03, 0x4f, 0x66, 0x66, 0x10, 0x00, 0x12, + 0x0a, 0x0a, 0x06, 0x54, 0x50, 0x72, 0x6f, 0x78, 0x79, 0x10, 0x01, 0x12, 0x0c, 0x0a, 0x08, 0x52, + 0x65, 0x64, 0x69, 0x72, 0x65, 0x63, 0x74, 0x10, 0x02, 0x22, 0xad, 0x01, 0x0a, 0x13, 0x48, 0x61, + 0x70, 0x70, 0x79, 0x45, 0x79, 0x65, 0x62, 0x61, 0x6c, 0x6c, 0x73, 0x43, 0x6f, 0x6e, 0x66, 0x69, + 0x67, 0x12, 0x27, 0x0a, 0x0f, 0x70, 0x72, 0x69, 0x6f, 0x72, 0x69, 0x74, 0x69, 0x7a, 0x65, 0x5f, + 0x69, 0x70, 0x76, 0x36, 0x18, 0x01, 0x20, 0x01, 0x28, 0x08, 0x52, 0x0e, 0x70, 0x72, 0x69, 0x6f, + 0x72, 0x69, 0x74, 0x69, 0x7a, 0x65, 0x49, 0x70, 0x76, 0x36, 0x12, 0x1e, 0x0a, 0x0a, 0x69, 0x6e, + 0x74, 0x65, 0x72, 0x6c, 0x65, 0x61, 0x76, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x0a, + 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6c, 0x65, 0x61, 0x76, 0x65, 0x12, 0x1f, 0x0a, 0x0b, 0x74, 0x72, + 0x79, 0x5f, 0x64, 0x65, 0x6c, 0x61, 0x79, 0x4d, 0x73, 0x18, 0x03, 0x20, 0x01, 0x28, 0x04, 0x52, + 0x0a, 0x74, 0x72, 0x79, 0x44, 0x65, 0x6c, 0x61, 0x79, 0x4d, 0x73, 0x12, 0x2c, 0x0a, 0x12, 0x6d, + 0x61, 0x78, 0x5f, 0x63, 0x6f, 0x6e, 0x63, 0x75, 0x72, 0x72, 0x65, 0x6e, 0x74, 0x5f, 0x74, 0x72, + 0x79, 0x18, 0x04, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x10, 0x6d, 0x61, 0x78, 0x43, 0x6f, 0x6e, 0x63, + 0x75, 0x72, 0x72, 0x65, 0x6e, 0x74, 0x54, 0x72, 0x79, 0x2a, 0xa9, 0x01, 0x0a, 0x0e, 0x44, 0x6f, + 0x6d, 0x61, 0x69, 0x6e, 0x53, 0x74, 0x72, 0x61, 0x74, 0x65, 0x67, 0x79, 0x12, 0x09, 0x0a, 0x05, + 0x41, 0x53, 0x5f, 0x49, 0x53, 0x10, 0x00, 0x12, 0x0a, 0x0a, 0x06, 0x55, 0x53, 0x45, 0x5f, 0x49, + 0x50, 0x10, 0x01, 0x12, 0x0b, 0x0a, 0x07, 0x55, 0x53, 0x45, 0x5f, 0x49, 0x50, 0x34, 0x10, 0x02, + 0x12, 0x0b, 0x0a, 0x07, 0x55, 0x53, 0x45, 0x5f, 0x49, 0x50, 0x36, 0x10, 0x03, 0x12, 0x0c, 0x0a, + 0x08, 0x55, 0x53, 0x45, 0x5f, 0x49, 0x50, 0x34, 0x36, 0x10, 0x04, 0x12, 0x0c, 0x0a, 0x08, 0x55, + 0x53, 0x45, 0x5f, 0x49, 0x50, 0x36, 0x34, 0x10, 0x05, 0x12, 0x0c, 0x0a, 0x08, 0x46, 0x4f, 0x52, + 0x43, 0x45, 0x5f, 0x49, 0x50, 0x10, 0x06, 0x12, 0x0d, 0x0a, 0x09, 0x46, 0x4f, 0x52, 0x43, 0x45, + 0x5f, 0x49, 0x50, 0x34, 0x10, 0x07, 0x12, 0x0d, 0x0a, 0x09, 0x46, 0x4f, 0x52, 0x43, 0x45, 0x5f, + 0x49, 0x50, 0x36, 0x10, 0x08, 0x12, 0x0e, 0x0a, 0x0a, 0x46, 0x4f, 0x52, 0x43, 0x45, 0x5f, 0x49, + 0x50, 0x34, 0x36, 0x10, 0x09, 0x12, 0x0e, 0x0a, 0x0a, 0x46, 0x4f, 0x52, 0x43, 0x45, 0x5f, 0x49, + 0x50, 0x36, 0x34, 0x10, 0x0a, 0x2a, 0x97, 0x01, 0x0a, 0x13, 0x41, 0x64, 0x64, 0x72, 0x65, 0x73, + 0x73, 0x50, 0x6f, 0x72, 0x74, 0x53, 0x74, 0x72, 0x61, 0x74, 0x65, 0x67, 0x79, 0x12, 0x08, 0x0a, + 0x04, 0x4e, 0x6f, 0x6e, 0x65, 0x10, 0x00, 0x12, 0x0f, 0x0a, 0x0b, 0x53, 0x72, 0x76, 0x50, 0x6f, + 0x72, 0x74, 0x4f, 0x6e, 0x6c, 0x79, 0x10, 0x01, 0x12, 0x12, 0x0a, 0x0e, 0x53, 0x72, 0x76, 0x41, + 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x4f, 0x6e, 0x6c, 0x79, 0x10, 0x02, 0x12, 0x15, 0x0a, 0x11, + 0x53, 0x72, 0x76, 0x50, 0x6f, 0x72, 0x74, 0x41, 0x6e, 0x64, 0x41, 0x64, 0x64, 0x72, 0x65, 0x73, + 0x73, 0x10, 0x03, 0x12, 0x0f, 0x0a, 0x0b, 0x54, 0x78, 0x74, 0x50, 0x6f, 0x72, 0x74, 0x4f, 0x6e, + 0x6c, 0x79, 0x10, 0x04, 0x12, 0x12, 0x0a, 0x0e, 0x54, 0x78, 0x74, 0x41, 0x64, 0x64, 0x72, 0x65, + 0x73, 0x73, 0x4f, 0x6e, 0x6c, 0x79, 0x10, 0x05, 0x12, 0x15, 0x0a, 0x11, 0x54, 0x78, 0x74, 0x50, + 0x6f, 0x72, 0x74, 0x41, 0x6e, 0x64, 0x41, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x10, 0x06, 0x42, + 0x67, 0x0a, 0x1b, 0x63, 0x6f, 0x6d, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x74, 0x72, 0x61, 0x6e, + 0x73, 0x70, 0x6f, 0x72, 0x74, 0x2e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x65, 0x74, 0x50, 0x01, + 0x5a, 0x2c, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x78, 0x74, 0x6c, + 0x73, 0x2f, 0x78, 0x72, 0x61, 0x79, 0x2d, 0x63, 0x6f, 0x72, 0x65, 0x2f, 0x74, 0x72, 0x61, 0x6e, + 0x73, 0x70, 0x6f, 0x72, 0x74, 0x2f, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x65, 0x74, 0xaa, 0x02, + 0x17, 0x58, 0x72, 0x61, 0x79, 0x2e, 0x54, 0x72, 0x61, 0x6e, 0x73, 0x70, 0x6f, 0x72, 0x74, 0x2e, + 0x49, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x65, 0x74, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( @@ -873,7 +966,7 @@ func file_transport_internet_config_proto_rawDescGZIP() []byte { } var file_transport_internet_config_proto_enumTypes = make([]protoimpl.EnumInfo, 3) -var file_transport_internet_config_proto_msgTypes = make([]protoimpl.MessageInfo, 5) +var file_transport_internet_config_proto_msgTypes = make([]protoimpl.MessageInfo, 6) var file_transport_internet_config_proto_goTypes = []any{ (DomainStrategy)(0), // 0: xray.transport.internet.DomainStrategy (AddressPortStrategy)(0), // 1: xray.transport.internet.AddressPortStrategy @@ -883,24 +976,26 @@ var file_transport_internet_config_proto_goTypes = []any{ (*ProxyConfig)(nil), // 5: xray.transport.internet.ProxyConfig (*CustomSockopt)(nil), // 6: xray.transport.internet.CustomSockopt (*SocketConfig)(nil), // 7: xray.transport.internet.SocketConfig - (*serial.TypedMessage)(nil), // 8: xray.common.serial.TypedMessage - (*net.IPOrDomain)(nil), // 9: xray.common.net.IPOrDomain + (*HappyEyeballsConfig)(nil), // 8: xray.transport.internet.HappyEyeballsConfig + (*serial.TypedMessage)(nil), // 9: xray.common.serial.TypedMessage + (*net.IPOrDomain)(nil), // 10: xray.common.net.IPOrDomain } var file_transport_internet_config_proto_depIdxs = []int32{ - 8, // 0: xray.transport.internet.TransportConfig.settings:type_name -> xray.common.serial.TypedMessage - 9, // 1: xray.transport.internet.StreamConfig.address:type_name -> xray.common.net.IPOrDomain - 3, // 2: xray.transport.internet.StreamConfig.transport_settings:type_name -> xray.transport.internet.TransportConfig - 8, // 3: xray.transport.internet.StreamConfig.security_settings:type_name -> xray.common.serial.TypedMessage - 7, // 4: xray.transport.internet.StreamConfig.socket_settings:type_name -> xray.transport.internet.SocketConfig - 2, // 5: xray.transport.internet.SocketConfig.tproxy:type_name -> xray.transport.internet.SocketConfig.TProxyMode - 0, // 6: xray.transport.internet.SocketConfig.domain_strategy:type_name -> xray.transport.internet.DomainStrategy - 6, // 7: xray.transport.internet.SocketConfig.customSockopt:type_name -> xray.transport.internet.CustomSockopt - 1, // 8: xray.transport.internet.SocketConfig.address_port_strategy:type_name -> xray.transport.internet.AddressPortStrategy - 9, // [9:9] is the sub-list for method output_type - 9, // [9:9] is the sub-list for method input_type - 9, // [9:9] is the sub-list for extension type_name - 9, // [9:9] is the sub-list for extension extendee - 0, // [0:9] is the sub-list for field type_name + 9, // 0: xray.transport.internet.TransportConfig.settings:type_name -> xray.common.serial.TypedMessage + 10, // 1: xray.transport.internet.StreamConfig.address:type_name -> xray.common.net.IPOrDomain + 3, // 2: xray.transport.internet.StreamConfig.transport_settings:type_name -> xray.transport.internet.TransportConfig + 9, // 3: xray.transport.internet.StreamConfig.security_settings:type_name -> xray.common.serial.TypedMessage + 7, // 4: xray.transport.internet.StreamConfig.socket_settings:type_name -> xray.transport.internet.SocketConfig + 2, // 5: xray.transport.internet.SocketConfig.tproxy:type_name -> xray.transport.internet.SocketConfig.TProxyMode + 0, // 6: xray.transport.internet.SocketConfig.domain_strategy:type_name -> xray.transport.internet.DomainStrategy + 6, // 7: xray.transport.internet.SocketConfig.customSockopt:type_name -> xray.transport.internet.CustomSockopt + 1, // 8: xray.transport.internet.SocketConfig.address_port_strategy:type_name -> xray.transport.internet.AddressPortStrategy + 8, // 9: xray.transport.internet.SocketConfig.happy_eyeballs:type_name -> xray.transport.internet.HappyEyeballsConfig + 10, // [10:10] is the sub-list for method output_type + 10, // [10:10] is the sub-list for method input_type + 10, // [10:10] is the sub-list for extension type_name + 10, // [10:10] is the sub-list for extension extendee + 0, // [0:10] is the sub-list for field type_name } func init() { file_transport_internet_config_proto_init() } @@ -914,7 +1009,7 @@ func file_transport_internet_config_proto_init() { GoPackagePath: reflect.TypeOf(x{}).PkgPath(), RawDescriptor: file_transport_internet_config_proto_rawDesc, NumEnums: 3, - NumMessages: 5, + NumMessages: 6, NumExtensions: 0, NumServices: 0, }, diff --git a/xray-core/transport/internet/config.proto b/xray-core/transport/internet/config.proto index cb892c307f..a40f09381e 100644 --- a/xray-core/transport/internet/config.proto +++ b/xray-core/transport/internet/config.proto @@ -130,4 +130,13 @@ message SocketConfig { repeated CustomSockopt customSockopt = 20; AddressPortStrategy address_port_strategy = 21; + + HappyEyeballsConfig happy_eyeballs = 22; +} + +message HappyEyeballsConfig { + bool prioritize_ipv6 = 1; + uint32 interleave = 2; + uint64 try_delayMs = 3; + uint32 max_concurrent_try = 4; } diff --git a/xray-core/transport/internet/dialer.go b/xray-core/transport/internet/dialer.go index 74e5f0b69b..5e403f672f 100644 --- a/xray-core/transport/internet/dialer.go +++ b/xray-core/transport/internet/dialer.go @@ -255,9 +255,11 @@ func DialSystem(ctx context.Context, dest net.Destination, sockopt *SocketConfig if sockopt.DomainStrategy.forceIP() { return nil, err } - } else { + } else if sockopt.HappyEyeballs == nil || sockopt.HappyEyeballs.TryDelayMs == 0 || sockopt.HappyEyeballs.MaxConcurrentTry == 0 || len(ips) < 2 || len(sockopt.DialerProxy) > 0 || dest.Network != net.Network_TCP { dest.Address = net.IPAddress(ips[dice.Roll(len(ips))]) errors.LogInfo(ctx, "replace destination with "+dest.String()) + } else { + return TcpRaceDial(ctx, src, ips, dest.Port, sockopt) } } diff --git a/xray-core/transport/internet/happy_eyeballs.go b/xray-core/transport/internet/happy_eyeballs.go new file mode 100644 index 0000000000..10adb23526 --- /dev/null +++ b/xray-core/transport/internet/happy_eyeballs.go @@ -0,0 +1,171 @@ +package internet + +import ( + "context" + "github.com/xtls/xray-core/common/net" + "time" +) + +type result struct { + err error + conn net.Conn + index int +} + +func TcpRaceDial(ctx context.Context, src net.Address, ips []net.IP, port net.Port, sockopt *SocketConfig) (net.Conn, error) { + if len(ips) < 2 { + panic("at least 2 ips is required to race dial") + } + + prioritizeIPv6 := sockopt.HappyEyeballs.PrioritizeIpv6 + interleave := sockopt.HappyEyeballs.Interleave + tryDelayMs := time.Duration(sockopt.HappyEyeballs.TryDelayMs) * time.Millisecond + maxConcurrentTry := sockopt.HappyEyeballs.MaxConcurrentTry + + ips = sortIPs(ips, prioritizeIPv6, interleave) + newCtx, cancel := context.WithCancel(ctx) + defer cancel() + var resultCh = make(chan *result, len(ips)) + nextTryIndex := 0 + activeNum := uint32(0) + timer := time.NewTimer(0) + var winConn net.Conn + for { + select { + case r := <-resultCh: + activeNum-- + select { + case <-ctx.Done(): + cancel() + timer.Stop() + if winConn != nil { + winConn.Close() + } + if r.conn != nil { + r.conn.Close() + } + if activeNum == 0 { + return nil, ctx.Err() + } + continue + default: + if r.conn != nil { + cancel() + timer.Stop() + if winConn == nil { + winConn = r.conn + } else { + r.conn.Close() + } + } + if winConn != nil && activeNum == 0 { + return winConn, nil + } + if winConn != nil { + continue + } + if nextTryIndex < len(ips) { + timer.Reset(0) + continue + } + if activeNum == 0 { + return nil, r.err + } + timer.Stop() + continue + } + + case <-timer.C: + if nextTryIndex == len(ips) || activeNum == maxConcurrentTry { + panic("impossible situation") + } + go tcpTryDial(newCtx, src, sockopt, ips[nextTryIndex], port, nextTryIndex, resultCh) + activeNum++ + nextTryIndex++ + if nextTryIndex == len(ips) || activeNum == maxConcurrentTry { + timer.Stop() + } else { + timer.Reset(tryDelayMs) + } + continue + } + } +} + +// sortIPs sort IPs according to rfc 8305. +func sortIPs(ips []net.IP, prioritizeIPv6 bool, interleave uint32) []net.IP { + if len(ips) == 0 { + return ips + } + var ip4 = make([]net.IP, 0, len(ips)) + var ip6 = make([]net.IP, 0, len(ips)) + for _, ip := range ips { + parsedIp := net.IPAddress(ip).IP() + if len(parsedIp) == net.IPv4len { + ip4 = append(ip4, parsedIp) + } else { + ip6 = append(ip6, parsedIp) + } + } + + if len(ip4) == 0 || len(ip6) == 0 { + return ips + } + + var newIPs = make([]net.IP, 0, len(ips)) + consumeIP4 := 0 + consumeIP6 := 0 + consumeTurn := uint32(0) + ip4turn := true + if prioritizeIPv6 { + ip4turn = false + } + for { + if ip4turn { + newIPs = append(newIPs, ip4[consumeIP4]) + consumeIP4++ + if consumeIP4 == len(ip4) { + newIPs = append(newIPs, ip6[consumeIP6:]...) + break + } + consumeTurn++ + if consumeTurn == interleave { + ip4turn = false + consumeTurn = uint32(0) + } + } else { + newIPs = append(newIPs, ip6[consumeIP6]) + consumeIP6++ + if consumeIP6 == len(ip6) { + newIPs = append(newIPs, ip4[consumeIP4:]...) + break + } + consumeTurn++ + if consumeTurn == interleave { + ip4turn = true + consumeTurn = uint32(0) + } + } + } + + return newIPs +} + +func tcpTryDial(ctx context.Context, src net.Address, sockopt *SocketConfig, ip net.IP, port net.Port, index int, resultCh chan<- *result) { + conn, err := effectiveSystemDialer.Dial(ctx, src, net.Destination{Address: net.IPAddress(ip), Network: net.Network_TCP, Port: port}, sockopt) + select { + case <-ctx.Done(): + if conn != nil { + conn.Close() + } + resultCh <- &result{err: ctx.Err(), index: index} + return + default: + if err != nil { + resultCh <- &result{err: err, index: index} + return + } + resultCh <- &result{conn: conn, index: index} + return + } +} diff --git a/yt-dlp/README.md b/yt-dlp/README.md index 6e2dc6243c..75de66a976 100644 --- a/yt-dlp/README.md +++ b/yt-dlp/README.md @@ -1797,7 +1797,7 @@ The following extractors use this feature: #### youtube * `lang`: Prefer translated metadata (`title`, `description` etc) of this language code (case-sensitive). By default, the video primary language metadata is preferred, with a fallback to `en` translated. See [youtube.py](https://github.com/yt-dlp/yt-dlp/blob/c26f9b991a0681fd3ea548d535919cec1fbbd430/yt_dlp/extractor/youtube.py#L381-L390) for list of supported content language codes * `skip`: One or more of `hls`, `dash` or `translated_subs` to skip extraction of the m3u8 manifests, dash manifests and [auto-translated subtitles](https://github.com/yt-dlp/yt-dlp/issues/4090#issuecomment-1158102032) respectively -* `player_client`: Clients to extract video data from. The currently available clients are `web`, `web_safari`, `web_embedded`, `web_music`, `web_creator`, `mweb`, `ios`, `android`, `android_vr`, `tv` and `tv_embedded`. By default, `tv,ios,web` is used, or `tv,web` is used when authenticating with cookies. The `web_music` client is added for `music.youtube.com` URLs when logged-in cookies are used. The `web_embedded` client is added for age-restricted videos but only works if the video is embeddable. The `tv_embedded` and `web_creator` clients are added for age-restricted videos if account age-verification is required. Some clients, such as `web` and `web_music`, require a `po_token` for their formats to be downloadable. Some clients, such as `web_creator`, will only work with authentication. Not all clients support authentication via cookies. You can use `default` for the default clients, or you can use `all` for all clients (not recommended). You can prefix a client with `-` to exclude it, e.g. `youtube:player_client=default,-ios` +* `player_client`: Clients to extract video data from. The currently available clients are `web`, `web_safari`, `web_embedded`, `web_music`, `web_creator`, `mweb`, `ios`, `android`, `android_vr`, `tv`, `tv_simply` and `tv_embedded`. By default, `tv,ios,web` is used, or `tv,web` is used when authenticating with cookies. The `web_music` client is added for `music.youtube.com` URLs when logged-in cookies are used. The `web_embedded` client is added for age-restricted videos but only works if the video is embeddable. The `tv_embedded` and `web_creator` clients are added for age-restricted videos if account age-verification is required. Some clients, such as `web` and `web_music`, require a `po_token` for their formats to be downloadable. Some clients, such as `web_creator`, will only work with authentication. Not all clients support authentication via cookies. You can use `default` for the default clients, or you can use `all` for all clients (not recommended). You can prefix a client with `-` to exclude it, e.g. `youtube:player_client=default,-ios` * `player_skip`: Skip some network requests that are generally needed for robust extraction. One or more of `configs` (skip client configs), `webpage` (skip initial webpage), `js` (skip js player), `initial_data` (skip initial data/next ep request). While these options can help reduce the number of requests needed or avoid some rate-limiting, they could cause issues such as missing formats or metadata. See [#860](https://github.com/yt-dlp/yt-dlp/pull/860) and [#12826](https://github.com/yt-dlp/yt-dlp/issues/12826) for more details * `player_params`: YouTube player parameters to use for player requests. Will overwrite any default ones set by yt-dlp. * `player_js_variant`: The player javascript variant to use for signature and nsig deciphering. The known variants are: `main`, `tce`, `tv`, `tv_es6`, `phone`, `tablet`. Only `main` is recommended as a possible workaround; the others are for debugging purposes. The default is to use what is prescribed by the site, and can be selected with `actual` diff --git a/yt-dlp/test/test_pot/test_pot_builtin_utils.py b/yt-dlp/test/test_pot/test_pot_builtin_utils.py index a95fc4e159..7645ba601f 100644 --- a/yt-dlp/test/test_pot/test_pot_builtin_utils.py +++ b/yt-dlp/test/test_pot/test_pot_builtin_utils.py @@ -11,7 +11,7 @@ class TestGetWebPoContentBinding: @pytest.mark.parametrize('client_name, context, is_authenticated, expected', [ *[(client, context, is_authenticated, expected) for client in [ - 'WEB', 'MWEB', 'TVHTML5', 'WEB_EMBEDDED_PLAYER', 'WEB_CREATOR', 'TVHTML5_SIMPLY_EMBEDDED_PLAYER'] + 'WEB', 'MWEB', 'TVHTML5', 'WEB_EMBEDDED_PLAYER', 'WEB_CREATOR', 'TVHTML5_SIMPLY_EMBEDDED_PLAYER', 'TVHTML5_SIMPLY'] for context, is_authenticated, expected in [ (PoTokenContext.GVS, False, ('example-visitor-data', ContentBindingType.VISITOR_DATA)), (PoTokenContext.PLAYER, False, ('example-video-id', ContentBindingType.VIDEO_ID)), diff --git a/yt-dlp/test/test_pot/test_pot_builtin_webpospec.py b/yt-dlp/test/test_pot/test_pot_builtin_webpospec.py index c5fb6f3820..078008415a 100644 --- a/yt-dlp/test/test_pot/test_pot_builtin_webpospec.py +++ b/yt-dlp/test/test_pot/test_pot_builtin_webpospec.py @@ -49,7 +49,7 @@ class TestWebPoPCSP: @pytest.mark.parametrize('client_name, context, is_authenticated, remote_host, source_address, request_proxy, expected', [ *[(client, context, is_authenticated, remote_host, source_address, request_proxy, expected) for client in [ - 'WEB', 'MWEB', 'TVHTML5', 'WEB_EMBEDDED_PLAYER', 'WEB_CREATOR', 'TVHTML5_SIMPLY_EMBEDDED_PLAYER'] + 'WEB', 'MWEB', 'TVHTML5', 'WEB_EMBEDDED_PLAYER', 'WEB_CREATOR', 'TVHTML5_SIMPLY_EMBEDDED_PLAYER', 'TVHTML5_SIMPLY'] for context, is_authenticated, remote_host, source_address, request_proxy, expected in [ (PoTokenContext.GVS, False, 'example-remote-host', 'example-source-address', 'example-request-proxy', {'t': 'webpo', 'ip': 'example-remote-host', 'sa': 'example-source-address', 'px': 'example-request-proxy', 'cb': '123abcXYZ_-', 'cbt': 'visitor_id'}), (PoTokenContext.PLAYER, False, 'example-remote-host', 'example-source-address', 'example-request-proxy', {'t': 'webpo', 'ip': 'example-remote-host', 'sa': 'example-source-address', 'px': 'example-request-proxy', 'cb': '123abcXYZ_-', 'cbt': 'video_id'}), diff --git a/yt-dlp/yt_dlp/extractor/mitele.py b/yt-dlp/yt_dlp/extractor/mitele.py index 55fa83b51f..0dded38c65 100644 --- a/yt-dlp/yt_dlp/extractor/mitele.py +++ b/yt-dlp/yt_dlp/extractor/mitele.py @@ -1,7 +1,5 @@ from .telecinco import TelecincoBaseIE -from ..networking.exceptions import HTTPError from ..utils import ( - ExtractorError, int_or_none, parse_iso8601, ) @@ -81,17 +79,7 @@ class MiTeleIE(TelecincoBaseIE): def _real_extract(self, url): display_id = self._match_id(url) - - try: # yt-dlp's default user-agents are too old and blocked by akamai - webpage = self._download_webpage(url, display_id, headers={ - 'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; rv:136.0) Gecko/20100101 Firefox/136.0', - }) - except ExtractorError as e: - if not isinstance(e.cause, HTTPError) or e.cause.status != 403: - raise - # Retry with impersonation if hardcoded UA is insufficient to bypass akamai - webpage = self._download_webpage(url, display_id, impersonate=True) - + webpage = self._download_akamai_webpage(url, display_id) pre_player = self._search_json( r'window\.\$REACTBASE_STATE\.prePlayer_mtweb\s*=', webpage, 'Pre Player', display_id)['prePlayer'] diff --git a/yt-dlp/yt_dlp/extractor/stacommu.py b/yt-dlp/yt_dlp/extractor/stacommu.py index 8300185183..e6866f1517 100644 --- a/yt-dlp/yt_dlp/extractor/stacommu.py +++ b/yt-dlp/yt_dlp/extractor/stacommu.py @@ -4,6 +4,7 @@ from .wrestleuniverse import WrestleUniverseBaseIE from ..utils import ( int_or_none, traverse_obj, + url_basename, url_or_none, ) @@ -65,9 +66,19 @@ class StacommuBaseIE(WrestleUniverseBaseIE): hls_info, decrypt = self._call_encrypted_api( video_id, ':watchArchive', 'stream information', data={'method': 1}) + formats = self._get_formats(hls_info, ('hls', 'urls', ..., {url_or_none}), video_id) + for f in formats: + # bitrates are exaggerated in PPV playlists, so avoid wrong/huge filesize_approx values + if f.get('tbr'): + f['tbr'] = int(f['tbr'] / 2.5) + # prefer variants with the same basename as the master playlist to avoid partial streams + f['format_id'] = url_basename(f['url']).partition('.')[0] + if not f['format_id'].startswith(url_basename(f['manifest_url']).partition('.')[0]): + f['preference'] = -10 + return { 'id': video_id, - 'formats': self._get_formats(hls_info, ('hls', 'urls', ..., {url_or_none}), video_id), + 'formats': formats, 'hls_aes': self._extract_hls_key(hls_info, 'hls', decrypt), **traverse_obj(video_info, { 'title': ('displayName', {str}), diff --git a/yt-dlp/yt_dlp/extractor/telecinco.py b/yt-dlp/yt_dlp/extractor/telecinco.py index a34f2afd4a..2dbe2a7768 100644 --- a/yt-dlp/yt_dlp/extractor/telecinco.py +++ b/yt-dlp/yt_dlp/extractor/telecinco.py @@ -63,6 +63,17 @@ class TelecincoBaseIE(InfoExtractor): 'http_headers': headers, } + def _download_akamai_webpage(self, url, display_id): + try: # yt-dlp's default user-agents are too old and blocked by akamai + return self._download_webpage(url, display_id, headers={ + 'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; rv:136.0) Gecko/20100101 Firefox/136.0', + }) + except ExtractorError as e: + if not isinstance(e.cause, HTTPError) or e.cause.status != 403: + raise + # Retry with impersonation if hardcoded UA is insufficient to bypass akamai + return self._download_webpage(url, display_id, impersonate=True) + class TelecincoIE(TelecincoBaseIE): IE_DESC = 'telecinco.es, cuatro.com and mediaset.es' @@ -140,7 +151,7 @@ class TelecincoIE(TelecincoBaseIE): def _real_extract(self, url): display_id = self._match_id(url) - webpage = self._download_webpage(url, display_id) + webpage = self._download_akamai_webpage(url, display_id) article = self._search_json( r'window\.\$REACTBASE_STATE\.article(?:_multisite)?\s*=', webpage, 'article', display_id)['article'] diff --git a/yt-dlp/yt_dlp/extractor/youtube/_base.py b/yt-dlp/yt_dlp/extractor/youtube/_base.py index 9c5bb75fe4..90e3927153 100644 --- a/yt-dlp/yt_dlp/extractor/youtube/_base.py +++ b/yt-dlp/yt_dlp/extractor/youtube/_base.py @@ -175,6 +175,15 @@ INNERTUBE_CLIENTS = { 'INNERTUBE_CONTEXT_CLIENT_NAME': 7, 'SUPPORTS_COOKIES': True, }, + 'tv_simply': { + 'INNERTUBE_CONTEXT': { + 'client': { + 'clientName': 'TVHTML5_SIMPLY', + 'clientVersion': '1.0', + }, + }, + 'INNERTUBE_CONTEXT_CLIENT_NAME': 75, + }, # This client now requires sign-in for every video # It was previously an age-gate workaround for videos that were `playable_in_embed` # It may still be useful if signed into an EU account that is not age-verified diff --git a/yt-dlp/yt_dlp/extractor/youtube/_video.py b/yt-dlp/yt_dlp/extractor/youtube/_video.py index 0b53756dc4..55ebdce1ba 100644 --- a/yt-dlp/yt_dlp/extractor/youtube/_video.py +++ b/yt-dlp/yt_dlp/extractor/youtube/_video.py @@ -250,7 +250,7 @@ class YoutubeIE(YoutubeBaseInfoExtractor): '400': {'ext': 'mp4', 'height': 1440, 'format_note': 'DASH video', 'vcodec': 'av01.0.12M.08'}, '401': {'ext': 'mp4', 'height': 2160, 'format_note': 'DASH video', 'vcodec': 'av01.0.12M.08'}, } - _SUBTITLE_FORMATS = ('json3', 'srv1', 'srv2', 'srv3', 'ttml', 'vtt') + _SUBTITLE_FORMATS = ('json3', 'srv1', 'srv2', 'srv3', 'ttml', 'srt', 'vtt') _DEFAULT_CLIENTS = ('tv', 'ios', 'web') _DEFAULT_AUTHED_CLIENTS = ('tv', 'web') diff --git a/yt-dlp/yt_dlp/extractor/youtube/pot/utils.py b/yt-dlp/yt_dlp/extractor/youtube/pot/utils.py index 7a5b7d4ab3..a27921d4af 100644 --- a/yt-dlp/yt_dlp/extractor/youtube/pot/utils.py +++ b/yt-dlp/yt_dlp/extractor/youtube/pot/utils.py @@ -20,6 +20,7 @@ WEBPO_CLIENTS = ( 'WEB_EMBEDDED_PLAYER', 'WEB_CREATOR', 'WEB_REMIX', + 'TVHTML5_SIMPLY', 'TVHTML5_SIMPLY_EMBEDDED_PLAYER', )