mirror of
https://github.com/Bluemangoo/sekai-unpacker.git
synced 2026-05-06 20:44:47 +08:00
48 lines
1.2 KiB
Rust
48 lines
1.2 KiB
Rust
use crate::stream::Identity;
|
|
use crate::{ClientTunnelConfig, ServerTunnelConfig, SslConfig};
|
|
use serde::{Deserialize, Serialize};
|
|
|
|
#[derive(Debug, Clone, Default, Serialize, Deserialize)]
|
|
pub struct ConnectConfig {
|
|
#[serde(default)]
|
|
pub server: Vec<TcpServerTunnelConfig>,
|
|
#[serde(default)]
|
|
pub client: Vec<TcpClientTunnelConfig>,
|
|
}
|
|
|
|
#[derive(Debug, Clone, Serialize, Deserialize)]
|
|
pub struct TcpServerTunnelConfig {
|
|
pub url: String,
|
|
#[serde(flatten)]
|
|
pub cert: Option<SslConfig>,
|
|
pub token: String,
|
|
}
|
|
|
|
impl TcpServerTunnelConfig {
|
|
pub fn into_tunnel_config(self, identity: Identity) -> anyhow::Result<ServerTunnelConfig> {
|
|
Ok(ServerTunnelConfig {
|
|
identity,
|
|
url: self.url,
|
|
cert: self.cert,
|
|
token: self.token,
|
|
})
|
|
}
|
|
}
|
|
|
|
#[derive(Debug, Clone, Serialize, Deserialize)]
|
|
pub struct TcpClientTunnelConfig {
|
|
pub host: Option<String>,
|
|
pub url: String,
|
|
pub token: String,
|
|
}
|
|
|
|
impl TcpClientTunnelConfig {
|
|
pub fn into_tunnel_config(self, identity: Identity) -> ClientTunnelConfig {
|
|
ClientTunnelConfig {
|
|
identity,
|
|
host: self.host,
|
|
url: self.url,
|
|
token: self.token,
|
|
}
|
|
}
|
|
} |