功能: - SMBConfig: 配置结构体 - SMBManager: 管理API - CLI工具:status/list/create/remove命令 验证: - ✅ status命令JSON输出 - ✅ list命令正确显示 - ✅ create命令生成配置指南 下一步: - 用户手动启用SMB服务(需要sudo) - Windows/macOS客户端测试 - Phase 2: 权限控制优化
49 lines
1.4 KiB
Rust
49 lines
1.4 KiB
Rust
use serde::{Deserialize, Serialize};
|
|
|
|
#[derive(Debug, Clone, Serialize, Deserialize)]
|
|
pub struct SMBConfig {
|
|
pub share_name: String,
|
|
pub path: String,
|
|
pub comment: String,
|
|
pub read_only: bool,
|
|
pub browseable: bool,
|
|
pub allow_users: Vec<String>,
|
|
}
|
|
|
|
impl Default for SMBConfig {
|
|
fn default() -> Self {
|
|
SMBConfig {
|
|
share_name: "markbase".to_string(),
|
|
path: "/Users/accusys/momentry/var/sftpgo/data".to_string(),
|
|
comment: "MarkBase File Sharing".to_string(),
|
|
read_only: false,
|
|
browseable: true,
|
|
allow_users: vec!["accusys".to_string()],
|
|
}
|
|
}
|
|
}
|
|
|
|
impl SMBConfig {
|
|
pub fn new(share_name: String, path: String) -> Self {
|
|
SMBConfig {
|
|
share_name,
|
|
path,
|
|
comment: "MarkBase File Sharing".to_string(),
|
|
read_only: false,
|
|
browseable: true,
|
|
allow_users: vec!["accusys".to_string()],
|
|
}
|
|
}
|
|
|
|
pub fn to_smb_conf(&self) -> String {
|
|
format!(
|
|
"[{}]\n path = {}\n comment = {}\n read only = {}\n browseable = {}\n valid users = {}\n",
|
|
self.share_name,
|
|
self.path,
|
|
self.comment,
|
|
if self.read_only { "yes" } else { "no" },
|
|
if self.browseable { "yes" } else { "no" },
|
|
self.allow_users.join(", ")
|
|
)
|
|
}
|
|
} |