feat: 新增 frp 远程访问扩展

This commit is contained in:
mofeng-git
2026-06-13 16:05:34 +08:00
parent 4b65eebd5d
commit 5de7ecd4c5
12 changed files with 828 additions and 69 deletions

View File

@@ -10,6 +10,7 @@ pub enum ExtensionId {
Ttyd,
Gostc,
Easytier,
Frpc,
}
impl ExtensionId {
@@ -18,7 +19,7 @@ impl ExtensionId {
}
pub fn all() -> &'static [ExtensionId] {
&[Self::Ttyd, Self::Gostc, Self::Easytier]
&[Self::Ttyd, Self::Gostc, Self::Easytier, Self::Frpc]
}
}
@@ -28,6 +29,7 @@ impl std::fmt::Display for ExtensionId {
Self::Ttyd => write!(f, "ttyd"),
Self::Gostc => write!(f, "gostc"),
Self::Easytier => write!(f, "easytier"),
Self::Frpc => write!(f, "frpc"),
}
}
}
@@ -40,6 +42,7 @@ impl std::str::FromStr for ExtensionId {
"ttyd" => Ok(Self::Ttyd),
"gostc" => Ok(Self::Gostc),
"easytier" => Ok(Self::Easytier),
"frpc" => Ok(Self::Frpc),
_ => Err(format!("Unknown extension: {}", s)),
}
}
@@ -114,6 +117,85 @@ pub struct EasytierConfig {
pub virtual_ip: Option<String>,
}
#[typeshare]
#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
#[serde(rename_all = "lowercase")]
pub enum FrpProxyType {
Tcp,
Udp,
Http,
Https,
Stcp,
Sudp,
Xtcp,
}
impl Default for FrpProxyType {
fn default() -> Self {
Self::Tcp
}
}
#[typeshare]
#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
#[serde(rename_all = "lowercase")]
pub enum FrpcConfigMode {
Quick,
Full,
}
impl Default for FrpcConfigMode {
fn default() -> Self {
Self::Quick
}
}
#[typeshare]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(default)]
pub struct FrpcConfig {
pub enabled: bool,
pub config_mode: FrpcConfigMode,
pub proxy_name: String,
pub proxy_type: FrpProxyType,
pub server_addr: String,
pub server_port: u16,
#[serde(skip_serializing_if = "String::is_empty")]
pub token: String,
pub local_ip: String,
pub local_port: u16,
#[serde(skip_serializing_if = "Option::is_none")]
pub remote_port: Option<u16>,
#[serde(skip_serializing_if = "Option::is_none")]
pub custom_domain: Option<String>,
#[serde(skip_serializing_if = "String::is_empty")]
pub secret_key: String,
pub tls: bool,
#[serde(skip_serializing_if = "String::is_empty")]
pub custom_toml: String,
}
impl Default for FrpcConfig {
fn default() -> Self {
Self {
enabled: false,
config_mode: FrpcConfigMode::Quick,
proxy_name: String::new(),
proxy_type: FrpProxyType::Tcp,
server_addr: String::new(),
server_port: 7000,
token: String::new(),
local_ip: "127.0.0.1".to_string(),
local_port: 22,
remote_port: None,
custom_domain: None,
secret_key: String::new(),
tls: true,
custom_toml: String::new(),
}
}
}
#[typeshare]
#[derive(Debug, Clone, Serialize, Deserialize, Default)]
#[serde(default)]
@@ -121,6 +203,7 @@ pub struct ExtensionsConfig {
pub ttyd: TtydConfig,
pub gostc: GostcConfig,
pub easytier: EasytierConfig,
pub frpc: FrpcConfig,
}
#[typeshare]
@@ -154,12 +237,21 @@ pub struct EasytierInfo {
pub config: EasytierConfig,
}
#[typeshare]
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct FrpcInfo {
pub available: bool,
pub status: ExtensionStatus,
pub config: FrpcConfig,
}
#[typeshare]
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct ExtensionsStatus {
pub ttyd: TtydInfo,
pub gostc: GostcInfo,
pub easytier: EasytierInfo,
pub frpc: FrpcInfo,
}
#[typeshare]