mirror of
https://github.com/YGGverse/aquatic.git
synced 2026-04-01 10:15:31 +00:00
aquatic http: request from path: whitelist url keys for security
This way, the non-ddos-resistant hashmap hasher can be kept. Also improves performance, probably simply because less hashing work is done: time: [2.8050 us 2.8156 us 2.8274 us] change: [-22.940% -22.412% -21.916%] (p = 0.00 < 0.01) Performance has improved.
This commit is contained in:
parent
09d27d5075
commit
54e801c6a9
6 changed files with 1017 additions and 1010 deletions
|
|
@ -166,13 +166,22 @@ impl Request {
|
|||
.with_context(|| format!("no key at {}..{}", position, equal_sign_index))?;
|
||||
let value = query_string.get(equal_sign_index + 1..segment_end)
|
||||
.with_context(|| format!("no value at {}..{}", equal_sign_index + 1, segment_end))?;
|
||||
|
||||
// whitelist keys to avoid having to use ddos-resistant hashmap
|
||||
match key {
|
||||
"info_hash" => {
|
||||
let value = Self::urldecode_memchr(value)?;
|
||||
|
||||
let value = Self::urldecode_memchr(value)?;
|
||||
info_hashes.push(value);
|
||||
},
|
||||
"peer_id" | "port" | "left" | "event" | "compact" | "numwant" | "key" => {
|
||||
let value = Self::urldecode_memchr(value)?;
|
||||
|
||||
if key == "info_hash" {
|
||||
info_hashes.push(value);
|
||||
} else {
|
||||
data.insert(key, value);
|
||||
data.insert(key, value);
|
||||
},
|
||||
k => {
|
||||
::log::info!("ignored unrecognized key: {}", k)
|
||||
}
|
||||
}
|
||||
|
||||
if segment_end == query_string.len(){
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue