From b33f1796e18dbcedfe3c3e9b76670c943a63eb82 Mon Sep 17 00:00:00 2001 From: Ara Sadoyan Date: Mon, 19 May 2025 20:20:15 +0200 Subject: [PATCH] Move to RusTLS, Static binary build, performance improvements. --- Cargo.lock | 1070 ++++++++++++++++++++++++++------------ Cargo.toml | 34 +- README.md | 31 +- etc/main.yaml | 2 +- etc/upstreams.yaml | 25 +- src/main.rs | 3 + src/utils/consul.rs | 6 +- src/utils/healthcheck.rs | 79 +-- src/utils/parceyaml.rs | 2 +- src/utils/structs.rs | 4 +- src/utils/tools.rs | 6 +- src/web/gethosts.rs | 6 +- src/web/proxyhttp.rs | 99 ++-- src/web/start.rs | 2 + 14 files changed, 922 insertions(+), 447 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index f0e859d..cae760a 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -27,7 +27,7 @@ dependencies = [ "getrandom 0.2.15", "once_cell", "version_check", - "zerocopy 0.7.35", + "zerocopy", ] [[package]] @@ -39,6 +39,12 @@ dependencies = [ "memchr", ] +[[package]] +name = "aliasable" +version = "0.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "250f629c0161ad8107cf89319e990051fae62832fd343083bea452d93e2205fd" + [[package]] name = "alloc-no-stdlib" version = "2.0.4" @@ -122,6 +128,45 @@ version = "0.7.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7c02d123df017efcdfbd739ef81735b36c5ba83ec3c59c80a9d7ecc718f92e50" +[[package]] +name = "asn1-rs" +version = "0.6.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5493c3bedbacf7fd7382c6346bbd66687d12bbaad3a89a2d2c303ee6cf20b048" +dependencies = [ + "asn1-rs-derive", + "asn1-rs-impl", + "displaydoc", + "nom", + "num-traits", + "rusticata-macros", + "thiserror 1.0.69", + "time", +] + +[[package]] +name = "asn1-rs-derive" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "965c2d33e53cb6b267e148a4cb0760bc01f4904c1cd4bb4002a085bb016d1490" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.100", + "synstructure", +] + +[[package]] +name = "asn1-rs-impl" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7b18050c2cd6fe86c3a76584ef5e0baf286d038cda203eb6223df2cc413565f7" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.100", +] + [[package]] name = "async-stream" version = "0.3.6" @@ -179,10 +224,33 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ace50bade8e6234aa140d9a2f552bbee1db4d353f69b8217bc503490fc1a9f26" [[package]] -name = "axum" -version = "0.8.3" +name = "aws-lc-rs" +version = "1.13.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "de45108900e1f9b9242f7f2e254aa3e2c029c921c258fe9e6b4217eeebd54288" +checksum = "93fcc8f365936c834db5514fc45aee5b1202d677e6b40e48468aaaa8183ca8c7" +dependencies = [ + "aws-lc-sys", + "zeroize", +] + +[[package]] +name = "aws-lc-sys" +version = "0.29.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "61b1d86e7705efe1be1b569bab41d4fa1e14e220b60a160f78de2db687add079" +dependencies = [ + "bindgen", + "cc", + "cmake", + "dunce", + "fs_extra", +] + +[[package]] +name = "axum" +version = "0.8.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "021e862c184ae977658b36c4500f7feac3221ca5da43e3f25bd04ab6c79a29b5" dependencies = [ "axum-core", "bytes", @@ -259,6 +327,29 @@ version = "0.22.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "72b3254f16251a8381aa12e40e3c4d2f0199f8c6508fbecb9d91f575e0fbb8c6" +[[package]] +name = "bindgen" +version = "0.69.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "271383c67ccabffb7381723dea0672a673f292304fcb45c01cc648c7a8d58088" +dependencies = [ + "bitflags 2.8.0", + "cexpr", + "clang-sys", + "itertools", + "lazy_static", + "lazycell", + "log", + "prettyplease", + "proc-macro2", + "quote", + "regex", + "rustc-hash 1.1.0", + "shlex", + "syn 2.0.100", + "which", +] + [[package]] name = "bitflags" version = "1.3.2" @@ -277,7 +368,7 @@ version = "0.10.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "46502ad458c9a52b69d4d4d32775c788b7a1b85e8bc9d482d92250fc0e3f8efe" dependencies = [ - "digest", + "digest 0.10.7", ] [[package]] @@ -289,6 +380,15 @@ dependencies = [ "generic-array", ] +[[package]] +name = "block-buffer" +version = "0.11.0-rc.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a229bfd78e4827c91b9b95784f69492c1b77c1ab75a45a8a037b139215086f94" +dependencies = [ + "hybrid-array", +] + [[package]] name = "brotli" version = "3.5.0" @@ -339,12 +439,55 @@ dependencies = [ "shlex", ] +[[package]] +name = "cexpr" +version = "0.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6fac387a98bb7c37292057cffc56d62ecb629900026402633ae9160df93a8766" +dependencies = [ + "nom", +] + +[[package]] +name = "cf-rustracing" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8911ac33364d043fa741f0d393e85c6f23b55015b97c3e3e14b51bc46edb4437" +dependencies = [ + "backtrace", + "rand 0.8.5", + "tokio", + "trackable", +] + +[[package]] +name = "cf-rustracing-jaeger" +version = "1.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d2ccda32f74f476a394a0880275270c238cab73bf6bbb2851a7868f55a1efa08" +dependencies = [ + "cf-rustracing", + "hostname", + "local-ip-address", + "percent-encoding", + "rand 0.8.5", + "thrift_codec", + "tokio", + "trackable", +] + [[package]] name = "cfg-if" version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" +[[package]] +name = "cfg_aliases" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "613afe47fcd5fac7ccf1db93babcb082c5994d996f20b8b159f2ad1658eb5724" + [[package]] name = "chrono" version = "0.4.39" @@ -354,6 +497,17 @@ dependencies = [ "num-traits", ] +[[package]] +name = "clang-sys" +version = "1.8.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0b023947811758c97c59bf9d1c188fd619ad4718dcaa767947df1cadb14f39f4" +dependencies = [ + "glob", + "libc", + "libloading", +] + [[package]] name = "clap" version = "3.2.25" @@ -442,15 +596,6 @@ dependencies = [ "cfg-if", ] -[[package]] -name = "crossbeam-channel" -version = "0.5.14" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "06ba6d68e24814cb8de6bb986db8222d3a027d15872cabc0d18817bc3c0e4471" -dependencies = [ - "crossbeam-utils", -] - [[package]] name = "crossbeam-queue" version = "0.3.12" @@ -476,6 +621,15 @@ dependencies = [ "typenum", ] +[[package]] +name = "crypto-common" +version = "0.2.0-rc.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "170d71b5b14dec99db7739f6fc7d6ec2db80b78c3acb77db48392ccc3d8a9ea0" +dependencies = [ + "hybrid-array", +] + [[package]] name = "daemonize" version = "0.5.0" @@ -501,9 +655,23 @@ dependencies = [ [[package]] name = "data-encoding" -version = "2.7.0" +version = "2.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0e60eed09d8c01d3cee5b7d30acb059b76614c918fa0f992e0dd6eeb10daad6f" +checksum = "2a2330da5de22e8a3cb63252ce2abb30116bf5265e89c0e01bc17015ce30a476" + +[[package]] +name = "der-parser" +version = "9.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5cd0a5c643689626bec213c4d8bd4d96acc8ffdb4ad4bb6bc16abf27d5f4b553" +dependencies = [ + "asn1-rs", + "displaydoc", + "nom", + "num-bigint", + "num-traits", + "rusticata-macros", +] [[package]] name = "deranged" @@ -531,11 +699,21 @@ version = "0.10.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9ed9a281f7bc9b7576e61468ba615a66a5c8cfdff42420a70aa82701a3b1e292" dependencies = [ - "block-buffer", - "crypto-common", + "block-buffer 0.10.4", + "crypto-common 0.1.6", "subtle", ] +[[package]] +name = "digest" +version = "0.11.0-pre.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6c478574b20020306f98d61c8ca3322d762e1ff08117422ac6106438605ea516" +dependencies = [ + "block-buffer 0.11.0-rc.4", + "crypto-common 0.2.0-rc.2", +] + [[package]] name = "displaydoc" version = "0.2.5" @@ -548,13 +726,16 @@ dependencies = [ ] [[package]] -name = "encoding_rs" -version = "0.8.35" +name = "dunce" +version = "1.0.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "75030f3c4f45dafd7586dd6780965a8c7e8e285a5ecb86713e63a79c5b2766f3" -dependencies = [ - "cfg-if", -] +checksum = "92773504d58c093f6de2459af4af33faa518c13451eb8f2b5698ed3d36e7c813" + +[[package]] +name = "either" +version = "1.15.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "48c757948c5ede0e46177b7add2e67155f70e33c07fea8284df6576da70b3719" [[package]] name = "env_filter" @@ -595,12 +776,6 @@ dependencies = [ "windows-sys 0.59.0", ] -[[package]] -name = "fastrand" -version = "2.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "37909eebbb50d72f9059c3b6d82c0463f2ff062c9e95845c43a6c9c0355411be" - [[package]] name = "filetime" version = "0.2.25" @@ -636,21 +811,6 @@ version = "0.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a0d2fde1f7b3d48b8395d5f2de76c18a528bd6a9cdde438df747bfcba3e05d6f" -[[package]] -name = "foreign-types" -version = "0.3.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f6f339eb8adc052cd2ca78910fda869aefa38d22d5cb648e6485e4d3fc06f3b1" -dependencies = [ - "foreign-types-shared", -] - -[[package]] -name = "foreign-types-shared" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "00b0228411908ca8685dba7fc2cdd70ec9990a6e753e89b6ac91a84c40fbaf4b" - [[package]] name = "form_urlencoded" version = "1.2.1" @@ -660,6 +820,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 = "fsevent-sys" version = "4.1.0" @@ -772,15 +938,17 @@ dependencies = [ "futures", "jsonwebtoken", "log", + "mimalloc", "notify", "pingora", "pingora-core", "pingora-http", "pingora-proxy", - "rand 0.9.0", + "rand 0.9.1", "reqwest", + "rustls", "serde", - "serde_yaml", + "serde_yaml 0.9.34+deprecated", "sha2", "tokio", "tonic", @@ -817,8 +985,10 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "43a49c392881ce6d5c3b8cb70f98717b7c07aabbdff06687b9030dbfbe2725f8" dependencies = [ "cfg-if", + "js-sys", "libc", "wasi 0.13.3+wasi-0.2.2", + "wasm-bindgen", "windows-targets 0.52.6", ] @@ -828,6 +998,12 @@ version = "0.31.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "07e28edb80900c19c28f1072f2e8aeca7fa06b23cd4169cefe1af5aa3260783f" +[[package]] +name = "glob" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a8d1add55171497b4705a648c6b583acafb01d58050a51727785f0b2c8e0a2b2" + [[package]] name = "h2" version = "0.4.7" @@ -891,6 +1067,15 @@ version = "0.4.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7f24254aa9a54b5c858eaee2f5bccdb46aaf0e486a595ed5fd8f86ba55232a70" +[[package]] +name = "home" +version = "0.5.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "589533453244b0995c858700322199b2becb13b627df2851f64a2775d024abcf" +dependencies = [ + "windows-sys 0.59.0", +] + [[package]] name = "hostname" version = "0.3.1" @@ -948,6 +1133,15 @@ version = "1.0.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "df3b46402a9d5adb4c86a0cf463f42e19994e3ee891101b1841f30a545cb49a9" +[[package]] +name = "hybrid-array" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "891d15931895091dea5c47afa5b3c9a01ba634b311919fd4d41388fa0e3d76af" +dependencies = [ + "typenum", +] + [[package]] name = "hyper" version = "1.6.0" @@ -984,6 +1178,7 @@ dependencies = [ "tokio", "tokio-rustls", "tower-service", + "webpki-roots 0.26.11", ] [[package]] @@ -999,22 +1194,6 @@ dependencies = [ "tower-service", ] -[[package]] -name = "hyper-tls" -version = "0.6.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "70206fc6890eaca9fde8a0bf71caa2ddfc9fe045ac9e5c70df101a7dbde866e0" -dependencies = [ - "bytes", - "http-body-util", - "hyper", - "hyper-util", - "native-tls", - "tokio", - "tokio-native-tls", - "tower-service", -] - [[package]] name = "hyper-util" version = "0.1.10" @@ -1225,6 +1404,15 @@ version = "1.70.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7943c866cc5cd64cbc25b2e01621d07fa8eb2a1a23160ee81ce38704e97b8ecf" +[[package]] +name = "itertools" +version = "0.12.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ba291022dbbd398a455acf126c1e341954079855bc60dfdda641363bd6922569" +dependencies = [ + "either", +] + [[package]] name = "itoa" version = "1.0.14" @@ -1315,12 +1503,38 @@ version = "1.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bbd2bcb4c963f2ddae06a2efc7e9f3591312473c50c6685e1f298068316e66fe" +[[package]] +name = "lazycell" +version = "1.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "830d08ce1d1d941e6b30645f1a0eb5643013d835ce3779a5fc208261dbe10f55" + [[package]] name = "libc" version = "0.2.169" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b5aba8db14291edd000dfcc4d620c7ebfb122c613afb886ca8803fa4e128a20a" +[[package]] +name = "libloading" +version = "0.8.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6a793df0d7afeac54f95b471d3af7f0d4fb975699f972341a4b76988d49cdf0c" +dependencies = [ + "cfg-if", + "windows-targets 0.53.0", +] + +[[package]] +name = "libmimalloc-sys" +version = "0.1.42" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ec9d6fac27761dabcd4ee73571cdb06b7022dc99089acbe5435691edffaac0f4" +dependencies = [ + "cc", + "libc", +] + [[package]] name = "libredox" version = "0.1.3" @@ -1360,6 +1574,18 @@ version = "0.7.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4ee93343901ab17bd981295f2cf0026d4ad018c7c31ba84549a4ddbb47a45104" +[[package]] +name = "local-ip-address" +version = "0.5.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "612ed4ea9ce5acfb5d26339302528a5e1e59dfed95e9e11af3c083236ff1d15d" +dependencies = [ + "libc", + "neli", + "thiserror 1.0.69", + "windows-sys 0.48.0", +] + [[package]] name = "lock_api" version = "0.4.12" @@ -1378,13 +1604,19 @@ checksum = "13dc2df351e3202783a1fe0d44375f7295ffb4049267b0f3018346dc122a1d94" [[package]] name = "lru" -version = "0.12.5" +version = "0.14.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "234cf4f4a04dc1f57e24b96cc0cd600cf2af460d4161ac5ecdd0af8e1f3b2a38" +checksum = "9f8cc7106155f10bdf99a6f379688f543ad6596a415375b36a59a054ceda1198" dependencies = [ "hashbrown 0.15.2", ] +[[package]] +name = "lru-slab" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "112b39cec0b298b6c1999fee3e31427f74f676e4cb9879ed1a121b43661a4154" + [[package]] name = "match_cfg" version = "0.1.0" @@ -1412,12 +1644,27 @@ dependencies = [ "autocfg", ] +[[package]] +name = "mimalloc" +version = "0.1.46" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "995942f432bbb4822a7e9c3faa87a695185b0d09273ba85f097b54f4e458f2af" +dependencies = [ + "libmimalloc-sys", +] + [[package]] name = "mime" version = "0.3.17" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6877bb514081ee2a7ff5ef9de3281f14a4dd4bceac4c09388074a6b5df8a139a" +[[package]] +name = "minimal-lexical" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "68354c5c6bd36d73ff3feceb05efa59b6acb7626617f4962be322a825e61f79a" + [[package]] name = "miniz_oxide" version = "0.8.3" @@ -1440,20 +1687,28 @@ dependencies = [ ] [[package]] -name = "native-tls" -version = "0.2.14" +name = "neli" +version = "0.6.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "87de3442987e9dbec73158d5c715e7ad9072fda936bb03d19d7fa10e00520f0e" +checksum = "93062a0dce6da2517ea35f301dfc88184ce18d3601ec786a727a87bf535deca9" dependencies = [ + "byteorder", "libc", "log", - "openssl", - "openssl-probe", - "openssl-sys", - "schannel", - "security-framework", - "security-framework-sys", - "tempfile", + "neli-proc-macros", +] + +[[package]] +name = "neli-proc-macros" +version = "0.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0c8034b7fbb6f9455b2a96c19e6edf8dc9fc34c70449938d8ee3b4df363f61fe" +dependencies = [ + "either", + "proc-macro2", + "quote", + "serde", + "syn 1.0.109", ] [[package]] @@ -1468,6 +1723,22 @@ dependencies = [ "memoffset", ] +[[package]] +name = "no_debug" +version = "3.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3f23a60c850e1144fc1dd9435152e0cfdc7dd18725350b4243584118013a52a4" + +[[package]] +name = "nom" +version = "7.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d273983c5a657a70a3e8f2a01329822f3b8c8172b73826411a55751e404a0a4a" +dependencies = [ + "memchr", + "minimal-lexical", +] + [[package]] name = "notify" version = "8.0.0" @@ -1536,72 +1807,57 @@ dependencies = [ "memchr", ] +[[package]] +name = "oid-registry" +version = "0.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a8d8034d9489cdaf79228eb9f6a3b8d7bb32ba00d6645ebd48eef4077ceb5bd9" +dependencies = [ + "asn1-rs", +] + [[package]] name = "once_cell" version = "1.20.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1261fe7e33c73b354eab43b1273a57c8f967d0391e80353e51f764ac02cf6775" -[[package]] -name = "openssl" -version = "0.10.71" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5e14130c6a98cd258fdcb0fb6d744152343ff729cbfcb28c656a9d12b999fbcd" -dependencies = [ - "bitflags 2.8.0", - "cfg-if", - "foreign-types", - "libc", - "once_cell", - "openssl-macros", - "openssl-sys", -] - -[[package]] -name = "openssl-macros" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a948666b637a0f465e8564c73e89d4dde00d72d4d473cc972f390fc3dcee7d9c" -dependencies = [ - "proc-macro2", - "quote", - "syn 2.0.100", -] - [[package]] name = "openssl-probe" version = "0.1.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d05e27ee213611ffe7d6348b942e8f942b37114c00cc03cec254295a4a17852e" -[[package]] -name = "openssl-src" -version = "300.4.2+3.4.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "168ce4e058f975fe43e89d9ccf78ca668601887ae736090aacc23ae353c298e2" -dependencies = [ - "cc", -] - -[[package]] -name = "openssl-sys" -version = "0.9.106" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8bb61ea9811cc39e3c2069f40b8b8e2e70d8569b361f879786cc7ed48b777cdd" -dependencies = [ - "cc", - "libc", - "openssl-src", - "pkg-config", - "vcpkg", -] - [[package]] name = "os_str_bytes" version = "6.6.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e2355d85b9a3786f481747ced0e0ff2ba35213a1f9bd406ed906554d7af805a1" +[[package]] +name = "ouroboros" +version = "0.18.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1e0f050db9c44b97a94723127e6be766ac5c340c48f2c4bb3ffa11713744be59" +dependencies = [ + "aliasable", + "ouroboros_macro", + "static_assertions", +] + +[[package]] +name = "ouroboros_macro" +version = "0.18.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3c7028bdd3d43083f6d8d4d5187680d0d3560d54df4cc9d752005268b41e64d0" +dependencies = [ + "heck 0.4.1", + "proc-macro2", + "proc-macro2-diagnostics", + "quote", + "syn 2.0.100", +] + [[package]] name = "parking_lot" version = "0.12.3" @@ -1681,9 +1937,9 @@ checksum = "8b870d8c151b6f2fb93e84a13146138f05d02ed11c7e7c54f8826aaaf7c9f184" [[package]] name = "pingora" -version = "0.4.0" +version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "79c9fc7098dc3e7d09d2d1647921005be9301cf68536826195dc5369e05124bd" +checksum = "0d793bb3f61d3aacb02b10d0e32724f5b4f1d3fcf2f51efc4188a1a6a5810606" dependencies = [ "pingora-cache", "pingora-core", @@ -1695,14 +1951,16 @@ dependencies = [ [[package]] name = "pingora-cache" -version = "0.4.0" +version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "35ee62f28526d8d484621e77f8d6a1807f1bd07558a06ab5a204b4834d6be056" +checksum = "dcb4b85ca73955092e7e2a6654304f6ee7868d38792f442733a197cbb3ac5f75" dependencies = [ "ahash", "async-trait", "blake2", "bytes", + "cf-rustracing", + "cf-rustracing-jaeger", "hex", "http", "httparse", @@ -1721,8 +1979,6 @@ dependencies = [ "regex", "rmp", "rmp-serde", - "rustracing", - "rustracing_jaeger", "serde", "strum", "tokio", @@ -1730,9 +1986,9 @@ dependencies = [ [[package]] name = "pingora-core" -version = "0.4.0" +version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d123320b69bd06e897fc16bd1dde962a7b488c4d2ae825683fbca0198fad8669" +checksum = "2298292e2dbd156294bcc8dd2ec34507277c78bab31bfe3aecc1cab9b1f91dff" dependencies = [ "ahash", "async-trait", @@ -1741,6 +1997,7 @@ dependencies = [ "chrono", "clap", "daemonize", + "derivative", "flate2", "futures", "h2", @@ -1749,46 +2006,46 @@ dependencies = [ "httpdate", "libc", "log", - "lru", "nix", "once_cell", "openssl-probe", + "ouroboros", "parking_lot", "percent-encoding", "pingora-error", "pingora-http", - "pingora-openssl", "pingora-pool", "pingora-runtime", + "pingora-rustls", "pingora-timeout", "prometheus", "rand 0.8.5", "regex", "serde", - "serde_yaml", + "serde_yaml 0.8.26", "sfv", "socket2", "strum", "strum_macros", - "thread_local", "tokio", "tokio-test", "unicase", "windows-sys 0.59.0", + "x509-parser", "zstd", ] [[package]] name = "pingora-error" -version = "0.4.0" +version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6389511530152c535a554f592ae4a9691b1246cff20eb4564f2a34fc921195c0" +checksum = "ca838db1ee9beef844d6db7e2e85e0006b50bb6bf8f19c96fb64bf2567e59039" [[package]] name = "pingora-header-serde" -version = "0.4.0" +version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bcb3f62d852da015e76ced56e93e6d52941679a9825281c90f2897841129e59d" +checksum = "659b46bad022e1b4a3ee6b12739e4e597ccca5e3652c9cbfb06155686c94adbe" dependencies = [ "bytes", "http", @@ -1802,9 +2059,9 @@ dependencies = [ [[package]] name = "pingora-http" -version = "0.4.0" +version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "70202f126056f366549afc804741e12dd9f419cfc79a0063ab15653007a0f4c6" +checksum = "0f15f9fa5ae034435adfe2b94620e25dee7b0859c2460acec499163de3d299f1" dependencies = [ "bytes", "http", @@ -1813,18 +2070,18 @@ dependencies = [ [[package]] name = "pingora-ketama" -version = "0.4.0" +version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3c1bb6c2e11823a05ec9140fc8827f112b8380d78b837535f284e0a98f24cc0a" +checksum = "e672fab42518ae10cbcbed2e4532c46744b222425c12886d2e6ae2ffd64b1e74" dependencies = [ "crc32fast", ] [[package]] name = "pingora-load-balancing" -version = "0.4.0" +version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "84d558167ecb05cea487a6479700390a67fe414724f203e10c3912584a0f2cb1" +checksum = "1c6fe587777e321fbead02352aa089e9965f6e3b87a944d12d7dfd3717fac4b1" dependencies = [ "arc-swap", "async-trait", @@ -1838,41 +2095,27 @@ dependencies = [ "pingora-http", "pingora-ketama", "pingora-runtime", - "rand 0.9.0", + "rand 0.8.5", "tokio", ] [[package]] name = "pingora-lru" -version = "0.4.0" +version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cb50f65f06c4b81ccb3edcceaa54bb9439608506b0b3b8c048798169a64aad8e" +checksum = "32f1c33f6ce9ca9b8e81190796f7d4d543d1ab2a310097d884ebe48ce5d33c4d" dependencies = [ "arrayvec", "hashbrown 0.15.2", "parking_lot", - "rand 0.9.0", -] - -[[package]] -name = "pingora-openssl" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4f18158b901a02289f2a2a954a531c96e4d0703c94f7c9291981c9e53fddc6c1" -dependencies = [ - "foreign-types", - "libc", - "openssl", - "openssl-src", - "openssl-sys", - "tokio-openssl", + "rand 0.8.5", ] [[package]] name = "pingora-pool" -version = "0.4.0" +version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bacdd5dbdec690d468856d988b170c8bb4ab62e0edefc0f432ba5e326489f421" +checksum = "a74589c2e4f089d00fde78030e2d51b44406341e1e43b0bdb5456b93b4459937" dependencies = [ "crossbeam-queue", "log", @@ -1885,9 +2128,9 @@ dependencies = [ [[package]] name = "pingora-proxy" -version = "0.4.0" +version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5031783d6743bd31e4de7d7c7a19e9eecf369174c3cbd8a57eb52bc6bf882d92" +checksum = "1d12839bb50f9716db46b6bafc2ea9cf0de504dee857ff79d7a96dc64f46063a" dependencies = [ "async-trait", "bytes", @@ -1901,16 +2144,15 @@ dependencies = [ "pingora-core", "pingora-error", "pingora-http", - "pingora-timeout", "regex", "tokio", ] [[package]] name = "pingora-runtime" -version = "0.4.0" +version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "31a7c445ca224630961045684201e3cf8da9af0b01f286ed54ff8b2403aaabff" +checksum = "e720a120466e8f61a64384deff6d7a52de6df6a4c54b0046c70c9cf0eaad1092" dependencies = [ "once_cell", "rand 0.8.5", @@ -1919,10 +2161,27 @@ dependencies = [ ] [[package]] -name = "pingora-timeout" -version = "0.4.0" +name = "pingora-rustls" +version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "685bb8808cc1919c63a06ab14fdac9b84a4887ced49259a5c0adc8bfb2ffe558" +checksum = "f57d17d2184dcb4edb8333904e2941f6341e6c4fba586853d2a39878115eaf89" +dependencies = [ + "log", + "no_debug", + "pingora-error", + "ring", + "rustls", + "rustls-native-certs", + "rustls-pemfile", + "rustls-pki-types", + "tokio-rustls", +] + +[[package]] +name = "pingora-timeout" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7fd4538cb5a3ae793c63126fc21e77e20778742931e31a5ac64e75b3ca10d176" dependencies = [ "once_cell", "parking_lot", @@ -1964,7 +2223,17 @@ version = "0.2.20" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "77957b295656769bb8ad2b6a6b09d897d94f05c41b069aede1fcdaa675eaea04" dependencies = [ - "zerocopy 0.7.35", + "zerocopy", +] + +[[package]] +name = "prettyplease" +version = "0.2.32" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "664ec5419c51e34154eec046ebcba56312d5a2fc3b09a06da188e1ad21afadf6" +dependencies = [ + "proc-macro2", + "syn 2.0.100", ] [[package]] @@ -2000,6 +2269,19 @@ dependencies = [ "unicode-ident", ] +[[package]] +name = "proc-macro2-diagnostics" +version = "0.10.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "af066a9c399a26e020ada66a034357a868728e72cd426f3adcd35f80d88d88c8" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.100", + "version_check", + "yansi", +] + [[package]] name = "prometheus" version = "0.13.4" @@ -2030,6 +2312,61 @@ version = "2.28.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "106dd99e98437432fed6519dedecfade6a06a73bb7b2a1e019fdd2bee5778d94" +[[package]] +name = "quinn" +version = "0.11.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "626214629cda6781b6dc1d316ba307189c85ba657213ce642d9c77670f8202c8" +dependencies = [ + "bytes", + "cfg_aliases", + "pin-project-lite", + "quinn-proto", + "quinn-udp", + "rustc-hash 2.1.1", + "rustls", + "socket2", + "thiserror 2.0.12", + "tokio", + "tracing", + "web-time", +] + +[[package]] +name = "quinn-proto" +version = "0.11.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "49df843a9161c85bb8aae55f101bc0bac8bcafd637a620d9122fd7e0b2f7422e" +dependencies = [ + "bytes", + "getrandom 0.3.1", + "lru-slab", + "rand 0.9.1", + "ring", + "rustc-hash 2.1.1", + "rustls", + "rustls-pki-types", + "slab", + "thiserror 2.0.12", + "tinyvec", + "tracing", + "web-time", +] + +[[package]] +name = "quinn-udp" +version = "0.5.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ee4e529991f949c5e25755532370b8af5d114acae52326361d68d47af64aa842" +dependencies = [ + "cfg_aliases", + "libc", + "once_cell", + "socket2", + "tracing", + "windows-sys 0.59.0", +] + [[package]] name = "quote" version = "1.0.38" @@ -2052,13 +2389,12 @@ dependencies = [ [[package]] name = "rand" -version = "0.9.0" +version = "0.9.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3779b94aeb87e8bd4e834cee3650289ee9e0d5677f976ecdb6d219e5f4f6cd94" +checksum = "9fbfd9d094a40bf3ae768db9361049ace4c0e04a4fd6b359518bd7b73a73dd97" dependencies = [ "rand_chacha 0.9.0", "rand_core 0.9.3", - "zerocopy 0.8.24", ] [[package]] @@ -2145,47 +2481,46 @@ checksum = "d19c46a6fdd48bc4dab94b6103fccc55d34c67cc0ad04653aad4ea2a07cd7bbb" dependencies = [ "base64", "bytes", - "encoding_rs", "futures-core", "futures-util", - "h2", "http", "http-body", "http-body-util", "hyper", "hyper-rustls", - "hyper-tls", "hyper-util", "ipnet", "js-sys", "log", "mime", - "native-tls", "once_cell", "percent-encoding", "pin-project-lite", + "quinn", + "rustls", "rustls-pemfile", + "rustls-pki-types", "serde", "serde_json", "serde_urlencoded", "sync_wrapper", - "system-configuration", "tokio", - "tokio-native-tls", + "tokio-rustls", "tower", "tower-service", "url", "wasm-bindgen", "wasm-bindgen-futures", "web-sys", + "webpki-roots 0.26.11", "windows-registry", ] [[package]] name = "ring" -version = "0.17.9" +version = "0.17.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e75ec5e92c4d8aede845126adc388046234541629e76029599ed35a003c7ed24" +checksum = "a4689e6c2294d81e88dc6261c768b63bc4fcdb852be6d1352498b114f61383b7" dependencies = [ "cc", "cfg-if", @@ -2233,6 +2568,27 @@ version = "0.1.24" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "719b953e2095829ee67db738b3bfa9fa368c94900df327b3f07fe6e794d2fe1f" +[[package]] +name = "rustc-hash" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "08d43f7aa6b08d49f382cde6a7982047c3426db949b1424bc4b7ec9ae12c6ce2" + +[[package]] +name = "rustc-hash" +version = "2.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "357703d41365b4b27c590e3ed91eabb1b663f07c4c084095e60cbed4362dff0d" + +[[package]] +name = "rusticata-macros" +version = "4.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "faf0c4a6ece9950b9abdb62b1cfcf2a68b3b67a10ba445b3bb85be2a293d0632" +dependencies = [ + "nom", +] + [[package]] name = "rustix" version = "0.38.44" @@ -2248,17 +2604,33 @@ dependencies = [ [[package]] name = "rustls" -version = "0.23.23" +version = "0.23.27" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "47796c98c480fce5406ef69d1c76378375492c3b0a0de587be0c1d9feb12f395" +checksum = "730944ca083c1c233a75c09f199e973ca499344a2b7ba9e755c457e86fb4a321" dependencies = [ + "aws-lc-rs", + "log", "once_cell", + "ring", "rustls-pki-types", "rustls-webpki", "subtle", "zeroize", ] +[[package]] +name = "rustls-native-certs" +version = "0.7.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e5bfb394eeed242e909609f56089eecfe5fda225042e8b171791b9c95f5931e5" +dependencies = [ + "openssl-probe", + "rustls-pemfile", + "rustls-pki-types", + "schannel", + "security-framework", +] + [[package]] name = "rustls-pemfile" version = "2.2.0" @@ -2273,45 +2645,22 @@ name = "rustls-pki-types" version = "1.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "917ce264624a4b4db1c364dcc35bfca9ded014d0a958cd47ad3e960e988ea51c" +dependencies = [ + "web-time", +] [[package]] name = "rustls-webpki" -version = "0.102.8" +version = "0.103.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "64ca1bc8749bd4cf37b5ce386cc146580777b4e8572c7b97baf22c83f444bee9" +checksum = "e4a72fe2bcf7a6ac6fd7d0b9e5cb68aeb7d4c0a0271730218b3e92d43b4eb435" dependencies = [ + "aws-lc-rs", "ring", "rustls-pki-types", "untrusted", ] -[[package]] -name = "rustracing" -version = "0.5.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a44822b10c095e574869de2b891e40c724fef42cadaea040d1cd3bdbb13d36a5" -dependencies = [ - "backtrace", - "crossbeam-channel", - "rand 0.8.5", - "trackable 0.2.24", -] - -[[package]] -name = "rustracing_jaeger" -version = "0.7.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a6c2fe9411ef5f43ac773f0e84ad735804c55719346a7aad52de2d9162db97c8" -dependencies = [ - "crossbeam-channel", - "hostname", - "percent-encoding", - "rand 0.8.5", - "rustracing", - "thrift_codec", - "trackable 0.2.24", -] - [[package]] name = "rustversion" version = "1.0.19" @@ -2438,25 +2787,38 @@ dependencies = [ ] [[package]] -name = "sfv" -version = "0.9.4" +name = "serde_yaml" +version = "0.9.34+deprecated" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f27daf6ed3fc7ffd5ea3ce9f684fe351c47e50f2fdbb6236e2bad0b440dbe408" +checksum = "6a8b1a1a2ebf674015cc02edccce75287f1a0130d394307b36743c2f5d504b47" dependencies = [ - "data-encoding", + "indexmap 2.7.1", + "itoa", + "ryu", + "serde", + "unsafe-libyaml", +] + +[[package]] +name = "sfv" +version = "0.10.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3fa1f336066b758b7c9df34ed049c0e693a426afe2b27ff7d5b14f410ab1a132" +dependencies = [ + "base64", "indexmap 2.7.1", "rust_decimal", ] [[package]] name = "sha2" -version = "0.10.8" +version = "0.11.0-pre.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "793db75ad2bcafc3ffa7c68b215fee268f537982cd901d132f89c6343f3a3dc8" +checksum = "19b4241d1a56954dce82cecda5c8e9c794eef6f53abe5e5216bac0a0ea71ffa7" dependencies = [ "cfg-if", "cpufeatures", - "digest", + "digest 0.11.0-pre.10", ] [[package]] @@ -2517,6 +2879,12 @@ version = "1.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a8f112729512f8e442d81f95a8a7ddf2b7c6b8a1a6f509a95864142b30cab2d3" +[[package]] +name = "static_assertions" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a2eb9349b6444b326872e140eb1cf5e7c522154d69e7a0ffb0fb81c06b37543f" + [[package]] name = "strsim" version = "0.10.0" @@ -2593,41 +2961,6 @@ dependencies = [ "syn 2.0.100", ] -[[package]] -name = "system-configuration" -version = "0.6.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3c879d448e9d986b661742763247d3693ed13609438cf3d006f51f5368a5ba6b" -dependencies = [ - "bitflags 2.8.0", - "core-foundation", - "system-configuration-sys", -] - -[[package]] -name = "system-configuration-sys" -version = "0.6.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8e1d1b10ced5ca923a1fcb8d03e96b8d3268065d724548c0211415ff6ac6bac4" -dependencies = [ - "core-foundation-sys", - "libc", -] - -[[package]] -name = "tempfile" -version = "3.17.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "22e5a0acb1f3f55f65cc4a866c361b2fb2a0ff6366785ae6fbb5f85df07ba230" -dependencies = [ - "cfg-if", - "fastrand", - "getrandom 0.3.1", - "once_cell", - "rustix", - "windows-sys 0.59.0", -] - [[package]] name = "termcolor" version = "1.4.1" @@ -2695,12 +3028,12 @@ dependencies = [ [[package]] name = "thrift_codec" -version = "0.1.1" +version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8fb61fb3d0a0af14949f3a6949b2639112e13226647112824f4d081533f9b1a8" +checksum = "fce3200b189fd4733eb2bb22235755c8aa0361ba1c66b67db54893144d147279" dependencies = [ "byteorder", - "trackable 0.2.24", + "trackable", ] [[package]] @@ -2745,10 +3078,25 @@ dependencies = [ ] [[package]] -name = "tokio" -version = "1.44.2" +name = "tinyvec" +version = "1.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e6b88822cbe49de4185e3a4cbf8321dd487cf5fe0c5c65695fef6346371e9c48" +checksum = "09b3661f17e86524eccd4371ab0429194e0d7c008abb45f7a7495b1719463c71" +dependencies = [ + "tinyvec_macros", +] + +[[package]] +name = "tinyvec_macros" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1f3ccbac311fea05f86f61904b462b55fb3df8837a366dfc601a0161d0532f20" + +[[package]] +name = "tokio" +version = "1.45.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2513ca694ef9ede0fb23fe71a4ee4107cb102b9dc1930f6d0fd77aae068ae165" dependencies = [ "backtrace", "bytes", @@ -2773,27 +3121,6 @@ dependencies = [ "syn 2.0.100", ] -[[package]] -name = "tokio-native-tls" -version = "0.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bbae76ab933c85776efabc971569dd6119c580d8f5d448769dec1764bf796ef2" -dependencies = [ - "native-tls", - "tokio", -] - -[[package]] -name = "tokio-openssl" -version = "0.6.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "59df6849caa43bb7567f9a36f863c447d95a11d5903c9cc334ba32576a27eadd" -dependencies = [ - "openssl", - "openssl-sys", - "tokio", -] - [[package]] name = "tokio-rustls" version = "0.26.1" @@ -2933,16 +3260,6 @@ dependencies = [ "once_cell", ] -[[package]] -name = "trackable" -version = "0.2.24" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b98abb9e7300b9ac902cc04920945a874c1973e08c310627cc4458c04b70dd32" -dependencies = [ - "trackable 1.3.0", - "trackable_derive", -] - [[package]] name = "trackable" version = "1.3.0" @@ -2986,6 +3303,12 @@ version = "1.0.15" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "11cd88e12b17c6494200a9c1b683a04fcac9573ed74cd1b62aeb2727c5592243" +[[package]] +name = "unsafe-libyaml" +version = "0.2.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "673aac59facbab8a9007c7f6108d11f63b603f7cabff99fabf650fea5c32b861" + [[package]] name = "untrusted" version = "0.9.0" @@ -3027,12 +3350,6 @@ version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "06abde3611657adf66d383f00b093d7faecc7fa57071cce2578660c9f1010821" -[[package]] -name = "vcpkg" -version = "0.2.15" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "accd4ea62f7bb7a82fe23066fb0957d48ef677f6eeb8215f372f52e48bb32426" - [[package]] name = "version_check" version = "0.9.5" @@ -3154,6 +3471,46 @@ 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-roots" +version = "0.26.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "521bc38abb08001b01866da9f51eb7c5d647a19260e00054a8c7fd5f9e57f7a9" +dependencies = [ + "webpki-roots 1.0.0", +] + +[[package]] +name = "webpki-roots" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2853738d1cc4f2da3a225c18ec6c3721abb31961096e9dbf5ab35fa88b19cfdb" +dependencies = [ + "rustls-pki-types", +] + +[[package]] +name = "which" +version = "4.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "87ba24419a2078cd2b0f2ede2691b6c66d8e47836da3b6db8265ebad47afbfc7" +dependencies = [ + "either", + "home", + "once_cell", + "rustix", +] + [[package]] name = "winapi" version = "0.3.9" @@ -3220,6 +3577,15 @@ dependencies = [ "windows-link", ] +[[package]] +name = "windows-sys" +version = "0.48.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "677d2418bec65e3338edb076e806bc1ec15693c5d0104683f2efe857f61056a9" +dependencies = [ + "windows-targets 0.48.5", +] + [[package]] name = "windows-sys" version = "0.52.0" @@ -3238,6 +3604,21 @@ dependencies = [ "windows-targets 0.52.6", ] +[[package]] +name = "windows-targets" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9a2fa6e2155d7247be68c096456083145c183cbbbc2764150dda45a87197940c" +dependencies = [ + "windows_aarch64_gnullvm 0.48.5", + "windows_aarch64_msvc 0.48.5", + "windows_i686_gnu 0.48.5", + "windows_i686_msvc 0.48.5", + "windows_x86_64_gnu 0.48.5", + "windows_x86_64_gnullvm 0.48.5", + "windows_x86_64_msvc 0.48.5", +] + [[package]] name = "windows-targets" version = "0.52.6" @@ -3270,6 +3651,12 @@ dependencies = [ "windows_x86_64_msvc 0.53.0", ] +[[package]] +name = "windows_aarch64_gnullvm" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2b38e32f0abccf9987a4e3079dfb67dcd799fb61361e53e2882c3cbaf0d905d8" + [[package]] name = "windows_aarch64_gnullvm" version = "0.52.6" @@ -3282,6 +3669,12 @@ version = "0.53.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "86b8d5f90ddd19cb4a147a5fa63ca848db3df085e25fee3cc10b39b6eebae764" +[[package]] +name = "windows_aarch64_msvc" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dc35310971f3b2dbbf3f0690a219f40e2d9afcf64f9ab7cc1be722937c26b4bc" + [[package]] name = "windows_aarch64_msvc" version = "0.52.6" @@ -3294,6 +3687,12 @@ version = "0.53.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c7651a1f62a11b8cbd5e0d42526e55f2c99886c77e007179efff86c2b137e66c" +[[package]] +name = "windows_i686_gnu" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a75915e7def60c94dcef72200b9a8e58e5091744960da64ec734a6c6e9b3743e" + [[package]] name = "windows_i686_gnu" version = "0.52.6" @@ -3318,6 +3717,12 @@ version = "0.53.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9ce6ccbdedbf6d6354471319e781c0dfef054c81fbc7cf83f338a4296c0cae11" +[[package]] +name = "windows_i686_msvc" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8f55c233f70c4b27f66c523580f78f1004e8b5a8b659e05a4eb49d4166cca406" + [[package]] name = "windows_i686_msvc" version = "0.52.6" @@ -3330,6 +3735,12 @@ version = "0.53.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "581fee95406bb13382d2f65cd4a908ca7b1e4c2f1917f143ba16efe98a589b5d" +[[package]] +name = "windows_x86_64_gnu" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "53d40abd2583d23e4718fddf1ebec84dbff8381c07cae67ff7768bbf19c6718e" + [[package]] name = "windows_x86_64_gnu" version = "0.52.6" @@ -3342,6 +3753,12 @@ version = "0.53.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2e55b5ac9ea33f2fc1716d1742db15574fd6fc8dadc51caab1c16a3d3b4190ba" +[[package]] +name = "windows_x86_64_gnullvm" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0b7b52767868a23d5bab768e390dc5f5c55825b6d30b86c844ff2dc7414044cc" + [[package]] name = "windows_x86_64_gnullvm" version = "0.52.6" @@ -3354,6 +3771,12 @@ version = "0.53.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0a6e035dd0599267ce1ee132e51c27dd29437f63325753051e71dd9e42406c57" +[[package]] +name = "windows_x86_64_msvc" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ed94fce61571a4006852b7389a063ab983c02eb1bb37b47f8272ce92d06d9538" + [[package]] name = "windows_x86_64_msvc" version = "0.52.6" @@ -3387,6 +3810,23 @@ version = "0.5.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1e9df38ee2d2c3c5948ea468a8406ff0db0b29ae1ffde1bcf20ef305bcc95c51" +[[package]] +name = "x509-parser" +version = "0.16.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fcbc162f30700d6f3f82a24bf7cc62ffe7caea42c0b2cba8bf7f3ae50cf51f69" +dependencies = [ + "asn1-rs", + "data-encoding", + "der-parser", + "lazy_static", + "nom", + "oid-registry", + "rusticata-macros", + "thiserror 1.0.69", + "time", +] + [[package]] name = "yaml-rust" version = "0.4.5" @@ -3396,6 +3836,12 @@ dependencies = [ "linked-hash-map", ] +[[package]] +name = "yansi" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cfe53a6657fd280eaa890a3bc59152892ffa3e30101319d168b781ed6529b049" + [[package]] name = "yoke" version = "0.7.5" @@ -3427,16 +3873,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1b9b4fd18abc82b8136838da5d50bae7bdea537c574d8dc1a34ed098d6c166f0" dependencies = [ "byteorder", - "zerocopy-derive 0.7.35", -] - -[[package]] -name = "zerocopy" -version = "0.8.24" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2586fea28e186957ef732a5f8b3be2da217d65c5969d4b1e17f973ebbe876879" -dependencies = [ - "zerocopy-derive 0.8.24", + "zerocopy-derive", ] [[package]] @@ -3450,17 +3887,6 @@ dependencies = [ "syn 2.0.100", ] -[[package]] -name = "zerocopy-derive" -version = "0.8.24" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a996a8f63c5c4448cd959ac1bab0aaa3306ccfd060472f85943ee0750f0169be" -dependencies = [ - "proc-macro2", - "quote", - "syn 2.0.100", -] - [[package]] name = "zerofrom" version = "0.1.5" diff --git a/Cargo.toml b/Cargo.toml index bc4c61a..9a7b44b 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -3,33 +3,39 @@ name = "gazan" version = "0.1.0" edition = "2021" +[profile.release] +lto = true +codegen-units = 1 +opt-level = 3 +strip = "symbols" + [dependencies] -tokio = { version = "1.44.2", features = ["full"] } -pingora = { version = "0.4.0", features = ["lb", "openssl"] } # openssl, rustls, boringssl +tokio = { version = "1.45.0", features = ["full"] } +pingora = { version = "0.5.0", features = ["lb", "rustls"] } # openssl, rustls, boringssl serde = { version = "1.0.219", features = ["derive"] } dashmap = "7.0.0-rc2" -pingora-core = "0.4.0" -pingora-proxy = "0.4.0" -pingora-http = "0.4.0" +pingora-core = "0.5.0" +pingora-proxy = "0.5.0" +pingora-http = "0.5.0" async-trait = "0.1.88" env_logger = "0.11.8" log = "0.4.27" futures = "0.3.31" notify = "8.0.0" -axum = { version = "0.8.3" } -reqwest = { version = "0.12.15", features = ["json"] } -serde_yaml = "0.8.26" -#hickory-client = "0.25.1" +axum = { version = "0.8.4" } +#reqwest = { version = "0.12.15", features = ["json", "native-tls-alpn"] } +#reqwest = { version = "0.12.15", features = ["json", "rustls-tls"] } +reqwest = { version = "0.12.15", default-features = false, features = ["rustls-tls", "json"] } + +serde_yaml = "0.9.34-deprecated" rand = "0.9.0" base64 = "0.22.1" jsonwebtoken = "9.3.1" -#hmac = "0.12.1" -#sha2 = "0.10.8" tonic = "0.13.0" -#uuid = { version = "1.16.0", features = ["v4"] } -sha2 = { version = "0.10.8", default-features = false } +sha2 = { version = "0.11.0-pre.5", default-features = false } base16ct = { version = "0.2.0", features = ["alloc"] } urlencoding = "2.1.3" arc-swap = "1.7.1" - +rustls = { version = "0.23.27", features = ["ring"] } +mimalloc = { version = "0.1.46", default-features = false } diff --git a/README.md b/README.md index 2a79fff..8fc1f81 100644 --- a/README.md +++ b/README.md @@ -27,16 +27,16 @@ Built on Rust, on top of **Cloudflareโ€™s Pingora engine**, **Gazan** delivers w ## ๐ŸŒ Highlights -- โš™๏ธ **Upstream Providers:** Supports `file`-based static upstreams, dynamic service discovery via `Consul` -- ๐Ÿ” **Hot Reloading:** Modify upstreams on the fly via `upstreams.yaml` โ€” no restart needed -- ๐Ÿ”ฎ **Automatic WebSocket Support:** Zero config โ€” connection upgrades are handled seamlessly -- ๐Ÿ”ฎ **Automatic GRPC Support:** Zero config, Requires `ssl` to proxy, gRPC is handled seamlessly -- ๐Ÿ”ฎ **Upstreams Session Stickiness:** Enable/Disable Sticky session support with single parameter in config file -- ๐Ÿ” **TLS Termination:** Fully supports TLS for incoming and upstream traffic -- ๐Ÿ›ก๏ธ **Built-in Authentication** Basic Auth, JWT, API key -- ๐Ÿง  **Header Injection:** Global and per-route header configuration -- ๐Ÿงช **Health Checks:** Pluggable health check methods for upstreams -- ๐Ÿ›ฐ๏ธ **Remote Config Push:** Lightweight HTTP API to update configs from CI/CD or other systems +- โš™๏ธ **Upstream Providers:** Supports `file`-based static upstreams, dynamic service discovery via `Consul`. +- ๐Ÿ” **Hot Reloading:** Modify upstreams on the fly via `upstreams.yaml` โ€” no restart needed. +- ๐Ÿ”ฎ **Automatic WebSocket Support:** Zero config โ€” connection upgrades are handled seamlessly. +- ๐Ÿ”ฎ **Automatic GRPC Support:** Zero config, Requires `ssl` to proxy, gRPC is handled seamlessly. +- ๐Ÿ”ฎ **Upstreams Session Stickiness:** Enable/Disable Sticky sessions. +- ๐Ÿ” **TLS Termination:** Fully supports TLS for incoming and upstream traffic. +- ๐Ÿ›ก๏ธ **Built-in Authentication** Basic Auth, JWT, API key. +- ๐Ÿง  **Header Injection:** Global and per-route header configuration. +- ๐Ÿงช **Health Checks:** Pluggable health check methods for upstreams. +- ๐Ÿ›ฐ๏ธ **Remote Config Push:** Lightweight HTTP API to update configs from CI/CD or other systems. --- @@ -82,7 +82,16 @@ Built on Rust, on top of **Cloudflareโ€™s Pingora engine**, **Gazan** delivers w ## ๐Ÿ›  Installation Download the prebuilt binary for your architecture from releases section of [GitHub](https://github.com/sadoyan/gazan/releases) repo -Make the binary executable `chmod 755 ./gazan` and run . +Make the binary executable `chmod 755 ./gazan-VERSION` and run. + +File names: + +| File Name | Description | +|--------------------------|---------------------------------------------------------------| +| `gazan-x86_64-musl.gz` | Static Linux x86_64 binary, without any system dependency | +| `gazan-x86_64-glibc.gz` | Dynamic Linux x86_64 binary, with minimal system dependencies | +| `gazan-aarch64-musl.gz` | Static Linux ARM64 binary, without any system dependency | +| `gazan-aarch64-glibc.gz` | Dynamic Linux ARM64 binary, with minimal system dependencies | ## ๐Ÿ”Œ Running the Proxy diff --git a/etc/main.yaml b/etc/main.yaml index 3d3f8e2..9599a6d 100644 --- a/etc/main.yaml +++ b/etc/main.yaml @@ -1,5 +1,5 @@ # Main configuration file , applied on startup -threads: 8 # Nubber of daemon threads default setting +threads: 12 # Nubber of daemon threads default setting #user: pastor # Username for running gazan after dropping root privileges, requires program to start as root #group: pastor # Group for running gazan after dropping root privileges, requires program to start as root daemon: false # Run in background diff --git a/etc/upstreams.yaml b/etc/upstreams.yaml index fae5bcb..26a2d05 100644 --- a/etc/upstreams.yaml +++ b/etc/upstreams.yaml @@ -8,12 +8,12 @@ globals: - "Access-Control-Max-Age:86400" - "X-Custom-Header:Something Special" # authorization: # Optional, only one of auth methods below can be active at a time -# - "basic" -# - "gazan:Gazanpass1234" -# - "apikey" -# - "5a28cc4c-ce10-4ff1-824e-743c38835f5c" # - "jwt" # - "910517d9-f9a1-48de-8826-dbadacbd84af-cb6f830e-ab16-47ec-9d8f-0090de732774" +# - "basic" +# - "zangag:Anhnazand1234" +# - "apikey" +# - "5a28cc4c-ce10-4ff1-824e-743c38835f5c" consul: # If the provider is consul. Otherwise ignored servers: - "http://master1:8500" @@ -68,11 +68,6 @@ upstreams: # If provider is files. Otherwise ignored servers: - "192.168.1.10:8000" - "192.168.1.1:8000" - apt.netangels.net: - paths: - "/": - servers: - - "apt.netangels.net:443" test.netangels.net: paths: "/": @@ -92,4 +87,14 @@ upstreams: # If provider is files. Otherwise ignored paths: "/": servers: - - "127.0.0.1:9000" \ No newline at end of file + - "127.0.0.1:9000" + ajbever.com: + paths: + "/": + servers: + - "ajbever.com:443" + apt.netangels.net: + paths: + "/": + servers: + - "85.17.24.1:443" diff --git a/src/main.rs b/src/main.rs index 4869eca..fa8fea4 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,6 +1,9 @@ mod utils; mod web; +#[global_allocator] +static GLOBAL: mimalloc::MiMalloc = mimalloc::MiMalloc; + fn main() { web::start::run(); } diff --git a/src/utils/consul.rs b/src/utils/consul.rs index 008ec4e..32284f6 100644 --- a/src/utils/consul.rs +++ b/src/utils/consul.rs @@ -109,7 +109,7 @@ async fn consul_request(url: String, whitelist: Option>, tok Some(upstreams) } -async fn get_by_http(url: String, token: Option) -> Option, AtomicUsize)>> { +async fn get_by_http(url: String, token: Option) -> Option, AtomicUsize)>> { let client = reqwest::Client::new(); let mut headers = HeaderMap::new(); if let Some(token) = token { @@ -118,7 +118,7 @@ async fn get_by_http(url: String, token: Option) -> Option, AtomicUsize)> = DashMap::new(); + let upstreams: DashMap, AtomicUsize)> = DashMap::new(); match u.await { Ok(r) => { let jason = r.json::>().await; @@ -127,7 +127,7 @@ async fn get_by_http(url: String, token: Option) -> Option, fullist: Arc, for val in fclone.iter() { let host = val.key(); let inner = DashMap::new(); - let mut _scheme: (String, u16, bool) = ("".to_string(), 0, false); + let mut _scheme: (String, u16, bool, bool) = ("".to_string(), 0, false, false); for path_entry in val.value().iter() { // let inner = DashMap::new(); let path = path_entry.key(); let mut innervec= Vec::new(); for k in path_entry.value().0 .iter().enumerate() { - let (ip, port, _ssl) = k.1; - let mut _pref = ""; + let (ip, port, _ssl, _version) = k.1; + let mut _link = String::new(); let tls = detect_tls(ip, port).await; - match tls { - true => _pref = "https://", - false => _pref = "http://", + let mut is_h2 = false; + + // if tls.1 == Some(Version::HTTP_11) { + // println!(" V1: ==> {:?}", tls.1) + // }else if tls.1 == Some(Version::HTTP_2) { + // is_h2 = true; + // println!(" V2: ==> {:?}", tls.1) + // } + + if tls.1 == Some(Version::HTTP_2) { + is_h2 = true; + // println!(" V2: ==> {} ==> {:?}", tls.0, tls.1) } - if _pref == "https://" { - _scheme = (ip.to_string(), *port, true); - }else { - _scheme = (ip.to_string(), *port, false); + + match tls.0 { + true => _link = format!("https://{}:{}{}", ip, port, path), + false => _link = format!("http://{}:{}{}", ip, port, path), } - let link = format!("{}{}:{}{}", _pref, ip, port, path); - let resp = http_request(link.as_str(), params.0, "").await; - match resp { + // if _pref == "https://" { + // _scheme = (ip.to_string(), *port, true); + // }else { + // _scheme = (ip.to_string(), *port, false); + // } + _scheme = (ip.to_string(), *port, tls.0, is_h2); + // let link = format!("{}{}:{}{}", _pref, ip, port, path); + let resp = http_request(_link.as_str(), params.0, "").await; + match resp.0 { true => { + if resp.1 { + _scheme = (ip.to_string(), *port, tls.0, true); + } innervec.push(_scheme.clone()); } false => { - warn!("Dead Upstream : {}", link); + warn!("Dead Upstream : {}", _link); } } } @@ -73,12 +91,12 @@ pub async fn hc2(upslist: Arc, fullist: Arc, } #[allow(dead_code)] -async fn http_request(url: &str, method: &str, payload: &str) -> bool { +async fn http_request(url: &str, method: &str, payload: &str) -> (bool, bool) { let client = Client::builder().danger_accept_invalid_certs(true).build().unwrap(); let timeout = Duration::from_secs(1); if !["POST", "GET", "HEAD"].contains(&method) { error!("Method {} not supported. Only GET|POST|HEAD are supported ", method); - return false; + return (false, false); } async fn send_request(client: &Client, method: &str, url: &str, payload: &str, timeout: Duration) -> Option { match method { @@ -92,11 +110,12 @@ async fn http_request(url: &str, method: &str, payload: &str) -> bool { match send_request(&client, method, url, payload, timeout).await { Some(response) => { let status = response.status().as_u16(); - (99..499).contains(&status) + ((99..499).contains(&status), false) } None => { - let fallback_url = url.replace("https", "http"); - ping_grpc(&fallback_url).await + // let fallback_url = url.replace("https", "http"); + // ping_grpc(&fallback_url).await + (ping_grpc(&url).await, true) } } } @@ -108,7 +127,10 @@ pub async fn ping_grpc(addr: &str) -> bool { let endpoint = endpoint.timeout(Duration::from_secs(2)); match tokio::time::timeout(Duration::from_secs(3), endpoint.connect()).await { - Ok(Ok(_channel)) => true, + Ok(Ok(_channel)) => { + // println!("{:?} ==> {:?} ==> {}", endpoint, _channel, addr); + true + } _ => false, } } else { @@ -116,20 +138,17 @@ pub async fn ping_grpc(addr: &str) -> bool { } } -async fn detect_tls(ip: &str, port: &u16) -> bool { +async fn detect_tls(ip: &str, port: &u16) -> (bool, Option) { let url = format!("https://{}:{}", ip, port); - let client = Client::builder() - .timeout(Duration::from_secs(2)) - .danger_accept_invalid_certs(true) // skip cert validation for testing - .build() - .unwrap(); + // let url = format!("{}:{}", ip, port); + let client = Client::builder().timeout(Duration::from_secs(2)).danger_accept_invalid_certs(true).build().unwrap(); match client.get(&url).send().await { - Ok(_) => true, + Ok(response) => (true, Some(response.version())), Err(e) => { if e.is_builder() || e.is_connect() || e.to_string().contains("tls") { - false + (false, None) } else { - false + (false, None) } } } diff --git a/src/utils/parceyaml.rs b/src/utils/parceyaml.rs index f64015c..769e359 100644 --- a/src/utils/parceyaml.rs +++ b/src/utils/parceyaml.rs @@ -87,7 +87,7 @@ pub fn load_configuration(d: &str, kind: &str) -> Option { if let Some((ip, port_str)) = server.split_once(':') { if let Ok(port) = port_str.parse::() { // server_list.push((ip.to_string(), port, path_config.ssl)); - server_list.push((ip.to_string(), port, true)); + server_list.push((ip.to_string(), port, true, false)); } } } diff --git a/src/utils/structs.rs b/src/utils/structs.rs index 3d05158..7fc82df 100644 --- a/src/utils/structs.rs +++ b/src/utils/structs.rs @@ -3,9 +3,9 @@ use serde::{Deserialize, Serialize}; use std::collections::HashMap; use std::sync::atomic::AtomicUsize; -pub type UpstreamsDashMap = DashMap, AtomicUsize)>>; +pub type UpstreamsDashMap = DashMap, AtomicUsize)>>; +pub type UpstreamsIdMap = DashMap; pub type Headers = DashMap>>; -pub type UpstreamsIdMap = DashMap; #[derive(Debug, Clone, Serialize, Deserialize)] pub struct ServiceMapping { diff --git a/src/utils/tools.rs b/src/utils/tools.rs index 8ad4e41..f3b51e9 100644 --- a/src/utils/tools.rs +++ b/src/utils/tools.rs @@ -16,8 +16,8 @@ pub fn print_upstreams(upstreams: &UpstreamsDashMap) { let path = path_entry.key(); println!(" Path: {}", path); - for (ip, port, ssl) in path_entry.value().0.clone() { - println!(" ===> IP: {}, Port: {}, SSL: {}", ip, port, ssl); + for (ip, port, ssl, vers) in path_entry.value().0.clone() { + println!(" ===> IP: {}, Port: {}, SSL: {}, H2: {}", ip, port, ssl, vers); } } } @@ -139,7 +139,7 @@ pub fn clone_idmap_into(original: &UpstreamsDashMap, cloned: &UpstreamsIdMap) { let hash = hasher.finalize(); let hex_hash = base16ct::lower::encode_string(&hash); let hh = hex_hash[0..50].to_string(); - cloned.insert(id, (hh.clone(), 0000, false)); + cloned.insert(id, (hh.clone(), 0000, false, false)); cloned.insert(hh, x.to_owned()); } new_inner_map.insert(path.clone(), new_vec); diff --git a/src/web/gethosts.rs b/src/web/gethosts.rs index c5bdc85..a8a40b0 100644 --- a/src/web/gethosts.rs +++ b/src/web/gethosts.rs @@ -4,12 +4,12 @@ use std::sync::atomic::Ordering; #[async_trait] pub trait GetHost { - fn get_host(&self, peer: &str, path: &str, backend_id: Option<&str>) -> Option<(String, u16, bool)>; + fn get_host(&self, peer: &str, path: &str, backend_id: Option<&str>) -> Option<(String, u16, bool, bool)>; fn get_header(&self, peer: &str, path: &str) -> Option>; } #[async_trait] impl GetHost for LB { - fn get_host(&self, peer: &str, path: &str, backend_id: Option<&str>) -> Option<(String, u16, bool)> { + fn get_host(&self, peer: &str, path: &str, backend_id: Option<&str>) -> Option<(String, u16, bool, bool)> { if let Some(b) = backend_id { if let Some(bb) = self.ump_byid.get(b) { // println!("BIB :===> {:?}", Some(bb.value())); @@ -19,7 +19,7 @@ impl GetHost for LB { let host_entry = self.ump_upst.get(peer)?; let mut current_path = path.to_string(); - let mut best_match: Option<(String, u16, bool)> = None; + let mut best_match: Option<(String, u16, bool, bool)> = None; loop { if let Some(entry) = host_entry.get(¤t_path) { let (servers, index) = entry.value(); diff --git a/src/web/proxyhttp.rs b/src/web/proxyhttp.rs index 190e96e..80ad981 100644 --- a/src/web/proxyhttp.rs +++ b/src/web/proxyhttp.rs @@ -33,52 +33,6 @@ impl ProxyHttp for LB { fn new_ctx(&self) -> Self::CTX { Context { backend_id: String::new() } } - async fn upstream_peer(&self, session: &mut Session, _ctx: &mut Self::CTX) -> Result> { - let host_name = return_header_host(&session); - - match host_name { - Some(host) => { - // session.req_header_mut().headers.insert("X-Host-Name", host.to_string().parse().unwrap()); - - let mut backend_id = None; - if self.extraparams.load().stickysessions { - if let Some(cookies) = session.req_header().headers.get("cookie") { - if let Ok(cookie_str) = cookies.to_str() { - for cookie in cookie_str.split(';') { - let trimmed = cookie.trim(); - if let Some(value) = trimmed.strip_prefix("backend_id=") { - backend_id = Some(value); - break; - } - } - } - } - } - - let ddr = self.get_host(host, host, backend_id); - - match ddr { - Some((host, port, ssl)) => { - // let mut peer = Box::new(HttpPeer::new((host, port), ssl, String::new())); - let mut peer = Box::new(HttpPeer::new((host.clone(), port.clone()), ssl, String::new())); - if session.is_http2() { - peer.options.alpn = ALPN::H2; - } - _ctx.backend_id = format!("{}:{}:{}", host.clone(), port.clone(), ssl); - Ok(peer) - } - None => { - warn!("Upstream not found. Host: {:?}, Path: {}", host, session.req_header().uri); - Ok(return_no_host(&self.config.local_server)) - } - } - } - None => { - warn!("Upstream not found. Host: {:?}, Path: {}", host_name, session.req_header().uri); - Ok(return_no_host(&self.config.local_server)) - } - } - } async fn request_filter(&self, session: &mut Session, _ctx: &mut Self::CTX) -> Result { if let Some(auth) = self.extraparams.load().authentication.get("authorization") { let authenticated = authenticate(&auth.value(), &session); @@ -95,6 +49,58 @@ impl ProxyHttp for LB { // }; Ok(false) } + async fn upstream_peer(&self, session: &mut Session, _ctx: &mut Self::CTX) -> Result> { + let host_name = return_header_host(&session); + + match host_name { + Some(hostname) => { + // session.req_header_mut().headers.insert("X-Host-Name", host.to_string().parse().unwrap()); + let mut backend_id = None; + if self.extraparams.load().stickysessions { + if let Some(cookies) = session.req_header().headers.get("cookie") { + if let Ok(cookie_str) = cookies.to_str() { + for cookie in cookie_str.split(';') { + let trimmed = cookie.trim(); + if let Some(value) = trimmed.strip_prefix("backend_id=") { + backend_id = Some(value); + break; + } + } + } + } + } + + let ddr = self.get_host(hostname, hostname, backend_id); + + match ddr { + Some((address, port, ssl, is_h2)) => { + let mut peer = Box::new(HttpPeer::new((address.clone(), port.clone()), ssl, String::new())); + // if session.is_http2() { + if is_h2 { + peer.options.alpn = ALPN::H2; + } + if ssl { + peer.sni = hostname.to_string(); + peer.options.verify_cert = false; + peer.options.verify_hostname = false; + } + // println!(" ==> {} ==> {} => {} => {:?}", hostname, address.as_str(), peer.options.alpn, is_h2); + _ctx.backend_id = format!("{}:{}:{}", address.clone(), port.clone(), ssl); + Ok(peer) + } + None => { + warn!("Upstream not found. Host: {:?}, Path: {}", hostname, session.req_header().uri); + Ok(return_no_host(&self.config.local_server)) + } + } + } + None => { + warn!("Upstream not found. Host: {:?}, Path: {}", host_name, session.req_header().uri); + Ok(return_no_host(&self.config.local_server)) + } + } + } + async fn upstream_request_filter(&self, _session: &mut Session, _upstream_request: &mut RequestHeader, _ctx: &mut Self::CTX) -> Result<()> { let clientip = _session.client_addr(); match clientip { @@ -118,7 +124,6 @@ impl ProxyHttp for LB { async fn response_filter(&self, _session: &mut Session, _upstream_response: &mut ResponseHeader, _ctx: &mut Self::CTX) -> Result<()> { // _upstream_response.insert_header("X-Proxied-From", "Fooooooooooooooo").unwrap(); - if self.extraparams.load().stickysessions { let backend_id = _ctx.backend_id.clone(); if let Some(bid) = self.ump_byid.get(&backend_id) { diff --git a/src/web/start.rs b/src/web/start.rs index bb0636c..b49c398 100644 --- a/src/web/start.rs +++ b/src/web/start.rs @@ -5,10 +5,12 @@ use dashmap::DashMap; use log::info; use pingora_core::prelude::{background_service, Opt}; use pingora_core::server::Server; +use rustls::crypto::ring::default_provider; use std::env; use std::sync::Arc; pub fn run() { + default_provider().install_default().expect("Failed to install rustls crypto provider"); let parameters = Some(Opt::parse_args()).unwrap(); let file = parameters.conf.clone().unwrap(); let maincfg = crate::utils::parceyaml::parce_main_config(file.as_str());