Merge pull request #199 from greatest-ape/work-2024-04-20_2

http: improve peer addr extraction logic; update dependencies
This commit is contained in:
Joakim Frostegård 2024-04-25 23:21:26 +02:00 committed by GitHub
commit bfd53ea3cc
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
8 changed files with 378 additions and 126 deletions

View file

@ -63,6 +63,9 @@
* Fix bug where clean up after closing connections wasn't always done * Fix bug where clean up after closing connections wasn't always done
* Quit whole application if any worker thread quits * Quit whole application if any worker thread quits
* Fix panic when sending failure response when running with metrics behind
reverse proxy
* Don't always close connections after sending failure response
### aquatic_ws ### aquatic_ws

387
Cargo.lock generated
View file

@ -456,9 +456,9 @@ checksum = "96d30a06541fbafbc7f82ed10c06164cfbd2c401138f6addd8404629c4b16711"
[[package]] [[package]]
name = "async-tungstenite" name = "async-tungstenite"
version = "0.24.0" version = "0.25.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3609af4bbf701ddaf1f6bb4e6257dff4ff8932327d0e685d3f653724c258b1ac" checksum = "2cca750b12e02c389c1694d35c16539f88b8bbaa5945934fdc1b41a776688589"
dependencies = [ dependencies = [
"futures-io", "futures-io",
"futures-util", "futures-util",
@ -484,6 +484,33 @@ version = "1.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f1fdabc7756949593fe60f30ec81974b613357de856987752631dea1e3394c80" checksum = "f1fdabc7756949593fe60f30ec81974b613357de856987752631dea1e3394c80"
[[package]]
name = "aws-lc-rs"
version = "1.7.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5509d663b2c00ee421bda8d6a24d6c42e15970957de1701b8df9f6fbe5707df1"
dependencies = [
"aws-lc-sys",
"mirai-annotations",
"paste",
"zeroize",
]
[[package]]
name = "aws-lc-sys"
version = "0.15.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8d5d317212c2a78d86ba6622e969413c38847b62f48111f8b763af3dac2f9840"
dependencies = [
"bindgen",
"cc",
"cmake",
"dunce",
"fs_extra",
"libc",
"paste",
]
[[package]] [[package]]
name = "backtrace" name = "backtrace"
version = "0.3.71" version = "0.3.71"
@ -523,6 +550,29 @@ dependencies = [
"snafu", "snafu",
] ]
[[package]]
name = "bindgen"
version = "0.69.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a00dc851838a2120612785d195287475a3ac45514741da670b735818822129a0"
dependencies = [
"bitflags 2.5.0",
"cexpr",
"clang-sys",
"itertools 0.12.1",
"lazy_static",
"lazycell",
"log",
"prettyplease",
"proc-macro2",
"quote",
"regex",
"rustc-hash",
"shlex",
"syn 2.0.60",
"which",
]
[[package]] [[package]]
name = "bitflags" name = "bitflags"
version = "0.7.0" version = "0.7.0"
@ -619,6 +669,19 @@ name = "cc"
version = "1.0.92" version = "1.0.92"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2678b2e3449475e95b0aa6f9b506a28e61b3dc8996592b983695e8ebb58a8b41" checksum = "2678b2e3449475e95b0aa6f9b506a28e61b3dc8996592b983695e8ebb58a8b41"
dependencies = [
"jobserver",
"libc",
]
[[package]]
name = "cexpr"
version = "0.6.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6fac387a98bb7c37292057cffc56d62ecb629900026402633ae9160df93a8766"
dependencies = [
"nom",
]
[[package]] [[package]]
name = "cfg-if" name = "cfg-if"
@ -653,6 +716,17 @@ dependencies = [
"half", "half",
] ]
[[package]]
name = "clang-sys"
version = "1.7.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "67523a3b4be3ce1989d607a828d036249522dd9c1c8de7f4dd2dae43a37369d1"
dependencies = [
"glob",
"libc",
"libloading",
]
[[package]] [[package]]
name = "clap" name = "clap"
version = "3.2.25" version = "3.2.25"
@ -696,7 +770,7 @@ dependencies = [
"heck 0.5.0", "heck 0.5.0",
"proc-macro2", "proc-macro2",
"quote", "quote",
"syn 2.0.58", "syn 2.0.60",
] ]
[[package]] [[package]]
@ -714,6 +788,15 @@ version = "0.7.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "98cc8fbded0c607b7ba9dd60cd98df59af97e84d24e49c8557331cfc26d301ce" checksum = "98cc8fbded0c607b7ba9dd60cd98df59af97e84d24e49c8557331cfc26d301ce"
[[package]]
name = "cmake"
version = "0.1.50"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a31c789563b815f77f4250caee12365734369f942439b7defd71e18a48197130"
dependencies = [
"cc",
]
[[package]] [[package]]
name = "colorchoice" name = "colorchoice"
version = "1.0.0" version = "1.0.0"
@ -938,6 +1021,12 @@ version = "0.3.3"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "fea41bba32d969b513997752735605054bc0dfa92b4c56bf1189f2e174be7a10" checksum = "fea41bba32d969b513997752735605054bc0dfa92b4c56bf1189f2e174be7a10"
[[package]]
name = "dunce"
version = "1.0.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "56ce8c6da7551ec6c462cbaf3bfbc75131ebbfa1c944aeaa9dab51ca1c5f0c3b"
[[package]] [[package]]
name = "duplicate" name = "duplicate"
version = "1.0.0" version = "1.0.0"
@ -1075,6 +1164,12 @@ dependencies = [
"percent-encoding", "percent-encoding",
] ]
[[package]]
name = "fs_extra"
version = "1.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "42703706b716c37f96a77aea830392ad231f44c9e9a67872fa5548707e11b11c"
[[package]] [[package]]
name = "futures" name = "futures"
version = "0.3.30" version = "0.3.30"
@ -1146,14 +1241,14 @@ checksum = "87750cf4b7a4c0625b1529e4c543c2182106e4dedc60a2a6455e00d212c489ac"
dependencies = [ dependencies = [
"proc-macro2", "proc-macro2",
"quote", "quote",
"syn 2.0.58", "syn 2.0.60",
] ]
[[package]] [[package]]
name = "futures-rustls" name = "futures-rustls"
version = "0.25.1" version = "0.26.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c8d8a2499f0fecc0492eb3e47eab4e92da7875e1028ad2528f214ac3346ca04e" checksum = "a8f2f12607f92c69b12ed746fabf9ca4f5c482cba46679c1a75b874ed7c26adb"
dependencies = [ dependencies = [
"futures-io", "futures-io",
"rustls", "rustls",
@ -1237,19 +1332,25 @@ dependencies = [
"log", "log",
"proc-macro2", "proc-macro2",
"quote", "quote",
"syn 2.0.58", "syn 2.0.60",
"time", "time",
] ]
[[package]] [[package]]
name = "glommio" name = "glob"
version = "0.8.0" version = "0.3.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ac1f09bf53139d5680da6325b4e79c6bc1518e94a65ab74df14b7e3693a8c78b" checksum = "d2fabcfbdc87f4758337ca535fb41a6d701b65693ce38287d856d1674551ec9b"
[[package]]
name = "glommio"
version = "0.9.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e1f8bc1fce949d18098dc0a4e861314e40351a0144ebf61e59bdb5254a2273b2"
dependencies = [ dependencies = [
"ahash 0.7.8", "ahash 0.7.8",
"backtrace", "backtrace",
"bitflags 1.3.2", "bitflags 2.5.0",
"bitmaps", "bitmaps",
"buddy-alloc", "buddy-alloc",
"cc", "cc",
@ -1263,7 +1364,7 @@ dependencies = [
"libc", "libc",
"lockfree", "lockfree",
"log", "log",
"nix 0.23.2", "nix 0.27.1",
"pin-project-lite", "pin-project-lite",
"rlimit", "rlimit",
"scoped-tls", "scoped-tls",
@ -1276,6 +1377,25 @@ dependencies = [
"typenum", "typenum",
] ]
[[package]]
name = "h2"
version = "0.4.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "816ec7294445779408f36fe57bc5b7fc1cf59664059096c65f905c1c61f58069"
dependencies = [
"bytes",
"fnv",
"futures-core",
"futures-sink",
"futures-util",
"http",
"indexmap 2.2.6",
"slab",
"tokio",
"tokio-util",
"tracing",
]
[[package]] [[package]]
name = "half" name = "half"
version = "2.4.1" version = "2.4.1"
@ -1361,14 +1481,12 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7f24254aa9a54b5c858eaee2f5bccdb46aaf0e486a595ed5fd8f86ba55232a70" checksum = "7f24254aa9a54b5c858eaee2f5bccdb46aaf0e486a595ed5fd8f86ba55232a70"
[[package]] [[package]]
name = "http" name = "home"
version = "0.2.12" version = "0.5.9"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "601cbb57e577e2f5ef5be8e7b83f0f63994f25aa94d673e54a92d5c516d101f1" checksum = "e3d1354bf6b7235cb4a0576c2619fd4ed18183f689b12b006a0ee7329eeff9a5"
dependencies = [ dependencies = [
"bytes", "windows-sys 0.52.0",
"fnv",
"itoa",
] ]
[[package]] [[package]]
@ -1384,12 +1502,24 @@ dependencies = [
[[package]] [[package]]
name = "http-body" name = "http-body"
version = "0.4.6" version = "1.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7ceab25649e9960c0311ea418d17bee82c0dcec1bd053b5f9a66e265a693bed2" checksum = "1cac85db508abc24a2e48553ba12a996e87244a0395ce011e62b37158745d643"
dependencies = [ dependencies = [
"bytes", "bytes",
"http 0.2.12", "http",
]
[[package]]
name = "http-body-util"
version = "0.1.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0475f8b2ac86659c21b64320d5d653f9efe42acd2a4e560073ec61a155a34f1d"
dependencies = [
"bytes",
"futures-core",
"http",
"http-body",
"pin-project-lite", "pin-project-lite",
] ]
@ -1431,25 +1561,43 @@ dependencies = [
[[package]] [[package]]
name = "hyper" name = "hyper"
version = "0.14.28" version = "1.3.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "bf96e135eb83a2a8ddf766e426a841d8ddd7449d5f00d34ea02b41d2f19eef80" checksum = "fe575dd17d0862a9a33781c8c4696a55c320909004a67a00fb286ba8b1bc496d"
dependencies = [ dependencies = [
"bytes", "bytes",
"futures-channel", "futures-channel",
"futures-core",
"futures-util", "futures-util",
"http 0.2.12", "h2",
"http",
"http-body", "http-body",
"httparse", "httparse",
"httpdate", "httpdate",
"itoa", "itoa",
"pin-project-lite", "pin-project-lite",
"smallvec",
"tokio",
"want",
]
[[package]]
name = "hyper-util"
version = "0.1.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ca38ef113da30126bbff9cd1705f9273e15d45498615d138b0c20279ac7a76aa"
dependencies = [
"bytes",
"futures-channel",
"futures-util",
"http",
"http-body",
"hyper",
"pin-project-lite",
"socket2 0.5.6", "socket2 0.5.6",
"tokio", "tokio",
"tower",
"tower-service", "tower-service",
"tracing", "tracing",
"want",
] ]
[[package]] [[package]]
@ -1557,6 +1705,15 @@ version = "1.0.11"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "49f1f14873335454500d59611f1cf4a4b0f786f9ac11f4312a78e4cf2566695b" checksum = "49f1f14873335454500d59611f1cf4a4b0f786f9ac11f4312a78e4cf2566695b"
[[package]]
name = "jobserver"
version = "0.1.31"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d2b099aaa34a9751c5bf0878add70444e1ed2dd73f347be99003d4577277de6e"
dependencies = [
"libc",
]
[[package]] [[package]]
name = "js-sys" name = "js-sys"
version = "0.3.69" version = "0.3.69"
@ -1582,6 +1739,12 @@ version = "1.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646"
[[package]]
name = "lazycell"
version = "1.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "830d08ce1d1d941e6b30645f1a0eb5643013d835ce3779a5fc208261dbe10f55"
[[package]] [[package]]
name = "lexical-core" name = "lexical-core"
version = "0.8.5" version = "0.8.5"
@ -1652,6 +1815,16 @@ version = "0.2.153"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9c198f91728a82281a64e1f4f9eeb25d82cb32a5de251c6bd1b5154d63a8e7bd" checksum = "9c198f91728a82281a64e1f4f9eeb25d82cb32a5de251c6bd1b5154d63a8e7bd"
[[package]]
name = "libloading"
version = "0.8.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0c2a198fb6b0eada2a8df47933734e6d35d350665a33a3593d7164fa52c75c19"
dependencies = [
"cfg-if",
"windows-targets 0.52.4",
]
[[package]] [[package]]
name = "libm" name = "libm"
version = "0.2.8" version = "0.2.8"
@ -1705,15 +1878,6 @@ version = "2.7.2"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6c8640c5d730cb13ebd907d8d04b52f55ac9a2eec55b440c8892f40d56c76c1d" checksum = "6c8640c5d730cb13ebd907d8d04b52f55ac9a2eec55b440c8892f40d56c76c1d"
[[package]]
name = "memoffset"
version = "0.6.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5aa361d4faea93603064a027415f07bd8e1d5c88c9fbf68bf56a285428fd79ce"
dependencies = [
"autocfg",
]
[[package]] [[package]]
name = "memoffset" name = "memoffset"
version = "0.7.1" version = "0.7.1"
@ -1744,12 +1908,14 @@ dependencies = [
[[package]] [[package]]
name = "metrics-exporter-prometheus" name = "metrics-exporter-prometheus"
version = "0.13.1" version = "0.14.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9bf4e7146e30ad172c42c39b3246864bd2d3c6396780711a1baf749cfe423e21" checksum = "5d58e362dc7206e9456ddbcdbd53c71ba441020e62104703075a69151e38d85f"
dependencies = [ dependencies = [
"base64 0.21.7", "base64 0.22.0",
"http-body-util",
"hyper", "hyper",
"hyper-util",
"indexmap 2.2.6", "indexmap 2.2.6",
"ipnet", "ipnet",
"metrics", "metrics",
@ -1757,6 +1923,7 @@ dependencies = [
"quanta", "quanta",
"thiserror", "thiserror",
"tokio", "tokio",
"tracing",
] ]
[[package]] [[package]]
@ -1814,6 +1981,12 @@ dependencies = [
"windows-sys 0.48.0", "windows-sys 0.48.0",
] ]
[[package]]
name = "mirai-annotations"
version = "1.12.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c9be0862c1b3f26a88803c4a49de6889c10e608b3ee9344e6ef5b45fb37ad3d1"
[[package]] [[package]]
name = "nanorand" name = "nanorand"
version = "0.7.0" version = "0.7.0"
@ -1832,19 +2005,6 @@ dependencies = [
"smallvec", "smallvec",
] ]
[[package]]
name = "nix"
version = "0.23.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8f3790c00a0150112de0f4cd161e3d7fc4b2d8a5542ffc35f099a2562aecb35c"
dependencies = [
"bitflags 1.3.2",
"cc",
"cfg-if",
"libc",
"memoffset 0.6.5",
]
[[package]] [[package]]
name = "nix" name = "nix"
version = "0.26.4" version = "0.26.4"
@ -1858,6 +2018,18 @@ dependencies = [
"pin-utils", "pin-utils",
] ]
[[package]]
name = "nix"
version = "0.27.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2eb04e9c688eff1c89d72b407f168cf79bb9e867a9d3323ed6c01519eb9cc053"
dependencies = [
"bitflags 2.5.0",
"cfg-if",
"libc",
"memoffset 0.9.1",
]
[[package]] [[package]]
name = "nom" name = "nom"
version = "7.1.3" version = "7.1.3"
@ -2024,6 +2196,12 @@ dependencies = [
"windows-targets 0.48.5", "windows-targets 0.48.5",
] ]
[[package]]
name = "paste"
version = "1.0.14"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "de3145af08024dea9fa9914f381a17b8fc6034dfb00f3a84013f7ff43f29ed4c"
[[package]] [[package]]
name = "percent-encoding" name = "percent-encoding"
version = "2.3.1" version = "2.3.1"
@ -2047,7 +2225,7 @@ checksum = "2f38a4412a78282e09a2cf38d195ea5420d15ba0602cb375210efbc877243965"
dependencies = [ dependencies = [
"proc-macro2", "proc-macro2",
"quote", "quote",
"syn 2.0.58", "syn 2.0.60",
] ]
[[package]] [[package]]
@ -2124,6 +2302,16 @@ dependencies = [
"yansi", "yansi",
] ]
[[package]]
name = "prettyplease"
version = "0.2.19"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5ac2cf0f2e4f42b49f5ffd07dae8d746508ef7526c13940e5f524012ae6c6550"
dependencies = [
"proc-macro2",
"syn 2.0.60",
]
[[package]] [[package]]
name = "privdrop" name = "privdrop"
version = "0.5.4" version = "0.5.4"
@ -2160,9 +2348,9 @@ dependencies = [
[[package]] [[package]]
name = "proc-macro2" name = "proc-macro2"
version = "1.0.79" version = "1.0.81"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e835ff2298f5721608eb1a980ecaee1aef2c132bf95ecc026a11b7bf3c01c02e" checksum = "3d1597b0c024618f09a9c3b8655b7e430397a36d23fdafec26d6965e9eec3eba"
dependencies = [ dependencies = [
"unicode-ident", "unicode-ident",
] ]
@ -2318,7 +2506,7 @@ checksum = "5fddb4f8d99b0a2ebafc65a87a69a7b9875e4b1ae1f00db265d300ef7f28bccc"
dependencies = [ dependencies = [
"proc-macro2", "proc-macro2",
"quote", "quote",
"syn 2.0.58", "syn 2.0.60",
] ]
[[package]] [[package]]
@ -2380,6 +2568,12 @@ version = "0.1.23"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d626bb9dae77e28219937af045c257c28bfd3f69333c512553507f5f9798cb76" checksum = "d626bb9dae77e28219937af045c257c28bfd3f69333c512553507f5f9798cb76"
[[package]]
name = "rustc-hash"
version = "1.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "08d43f7aa6b08d49f382cde6a7982047c3426db949b1424bc4b7ec9ae12c6ce2"
[[package]] [[package]]
name = "rustix" name = "rustix"
version = "0.38.32" version = "0.38.32"
@ -2395,12 +2589,13 @@ dependencies = [
[[package]] [[package]]
name = "rustls" name = "rustls"
version = "0.22.3" version = "0.23.5"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "99008d7ad0bbbea527ec27bddbc0e432c5b87d8175178cee68d2eec9c4a1813c" checksum = "afabcee0551bd1aa3e18e5adbf2c0544722014b899adb31bd186ec638d3da97e"
dependencies = [ dependencies = [
"aws-lc-rs",
"log", "log",
"ring", "once_cell",
"rustls-pki-types", "rustls-pki-types",
"rustls-webpki", "rustls-webpki",
"subtle", "subtle",
@ -2429,6 +2624,7 @@ version = "0.102.2"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "faaa0a62740bedb9b2ef5afa303da42764c012f743917351dc9a237ea1663610" checksum = "faaa0a62740bedb9b2ef5afa303da42764c012f743917351dc9a237ea1663610"
dependencies = [ dependencies = [
"aws-lc-rs",
"ring", "ring",
"rustls-pki-types", "rustls-pki-types",
"untrusted", "untrusted",
@ -2503,7 +2699,7 @@ checksum = "7eb0b34b42edc17f6b7cac84a52a1c5f0e1bb2227e997ca9011ea3dd34e8610b"
dependencies = [ dependencies = [
"proc-macro2", "proc-macro2",
"quote", "quote",
"syn 2.0.58", "syn 2.0.60",
] ]
[[package]] [[package]]
@ -2537,6 +2733,12 @@ dependencies = [
"digest", "digest",
] ]
[[package]]
name = "shlex"
version = "1.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0fda2ff0d084019ba4d7c6f371c95d8fd75ce3524c3cb8fb653a3023f6323e64"
[[package]] [[package]]
name = "signal-hook" name = "signal-hook"
version = "0.3.17" version = "0.3.17"
@ -2718,9 +2920,9 @@ dependencies = [
[[package]] [[package]]
name = "syn" name = "syn"
version = "2.0.58" version = "2.0.60"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "44cfb93f38070beee36b3fef7d4f5a16f27751d94b187b666a5cc5e9b0d30687" checksum = "909518bc7b1c9b779f1bbf07f2929d35af9f0f37e47c6e9ef7f9dddc1e1821f3"
dependencies = [ dependencies = [
"proc-macro2", "proc-macro2",
"quote", "quote",
@ -2771,7 +2973,7 @@ checksum = "c61f3ba182994efc43764a46c018c347bc492c79f024e705f46567b418f6d4f7"
dependencies = [ dependencies = [
"proc-macro2", "proc-macro2",
"quote", "quote",
"syn 2.0.58", "syn 2.0.60",
] ]
[[package]] [[package]]
@ -2839,13 +3041,29 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1adbebffeca75fcfd058afa480fb6c0b81e165a0323f9c9d39c9697e37c46787" checksum = "1adbebffeca75fcfd058afa480fb6c0b81e165a0323f9c9d39c9697e37c46787"
dependencies = [ dependencies = [
"backtrace", "backtrace",
"bytes",
"libc", "libc",
"mio", "mio",
"num_cpus",
"pin-project-lite", "pin-project-lite",
"socket2 0.5.6", "socket2 0.5.6",
"windows-sys 0.48.0", "windows-sys 0.48.0",
] ]
[[package]]
name = "tokio-util"
version = "0.7.10"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5419f34732d9eb6ee4c3578b7989078579b7f039cbbb9ca2c4da015749371e15"
dependencies = [
"bytes",
"futures-core",
"futures-sink",
"pin-project-lite",
"tokio",
"tracing",
]
[[package]] [[package]]
name = "toml" name = "toml"
version = "0.5.11" version = "0.5.11"
@ -2889,6 +3107,28 @@ dependencies = [
"winnow", "winnow",
] ]
[[package]]
name = "tower"
version = "0.4.13"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b8fa9be0de6cf49e536ce1851f987bd21a43b771b09473c3549a6c853db37c1c"
dependencies = [
"futures-core",
"futures-util",
"pin-project",
"pin-project-lite",
"tokio",
"tower-layer",
"tower-service",
"tracing",
]
[[package]]
name = "tower-layer"
version = "0.3.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c20c8dbed6283a09604c3e69b4b7eeb54e298b8a600d4d5ecb5ad39de609f1d0"
[[package]] [[package]]
name = "tower-service" name = "tower-service"
version = "0.3.2" version = "0.3.2"
@ -2901,6 +3141,7 @@ version = "0.1.40"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c3523ab5a71916ccf420eebdf5521fcef02141234bbc0b8a49f2fdc4544364ef" checksum = "c3523ab5a71916ccf420eebdf5521fcef02141234bbc0b8a49f2fdc4544364ef"
dependencies = [ dependencies = [
"log",
"pin-project-lite", "pin-project-lite",
"tracing-attributes", "tracing-attributes",
"tracing-core", "tracing-core",
@ -2914,7 +3155,7 @@ checksum = "34704c8d6ebcbc939824180af020566b01a7c01f80641264eba0999f6c2b6be7"
dependencies = [ dependencies = [
"proc-macro2", "proc-macro2",
"quote", "quote",
"syn 2.0.58", "syn 2.0.60",
] ]
[[package]] [[package]]
@ -2941,7 +3182,7 @@ dependencies = [
"byteorder", "byteorder",
"bytes", "bytes",
"data-encoding", "data-encoding",
"http 1.1.0", "http",
"httparse", "httparse",
"log", "log",
"rand", "rand",
@ -3083,7 +3324,7 @@ dependencies = [
"once_cell", "once_cell",
"proc-macro2", "proc-macro2",
"quote", "quote",
"syn 2.0.58", "syn 2.0.60",
"wasm-bindgen-shared", "wasm-bindgen-shared",
] ]
@ -3105,7 +3346,7 @@ checksum = "e94f17b526d0a461a191c78ea52bbce64071ed5c04c9ffe424dcb38f74171bb7"
dependencies = [ dependencies = [
"proc-macro2", "proc-macro2",
"quote", "quote",
"syn 2.0.58", "syn 2.0.60",
"wasm-bindgen-backend", "wasm-bindgen-backend",
"wasm-bindgen-shared", "wasm-bindgen-shared",
] ]
@ -3126,6 +3367,18 @@ dependencies = [
"wasm-bindgen", "wasm-bindgen",
] ]
[[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]] [[package]]
name = "winapi" name = "winapi"
version = "0.2.8" version = "0.2.8"
@ -3334,7 +3587,7 @@ checksum = "9ce1b18ccd8e73a9321186f97e46f9f04b778851177567b1975109d26a08d2a6"
dependencies = [ dependencies = [
"proc-macro2", "proc-macro2",
"quote", "quote",
"syn 2.0.58", "syn 2.0.60",
] ]
[[package]] [[package]]

View file

@ -38,13 +38,13 @@ simplelog = { version = "0.12" }
toml = "0.5" toml = "0.5"
# rustls feature # rustls feature
rustls = { version = "0.22", optional = true } rustls = { version = "0.23", optional = true }
rustls-pemfile = { version = "2", optional = true } rustls-pemfile = { version = "2", optional = true }
# prometheus feature # prometheus feature
metrics = { version = "0.22", optional = true } metrics = { version = "0.22", optional = true }
metrics-util = { version = "0.16", optional = true } metrics-util = { version = "0.16", optional = true }
metrics-exporter-prometheus = { version = "0.13", optional = true, default-features = false, features = ["http-listener"] } metrics-exporter-prometheus = { version = "0.14", optional = true, default-features = false, features = ["http-listener"] }
tokio = { version = "1", optional = true, features = ["rt", "net", "time"] } tokio = { version = "1", optional = true, features = ["rt", "net", "time"] }
# cpu pinning feature # cpu pinning feature

View file

@ -34,8 +34,8 @@ cfg-if = "1"
either = "1" either = "1"
futures = "0.3" futures = "0.3"
futures-lite = "1" futures-lite = "1"
futures-rustls = "0.25" futures-rustls = "0.26"
glommio = "0.8" glommio = "0.9"
httparse = "1" httparse = "1"
itoa = "1" itoa = "1"
libc = "0.2" libc = "0.2"

View file

@ -14,7 +14,6 @@ use aquatic_http_protocol::response::{
FailureResponse, Response, ScrapeResponse, ScrapeStatistics, FailureResponse, Response, ScrapeResponse, ScrapeStatistics,
}; };
use arc_swap::ArcSwap; use arc_swap::ArcSwap;
use either::Either;
use futures::stream::FuturesUnordered; use futures::stream::FuturesUnordered;
use futures_lite::{AsyncReadExt, AsyncWriteExt, StreamExt}; use futures_lite::{AsyncReadExt, AsyncWriteExt, StreamExt};
use futures_rustls::TlsAcceptor; use futures_rustls::TlsAcceptor;
@ -110,7 +109,6 @@ pub(super) async fn run_connection(
request_senders, request_senders,
valid_until, valid_until,
server_start_instant, server_start_instant,
opt_peer_addr,
peer_port, peer_port,
request_buffer, request_buffer,
request_buffer_position: 0, request_buffer_position: 0,
@ -119,7 +117,7 @@ pub(super) async fn run_connection(
worker_index_string: worker_index.to_string(), worker_index_string: worker_index.to_string(),
}; };
conn.run().await conn.run(opt_peer_addr).await
} else { } else {
let mut conn = Connection { let mut conn = Connection {
config, config,
@ -127,7 +125,6 @@ pub(super) async fn run_connection(
request_senders, request_senders,
valid_until, valid_until,
server_start_instant, server_start_instant,
opt_peer_addr,
peer_port, peer_port,
request_buffer, request_buffer,
request_buffer_position: 0, request_buffer_position: 0,
@ -136,7 +133,7 @@ pub(super) async fn run_connection(
worker_index_string: worker_index.to_string(), worker_index_string: worker_index.to_string(),
}; };
conn.run().await conn.run(opt_peer_addr).await
} }
} }
@ -146,9 +143,6 @@ struct Connection<S> {
request_senders: Rc<Senders<ChannelRequest>>, request_senders: Rc<Senders<ChannelRequest>>,
valid_until: Rc<RefCell<ValidUntil>>, valid_until: Rc<RefCell<ValidUntil>>,
server_start_instant: ServerStartInstant, server_start_instant: ServerStartInstant,
// If we're running behind a reverse proxy, gets set as soon as we get a
// valid requiest. Otherwise, must be set before calling `run`.
opt_peer_addr: Option<CanonicalSocketAddr>,
peer_port: u16, peer_port: u16,
request_buffer: Box<[u8; REQUEST_BUFFER_SIZE]>, request_buffer: Box<[u8; REQUEST_BUFFER_SIZE]>,
request_buffer_position: usize, request_buffer_position: usize,
@ -161,16 +155,23 @@ impl<S> Connection<S>
where where
S: futures::AsyncRead + futures::AsyncWrite + Unpin + 'static, S: futures::AsyncRead + futures::AsyncWrite + Unpin + 'static,
{ {
async fn run(&mut self) -> Result<(), ConnectionError> { async fn run(
&mut self,
// Set unless running behind reverse proxy
opt_stable_peer_addr: Option<CanonicalSocketAddr>,
) -> Result<(), ConnectionError> {
loop { loop {
let response = match self.read_request().await? { let (request, opt_peer_addr) = self.read_request().await?;
Either::Left(response) => Response::Failure(response),
Either::Right(request) => self.handle_request(request).await?,
};
self.write_response(&response).await?; let peer_addr = opt_stable_peer_addr
.or(opt_peer_addr)
.ok_or(anyhow::anyhow!("Could not extract peer addr"))?;
if matches!(response, Response::Failure(_)) || !self.config.network.keep_alive { let response = self.handle_request(request, peer_addr).await?;
self.write_response(&response, peer_addr).await?;
if !self.config.network.keep_alive {
break; break;
} }
} }
@ -178,7 +179,9 @@ where
Ok(()) Ok(())
} }
async fn read_request(&mut self) -> Result<Either<FailureResponse, Request>, ConnectionError> { async fn read_request(
&mut self,
) -> Result<(Request, Option<CanonicalSocketAddr>), ConnectionError> {
self.request_buffer_position = 0; self.request_buffer_position = 0;
loop { loop {
@ -202,17 +205,19 @@ where
match parse_request(&self.config, buffer_slice) { match parse_request(&self.config, buffer_slice) {
Ok((request, opt_peer_ip)) => { Ok((request, opt_peer_ip)) => {
if self.config.network.runs_behind_reverse_proxy { let opt_peer_addr = if self.config.network.runs_behind_reverse_proxy {
let peer_ip = opt_peer_ip let peer_ip = opt_peer_ip
.expect("logic error: peer ip must have been extracted at this point"); .expect("logic error: peer ip must have been extracted at this point");
self.opt_peer_addr = Some(CanonicalSocketAddr::new(SocketAddr::new( Some(CanonicalSocketAddr::new(SocketAddr::new(
peer_ip, peer_ip,
self.peer_port, self.peer_port,
))); )))
} } else {
None
};
return Ok(Either::Right(request)); return Ok((request, opt_peer_addr));
} }
Err(RequestParseError::MoreDataNeeded) => continue, Err(RequestParseError::MoreDataNeeded) => continue,
Err(RequestParseError::RequiredPeerIpHeaderMissing(err)) => { Err(RequestParseError::RequiredPeerIpHeaderMissing(err)) => {
@ -220,12 +225,6 @@ where
} }
Err(RequestParseError::Other(err)) => { Err(RequestParseError::Other(err)) => {
::log::debug!("Failed parsing request: {:#}", err); ::log::debug!("Failed parsing request: {:#}", err);
let response = FailureResponse {
failure_reason: "Invalid request".into(),
};
return Ok(Either::Left(response));
} }
} }
} }
@ -238,11 +237,11 @@ where
/// response /// response
/// - If it is a scrape requests, split it up, pass on the parts to /// - If it is a scrape requests, split it up, pass on the parts to
/// relevant swarm workers and await a response /// relevant swarm workers and await a response
async fn handle_request(&mut self, request: Request) -> Result<Response, ConnectionError> { async fn handle_request(
let peer_addr = self &mut self,
.opt_peer_addr request: Request,
.expect("peer addr should already have been extracted by now"); peer_addr: CanonicalSocketAddr,
) -> Result<Response, ConnectionError> {
*self.valid_until.borrow_mut() = ValidUntil::new( *self.valid_until.borrow_mut() = ValidUntil::new(
self.server_start_instant, self.server_start_instant,
self.config.cleaning.max_connection_idle, self.config.cleaning.max_connection_idle,
@ -385,7 +384,11 @@ where
} }
} }
async fn write_response(&mut self, response: &Response) -> Result<(), ConnectionError> { async fn write_response(
&mut self,
response: &Response,
peer_addr: CanonicalSocketAddr,
) -> Result<(), ConnectionError> {
// Write body and final newline to response buffer // Write body and final newline to response buffer
let mut position = RESPONSE_HEADER.len(); let mut position = RESPONSE_HEADER.len();
@ -443,15 +446,7 @@ where
Response::Failure(_) => "error", Response::Failure(_) => "error",
}; };
// If we're behind a reverse proxy and we're sending an error let ip_version_str = peer_addr_to_ip_version_str(&peer_addr);
// response due to failing to parse a request, opt_peer_addr might
// not yet be set (and in that case, we don't know if the true peer
// connects over IPv4 or IPv6)
let ip_version_str = self
.opt_peer_addr
.as_ref()
.map(peer_addr_to_ip_version_str)
.unwrap_or("?");
::metrics::counter!( ::metrics::counter!(
"aquatic_responses_total", "aquatic_responses_total",

View file

@ -22,14 +22,14 @@ aquatic_toml_config.workspace = true
anyhow = "1" anyhow = "1"
futures = "0.3" futures = "0.3"
futures-lite = "1" futures-lite = "1"
futures-rustls = "0.25" futures-rustls = "0.26"
hashbrown = "0.14" hashbrown = "0.14"
glommio = "0.8" glommio = "0.9"
log = "0.4" log = "0.4"
mimalloc = { version = "0.1", default-features = false } mimalloc = { version = "0.1", default-features = false }
rand = { version = "0.8", features = ["small_rng"] } rand = { version = "0.8", features = ["small_rng"] }
rand_distr = "0.4" rand_distr = "0.4"
rustls = { version = "0.22", default-features = false, features = ["logging"] } # TLS 1.2 disabled rustls = { version = "0.23", default-features = false, features = ["logging"] } # TLS 1.2 disabled
serde = { version = "1", features = ["derive"] } serde = { version = "1", features = ["derive"] }
[dev-dependencies] [dev-dependencies]

View file

@ -21,8 +21,9 @@ name = "aquatic_ws"
default = ["prometheus", "mimalloc"] default = ["prometheus", "mimalloc"]
prometheus = ["metrics", "aquatic_common/prometheus"] prometheus = ["metrics", "aquatic_common/prometheus"]
metrics = ["dep:metrics", "dep:metrics-util"] metrics = ["dep:metrics", "dep:metrics-util"]
# Use mimalloc allocator for much better performance. Requires cmake and a # Use mimalloc allocator for much better performance.
# C/C++ compiler #
# Requires cmake and a C compiler
mimalloc = ["dep:mimalloc"] mimalloc = ["dep:mimalloc"]
[dependencies] [dependencies]
@ -32,13 +33,13 @@ aquatic_toml_config.workspace = true
aquatic_ws_protocol.workspace = true aquatic_ws_protocol.workspace = true
anyhow = "1" anyhow = "1"
async-tungstenite = "0.24" async-tungstenite = "0.25"
arc-swap = "1" arc-swap = "1"
cfg-if = "1" cfg-if = "1"
futures = "0.3" futures = "0.3"
futures-lite = "1" futures-lite = "1"
futures-rustls = "0.25" futures-rustls = "0.26"
glommio = "0.8" glommio = "0.9"
hashbrown = { version = "0.14", features = ["serde"] } hashbrown = { version = "0.14", features = ["serde"] }
httparse = "1" httparse = "1"
indexmap = "2" indexmap = "2"
@ -46,7 +47,7 @@ log = "0.4"
mimalloc = { version = "0.1", default-features = false, optional = true } mimalloc = { version = "0.1", default-features = false, optional = true }
privdrop = "0.5" privdrop = "0.5"
rand = { version = "0.8", features = ["small_rng"] } rand = { version = "0.8", features = ["small_rng"] }
rustls = "0.22" rustls = "0.23"
rustls-pemfile = "2" rustls-pemfile = "2"
serde = { version = "1", features = ["derive"] } serde = { version = "1", features = ["derive"] }
signal-hook = { version = "0.3" } signal-hook = { version = "0.3" }

View file

@ -20,15 +20,15 @@ aquatic_toml_config.workspace = true
aquatic_ws_protocol.workspace = true aquatic_ws_protocol.workspace = true
anyhow = "1" anyhow = "1"
async-tungstenite = "0.24" async-tungstenite = "0.25"
futures = "0.3" futures = "0.3"
futures-rustls = "0.25" futures-rustls = "0.26"
glommio = "0.8" glommio = "0.9"
log = "0.4" log = "0.4"
mimalloc = { version = "0.1", default-features = false } mimalloc = { version = "0.1", default-features = false }
rand = { version = "0.8", features = ["small_rng"] } rand = { version = "0.8", features = ["small_rng"] }
rand_distr = "0.4" rand_distr = "0.4"
rustls = { version = "0.22" } rustls = { version = "0.23" }
serde = { version = "1", features = ["derive"] } serde = { version = "1", features = ["derive"] }
serde_json = "1" serde_json = "1"
tungstenite = "0.21" tungstenite = "0.21"