diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 56fa80be..4c9fd502 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -29,6 +29,10 @@ jobs: os: macos-14 - target: x86_64-pc-windows-msvc os: windows-2022 + # Windows XP and later, 32-bit + - target: i686-pc-windows-msvc + os: windows-2022 + features: xp # Android's own libc (bionic): DNS goes through Android's resolver, which a # static musl binary cannot use - target: aarch64-linux-android @@ -65,7 +69,7 @@ jobs: - uses: Swatinem/rust-cache@9d47c6ad4b02e050fd481d890b2ea34778fd09d6 # v2.7.8 with: key: ${{ matrix.profile }}-${{ matrix.platform.target }} - - run: cargo build --locked --bins ${{ matrix.profile == 'release' && '--release' || '' }} --target ${{ matrix.platform.target }} + - run: cargo build --locked --bins ${{ matrix.profile == 'release' && '--release' || '' }} --target ${{ matrix.platform.target }} ${{ matrix.platform.features && format('--no-default-features --features {0}', matrix.platform.features) || '' }} - uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2 with: name: ${{ matrix.profile }}-${{ matrix.platform.target }} diff --git a/Cargo.lock b/Cargo.lock index f924e607..a71201c4 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -32,6 +32,29 @@ version = "1.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1505bd5d3d116872e7271a6d4e16d81d0c8570876c8de68093a09ac269d8aac0" +[[package]] +name = "aws-lc-rs" +version = "1.18.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b281d307588d634de920874890732659e2e7672f72b5e10e81badc1a8a83621e" +dependencies = [ + "aws-lc-sys", + "zeroize", +] + +[[package]] +name = "aws-lc-sys" +version = "0.45.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9bff6c3b54fad79a2e60b8102caf565819711497c1f5f092f49508e2f5c31b27" +dependencies = [ + "cc", + "cmake", + "dunce", + "fs_extra", + "pkg-config", +] + [[package]] name = "base64" version = "0.23.1" @@ -95,6 +118,12 @@ version = "1.0.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4e7648175b45a9a48536d676f68d918270699102aa8dab5496df06904c914600" +[[package]] +name = "cfg_aliases" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f079e83a288787bcd14a6aea84cee5c87a67c5a3e660c30f557a3d24761b3527" + [[package]] name = "chacha20" version = "0.10.2" @@ -106,6 +135,25 @@ dependencies = [ "rand_core", ] +[[package]] +name = "cmake" +version = "0.1.58" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c0f78a02292a74a88ac736019ab962ece0bc380e3f977bf72e376c5d78ff0678" +dependencies = [ + "cc", +] + +[[package]] +name = "combine" +version = "4.6.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cfc320937d09e6de266b31b9afb480f197d7a861be86be7cb2ea7e5d1bfffc5e" +dependencies = [ + "bytes", + "memchr", +] + [[package]] name = "const-oid" version = "0.10.2" @@ -274,6 +322,12 @@ version = "0.15.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1aaf95b3e5c8f23aa320147307562d361db0ae0d51242340f558153b4eb2439b" +[[package]] +name = "dunce" +version = "1.0.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "92773504d58c093f6de2459af4af33faa518c13451eb8f2b5698ed3d36e7c813" + [[package]] name = "either" version = "1.19.0" @@ -363,6 +417,12 @@ dependencies = [ "percent-encoding", ] +[[package]] +name = "fs_extra" +version = "1.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "42703706b716c37f96a77aea830392ad231f44c9e9a67872fa5548707e11b11c" + [[package]] name = "futures-channel" version = "0.3.34" @@ -419,8 +479,10 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ff2abc00be7fca6ebc474524697ae276ad847ad0a6b3faa4bcb027e9a4614ad0" dependencies = [ "cfg-if", + "js-sys", "libc", "wasi", + "wasm-bindgen", ] [[package]] @@ -430,9 +492,11 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "300e883d756b2e4ec94e02791f39b04b522276138852cfc41d9fb7e904106099" dependencies = [ "cfg-if", + "js-sys", "libc", "r-efi", "rand_core", + "wasm-bindgen", ] [[package]] @@ -722,6 +786,55 @@ version = "1.0.18" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8f42a60cbdf9a97f5d2305f08a87dc4e09308d1276d28c869c684d7777685682" +[[package]] +name = "jni" +version = "0.22.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5efd9a482cf3a427f00d6b35f14332adc7902ce91efb778580e180ff90fa3498" +dependencies = [ + "cfg-if", + "combine", + "jni-macros", + "jni-sys", + "log", + "simd_cesu8", + "thiserror", + "walkdir", + "windows-link", +] + +[[package]] +name = "jni-macros" +version = "0.22.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a00109accc170f0bdb141fed3e393c565b6f5e072365c3bd58f5b062591560a3" +dependencies = [ + "proc-macro2", + "quote", + "rustc_version", + "simd_cesu8", + "syn 2.0.119", +] + +[[package]] +name = "jni-sys" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c6377a88cb3910bee9b0fa88d4f42e1d2da8e79915598f65fb0c7ee14c878af2" +dependencies = [ + "jni-sys-macros", +] + +[[package]] +name = "jni-sys-macros" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "38c0b942f458fe50cdac086d2f946512305e5631e720728f2a61aabcd47a6264" +dependencies = [ + "quote", + "syn 2.0.119", +] + [[package]] name = "jobserver" version = "0.1.35" @@ -797,6 +910,12 @@ version = "0.4.34" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f9f8bd3e56ce4dfc153cf470fffbfa98c7620958b312ca5c3a4b8d5181fd13c6" +[[package]] +name = "lru-slab" +version = "0.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4050469837a6ff301cd14c1f8f24f88549e6d548f24f64e2148eb0f72cebc51f" + [[package]] name = "memchr" version = "2.8.3" @@ -949,10 +1068,12 @@ dependencies = [ "dotenvy", "git2", "openssl", + "rustls", "self_update", "serde", "serde_json", "sysinfo", + "thunk-rs", "tungstenite", "windows-sys 0.61.2", "winres", @@ -1009,6 +1130,63 @@ dependencies = [ "unicode-ident", ] +[[package]] +name = "quinn" +version = "0.11.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4051e23e9185c255a7e33ef59cdbca87a22d359052eecd22fc6b901fb37d9d11" +dependencies = [ + "bytes", + "cfg_aliases", + "pin-project-lite", + "quinn-proto", + "quinn-udp", + "rustc-hash", + "rustls", + "socket2", + "thiserror", + "tokio", + "tracing", + "web-time", +] + +[[package]] +name = "quinn-proto" +version = "0.11.19" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0e750cca55fe4f0439a15d0bb529da9651e79993e8e72c61a899a36d462befbe" +dependencies = [ + "aws-lc-rs", + "bytes", + "getrandom 0.4.3", + "lru-slab", + "rand", + "rand_pcg", + "ring", + "rustc-hash", + "rustls", + "rustls-pki-types", + "slab", + "thiserror", + "tinyvec", + "tracing", + "web-time", +] + +[[package]] +name = "quinn-udp" +version = "0.5.16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "af66907df18639dcf4db56ca65490cabc4b27a97dbadd96f2926cca73298f016" +dependencies = [ + "cfg_aliases", + "libc", + "once_cell", + "socket2", + "tracing", + "windows-sys 0.61.2", +] + [[package]] name = "quote" version = "1.0.47" @@ -1041,6 +1219,15 @@ version = "0.10.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "63b8176103e19a2643978565ca18b50549f6101881c443590420e4dc998a3c69" +[[package]] +name = "rand_pcg" +version = "0.10.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "caa0f4137e1c0a72f4c651489402276c8e8e1cf081f3b0ba156d2cbeef09e86a" +dependencies = [ + "rand_core", +] + [[package]] name = "rayon" version = "1.12.0" @@ -1114,12 +1301,16 @@ dependencies = [ "native-tls", "percent-encoding", "pin-project-lite", + "quinn", + "rustls", "rustls-pki-types", + "rustls-platform-verifier", "serde", "serde_json", "sync_wrapper", "tokio", "tokio-native-tls", + "tokio-rustls", "tower", "tower-http", "tower-service", @@ -1143,6 +1334,21 @@ dependencies = [ "windows-sys 0.52.0", ] +[[package]] +name = "rustc-hash" +version = "2.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6b1e7f9a428571be2dc5bc0505c13fb6bf936822b894ec87abf8a08a4e51742d" + +[[package]] +name = "rustc_version" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cfcb3a22ef46e85b45de6ee7e79d063319ebb6594faafcf1c225ea92ab6e9b92" +dependencies = [ + "semver", +] + [[package]] name = "rustix" version = "1.1.5" @@ -1162,28 +1368,72 @@ version = "0.23.45" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0d41d731c7d2f962d1ccc364cec258de3c0e93b38c2fb3ba97ac74513048d634" dependencies = [ + "aws-lc-rs", + "log", "once_cell", + "ring", "rustls-pki-types", "rustls-webpki", "subtle", "zeroize", ] +[[package]] +name = "rustls-native-certs" +version = "0.8.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dab5152771c58876a2146916e53e35057e1a4dfa2b9df0f0305b07f611fdea4d" +dependencies = [ + "openssl-probe", + "rustls-pki-types", + "schannel", + "security-framework", +] + [[package]] name = "rustls-pki-types" version = "1.15.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2f4925028c7eb5d1fcdaf196971378ed9d2c1c4efc7dc5d011256f76c99c0a96" dependencies = [ + "web-time", "zeroize", ] +[[package]] +name = "rustls-platform-verifier" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "26d1e2536ce4f35f4846aa13bff16bd0ff40157cdb14cc056c7b14ba41233ba0" +dependencies = [ + "core-foundation", + "core-foundation-sys", + "jni", + "log", + "once_cell", + "rustls", + "rustls-native-certs", + "rustls-platform-verifier-android", + "rustls-webpki", + "security-framework", + "security-framework-sys", + "webpki-root-certs", + "windows-sys 0.61.2", +] + +[[package]] +name = "rustls-platform-verifier-android" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f87165f0995f63a9fbeea62b64d10b4d9d8e78ec6d7d51fb2125fda7bb36788f" + [[package]] name = "rustls-webpki" version = "0.103.15" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f3c3cf1d8b1e7d4927e2d154c3fcb02979afb9939629c62cd9048d4f07b60ac2" dependencies = [ + "aws-lc-rs", "ring", "rustls-pki-types", "untrusted", @@ -1195,6 +1445,15 @@ version = "1.0.23" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "cf54715a573b99ac80df0bc206da022bcd442c974952c7b9720069370852e21f" +[[package]] +name = "same-file" +version = "1.0.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "93fc1dc3aaa9bfed95e02e6eadabb4baf7e3078b0bd1b4d7b6b0b68378900502" +dependencies = [ + "winapi-util", +] + [[package]] name = "schannel" version = "0.1.29" @@ -1335,6 +1594,16 @@ version = "0.3.10" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3a219298ac11a56ea9a6d2120044824d6f01aeb034955e7af7bc16858527deea" +[[package]] +name = "simd_cesu8" +version = "1.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "11031e251abf8611c80f460e19dbdeb54a66db918e49c65a7065b46ac7aec520" +dependencies = [ + "rustc_version", + "simdutf8", +] + [[package]] name = "simdutf8" version = "0.1.5" @@ -1476,6 +1745,12 @@ dependencies = [ "syn 3.0.6", ] +[[package]] +name = "thunk-rs" +version = "0.3.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9b4c52c965c79d34af24f3c3a891c4a1441c9ae20e7465607c20ecf3a544d0e1" + [[package]] name = "time" version = "0.3.55" @@ -1516,6 +1791,12 @@ dependencies = [ "zerovec", ] +[[package]] +name = "tinyvec" +version = "1.13.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fd3ca314f692efd6c868f8408f53fe444634a845f96c028b97d35f6a1f79f0ee" + [[package]] name = "tokio" version = "1.53.2" @@ -1656,9 +1937,12 @@ dependencies = [ "log", "native-tls", "rand", + "rustls", + "rustls-pki-types", "sha1", "thiserror", "url", + "webpki-roots 0.26.11", ] [[package]] @@ -1693,6 +1977,7 @@ dependencies = [ "log", "native-tls", "percent-encoding", + "rustls", "rustls-pki-types", "serde", "serde_json", @@ -1700,6 +1985,7 @@ dependencies = [ "ureq-proto", "utf8-zero", "webpki-root-certs", + "webpki-roots 1.0.9", ] [[package]] @@ -1756,6 +2042,16 @@ version = "0.9.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0b928f33d975fc6ad9f86c8f283853ad26bdd5b10b7f1542aa2fa15e2289105a" +[[package]] +name = "walkdir" +version = "2.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "29790946404f91d9c5d06f9874efddea1dc06c5efe94541a7d6863108e3a5e4b" +dependencies = [ + "same-file", + "winapi-util", +] + [[package]] name = "want" version = "0.3.2" @@ -1837,6 +2133,16 @@ dependencies = [ "wasm-bindgen", ] +[[package]] +name = "web-time" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5a6580f308b1fad9207618087a65c04e7a10bc77e02c8e84e9b00dd4b12fa0bb" +dependencies = [ + "js-sys", + "wasm-bindgen", +] + [[package]] name = "webpki-root-certs" version = "1.0.9" @@ -1846,6 +2152,24 @@ dependencies = [ "rustls-pki-types", ] +[[package]] +name = "webpki-roots" +version = "0.26.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "521bc38abb08001b01866da9f51eb7c5d647a19260e00054a8c7fd5f9e57f7a9" +dependencies = [ + "webpki-roots 1.0.9", +] + +[[package]] +name = "webpki-roots" +version = "1.0.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7dcd9d09a39985f5344844e66b0c530a33843579125f23e21e9f0f220850f22a" +dependencies = [ + "rustls-pki-types", +] + [[package]] name = "winapi" version = "0.3.9" @@ -1862,6 +2186,15 @@ version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" +[[package]] +name = "winapi-util" +version = "0.1.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c2a7b1c03c876122aa43f3020e6c3c3ee5c05081c9a00739faf7503aeba10d22" +dependencies = [ + "windows-sys 0.61.2", +] + [[package]] name = "winapi-x86_64-pc-windows-gnu" version = "0.4.0" diff --git a/Cargo.toml b/Cargo.toml index baf0cfbb..5d4d8f2c 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -10,15 +10,35 @@ rust-version = "1.98" arc-swap = "=1.9.2" cfg-if = "=1.0.5" dotenvy = "=0.15.7" -# Releases are bare binaries; TLS goes through native-tls like tungstenite -self_update = { version = "=1.3.0", default-features = false, features = ["github", "reqwest", "native-tls"] } +# Only for the xp feature, which needs ring rather than aws-lc-rs +rustls = { version = "=0.23.45", optional = true, default-features = false, features = ["ring", "std", "tls12"] } +# Releases are bare binaries; the HTTP client and TLS come from the native-tls or xp feature +self_update = { version = "=1.3.0", default-features = false, features = ["github"] } serde = { version = "=1.0.229", features = ["derive"] } serde_json = "=1.0.151" -tungstenite = { version = "=0.30.0", features = ["native-tls", "url"] } +tungstenite = { version = "=0.30.0", features = ["url"] } sysinfo = { version = "=0.39.6", default-features = false, features = ["component", "disk", "multithread", "system"] } +[features] +default = ["native-tls"] +# TLS goes through native-tls for both the WebSocket and the updater +native-tls = ["tungstenite/native-tls", "self_update/reqwest", "self_update/native-tls", "dep:openssl"] +# Windows XP build (`--target i686-pc-windows-msvc --no-default-features --features xp`). +# XP has no usable TLS stack and outdated roots, so TLS is rustls with ring and the +# bundled Mozilla roots, and the updater uses ureq, since reqwest's rustls needs +# aws-lc-rs and the system roots. VC-LTL5 and YY-Thunks are linked through +# thunk-rs, which needs curl and 7z unless VC_LTL and YY_THUNKS point at them. +xp = [ + "dep:rustls", + "dep:thunk-rs", + "tungstenite/rustls-tls-webpki-roots", + "self_update/ureq", + "self_update/rustls", +] + [build-dependencies] git2 = { version = "=0.21.0", default-features = false } +thunk-rs = { version = "=0.3.5", optional = true, features = ["subsystem_windows"] } [target.'cfg(windows)'.build-dependencies] winres = "=0.1.12" @@ -27,7 +47,7 @@ winres = "=0.1.12" windows-sys = { version = "=0.61.2", features = ["Win32_Foundation", "Win32_System_Power"] } [target.'cfg(not(any(target_os = "windows", target_os = "macos", target_os = "ios")))'.dependencies] -openssl = { version = "=0.10.81", features = ["vendored"] } +openssl = { version = "=0.10.81", optional = true, features = ["vendored"] } [lints.clippy] pedantic = "warn" diff --git a/README.md b/README.md index b30a56a5..faab31ca 100644 --- a/README.md +++ b/README.md @@ -33,7 +33,7 @@ HOSTNAME=ホスト名として表示させたい文字列 ## 対応環境 -最近の Windows (Server 含む), macOS, Linux であれば動作すると思います。\ +最近の Windows (Server 含む), macOS, Linux であれば動作すると思います。Windows XP などの古い Windows では、32 ビット版 (`pcsc-rs-…-i686-pc-windows-msvc.exe`) を[手動で入れて](#windows)ください。\ もし動作しない場合は [Issues](https://github.com/Zel9278/pcsc-rs/issues) から報告をお願いします。 ## 使い方 diff --git a/build.rs b/build.rs index a29e3f2b..9c7d59cc 100644 --- a/build.rs +++ b/build.rs @@ -16,6 +16,8 @@ fn main() -> io::Result<()> { .set_icon("assets/icon.ico") .compile()?; } + #[cfg(feature = "xp")] + thunk::thunk(); Ok(()) } diff --git a/src/client.rs b/src/client.rs index dca453cd..381d10aa 100644 --- a/src/client.rs +++ b/src/client.rs @@ -139,7 +139,10 @@ fn send(socket: &mut Socket, message: &ClientMessage) -> tungstenite::Result<()> fn set_read_timeout(socket: &Socket) -> std::io::Result<()> { let stream = match socket.get_ref() { MaybeTlsStream::Plain(stream) => stream, + #[cfg(feature = "native-tls")] MaybeTlsStream::NativeTls(stream) => stream.get_ref(), + #[cfg(feature = "xp")] + MaybeTlsStream::Rustls(stream) => stream.get_ref(), _ => return Ok(()), }; stream.set_read_timeout(Some(READ_TIMEOUT)) diff --git a/src/lib.rs b/src/lib.rs index 44d1bad8..89b36da1 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -14,6 +14,12 @@ mod update; pub use config::Config; +// With both, tungstenite and self_update pick native-tls, which fails on XP +#[cfg(all(feature = "native-tls", feature = "xp"))] +compile_error!( + "the xp feature replaces native-tls: build with --no-default-features --features xp" +); + /// Checks for an update, starts the system monitor, keeps a connection to the /// PC Status server, and never returns. pub fn start(config: &Config) -> ! { diff --git a/src/status.rs b/src/status.rs index 759da300..3ad560a7 100644 --- a/src/status.rs +++ b/src/status.rs @@ -268,13 +268,23 @@ fn platform() -> (String, String, Option) { crate::android::device_name().or_else(System::host_name), ); } - ( - System::name().unwrap_or_else(|| "Unknown OS".into()), - System::os_version() - .or_else(System::kernel_version) - .unwrap_or_default(), - System::host_name(), - ) + #[cfg_attr(not(windows), allow(unused_mut))] + let mut name = System::name().unwrap_or_else(|| "Unknown OS".into()); + #[cfg_attr(not(windows), allow(unused_mut))] + let mut version = System::os_version() + .or_else(System::kernel_version) + .unwrap_or_default(); + // sysinfo takes the major version from CurrentMajorVersionNumber, which only + // exists since Windows 10, so older versions come out as "0 (2600)". Use the + // product name ("Microsoft Windows XP") there instead. + #[cfg(windows)] + if version.starts_with("0 ") + && let Some(product) = System::long_os_version() + { + version.drain(.."0 ".len()); + name = product; + } + (name, version, System::host_name()) } #[cfg(test)]