Skip to content

Commit be2d2cf

Browse files
committed
refactor(dependencies): update dependency versions and improve random number generation
1 parent 4fb1940 commit be2d2cf

6 files changed

Lines changed: 32 additions & 35 deletions

File tree

Cargo.toml

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -5,38 +5,38 @@ edition = "2021"
55

66
[dependencies]
77
arc-swap = "1.7.1"
8-
async-trait = "0.1.83"
8+
async-trait = "0.1.42"
99
base64 = "0.22.1"
10-
bytes = "1.8.0"
11-
dashmap = "6.1.0"
10+
bytes = "1.0"
11+
dashmap = "5"
1212
env_logger = { version = "0.11.5", features = ["unstable-kv"] }
13-
etcd-client = "0.16.1"
14-
futures = "0.3.31"
15-
hex = "0.4.3"
13+
etcd-client = "0.18.0"
14+
futures = "0.3"
15+
hex = "0.4"
1616
hickory-resolver = "0.25.2"
17-
http = "1.1.0"
17+
http = "1"
1818
ipnetwork = { version = "0.21.1", features = ["serde"] }
1919
jsonwebtoken = "9.3.1"
20-
log = { version = "0.4.22", features = ["kv"] }
20+
log = { version = "0.4", features = ["kv"] }
2121
matchit = "0.8.4"
22-
once_cell = "1.20.2"
23-
pingora = { version = "0.6.0", features = ["openssl", "sentry"] }
24-
pingora-cache = "0.6.0"
25-
pingora-core = "0.6.0"
26-
pingora-error = "0.6.0"
27-
pingora-http = "0.6.0"
28-
pingora-limits = "0.6.0"
29-
pingora-load-balancing = "0.6.0"
30-
pingora-proxy = "0.6.0"
31-
pingora-runtime = "0.6.0"
32-
prometheus = "0.13.4"
33-
rand = "0.9.2"
22+
once_cell = "1"
23+
pingora = { version = "0.7.0", features = ["openssl", "sentry"] }
24+
pingora-cache = "0.7.0"
25+
pingora-core = "0.7.0"
26+
pingora-error = "0.7.0"
27+
pingora-http = "0.7.0"
28+
pingora-limits = "0.7.0"
29+
pingora-load-balancing = "0.7.0"
30+
pingora-proxy = "0.7.0"
31+
pingora-runtime = "0.7.0"
32+
prometheus = "0.13"
33+
rand = "0.8"
3434
regex = "1.11.1"
3535
sentry = "0.36"
36-
serde = { version = "1.0.197", features = ["derive"] }
37-
serde_json = "1.0.133"
36+
serde = { version = "1.0", features = ["derive"] }
37+
serde_json = "1.0"
3838
serde_with = "3.12.0"
39-
serde_yaml = "0.9.34"
39+
serde_yaml = "0.9"
4040
sha2 = "0.10.9"
4141
tokio = { version = "1.41.1", features = ["fs"] }
4242
uuid = { version = "1.16.0", features = ["v4"] }

src/config/etcd.rs

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -85,18 +85,13 @@ impl EtcdConfigSync {
8585

8686
let client = self.get_client().await?;
8787

88-
let (mut watcher, mut stream) = client
88+
let mut stream = client
8989
.watch(prefix.as_str(), Some(options))
9090
.await
9191
.map_err(|e| {
9292
ProxyError::etcd_error_with_cause(format!("Failed to watch key '{prefix}'"), e)
9393
})?;
9494

95-
watcher
96-
.request_progress()
97-
.await
98-
.map_err(|e| ProxyError::etcd_error_with_cause("Failed to request progress", e))?;
99-
10095
while let Some(response) = stream
10196
.message()
10297
.await

src/plugins/csrf.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,9 +87,9 @@ impl PluginCsrf {
8787
///
8888
/// Returns None if system time is unavailable (should never happen in practice)
8989
fn gen_token_string(&self) -> Option<String> {
90-
let mut rng = rand::rng();
90+
let mut rng = rand::thread_rng();
9191
// Generate 16 random bytes for better entropy than f64
92-
let random_bytes: [u8; 16] = rng.random();
92+
let random_bytes: [u8; 16] = rng.gen();
9393
let random = hex::encode(random_bytes);
9494

9595
// Get current timestamp, handle potential system time errors gracefully

src/plugins/fault_injection.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -103,8 +103,8 @@ impl PluginFaultInjection {
103103
match percentage {
104104
None => true, // If no percentage is set, always apply
105105
Some(pct) => {
106-
let mut rng = rand::rng();
107-
rng.random_range(1..=100) <= pct
106+
let mut rng = rand::thread_rng();
107+
rng.gen_range(1..=100) <= pct
108108
}
109109
}
110110
}

src/plugins/request_id.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ impl PluginRequestID {
131131
return Uuid::new_v4().to_string();
132132
}
133133

134-
let mut rng = rand::rng();
134+
let mut rng = rand::thread_rng();
135135
(0..self.config.range_id.length)
136136
.map(|_| {
137137
chars

src/plugins/traffic_split.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
use async_trait::async_trait;
22
use pingora_error::Result;
33
use pingora_proxy::Session;
4+
use rand::Rng;
45
use serde::{Deserialize, Serialize};
56
use serde_json::Value as JsonValue;
67
use std::sync::Arc;
@@ -115,7 +116,8 @@ impl PluginTrafficSplit {
115116
return None;
116117
}
117118

118-
let mut n = rand::random_range(0..total_weight);
119+
let mut rng = rand::thread_rng();
120+
let mut n = rng.gen_range(0..total_weight);
119121

120122
for (i, ups_cfg) in upstreams.iter().enumerate() {
121123
if n < ups_cfg.weight {

0 commit comments

Comments
 (0)