mirror of
https://codeberg.org/icewind/nextcloud-config-parser.git
synced 2026-06-04 00:54:11 +02:00
parse redis ssl_context
This commit is contained in:
parent
88db1d1d86
commit
e4bb72fd00
6 changed files with 220 additions and 14 deletions
40
src/lib.rs
40
src/lib.rs
|
|
@ -31,14 +31,41 @@ pub enum RedisConnectionAddr {
|
|||
TcpTls {
|
||||
host: String,
|
||||
port: u16,
|
||||
insecure: bool,
|
||||
tls_params: Option<String>,
|
||||
tls_params: Option<RedisTlsParams>,
|
||||
},
|
||||
Unix {
|
||||
path: PathBuf,
|
||||
},
|
||||
}
|
||||
|
||||
impl RedisConnectionAddr {
|
||||
pub fn with_tls(self, tls_params: RedisTlsParams) -> Self {
|
||||
match self {
|
||||
RedisConnectionAddr::Tcp { host, port }
|
||||
| RedisConnectionAddr::TcpTls { host, port, .. } => RedisConnectionAddr::TcpTls {
|
||||
host,
|
||||
port,
|
||||
tls_params: Some(tls_params),
|
||||
},
|
||||
unix => unix,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn with_tls_opt(self, tls_params: Option<RedisTlsParams>) -> Self {
|
||||
if let Some(params) = tls_params {
|
||||
self.with_tls(params)
|
||||
} else {
|
||||
match self {
|
||||
RedisConnectionAddr::Tcp { host, port }
|
||||
| RedisConnectionAddr::TcpTls { host, port, .. } => {
|
||||
RedisConnectionAddr::Tcp { host, port }
|
||||
}
|
||||
unix => unix,
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug)]
|
||||
pub struct RedisConnectionInfo {
|
||||
pub addr: RedisConnectionAddr,
|
||||
|
|
@ -47,6 +74,15 @@ pub struct RedisConnectionInfo {
|
|||
pub password: Option<String>,
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug)]
|
||||
pub struct RedisTlsParams {
|
||||
pub local_cert: Option<PathBuf>,
|
||||
pub local_pk: Option<PathBuf>,
|
||||
pub ca_file: Option<PathBuf>,
|
||||
pub accept_invalid_hostname: bool,
|
||||
pub insecure: bool,
|
||||
}
|
||||
|
||||
impl RedisConfig {
|
||||
pub fn addr(&self) -> impl Iterator<Item = &RedisConnectionAddr> {
|
||||
let boxed: Box<dyn Iterator<Item = &RedisConnectionAddr>> = match self {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue