1
0

deserde certs & priv_keys path as PathBuf

This commit is contained in:
EAimTY 2023-02-04 17:03:52 +09:00
parent f4dfa75e4c
commit 53c95d9860
2 changed files with 6 additions and 4 deletions

View File

@ -8,6 +8,7 @@ use std::{
fs::File, fs::File,
io::Error as IoError, io::Error as IoError,
net::{IpAddr, SocketAddr}, net::{IpAddr, SocketAddr},
path::PathBuf,
str::FromStr, str::FromStr,
time::Duration, time::Duration,
}; };
@ -37,7 +38,7 @@ pub struct Relay {
pub token: String, pub token: String,
pub ip: Option<IpAddr>, pub ip: Option<IpAddr>,
#[serde(default = "default::relay::certificates")] #[serde(default = "default::relay::certificates")]
pub certificates: Vec<String>, pub certificates: Vec<PathBuf>,
#[serde( #[serde(
default = "default::relay::udp_relay_mode", default = "default::relay::udp_relay_mode",
deserialize_with = "deserialize_from_str" deserialize_with = "deserialize_from_str"
@ -111,9 +112,9 @@ impl Config {
mod default { mod default {
pub mod relay { pub mod relay {
use crate::utils::{CongestionControl, UdpRelayMode}; use crate::utils::{CongestionControl, UdpRelayMode};
use std::time::Duration; use std::{path::PathBuf, time::Duration};
pub fn certificates() -> Vec<String> { pub fn certificates() -> Vec<PathBuf> {
Vec::new() Vec::new()
} }

View File

@ -5,11 +5,12 @@ use std::{
fs::{self, File}, fs::{self, File},
io::BufReader, io::BufReader,
net::{IpAddr, SocketAddr}, net::{IpAddr, SocketAddr},
path::PathBuf,
str::FromStr, str::FromStr,
}; };
use tokio::net; use tokio::net;
pub fn load_certs(paths: Vec<String>, disable_native: bool) -> Result<RootCertStore, Error> { pub fn load_certs(paths: Vec<PathBuf>, disable_native: bool) -> Result<RootCertStore, Error> {
let mut certs = RootCertStore::empty(); let mut certs = RootCertStore::empty();
for path in &paths { for path in &paths {