Skip to content

Commit 3589c5a

Browse files
authored
Merge pull request #690 from nextcloud/updates-03-26
Dependency updates
2 parents 846858b + 9007341 commit 3589c5a

9 files changed

Lines changed: 896 additions & 595 deletions

File tree

Cargo.lock

Lines changed: 826 additions & 531 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ edition = "2021"
88
rust-version = "1.88.0"
99

1010
[dependencies]
11-
redis = { version = "0.31.0", default-features = false, features = ["tokio-comp", "aio", "cluster", "cluster-async", "keep-alive", "tls-rustls", "tokio-rustls-comp", "tls-rustls-webpki-roots", "tls-rustls-insecure"] }
11+
redis = { version = "1.0.5", default-features = false, features = ["tokio-comp", "aio", "cluster", "cluster-async", "tls-rustls", "tokio-rustls-comp", "tls-rustls-webpki-roots", "tls-rustls-insecure"] }
1212
serde = { version = "1.0.219", features = ["derive"] }
1313
serde_json = "1.0.142"
1414
thiserror = "2.0.12"
@@ -22,21 +22,22 @@ dashmap = "6.1.0"
2222
once_cell = "1.21.3"
2323
miette = { version = "7.6.0", features = ["fancy"] }
2424
smallvec = { version = "1.15.1", features = ["serde"] }
25-
reqwest = { version = "0.12.22", default-features = false, features = ["rustls-tls", "rustls-tls-native-roots", "json"] }
25+
reqwest = { version = "0.13.2", features = ["json"] }
2626
warp-real-ip = "0.2.0"
2727
parse-display = "0.10.0"
2828
rand = { version = "0.8.5", features = ["small_rng"] }
2929
ahash = "0.8.12"
30-
flexi_logger = { version = "0.29.8", features = ["colors"] }
30+
flexi_logger = { version = "0.31.8", features = ["colors"] }
3131
tokio-stream = { version = "0.1.17", features = ["net"] }
3232
nextcloud-config-parser = "0.15.1"
3333
url = "2.5.4"
3434
clap = { version = "4.5.43", features = ["derive"] }
35-
sd-notify = { version = "0.4.5", optional = true }
35+
sd-notify = { version = "0.5.0", optional = true }
36+
webpki-root-certs = "1.0.6"
3637

3738
[dev-dependencies]
3839
mini-redis = "0.4.1"
39-
tokio-tungstenite = "0.26.2"
40+
tokio-tungstenite = "0.28.0"
4041
http-auth-basic = "0.3.5"
4142
test_client = { path = "test_client" }
4243

flake.nix

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@
114114
};
115115

116116
devShells = {
117-
default = cross-naersk'.mkShell targets {
117+
default = cross-naersk'.mkShell ["x86_64-unknown-linux-gnu"] {
118118
nativeBuildInputs = with pkgs; [
119119
(rust-bin.stable.latest.default.override {targets = targets ++ [hostTarget];})
120120
krankerl
@@ -126,7 +126,7 @@
126126
phpPackages.composer
127127
];
128128
};
129-
msrv = cross-naersk'.mkShell targets {
129+
msrv = cross-naersk'.mkShell ["x86_64-unknown-linux-gnu"] {
130130
nativeBuildInputs = with pkgs; [
131131
msrvToolchain
132132
];

src/config.rs

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -297,7 +297,7 @@ impl PartialConfig {
297297
let max_connection_time = parse_var("MAX_CONNECTION_TIME")?;
298298

299299
let redis = redis.map(|redis| {
300-
let addr = map_redis_addr(redis.addr);
300+
let addr = map_redis_addr(redis.addr().clone());
301301

302302
let accept_invalid_hostname = redis_tls_dont_validate_hostname
303303
.filter(|b| *b != 0)
@@ -315,9 +315,9 @@ impl PartialConfig {
315315

316316
RedisConfig::Single(RedisConnectionInfo {
317317
addr,
318-
db: redis.redis.db,
319-
username: redis.redis.username,
320-
password: redis.redis.password,
318+
db: redis.redis_settings().db(),
319+
username: redis.redis_settings().username().map(String::from),
320+
password: redis.redis_settings().password().map(String::from),
321321
tls_params,
322322
})
323323
});
@@ -357,7 +357,7 @@ impl PartialConfig {
357357
0 => None,
358358
1 => {
359359
let redis = opt.redis_url.into_iter().next().unwrap();
360-
let addr = map_redis_addr(redis.addr);
360+
let addr = map_redis_addr(redis.addr().clone());
361361

362362
let redis_tls = matches!(addr, RedisConnectionAddr::Tcp { tls: true, .. });
363363

@@ -371,17 +371,17 @@ impl PartialConfig {
371371

372372
Some(RedisConfig::Single(RedisConnectionInfo {
373373
addr,
374-
db: redis.redis.db,
375-
username: redis.redis.username,
376-
password: redis.redis.password,
374+
db: redis.redis_settings().db(),
375+
username: redis.redis_settings().username().map(String::from),
376+
password: redis.redis_settings().password().map(String::from),
377377
tls_params,
378378
}))
379379
}
380380
_ => {
381381
let addr: Vec<_> = opt
382382
.redis_url
383383
.iter()
384-
.map(|redis| map_redis_addr(redis.addr.clone()))
384+
.map(|redis| map_redis_addr(redis.addr().clone()))
385385
.collect();
386386

387387
let redis_tls = matches!(
@@ -397,12 +397,13 @@ impl PartialConfig {
397397
insecure: opt.redis_tls_insecure,
398398
});
399399

400-
let redis = opt.redis_url.into_iter().next().unwrap().redis;
400+
let redis = opt.redis_url.into_iter().next().unwrap();
401+
let redis = redis.redis_settings();
401402
Some(RedisConfig::Cluster(RedisClusterConnectionInfo {
402403
addr,
403-
db: redis.db,
404-
username: redis.username,
405-
password: redis.password,
404+
db: redis.db(),
405+
username: redis.username().map(String::from),
406+
password: redis.password().map(String::from),
406407
tls_params,
407408
}))
408409
}
@@ -483,5 +484,6 @@ fn map_redis_addr(addr: ConnectionAddr) -> RedisConnectionAddr {
483484
tls: true,
484485
},
485486
ConnectionAddr::Unix(path) => RedisConnectionAddr::Unix { path },
487+
_ => unreachable!("unknown redis address"),
486488
}
487489
}

src/main.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ async fn run(config: Config, log_handle: LoggerHandle) -> Result<()> {
105105

106106
// tell SystemD that sockets have been bound to their addresses
107107
#[cfg(feature = "systemd")]
108-
sd_notify::notify(true, &[sd_notify::NotifyState::Ready]).map_err(Error::SystemD)?;
108+
sd_notify::notify(&[sd_notify::NotifyState::Ready]).map_err(Error::SystemD)?;
109109

110110
spawn(listen_loop(app, listen_cancel_handle));
111111

src/nc.rs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
use crate::error::{AuthenticationError, NextCloudError};
77
use crate::{Result, UserId};
88
use reqwest::header::HeaderName;
9-
use reqwest::{Response, StatusCode, Url};
9+
use reqwest::{Certificate, Response, StatusCode, Url};
1010
use std::fmt::Write;
1111
use std::net::IpAddr;
1212

@@ -21,7 +21,12 @@ impl Client {
2121
pub fn new(base_url: &str, allow_self_signed: bool) -> Result<Self, NextCloudError> {
2222
let base_url = Url::parse(base_url)?;
2323
let http = reqwest::Client::builder()
24-
.danger_accept_invalid_certs(allow_self_signed)
24+
.tls_certs_merge(
25+
webpki_root_certs::TLS_SERVER_ROOT_CERTS
26+
.iter()
27+
.map(|root| Certificate::from_der(root).unwrap()),
28+
)
29+
.tls_danger_accept_invalid_certs(allow_self_signed)
2530
.build()?;
2631
Ok(Client { http, base_url })
2732
}

src/redis.rs

Lines changed: 31 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ use redis::aio::{MultiplexedConnection, PubSub};
1111
use redis::cluster::ClusterClient;
1212
use redis::cluster_async::ClusterConnection;
1313
use redis::{
14-
AsyncCommands, Client, ClientTlsConfig, ConnectionAddr, ConnectionInfo, RedisConnectionInfo,
15-
RedisError, TlsCertificates,
14+
AsyncCommands, Client, ClientTlsConfig, ConnectionAddr, ConnectionInfo, IntoConnectionInfo,
15+
RedisConnectionInfo, RedisError, TlsCertificates,
1616
};
1717
use std::fs::read;
1818

@@ -56,25 +56,27 @@ impl Redis {
5656
pub fn open_single(
5757
info: &nextcloud_config_parser::RedisConnectionInfo,
5858
) -> Result<Client, RedisError> {
59-
let redis = RedisConnectionInfo {
60-
db: info.db,
61-
username: info.username.clone(),
62-
password: info.password.clone(),
63-
protocol: Default::default(),
64-
};
59+
let mut redis = RedisConnectionInfo::default().set_db(info.db);
60+
if let Some(username) = info.username.as_deref() {
61+
redis = redis.set_username(username);
62+
}
63+
if let Some(password) = info.password.as_deref() {
64+
redis = redis.set_password(password);
65+
}
6566
let connection_info = build_connection_info(info.addr.clone(), redis, info.tls_params.as_ref());
6667
Ok(match info.tls_params.as_ref() {
6768
None => Client::open(connection_info)?,
6869
Some(tls_params) => {
6970
// the redis library doesn't let us set both `danger_accept_invalid_hostnames` and certificates without this mess:
7071
// `Client::build_with_tls` doesn't use the `danger_accept_invalid_hostnames` from the passed in info
7172
// so we first use it to get build the certificates then take the connection info from it so we can configure it further
72-
let mut connection_info =
73+
let connection_info =
7374
Client::build_with_tls(connection_info, build_tls_certificates(tls_params)?)?
7475
.get_connection_info()
7576
.clone();
7677
connection_info
77-
.addr
78+
.addr()
79+
.clone()
7880
.set_danger_accept_invalid_hostnames(tls_params.accept_invalid_hostname);
7981
Client::open(connection_info)?
8082
}
@@ -86,48 +88,43 @@ fn build_connection_info(
8688
redis: RedisConnectionInfo,
8789
tls: Option<&RedisTlsParams>,
8890
) -> ConnectionInfo {
89-
match (addr, tls) {
91+
let addr = match (addr, tls) {
9092
(
9193
RedisConnectionAddr::Tcp {
9294
host,
9395
port,
9496
tls: false,
9597
},
9698
_,
97-
) => ConnectionInfo {
98-
addr: ConnectionAddr::Tcp(host, port),
99-
redis,
100-
},
99+
) => ConnectionAddr::Tcp(host, port),
101100
(
102101
RedisConnectionAddr::Tcp {
103102
host,
104103
port,
105104
tls: true,
106105
},
107106
tls_params,
108-
) => ConnectionInfo {
109-
addr: ConnectionAddr::TcpTls {
110-
host,
111-
port,
112-
insecure: tls_params.map(|tls| tls.insecure).unwrap_or_default(),
113-
tls_params: None,
114-
},
115-
redis,
107+
) => ConnectionAddr::TcpTls {
108+
host,
109+
port,
110+
insecure: tls_params.map(|tls| tls.insecure).unwrap_or_default(),
111+
tls_params: None,
116112
},
117-
(RedisConnectionAddr::Unix { path }, _) => ConnectionInfo {
118-
addr: ConnectionAddr::Unix(path),
119-
redis,
120-
},
121-
}
113+
(RedisConnectionAddr::Unix { path }, _) => ConnectionAddr::Unix(path),
114+
};
115+
addr.into_connection_info()
116+
.unwrap()
117+
.set_redis_settings(redis)
122118
}
123119

124120
fn open_cluster(info: &RedisClusterConnectionInfo) -> Result<ClusterClient, RedisError> {
125-
let redis = RedisConnectionInfo {
126-
db: info.db,
127-
username: info.username.clone(),
128-
password: info.password.clone(),
129-
protocol: Default::default(),
130-
};
121+
let mut redis = RedisConnectionInfo::default().set_db(info.db);
122+
if let Some(username) = info.username.as_deref() {
123+
redis = redis.set_username(username);
124+
}
125+
if let Some(password) = info.password.as_deref() {
126+
redis = redis.set_password(password);
127+
}
131128
let mut builder =
132129
ClusterClient::builder(info.addr.iter().map(|addr| {
133130
build_connection_info(addr.clone(), redis.clone(), info.tls_params.as_ref())

test_client/Cargo.toml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,10 @@ authors = ["Robin Appelman <robin@icewind.nl>"]
77
edition = "2018"
88

99
[dependencies]
10-
tungstenite = { version = "0.26.2", features = ["rustls-tls-webpki-roots", "url"] }
10+
tungstenite = { version = "0.28.0", features = ["rustls-tls-webpki-roots", "url"] }
1111
serde_json = "1.0.142"
12-
ureq = "2.12.1"
13-
flexi_logger = { version = "0.29.8", features = ["colors"] }
12+
ureq = "3.2.0"
13+
flexi_logger = { version = "0.31.8", features = ["colors"] }
1414
log = "0.4.27"
1515
base64 = "0.22.1"
1616
miette = { version = "7.6.0", features = ["fancy"] }

test_client/src/main.rs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -80,18 +80,19 @@ fn main() -> Result<()> {
8080

8181
fn get_endpoint(nc_url: &str, user: &str, password: &str) -> Result<String> {
8282
let raw = ureq::get(&format!("{nc_url}/ocs/v2.php/cloud/capabilities"))
83-
.set(
83+
.header(
8484
"Authorization",
8585
&format!(
8686
"Basic {}",
8787
base64::engine::general_purpose::STANDARD.encode(format!("{user}:{password}"))
8888
),
8989
)
90-
.set("Accept", "application/json")
91-
.set("OCS-APIREQUEST", "true")
90+
.header("Accept", "application/json")
91+
.header("OCS-APIREQUEST", "true")
9292
.call()
9393
.into_diagnostic()?
94-
.into_string()
94+
.into_body()
95+
.read_to_string()
9596
.into_diagnostic()?;
9697
trace!("Capabilities response: {raw}");
9798
let json: Value = serde_json::from_str(&raw)

0 commit comments

Comments
 (0)