diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..12376f9 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,71 @@ +# If this file is renamed, the incrementing run attempt number will be reset. + +name: CI + +on: + push: + branches: [ "dev", "release" ] + pull_request: + branches: [ "dev", "release" ] + +env: + CI_BUILD_NUMBER_BASE: ${{ github.run_number }} + CI_TARGET_BRANCH: ${{ github.head_ref || github.ref_name }} + CI_EVENT: ${{ github.event_name }} + +jobs: + build-windows: + name: Build (Windows) + runs-on: windows-latest + needs: build-linux + + permissions: + contents: write + + steps: + - uses: actions/checkout@v4 + - name: Setup + uses: actions/setup-dotnet@v4 + with: + dotnet-version: 10.0.x + - uses: actions/download-artifact@v5 + with: + name: squiflog-x86_64-unknown-linux-musl + path: ./target/x86_64-unknown-linux-musl/release + - uses: actions/download-artifact@v5 + with: + name: squiflog-aarch64-unknown-linux-musl + path: ./target/aarch64-unknown-linux-musl/release + - name: Build and Publish + env: + DOTNET_CLI_TELEMETRY_OPTOUT: true + NUGET_API_KEY: ${{ secrets.NUGET_API_KEY }} + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + shell: pwsh + run: | + ./ci/win-x64/build.ps1 + + build-linux: + name: Build (Linux) + runs-on: ubuntu-22.04 + + permissions: + contents: write + + steps: + - uses: actions/checkout@v4 + - name: Build and Publish + env: + DOCKER_USER: ${{ secrets.DOCKER_USER }} + DOCKER_TOKEN: ${{ secrets.DOCKER_TOKEN }} + shell: pwsh + run: | + ./ci/linux-x64/build.ps1 + - uses: actions/upload-artifact@v4 + with: + name: squiflog-x86_64-unknown-linux-musl + path: ./target/x86_64-unknown-linux-musl/release/squiflog + - uses: actions/upload-artifact@v4 + with: + name: squiflog-aarch64-unknown-linux-musl + path: ./target/aarch64-unknown-linux-musl/release/squiflog diff --git a/Cargo.lock b/Cargo.lock index 7065b8e..27d56cf 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1,110 +1,62 @@ # This file is automatically @generated by Cargo. # It is not intended for manual editing. -version = 3 - -[[package]] -name = "addr2line" -version = "0.22.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6e4503c46a5c0c7844e948c9a4d6acd9f50cccb4de1c48eb9e291ea17470c678" -dependencies = [ - "gimli", -] - -[[package]] -name = "adler" -version = "1.0.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f26201604c87b1e01bd3d98f8d5d9a8fcbb815e8cedb41ffccbeb4bf593a35fe" - -[[package]] -name = "adler32" -version = "1.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "aae1277d39aeec15cb388266ecc24b11c80469deae6067e17a1a7aa9e5c1f234" - -[[package]] -name = "android-tzdata" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e999941b234f3131b00bc13c22d06e8c5ff726d1b6318ac7eb276997bbb4fef0" +version = 4 [[package]] name = "android_system_properties" -version = "0.1.5" +version = "0.1.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "819e7219dbd41043ac279b19830f2efc897156490d7fd6ea916720117ee66311" +checksum = "ae221649c9976a6f6c56ae1facf410f3ddb33cc661c4b7b61020a912d4237fbc" dependencies = [ "libc", ] [[package]] name = "autocfg" -version = "1.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0c4b4d0bd25bd0b74681c0ad21497610ce1b7c91b1022cd21c80c6fbdd9476b0" - -[[package]] -name = "backtrace" -version = "0.3.73" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5cc23269a4f8976d0a4d2e7109211a419fe30e8d88d677cd60b6bc79c5732e0a" -dependencies = [ - "addr2line", - "cc", - "cfg-if", - "libc", - "miniz_oxide", - "object", - "rustc-demangle", -] - -[[package]] -name = "bitflags" -version = "2.6.0" +version = "1.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b048fb63fd8b5923fc5aa7b340d8e156aec7ec02f0c78fa8a6ddc2613f6f71de" +checksum = "f2032f911046de80f0a198e0901378627c33f59ea0ac00e363d481118bd70a53" [[package]] name = "bumpalo" -version = "3.16.0" +version = "3.20.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "79296716171880943b8470b5f8d03aa55eb2e645a4874bdbb28adb49162e012c" +checksum = "72f5acc6cb2ba439de613abc23857ec3d78374d8ed5ac84e9d11336e87da8649" [[package]] name = "bytes" -version = "1.7.1" +version = "1.12.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8318a53db07bb3f8dca91a600466bdb3f2eaadeedfdbcf02e1accbad9271ba50" +checksum = "fc652a48c352aef3ea3aed32080501cf3ef6ed5da78602a020c991775b0aff04" [[package]] name = "cc" -version = "1.1.11" +version = "1.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5fb8dd288a69fc53a1996d7ecfbf4a20d59065bff137ce7e56bbd620de191189" +checksum = "877bf67ac8e52449eb2f9e98a344ea163beb70dd1f9eebe3cc5357dcfeaee4df" dependencies = [ + "find-msvc-tools", "shlex", ] [[package]] name = "cfg-if" -version = "1.0.0" +version = "1.0.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" +checksum = "4e7648175b45a9a48536d676f68d918270699102aa8dab5496df06904c914600" [[package]] name = "chrono" -version = "0.4.38" +version = "0.4.45" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a21f936df1771bf62b77f047b726c4625ff2e8aa607c01ec06e5a05bd8463401" +checksum = "1aa79e62e7697b8e29b513a68abacf485adcd1fe8284a4316c5ae868e6633327" dependencies = [ - "android-tzdata", "iana-time-zone", "js-sys", "num-traits", "serde", "wasm-bindgen", - "windows-targets", + "windows-link", ] [[package]] @@ -114,19 +66,26 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "773648b94d0e5d620f64f280777445740e61fe701025087ec8b57f45c791888b" [[package]] -name = "crc32fast" -version = "1.4.2" +name = "errno" +version = "0.3.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a97769d94ddab943e4510d138150169a2758b5ef3eb191a9ee688de3e23ef7b3" +checksum = "39cab71617ae0d63f51a36d69f866391735b51691dbda63cf6f96d042b63efeb" dependencies = [ - "cfg-if", + "libc", + "windows-sys", ] +[[package]] +name = "find-msvc-tools" +version = "0.1.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1c66915cc5391097de7a2b0b972e8505aa33c0df401fd3a6811dbdb32881ba48" + [[package]] name = "futures" -version = "0.3.30" +version = "0.3.34" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "645c6916888f6cb6350d2550b80fb63e734897a8498abe35cfb732b6487804b0" +checksum = "9a31d2a3fbaaeb2af2368bbdd904aa8e812d3c04a1ee10d3171f52d556e5d0a3" dependencies = [ "futures-channel", "futures-core", @@ -139,9 +98,9 @@ dependencies = [ [[package]] name = "futures-channel" -version = "0.3.30" +version = "0.3.34" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "eac8f7d7865dcb88bd4373ab671c8cf4508703796caa2b1985a9ca867b3fcb78" +checksum = "b1f9e3d69d39e4862ffed03ed071a76f9a13ba1d9109d355b0f0aa6b15e393c4" dependencies = [ "futures-core", "futures-sink", @@ -149,15 +108,15 @@ dependencies = [ [[package]] name = "futures-core" -version = "0.3.30" +version = "0.3.34" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dfc6580bb841c5a68e9ef15c77ccc837b40a7504914d52e47b8b0e9bbda25a1d" +checksum = "92d699e522242e69e3003b94ecc1f960f3a5e015aa7c5d7486e65ad01dd94f5e" [[package]] name = "futures-executor" -version = "0.3.30" +version = "0.3.34" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a576fc72ae164fca6b9db127eaa9a9dda0d61316034f33a0a0d4eda41f02b01d" +checksum = "031b47cf1a3c6cc8bc2fc76cd437f521619387907d469316e7c0bc278f1f5432" dependencies = [ "futures-core", "futures-task", @@ -166,38 +125,38 @@ dependencies = [ [[package]] name = "futures-io" -version = "0.3.30" +version = "0.3.34" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a44623e20b9681a318efdd71c299b6b222ed6f231972bfe2f224ebad6311f0c1" +checksum = "53c0fa8157de1303bfffdaa1cc2a673bfffb60102f76b0ef4441659124373fed" [[package]] name = "futures-macro" -version = "0.3.30" +version = "0.3.34" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "87750cf4b7a4c0625b1529e4c543c2182106e4dedc60a2a6455e00d212c489ac" +checksum = "9fb9654ba8355388abeb8dcb4fc62f511300867002afc858860463bdd9fe0c44" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 3.0.9", ] [[package]] name = "futures-sink" -version = "0.3.30" +version = "0.3.34" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9fb8e00e87438d937621c1c6269e53f536c14d3fbd6a042bb24879e57d474fb5" +checksum = "1944426bf7d03f1d14f708785e4b33efd750b36d48a157b836b3efc15ede8e1d" [[package]] name = "futures-task" -version = "0.3.30" +version = "0.3.34" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "38d84fa142264698cdce1a9f9172cf383a0c82de1bddcf3092901442c4097004" +checksum = "cd417de3d1d015fc3bfd2b1ea46dfc7bab72ef86f1cc7cc9c78e728b34a6d1fd" [[package]] name = "futures-util" -version = "0.3.30" +version = "0.3.34" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3d6401deb83407ab3da39eba7e33987a73c3df0c82b4bb5813ee871c19c41d48" +checksum = "0d50a92467f8ba5dd6e3ee5d4bd04d73ab2e4e1c44474a0674821dfce14b79bc" dependencies = [ "futures-channel", "futures-core", @@ -207,32 +166,20 @@ dependencies = [ "futures-task", "memchr", "pin-project-lite", - "pin-utils", "slab", ] -[[package]] -name = "gimli" -version = "0.29.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "40ecd4077b5ae9fd2e9e169b102c6c330d0605168eb0e8bf79952b256dbefffd" - -[[package]] -name = "hermit-abi" -version = "0.3.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d231dfb89cfffdbc30e7fc41579ed6066ad03abda9e567ccafae602b97ec5024" - [[package]] name = "iana-time-zone" -version = "0.1.60" +version = "0.1.65" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e7ffbb5a1b541ea2561f8c41c087286cc091e21e556a4f09a8f6cbf17b69b141" +checksum = "e31bc9ad994ba00e440a8aa5c9ef0ec67d5cb5e5cb0cc7f8b744a35b389cc470" dependencies = [ "android_system_properties", "core-foundation-sys", "iana-time-zone-haiku", "js-sys", + "log", "wasm-bindgen", "windows-core", ] @@ -246,100 +193,58 @@ dependencies = [ "cc", ] -[[package]] -name = "inlinable_string" -version = "0.1.15" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c8fae54786f62fb2918dcfae3d568594e50eb9b5c25bf04371af6fe7516452fb" - [[package]] name = "itoa" -version = "1.0.11" +version = "1.0.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "49f1f14873335454500d59611f1cf4a4b0f786f9ac11f4312a78e4cf2566695b" +checksum = "8f42a60cbdf9a97f5d2305f08a87dc4e09308d1276d28c869c684d7777685682" [[package]] name = "js-sys" -version = "0.3.70" +version = "0.3.106" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1868808506b929d7b0cfa8f75951347aa71bb21144b7791bae35d9bccfcfe37a" +checksum = "7883d941dae510fb2d978fc3fe018c71c9e2892fd38854de3e8b92c2e5ad9cc5" dependencies = [ + "cfg-if", + "futures-util", "wasm-bindgen", ] [[package]] name = "lazy_static" -version = "1.5.0" +version = "1.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bbd2bcb4c963f2ddae06a2efc7e9f3591312473c50c6685e1f298068316e66fe" +checksum = "20870f649af7073d53e38067b2a84312175d56ea15217e1b15bc83506ec50afb" [[package]] name = "libc" -version = "0.2.155" +version = "0.2.191" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "97b3888a4aecf77e811145cadf6eef5901f4782c53886191b2f693f24761847c" - -[[package]] -name = "libflate" -version = "0.1.27" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d9135df43b1f5d0e333385cb6e7897ecd1a43d7d11b91ac003f4d2c2d2401fdd" -dependencies = [ - "adler32", - "crc32fast", - "rle-decode-fast", - "take_mut", -] - -[[package]] -name = "lock_api" -version = "0.4.12" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "07af8b9cdd281b7915f413fa73f29ebd5d55d0d3f0155584dade1ff18cea1b17" -dependencies = [ - "autocfg", - "scopeguard", -] +checksum = "65cd87c9a6d60536580b316ad985726104730a5151c99845f2490428ef91240a" [[package]] name = "log" -version = "0.4.22" +version = "0.4.34" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a7a70ba024b9dc04c27ea2f0c0548feb474ec5c54bba33a7f72f873a39d07b24" +checksum = "f9f8bd3e56ce4dfc153cf470fffbfa98c7620958b312ca5c3a4b8d5181fd13c6" [[package]] name = "memchr" -version = "2.7.4" +version = "2.8.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "78ca9ab1a0babb1e7d5695e3530886289c18cf2f87ec19a575a0abdce112e3a3" - -[[package]] -name = "miniz_oxide" -version = "0.7.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b8a240ddb74feaf34a79a7add65a741f3167852fba007066dcac1ca548d89c08" -dependencies = [ - "adler", -] +checksum = "cf8baf1c55e62ffcace7a9f06f4bd9cd3f0c4beb022d3b367256b91b87513d98" [[package]] name = "mio" -version = "1.0.2" +version = "1.2.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "80e04d1dcff3aae0704555fe5fee3bcfaf3d1fdf8a7e521d5b9d2b42acb52cec" +checksum = "1788edb87fdc09c7e26304471e2f5be8cdefb1b6930d6e3985fc02ff53bf86ee" dependencies = [ - "hermit-abi", "libc", "wasi", "windows-sys", ] -[[package]] -name = "new_debug_unreachable" -version = "1.0.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "650eef8c711430f1a879fdd01d4745a7deea475becfb90269c06775983bbf086" - [[package]] name = "num-traits" version = "0.2.19" @@ -349,195 +254,111 @@ dependencies = [ "autocfg", ] -[[package]] -name = "object" -version = "0.36.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "27b64972346851a39438c60b341ebc01bba47464ae329e55cf343eb93964efd9" -dependencies = [ - "memchr", -] - [[package]] name = "once_cell" -version = "1.19.0" +version = "1.21.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3fdb12b2476b595f9358c5161aa467c2438859caa136dec86c26fdd2efe17b92" - -[[package]] -name = "parking_lot" -version = "0.12.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f1bf18183cf54e8d6059647fc3063646a1801cf30896933ec2311622cc4b9a27" -dependencies = [ - "lock_api", - "parking_lot_core", -] - -[[package]] -name = "parking_lot_core" -version = "0.9.10" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1e401f977ab385c9e4e3ab30627d6f26d00e2c73eef317493c4ec6d468726cf8" -dependencies = [ - "cfg-if", - "libc", - "redox_syscall", - "smallvec", - "windows-targets", -] - -[[package]] -name = "phf_shared" -version = "0.10.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b6796ad771acdc0123d2a88dc428b5e38ef24456743ddb1744ed628f9815c096" -dependencies = [ - "siphasher", -] +checksum = "9f7c3e4beb33f85d45ae3e3a1792185706c8e16d043238c593331cc7cd313b50" [[package]] name = "pin-project-lite" -version = "0.2.14" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bda66fc9667c18cb2758a2ac84d1167245054bcf85d5d1aaa6923f45801bdd02" - -[[package]] -name = "pin-utils" -version = "0.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8b870d8c151b6f2fb93e84a13146138f05d02ed11c7e7c54f8826aaaf7c9f184" - -[[package]] -name = "precomputed-hash" -version = "0.1.1" +version = "0.2.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "925383efa346730478fb4838dbe9137d2a47675ad789c546d150a6e1dd4ab31c" +checksum = "a89322df9ebe1c1578d689c92318e070967d1042b512afbe49518723f4e6d5cd" [[package]] name = "proc-macro2" -version = "1.0.86" +version = "1.0.107" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5e719e8df665df0d1c8fbfd238015744736151d4445ec0836b8e628aae103b77" +checksum = "985e7ec9bb745e6ce6535b544d84d6cd6f7ad8bd711c398938ae983b91a766d9" dependencies = [ "unicode-ident", ] [[package]] name = "quote" -version = "1.0.36" +version = "1.0.47" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0fa76aaf39101c457836aec0ce2316dbdc3ab723cdda1c6bd4e6ad4208acaca7" +checksum = "1fbf4db142a473a8d80c26bbf18454ed458bf8d26c8219c331daecfdbd079001" dependencies = [ "proc-macro2", ] [[package]] -name = "redox_syscall" -version = "0.5.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2a908a6e00f1fdd0dfd9c0eb08ce85126f6d8bbda50017e74bc4a4b7d4a926a4" -dependencies = [ - "bitflags", -] - -[[package]] -name = "rle-decode-fast" -version = "1.0.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3582f63211428f83597b51b2ddb88e2a91a9d52d12831f9d08f5e624e8977422" - -[[package]] -name = "rustc-demangle" -version = "0.1.24" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "719b953e2095829ee67db738b3bfa9fa368c94900df327b3f07fe6e794d2fe1f" - -[[package]] -name = "ryu" -version = "1.0.18" +name = "rustversion" +version = "1.0.23" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f3cb5ba0dc43242ce17de99c180e96db90b235b8a9fdc9543c96d2209116bd9f" +checksum = "cf54715a573b99ac80df0bc206da022bcd442c974952c7b9720069370852e21f" [[package]] -name = "scopeguard" -version = "1.2.0" +name = "serde" +version = "1.0.229" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49" +checksum = "4148590afebada386688f18773da617792bf2ef03ffc1e4cbd2b1d45b023e0ba" +dependencies = [ + "serde_core", +] [[package]] -name = "serde" -version = "1.0.207" +name = "serde_core" +version = "1.0.229" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5665e14a49a4ea1b91029ba7d3bca9f299e1f7cfa194388ccc20f14743e784f2" +checksum = "67dca2c9c51e58a4791a4b1ed58308b39c64224d349a935ab5039aa360942a48" dependencies = [ "serde_derive", ] [[package]] name = "serde_derive" -version = "1.0.207" +version = "1.0.229" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6aea2634c86b0e8ef2cfdc0c340baede54ec27b1e46febd7f80dffb2aa44a00e" +checksum = "e7a5d71263a5a7d47b41f6b3f06ba276f10cc18b0931f1799f710578e2309348" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 3.0.9", ] [[package]] name = "serde_json" -version = "1.0.125" +version = "1.0.154" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "83c8e735a073ccf5be70aa8066aa984eaf2fa000db6c8d0100ae605b366d31ed" +checksum = "e7e9cc8b1b85264074fbcc02a88680c4096b1e47df8f739dceb03bf482f04bd6" dependencies = [ "itoa", "memchr", - "ryu", "serde", + "serde_core", + "zmij", ] [[package]] name = "shlex" -version = "1.3.0" +version = "2.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0fda2ff0d084019ba4d7c6f371c95d8fd75ce3524c3cb8fb653a3023f6323e64" +checksum = "f8fadd59c855ef2080decdef8ff161eb6661b86933c9d82e5ba29dc602a55aba" [[package]] name = "signal-hook-registry" -version = "1.4.2" +version = "1.4.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a9e9e0b4211b72e7b8b6e85c807d36c212bdb33ea8587f7569562a84df5465b1" +checksum = "c4db69cba1110affc0e9f7bcd48bbf87b3f4fc7c61fc9155afd4c469eb3d6c1b" dependencies = [ + "errno", "libc", ] -[[package]] -name = "siphasher" -version = "0.3.11" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "38b58827f4464d87d377d175e90bf58eb00fd8716ff0a62f80356b5e61555d0d" - [[package]] name = "slab" -version = "0.4.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8f92a496fb766b417c996b9c5e57daf2f7ad3b0bebe1ccfca4856390e3d3bb67" -dependencies = [ - "autocfg", -] - -[[package]] -name = "smallvec" -version = "1.13.2" +version = "0.4.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3c5e1a9a646d36c3599cd173a41282daf47c44583ad367b8e6837255952e5c67" +checksum = "0c790de23124f9ab44544d7ac05d60440adc586479ce501c1d6d7da3cd8c9cf5" [[package]] name = "socket2" -version = "0.5.7" +version = "0.6.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ce305eb0b4296696835b71df73eb912e0f1ffd2556a501fcede6e0c50349191c" +checksum = "c3d1e2c7f27f8d4cb10542a02c49005dbd6e93095799d6f3be745fae9f8fedd4" dependencies = [ "libc", "windows-sys", @@ -550,56 +371,42 @@ dependencies = [ "bytes", "chrono", "futures", - "inlinable_string", "lazy_static", - "libflate", - "pin-utils", "serde", "serde_derive", "serde_json", - "string_cache", "tokio", "tokio-util", ] [[package]] -name = "string_cache" -version = "0.8.7" +name = "syn" +version = "2.0.119" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f91138e76242f575eb1d3b38b4f1362f10d3a43f47d182a5b359af488a02293b" +checksum = "872831b642d1a07999a962a351ed35b955ea2cfc8f3862091e2a240a84f17297" dependencies = [ - "new_debug_unreachable", - "once_cell", - "parking_lot", - "phf_shared", - "precomputed-hash", - "serde", + "proc-macro2", + "quote", + "unicode-ident", ] [[package]] name = "syn" -version = "2.0.74" +version = "3.0.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1fceb41e3d546d0bd83421d3409b1460cc7444cd389341a4c880fe7a042cb3d7" +checksum = "d78c8dee4c7bf0e14673097256fed6142ce9d3b85a408189d07482442145823b" dependencies = [ "proc-macro2", "quote", "unicode-ident", ] -[[package]] -name = "take_mut" -version = "0.2.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f764005d11ee5f36500a149ace24e00e3da98b0158b3e2d53a7495660d3f4d60" - [[package]] name = "tokio" -version = "1.39.2" +version = "1.54.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "daa4fb1bc778bd6f04cbfc4bb2d06a7396a8f299dc33ea1900cedaa316f467b1" +checksum = "b52fd3255258d26fac7264ab5a76b53c13367136dc011d3d6ad4f8ed070396a3" dependencies = [ - "backtrace", "libc", "mio", "pin-project-lite", @@ -610,60 +417,48 @@ dependencies = [ [[package]] name = "tokio-util" -version = "0.7.11" +version = "0.7.20" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9cf6b47b3771c49ac75ad09a6162f53ad4b8088b76ac60e8ec1455b31a189fe1" +checksum = "e464cf451ba96ebfc6f9b6542f17ee8b8956e33f1e40d9690624e59d7a7f8a4b" dependencies = [ "bytes", "futures-core", "futures-sink", + "libc", "pin-project-lite", "tokio", ] [[package]] name = "unicode-ident" -version = "1.0.12" +version = "1.0.27" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3354b9ac3fae1ff6755cb6db53683adb661634f67557942dea4facebec0fee4b" +checksum = "a2c754d6c33795a1c324727428e5a7dedb5b06195f9890bdbcba760d3e246563" [[package]] name = "wasi" -version = "0.11.0+wasi-snapshot-preview1" +version = "0.11.1+wasi-snapshot-preview1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" +checksum = "ccf3ec651a847eb01de73ccad15eb7d99f80485de043efb2f370cd654f4ea44b" [[package]] name = "wasm-bindgen" -version = "0.2.93" +version = "0.2.129" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a82edfc16a6c469f5f44dc7b571814045d60404b55a0ee849f9bcfa2e63dd9b5" +checksum = "9bb54f33acc68fd454578d9820b0bde1a1a3d17aa17bb7b6595806d02886d409" dependencies = [ "cfg-if", "once_cell", + "rustversion", "wasm-bindgen-macro", -] - -[[package]] -name = "wasm-bindgen-backend" -version = "0.2.93" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9de396da306523044d3302746f1208fa71d7532227f15e347e2d93e4145dd77b" -dependencies = [ - "bumpalo", - "log", - "once_cell", - "proc-macro2", - "quote", - "syn", "wasm-bindgen-shared", ] [[package]] name = "wasm-bindgen-macro" -version = "0.2.93" +version = "0.2.129" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "585c4c91a46b072c92e908d99cb1dcdf95c5218eeb6f3bf1efa991ee7a68cccf" +checksum = "2e29d0c35b16e224a7eeb5cd2d25e3e1968fbd65604117b44d3b789d00ee8535" dependencies = [ "quote", "wasm-bindgen-macro-support", @@ -671,101 +466,96 @@ dependencies = [ [[package]] name = "wasm-bindgen-macro-support" -version = "0.2.93" +version = "0.2.129" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "afc340c74d9005395cf9dd098506f7f44e38f2b4a21c6aaacf9a105ea5e1e836" +checksum = "6f501a8bc3719dba86ef8ae4728879c08001bea749eb1333ac5b91e040e2a6b7" dependencies = [ + "bumpalo", "proc-macro2", "quote", - "syn", - "wasm-bindgen-backend", + "syn 3.0.9", "wasm-bindgen-shared", ] [[package]] name = "wasm-bindgen-shared" -version = "0.2.93" +version = "0.2.129" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c62a0a307cb4a311d3a07867860911ca130c3494e8c2719593806c08bc5d0484" +checksum = "23f0c9c52aa7cd7d77769a4cfe2a9adb1b331f489a41d912ce14513d5ab995c6" +dependencies = [ + "unicode-ident", +] [[package]] name = "windows-core" -version = "0.52.0" +version = "0.62.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "33ab640c8d7e35bf8ba19b884ba838ceb4fba93a4e8c65a9059d08afcfc683d9" +checksum = "b8e83a14d34d0623b51dce9581199302a221863196a1dde71a7663a4c2be9deb" dependencies = [ - "windows-targets", + "windows-implement", + "windows-interface", + "windows-link", + "windows-result", + "windows-strings", ] [[package]] -name = "windows-sys" -version = "0.52.0" +name = "windows-implement" +version = "0.60.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "282be5f36a8ce781fad8c8ae18fa3f9beff57ec1b52cb3de0789201425d9a33d" +checksum = "053e2e040ab57b9dc951b72c264860db7eb3b0200ba345b4e4c3b14f67855ddf" dependencies = [ - "windows-targets", + "proc-macro2", + "quote", + "syn 2.0.119", ] [[package]] -name = "windows-targets" -version = "0.52.6" +name = "windows-interface" +version = "0.59.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9b724f72796e036ab90c1021d4780d4d3d648aca59e491e6b98e725b84e99973" +checksum = "3f316c4a2570ba26bbec722032c4099d8c8bc095efccdc15688708623367e358" dependencies = [ - "windows_aarch64_gnullvm", - "windows_aarch64_msvc", - "windows_i686_gnu", - "windows_i686_gnullvm", - "windows_i686_msvc", - "windows_x86_64_gnu", - "windows_x86_64_gnullvm", - "windows_x86_64_msvc", + "proc-macro2", + "quote", + "syn 2.0.119", ] [[package]] -name = "windows_aarch64_gnullvm" -version = "0.52.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "32a4622180e7a0ec044bb555404c800bc9fd9ec262ec147edd5989ccd0c02cd3" - -[[package]] -name = "windows_aarch64_msvc" -version = "0.52.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "09ec2a7bb152e2252b53fa7803150007879548bc709c039df7627cabbd05d469" - -[[package]] -name = "windows_i686_gnu" -version = "0.52.6" +name = "windows-link" +version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8e9b5ad5ab802e97eb8e295ac6720e509ee4c243f69d781394014ebfe8bbfa0b" +checksum = "f0805222e57f7521d6a62e36fa9163bc891acd422f971defe97d64e70d0a4fe5" [[package]] -name = "windows_i686_gnullvm" -version = "0.52.6" +name = "windows-result" +version = "0.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0eee52d38c090b3caa76c563b86c3a4bd71ef1a819287c19d586d7334ae8ed66" - -[[package]] -name = "windows_i686_msvc" -version = "0.52.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "240948bc05c5e7c6dabba28bf89d89ffce3e303022809e73deaefe4f6ec56c66" +checksum = "7781fa89eaf60850ac3d2da7af8e5242a5ea78d1a11c49bf2910bb5a73853eb5" +dependencies = [ + "windows-link", +] [[package]] -name = "windows_x86_64_gnu" -version = "0.52.6" +name = "windows-strings" +version = "0.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "147a5c80aabfbf0c7d901cb5895d1de30ef2907eb21fbbab29ca94c5b08b1a78" +checksum = "7837d08f69c77cf6b07689544538e017c1bfcf57e34b4c0ff58e6c2cd3b37091" +dependencies = [ + "windows-link", +] [[package]] -name = "windows_x86_64_gnullvm" -version = "0.52.6" +name = "windows-sys" +version = "0.61.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "24d5b23dc417412679681396f2b49f3de8c1473deb516bd34410872eff51ed0d" +checksum = "ae137229bcbd6cdf0f7b80a31df61766145077ddf49416a728b02cb3921ff3fc" +dependencies = [ + "windows-link", +] [[package]] -name = "windows_x86_64_msvc" -version = "0.52.6" +name = "zmij" +version = "1.0.23" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "589f6da84c646204747d1270a2a5661ea66ed1cced2631d546fdfb155959f9ec" +checksum = "29666d0abbfad1e3dc4dcf6144730dd3a3ab225bbbdac83319345b1b44ccfc1b" diff --git a/appveyor.yml b/appveyor.yml deleted file mode 100644 index 5e3efc0..0000000 --- a/appveyor.yml +++ /dev/null @@ -1,53 +0,0 @@ -version: '1.0.{build}' -skip_tags: true -image: -- Visual Studio 2019 -- Ubuntu1804 -test: off - -environment: - CLI_VERSION: '2024.3.873' - RUST_TOOLCHAIN: '1.80.0' - DOCKER_TOKEN: - secure: QKr2YEuliXdFKe3jN7w97w== - DOCKER_USER: - secure: bn3qFcGsm8Qw1V7px12K5w== - -init: - - git config --global core.longpaths true - -for: -- - matrix: - only: - - image: Visual Studio 2019 - - install: - - ps: ./ci/win-x64/setup.ps1 - - ps: $env:Path = "C:\Users\appveyor\.cargo\bin;$env:Path" - - build_script: - - ps: ./ci/win-x64/build.ps1 -shortver "$($env:APPVEYOR_BUILD_VERSION)" - - deploy: - - provider: NuGet - api_key: - secure: kpqwuq5o4VPX6bcnNkpF8z2rUQ2P4z3A4GcHG21Z/Rz9hAlJ/Qfaf1479VE+hADW - skip_symbols: true - artifact: /Seq.Input.Syslog.*\.nupkg/ - on: - branch: /^(dev|release)$/ -- - matrix: - only: - - image: Ubuntu1804 - - install: - - ./ci/linux-x64/setup.sh - - ps: $env:PATH = "/home/appveyor/.cargo/bin:$env:PATH" - - build_script: - - ps: ./ci/linux-x64/build.ps1 -shortver "$($env:APPVEYOR_BUILD_VERSION)" - -artifacts: -- path: publish\* diff --git a/baseversion b/baseversion new file mode 100644 index 0000000..9f8e9b6 --- /dev/null +++ b/baseversion @@ -0,0 +1 @@ +1.0 \ No newline at end of file diff --git a/ci/build-deps.ps1 b/ci/build-deps.ps1 index e5446d5..cd71b70 100644 --- a/ci/build-deps.ps1 +++ b/ci/build-deps.ps1 @@ -1,6 +1,3 @@ -$IsCIBuild = $null -ne $env:APPVEYOR_BUILD_NUMBER -$IsPublishedBuild = $IsCIBuild -and $null -eq $env:APPVEYOR_PULL_REQUEST_HEAD_REPO_BRANCH - function Write-BeginStep($invocation) { Write-Output "" @@ -13,16 +10,18 @@ function Write-BeginStep($invocation) Write-Output "" } -function Get-SemVer($shortver) +function Get-SemVer() { - # This script originally (c) 2016 Serilog Contributors - license Apache 2.0 - $branch = @{ $true = $env:APPVEYOR_REPO_BRANCH; $false = $(git symbolic-ref --short -q HEAD) }[$env:APPVEYOR_REPO_BRANCH -ne $NULL]; - $suffix = @{ $true = ""; $false = ($branch.Substring(0, [math]::Min(10,$branch.Length)) -replace '[\/\+]','-').Trim("-")}[$branch -eq "release"] + $branch = @{ $true = $env:CI_TARGET_BRANCH; $false = $(git symbolic-ref --short -q HEAD) }[$NULL -ne $env:CI_TARGET_BRANCH]; + $revision = @{ $true = "{0:00000}" -f $([convert]::ToInt32($env:CI_BUILD_NUMBER_BASE, 10) + 100); $false = "local" }[$NULL -ne $env:CI_BUILD_NUMBER_BASE] + $suffix = @{ $true = ""; $false = "$($branch.Substring(0, [math]::Min(10,$branch.Length)) -replace '([^a-zA-Z0-9\-]*)', '')-$revision"}[$branch -eq "release" -and $revision -ne "local"] + + $base = $(Get-Content ./baseversion).Trim() if ($suffix) { - $shortver + "-" + $suffix + $base + "." + $revision + "-" + $suffix } else { - $shortver + $base + "." + $revision } } @@ -33,7 +32,7 @@ function Run-Command # For commands that treat stderr like stdetc $out = New-TemporaryFile $err = New-TemporaryFile - $r = Start-Process $Exe -ArgumentList $ArgumentList -Wait -PassThru -RedirectStandardOut $out.FullName -RedirectStandardError $err.FullName + $r = Start-Process $Exe -ArgumentList $ArgumentList -Wait -PassThru -RedirectStandardOut $out.FullName -RedirectStandardError $err.FullName -NoNewWindow Write-Output "STDOUT" Get-Content -Path $out.FullName @@ -106,6 +105,25 @@ function Invoke-NuGetPack($version) if ($LASTEXITCODE) { exit 1 } } +function Publish-NuPkg($version) +{ + Write-BeginStep $MYINVOCATION + + foreach ($nupkg in Get-ChildItem publish/*.nupkg) { + & dotnet nuget push -k $env:NUGET_API_KEY -s https://api.nuget.org/v3/index.json "$nupkg" + if($LASTEXITCODE -ne 0) { throw "Publishing failed" } + } +} + +function Publish-GitHubRelease($version) +{ + Write-BeginStep $MYINVOCATION + + Write-Output "build: Creating release for version $version" + + iex "gh release create v$version --title v$version --generate-notes $(get-item ./publish/*.nupkg)" +} + function Publish-Container($version) { Write-BeginStep $MYINVOCATION @@ -113,11 +131,8 @@ function Publish-Container($version) docker tag squiflog-ci:latest datalust/squiflog-ci:$version if ($LASTEXITCODE) { exit 1 } - if ($IsCIBuild) - { - echo "$env:DOCKER_TOKEN" | docker login -u $env:DOCKER_USER --password-stdin - if ($LASTEXITCODE) { exit 1 } - } + echo "$env:DOCKER_TOKEN" | docker login -u $env:DOCKER_USER --password-stdin + if ($LASTEXITCODE) { exit 1 } docker push datalust/squiflog-ci:$version if ($LASTEXITCODE) { exit 1 } @@ -150,6 +165,7 @@ function Start-SeqEnvironment($protocol) { docker run --name squiflog-test-seq ` --network squiflog-test ` -e ACCEPT_EULA=Y ` + -e SEQ_FIRSTRUN_NOAUTHENTICATION=True ` -itd ` -p 5342:80 ` datalust/seq:latest diff --git a/ci/linux-x64/build.ps1 b/ci/linux-x64/build.ps1 index 9de04aa..3d5576d 100644 --- a/ci/linux-x64/build.ps1 +++ b/ci/linux-x64/build.ps1 @@ -1,12 +1,21 @@ -param ( - [string] $shortver = "99.99.99" -) +$RequiredRustToolchain = $(cat ./rust-toolchain) + +curl https://sh.rustup.rs -sSf | sh -s -- --default-host x86_64-unknown-linux-gnu --default-toolchain $RequiredRustToolchain -y + +$env:PATH = "$HOME/.cargo/bin:$env:PATH" + +& rustup target add x86_64-unknown-linux-musl +if ($LASTEXITCODE) { exit 1 } + +& rustup target add aarch64-unknown-linux-musl +if ($LASTEXITCODE) { exit 1 } -$ErrorActionPreference = "Stop" Push-Location "$PSScriptRoot/../../" . "./ci/build-deps.ps1" +$version = Get-SemVer + function Invoke-SmokeTest($protocol, $format) { Write-BeginStep $MYINVOCATION @@ -51,8 +60,8 @@ Build-TestAppContainer Invoke-SmokeTest "udp" "rfc5424" Invoke-SmokeTest "udp" "rfc3164" -if ($IsPublishedBuild) { - Publish-Container (Get-SemVer $shortver) +if ($env:CI_EVENT -eq "push" -and $env:DOCKER_TOKEN -ne "") { + Publish-Container ($version) } else { Write-Output "Not publishing Docker container" diff --git a/ci/linux-x64/setup.sh b/ci/linux-x64/setup.sh deleted file mode 100755 index 2a08cc6..0000000 --- a/ci/linux-x64/setup.sh +++ /dev/null @@ -1,13 +0,0 @@ -#!/bin/bash - -RequiredRustToolchain=$RUST_TOOLCHAIN - -curl https://sh.rustup.rs -sSf | sh -s -- --default-host x86_64-unknown-linux-gnu --default-toolchain $RequiredRustToolchain -y - -export PATH="$HOME/.cargo/bin:$PATH" - -rustup target add x86_64-unknown-linux-musl -rustup target add aarch64-unknown-linux-musl - -ls /home/appveyor -ls /home/appveyor/.cargo diff --git a/ci/win-x64/build.ps1 b/ci/win-x64/build.ps1 index f9fff04..963df10 100644 --- a/ci/win-x64/build.ps1 +++ b/ci/win-x64/build.ps1 @@ -1,16 +1,33 @@ -param ( - [string] $shortver = "99.99.99" -) +$RequiredRustToolchain = $(cat ./rust-toolchain) + +Invoke-WebRequest -OutFile ./rustup-init.exe -Uri https://win.rustup.rs +& ./rustup-init.exe --default-host x86_64-pc-windows-msvc --default-toolchain $RequiredRustToolchain -y +if ($LASTEXITCODE) { exit 1 } + +$env:Path = "$HOME\.cargo\bin;$env:Path" -$ErrorActionPreference = "Stop" Push-Location "$PSScriptRoot/../../" . "./ci/build-deps.ps1" +$version = Get-SemVer + Initialize-Filesystem Invoke-WindowsBuild Invoke-WindowsTests -Invoke-LinuxBuild -Invoke-NuGetPack (Get-SemVer $shortver) +# NOTE: We're relying on GitHub Actions to copy the linux binaries across here instead of building locally +# Invoke-LinuxBuild +Invoke-NuGetPack ($version) + +if ($env:CI_EVENT -eq "push" -and $env:NUGET_API_KEY -ne "") { + Publish-NuPkg ($version) + + if ($env:CI_TARGET_BRANCH -eq "release") { + Publish-GitHubRelease ($version) + } +} +else { + Write-Output "Not publishing NUPKG or GitHub release" +} -Pop-Location \ No newline at end of file +Pop-Location diff --git a/ci/win-x64/setup.ps1 b/ci/win-x64/setup.ps1 deleted file mode 100644 index a39dd18..0000000 --- a/ci/win-x64/setup.ps1 +++ /dev/null @@ -1,18 +0,0 @@ -$ErrorActionPreference = "Stop" - -$RequiredRustToolchain = $env:RUST_TOOLCHAIN - -Invoke-WebRequest -OutFile ./rustup-init.exe -Uri https://win.rustup.rs -$ErrorActionPreference = "Continue" -& ./rustup-init.exe --default-host x86_64-pc-windows-msvc --default-toolchain $RequiredRustToolchain -y -if ($LASTEXITCODE) { exit 1 } - -$env:Path = "C:\Users\appveyor\.cargo\bin;$env:Path" - -& rustup target add x86_64-unknown-linux-musl -if ($LASTEXITCODE) { exit 1 } - -& rustup target add aarch64-unknown-linux-musl -if ($LASTEXITCODE) { exit 1 } - -$ErrorActionPreference = "Stop" diff --git a/rust-toolchain b/rust-toolchain new file mode 100644 index 0000000..3bd6c56 --- /dev/null +++ b/rust-toolchain @@ -0,0 +1 @@ +1.99.1 diff --git a/squiflog/Cargo.toml b/squiflog/Cargo.toml index fcc24f4..14a79f0 100644 --- a/squiflog/Cargo.toml +++ b/squiflog/Cargo.toml @@ -1,34 +1,28 @@ -[package] -name = "squiflog" -version = "0.0.0" -authors = ["Datalust"] -edition = "2018" -license = "Apache-2.0" - -[dependencies] -serde = "1" -serde_json = "1" -serde_derive = "1" -inlinable_string = "0.1" -string_cache = "0.8" -bytes = "1" -lazy_static = "1.4" -libflate = "0.1" - -[dependencies.chrono] - version = "0.4" - features = ["serde"] - -[dependencies.futures] -version = "0.3" - -[dependencies.pin-utils] -version = "0.1" - -[dependencies.tokio] -version = "1" -features = ["signal", "sync", "net", "time", "rt", "rt-multi-thread"] - -[dependencies.tokio-util] -version = "0.7" -features = ["codec", "net"] +[package] +name = "squiflog" +version = "0.0.0" +authors = ["Datalust"] +edition = "2018" +license = "Apache-2.0" + +[dependencies] +serde = "1" +serde_json = "1" +serde_derive = "1" +bytes = "1" +lazy_static = "1.4" + +[dependencies.chrono] + version = "0.4" + features = ["serde"] + +[dependencies.futures] +version = "0.3" + +[dependencies.tokio] +version = "1" +features = ["signal", "sync", "net", "time", "rt", "rt-multi-thread"] + +[dependencies.tokio-util] +version = "0.7" +features = ["codec", "net"] diff --git a/squiflog/src/config.rs b/squiflog/src/config.rs index 99b5c0b..af21097 100644 --- a/squiflog/src/config.rs +++ b/squiflog/src/config.rs @@ -49,10 +49,10 @@ pub fn is_seq_app() -> bool { fn is_truthy(name: impl AsRef) -> Result { match env::var(name.as_ref()) { // The evironment variable contains a truthy value - Ok(ref v) if v == "True" || v == "true" => return Ok(true), + Ok(ref v) if v == "True" || v == "true" => Ok(true), // The environment variable is not set or doesn't contain // a truthy value - Ok(_) | Err(env::VarError::NotPresent) => return Ok(false), + Ok(_) | Err(env::VarError::NotPresent) => Ok(false), // The environment variable is invalid Err(e) => Err(e)?, } @@ -65,9 +65,9 @@ where { match env::var(name.as_ref()) { // The environment variable exists, but is empty - Ok(ref v) if v == "" => return Ok(()), + Ok(ref v) if v.is_empty() => Ok(()), // The environment variable does not exist - Err(env::VarError::NotPresent) => return Ok(()), + Err(env::VarError::NotPresent) => Ok(()), // The environment variable is invalid Err(e) => Err(e)?, // The environment variable has a value diff --git a/squiflog/src/data/mod.rs b/squiflog/src/data/mod.rs index c667a6a..86f12ee 100644 --- a/squiflog/src/data/mod.rs +++ b/squiflog/src/data/mod.rs @@ -24,15 +24,9 @@ metrics! { /** Configuration for CLEF formatting. */ -#[derive(Debug, Clone)] +#[derive(Debug, Clone, Default)] pub struct Config {} -impl Default for Config { - fn default() -> Self { - Config {} - } -} - /** Build a CLEF processor to handle messages. */ @@ -123,7 +117,7 @@ impl<'a> syslog::Message<'a> { } clef::Message { - timestamp: timestamp.unwrap_or_else(|| Utc::now()), + timestamp: timestamp.unwrap_or_else(Utc::now), level: Some(priority.severity()), message, message_template: None, @@ -194,9 +188,7 @@ mod test { let message = "hello world"; - let mut sd_params = vec![]; - sd_params.push(("hello", "world".to_owned())); - sd_params.push(("event", "value".to_owned())); + let sd_params = vec![("hello", "world".to_owned()), ("event", "value".to_owned())]; let syslog = syslog::Message { priority: syslog::Priority { @@ -237,9 +229,10 @@ mod test { let message = "hello world"; - let mut sd_params = vec![]; - sd_params.push(("ip", "192.0.2.1".to_owned())); - sd_params.push(("ip", "192.0.2.129".to_owned())); + let sd_params = vec![ + ("ip", "192.0.2.1".to_owned()), + ("ip", "192.0.2.129".to_owned()), + ]; let syslog = syslog::Message { priority: syslog::Priority { diff --git a/squiflog/src/data/parsers.rs b/squiflog/src/data/parsers.rs index 1700ab4..0cec864 100644 --- a/squiflog/src/data/parsers.rs +++ b/squiflog/src/data/parsers.rs @@ -15,24 +15,24 @@ use chrono::{ type ParserResult<'a, T> = Result<(T, &'a [u8]), Error>; -pub fn priority(i: &[u8]) -> ParserResult { +pub fn priority(i: &[u8]) -> ParserResult<'_, u8> { let (content, rem) = delimited(i, b'<', b'>')?; - if content.len() == 0 || content.iter().any(|b| !char::is_digit(*b as char, 10)) { + if content.is_empty() || content.iter().any(|b| !char::is_digit(*b as char, 10)) { return Err(err_msg("invalid priority content")); } let pval = std::str::from_utf8(content)?.parse::()?; Ok((pval, rem)) } -pub fn any_byte(i: &[u8]) -> ParserResult { - if i.len() == 0 { +pub fn any_byte(i: &[u8]) -> ParserResult<'_, u8> { + if i.is_empty() { Err(err_msg("unexpected end of input")) } else { Ok((i[0], &i[1..])) } } -pub fn byte(i: &[u8], b: u8) -> ParserResult<()> { +pub fn byte(i: &[u8], b: u8) -> ParserResult<'_, ()> { if let Ok((actual, rem)) = any_byte(i) { if actual == b { Ok(((), rem)) @@ -44,10 +44,10 @@ pub fn byte(i: &[u8], b: u8) -> ParserResult<()> { } } -pub fn until(i: &[u8], end: u8) -> ParserResult<&[u8]> { +pub fn until(i: &[u8], end: u8) -> ParserResult<'_, &[u8]> { let mut rem = i; let mut count = 0; - while rem.len() != 0 { + while !rem.is_empty() { if rem[0] == end { return Ok((&i[0..count], rem)); } @@ -58,14 +58,14 @@ pub fn until(i: &[u8], end: u8) -> ParserResult<&[u8]> { Err(err_msg(format!("missing end `{}` delimiter", end as char))) } -pub fn delimited(i: &[u8], start: u8, end: u8) -> ParserResult<&[u8]> { +pub fn delimited(i: &[u8], start: u8, end: u8) -> ParserResult<'_, &[u8]> { let rem = i; - if rem.len() == 0 || rem[0] != start { + if rem.is_empty() || rem[0] != start { return Err(err_msg("missing start delimiter")); } let rem = &rem[1..]; - if rem.len() == 0 { + if rem.is_empty() { return Err(err_msg("missing delimited content")); } @@ -74,7 +74,7 @@ pub fn delimited(i: &[u8], start: u8, end: u8) -> ParserResult<&[u8]> { Ok((content, &rem[1..])) } -pub fn take(i: &[u8], count: usize) -> ParserResult<&[u8]> { +pub fn take(i: &[u8], count: usize) -> ParserResult<'_, &[u8]> { if i.len() < count { return Err(err_msg("the input is too short")); } @@ -82,17 +82,14 @@ pub fn take(i: &[u8], count: usize) -> ParserResult<&[u8]> { Ok((&i[..count], &i[count..])) } -pub fn iso8601_timestamp(i: &[u8]) -> ParserResult> { +pub fn iso8601_timestamp(i: &[u8]) -> ParserResult<'_, DateTime> { let (to_space, rem) = until(i, b' ')?; // Cheating a little here; we shouldn't need any trailing delimiter let maybe_ts = std::str::from_utf8(to_space)?; let utc = DateTime::parse_from_rfc3339(maybe_ts)?.with_timezone(&Utc); Ok((utc, rem)) } -pub fn loose_timestamp<'a, 'b>( - i: &'a [u8], - now: &'b DateTime, -) -> ParserResult<'a, DateTime> { +pub fn loose_timestamp<'a>(i: &'a [u8], now: &DateTime) -> ParserResult<'a, DateTime> { if let Ok((iso_ts, rem)) = iso8601_timestamp(i) { return Ok((iso_ts, rem)); } @@ -104,9 +101,9 @@ pub fn loose_timestamp<'a, 'b>( .and_local_timezone(Local) .unwrap(); - let year_offset = if &month_day_h_m_s[0..3] == &b"Dec"[..] && now.month() == 1 { + let year_offset = if month_day_h_m_s[0..3] == b"Dec"[..] && now.month() == 1 { -1 - } else if &month_day_h_m_s[0..3] == &b"Jan"[..] && now.month() == 12 { + } else if month_day_h_m_s[0..3] == b"Jan"[..] && now.month() == 12 { 1 } else { 0 @@ -131,14 +128,14 @@ pub fn loose_timestamp<'a, 'b>( pub fn header_item<'a>(i: &'a [u8], name: &'static str) -> ParserResult<'a, Option<&'a str>> { let (content, rem) = until(i, b' ').map_err(|_| err_msg(format!("missing {}", name)))?; let (_, rem) = byte(rem, b' ')?; - if &content[..] == &b"-"[..] { + if content == &b"-"[..] { Ok((None, rem)) } else { Ok((Some(std::str::from_utf8(content)?), rem)) } } -pub fn param_value_content_char(i: &[u8]) -> ParserResult { +pub fn param_value_content_char(i: &[u8]) -> ParserResult<'_, u8> { let (b, rem) = any_byte(i)?; if b == b'"' { Err(err_msg("no param value content char found")) @@ -154,7 +151,7 @@ pub fn param_value_content_char(i: &[u8]) -> ParserResult { } } -pub fn structured_data_element(i: &[u8]) -> ParserResult { +pub fn structured_data_element(i: &[u8]) -> ParserResult<'_, StructuredDataElement<'_>> { let (_, rem) = byte(i, b'[')?; let (id, mut rem) = sd_name(rem)?; @@ -169,7 +166,7 @@ pub fn structured_data_element(i: &[u8]) -> ParserResult Ok((StructuredDataElement { id, params }, rem)) } -pub fn param_value_content(i: &[u8]) -> ParserResult { +pub fn param_value_content(i: &[u8]) -> ParserResult<'_, String> { let mut bytes = vec![]; let mut rem = i; let mut maybe_content = param_value_content_char(rem); @@ -181,14 +178,14 @@ pub fn param_value_content(i: &[u8]) -> ParserResult { Ok((std::str::from_utf8(&bytes[..])?.into(), rem)) } -pub fn param_value(i: &[u8]) -> ParserResult { +pub fn param_value(i: &[u8]) -> ParserResult<'_, String> { let (_, rem) = byte(i, b'"')?; let (content, rem) = param_value_content(rem)?; let (_, rem) = byte(rem, b'"')?; Ok((content, rem)) } -pub fn sd_name(i: &[u8]) -> ParserResult<&str> { +pub fn sd_name(i: &[u8]) -> ParserResult<'_, &str> { let disallowed: &[u8] = &b"\" ]="[..]; let mut rem = i; let mut count = 0; @@ -208,7 +205,7 @@ pub fn sd_name(i: &[u8]) -> ParserResult<&str> { } } -pub fn param(i: &[u8]) -> ParserResult<(&str, String)> { +pub fn param(i: &[u8]) -> ParserResult<'_, (&str, String)> { let (name, rem) = sd_name(i)?; let (_, rem) = byte(rem, b'=')?; let (value, rem) = param_value(rem)?; diff --git a/squiflog/src/data/syslog.rs b/squiflog/src/data/syslog.rs index beea25d..dad7363 100644 --- a/squiflog/src/data/syslog.rs +++ b/squiflog/src/data/syslog.rs @@ -88,6 +88,8 @@ pub struct Message<'a> { } impl<'a> Message<'a> { + // `FromStr` can't be implemented here because the message borrows from its input + #[allow(clippy::should_implement_trait)] pub fn from_str(s: &'a str) -> Self { Self::from_bytes(s.as_bytes()) } @@ -130,14 +132,14 @@ impl<'a> Message<'a> { } } - result.message = if unparsed.len() > 0 { + result.message = if !unparsed.is_empty() { Some(String::from_utf8_lossy(unparsed)) } else { None }; if result.timestamp.is_none() { - result.timestamp = Some(now.clone()) + result.timestamp = Some(*now) } result @@ -214,7 +216,7 @@ impl<'a> Message<'a> { result.message = if is_utf8 { let trimmed = std::str::from_utf8(message_bytes)?.trim(); - if trimmed.len() > 0 { + if !trimmed.is_empty() { Some(Cow::Borrowed(trimmed)) } else { None @@ -222,7 +224,7 @@ impl<'a> Message<'a> { } else { let owned = String::from_utf8_lossy(message_bytes); let trimmed = owned.trim(); - if trimmed.len() > 0 { + if !trimmed.is_empty() { Some(Cow::Owned(trimmed.to_owned())) } else { None @@ -247,7 +249,7 @@ mod tests { impl<'a> StructuredDataElement<'a> { fn from_str(s: &'a str) -> Result { let (r, rem) = parsers::structured_data_element(s.as_bytes())?; - if rem.len() > 0 { + if !rem.is_empty() { Err(err_msg("too much input")) } else { Ok(r) @@ -341,10 +343,11 @@ mod tests { // example 3 from https://tools.ietf.org/html/rfc5424 let input = b"<165>1 2003-10-11T22:14:15.003Z mymachine.example.com evntslog - ID47 [exampleSDID@32473 iut=\"3\" eventSource=\"Application\" eventID=\"1011\"] \xEF\xBB\xBFAn application event log entry...\n"; - let mut sd_params = vec![]; - sd_params.push(("iut", "3".to_owned())); - sd_params.push(("eventSource", "Application".to_owned())); - sd_params.push(("eventID", "1011".to_owned())); + let sd_params = vec![ + ("iut", "3".to_owned()), + ("eventSource", "Application".to_owned()), + ("eventID", "1011".to_owned()), + ]; let expected = Message { priority: Priority { @@ -374,13 +377,13 @@ mod tests { let input = b"<165>1 2003-10-11T22:14:15.003Z mymachine.example.com evntslog - ID47 [exampleSDID@32473 iut=\"3\" eventSource=\"Application\" eventID=\"1011\"][examplePriority@32473 class=\"high\"]"; - let mut sd_params = vec![]; - sd_params.push(("iut", "3".to_owned())); - sd_params.push(("eventSource", "Application".to_owned())); - sd_params.push(("eventID", "1011".to_owned())); + let sd_params = vec![ + ("iut", "3".to_owned()), + ("eventSource", "Application".to_owned()), + ("eventID", "1011".to_owned()), + ]; - let mut sd_params2 = vec![]; - sd_params2.push(("class", "high".to_owned())); + let sd_params2 = vec![("class", "high".to_owned())]; let sd = vec![ StructuredDataElement { @@ -439,10 +442,11 @@ mod tests { fn structured_data_param_from_string() { let input = "[exampleSDID@32473 iut=\"3\" eventSource=\"Application\" eventID=\"1011\"]"; - let mut sd_params = vec![]; - sd_params.push(("iut", "3".to_owned())); - sd_params.push(("eventSource", "Application".to_owned())); - sd_params.push(("eventID", "1011".to_owned())); + let sd_params = vec![ + ("iut", "3".to_owned()), + ("eventSource", "Application".to_owned()), + ("eventID", "1011".to_owned()), + ]; let expected = StructuredDataElement { id: "exampleSDID@32473", diff --git a/squiflog/src/diagnostics.rs b/squiflog/src/diagnostics.rs index 422a6c6..29fd75c 100644 --- a/squiflog/src/diagnostics.rs +++ b/squiflog/src/diagnostics.rs @@ -49,7 +49,7 @@ pub struct Config { impl Default for Config { fn default() -> Self { Config { - metrics_interval_ms: 1 * 1000 * 60, // 1 minute + metrics_interval_ms: 1000 * 60, // 1 minute min_level: Level::Error, } } @@ -206,7 +206,7 @@ impl<'a> DiagnosticEvent<'a> { pub fn emit(message_template: &'static str) { if MIN_LEVEL.includes(Level::Debug) { - let evt = DiagnosticEvent::new("DEBUG", None, &message_template, None); + let evt = DiagnosticEvent::new("DEBUG", None, message_template, None); let json = serde_json::to_string(&evt).expect("infallible JSON"); eprintln!("{}", json); } @@ -215,7 +215,7 @@ pub fn emit(message_template: &'static str) { pub fn emit_err(error: &impl Display, message_template: &'static str) { if MIN_LEVEL.includes(Level::Error) { let err_str = format!("{}", error); - let evt = DiagnosticEvent::new("ERROR", Some(&err_str), &message_template, None); + let evt = DiagnosticEvent::new("ERROR", Some(&err_str), message_template, None); let json = serde_json::to_string(&evt).expect("infallible JSON"); eprintln!("{}", json); } diff --git a/squiflog/src/main.rs b/squiflog/src/main.rs index ef6b5c8..09e5c4d 100644 --- a/squiflog/src/main.rs +++ b/squiflog/src/main.rs @@ -32,7 +32,7 @@ fn run() -> Result<(), Box> { // The processor for converting SYSLOG into CLEF let process = { let data = data::build(config.data); - move |msg: Bytes| data.read_as_clef(&*msg) + move |msg: Bytes| data.read_as_clef(&msg) }; // The server that drives the receiver and processor @@ -76,7 +76,7 @@ fn listen_for_stdin_closed(handle: server::Handle) { } fn main() { - let run_server: Result<(), Box> = catch_unwind(|| run()) + let run_server: Result<(), Box> = catch_unwind(run) .map_err(|panic| unwrap_panic(panic).into()) .and_then(|inner| inner);