Skip to content

Commit

Permalink
refine Config class
Browse files Browse the repository at this point in the history
  • Loading branch information
ssrlive committed Mar 25, 2024
1 parent 6d2f862 commit 3afdb22
Showing 1 changed file with 22 additions and 2 deletions.
24 changes: 22 additions & 2 deletions src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,21 @@ use std::{

#[derive(Clone, Serialize, Deserialize, Debug)]
pub struct Config {
#[serde(rename(deserialize = "server_settings", serialize = "server_settings"))]
#[serde(
rename(deserialize = "server_settings", serialize = "server_settings"),
skip_serializing_if = "Option::is_none"
)]
pub server: Option<Server>,
#[serde(rename(deserialize = "client_settings", serialize = "client_settings"))]
#[serde(
rename(deserialize = "client_settings", serialize = "client_settings"),
skip_serializing_if = "Option::is_none"
)]
pub client: Option<Client>,
#[serde(skip_serializing_if = "Option::is_none")]
pub remarks: Option<String>,
#[serde(skip_serializing_if = "Option::is_none")]
pub method: Option<String>,
#[serde(skip_serializing_if = "Option::is_none")]
pub password: Option<String>,
pub tunnel_path: TunnelPath,
#[serde(skip)]
Expand Down Expand Up @@ -90,10 +99,15 @@ impl TunnelPath {

#[derive(Clone, Serialize, Deserialize, Debug, Default)]
pub struct Server {
#[serde(skip_serializing_if = "Option::is_none")]
pub disable_tls: Option<bool>,
#[serde(skip_serializing_if = "Option::is_none")]
pub manage_clients: Option<ManageClients>,
#[serde(skip_serializing_if = "Option::is_none")]
pub certfile: Option<PathBuf>,
#[serde(skip_serializing_if = "Option::is_none")]
pub keyfile: Option<PathBuf>,
#[serde(skip_serializing_if = "Option::is_none")]
pub forward_addr: Option<String>,
pub listen_host: String,
pub listen_port: u16,
Expand All @@ -111,15 +125,21 @@ pub struct ManageClients {

#[derive(Clone, Serialize, Deserialize, Debug, Default)]
pub struct Client {
#[serde(skip_serializing_if = "Option::is_none")]
pub disable_tls: Option<bool>,
#[serde(skip_serializing_if = "Option::is_none")]
pub client_id: Option<String>,
pub server_host: String,
pub server_port: u16,
#[serde(skip_serializing_if = "Option::is_none")]
pub server_domain: Option<String>,
#[serde(skip_serializing_if = "Option::is_none")]
pub cafile: Option<PathBuf>,
pub listen_host: String,
pub listen_port: u16,
#[serde(skip_serializing_if = "Option::is_none")]
pub listen_user: Option<String>,
#[serde(skip_serializing_if = "Option::is_none")]
pub listen_password: Option<String>,
#[serde(skip)]
pub cache_dns: bool,
Expand Down

0 comments on commit 3afdb22

Please sign in to comment.