Documentation
¶
Overview ¶
Package smb 实现 SMB 文件服务:多用户,每个用户映射到一个或多个目录,每个目录作为一个共享,可设为只读。 协议实现来自内置的 gosamba(internal/gosamba),支持 SMB 2.0.2 ~ 3.1.1、NTLMv2 认证、签名与加密。
Index ¶
Constants ¶
const ( IssueName = "name" // 用户名含有 SMB 不允许的字符 IssueBcrypt = "bcrypt" // 密码是 bcrypt 哈希,NTLM 需要明文 )
共享用户无法登录 SMB 的原因,界面按代码显示对应语言的说明。
const DefaultPort = 445
DefaultPort 是 SMB 的标准端口。Windows 只会连接这个端口。
const ID = "smb"
ID 是模块标识。
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Settings ¶
type Settings struct {
Enable bool `json:"enable"`
ListenIP string `json:"listenIp"`
Port int `json:"port"`
// RequireEncryption 要求客户端使用 SMB 3 加密,不支持加密的客户端(SMB 2.x)将无法连接
RequireEncryption bool `json:"requireEncryption"`
// MDNS 通过 Bonjour 广播服务,macOS 访达的「网络」中可以直接看到
MDNS bool `json:"mdns"`
Users []User `json:"users"`
SharedUsers bool `json:"sharedUsers"`
}
Settings 是模块配置。
type User ¶
type User struct {
Name string `json:"name"`
Password string `json:"password"`
// Root 为单目录模式下的目录(绝对路径),共享名为用户名;Mounts 非空时 Root 与 ReadOnly 不再使用
Root string `json:"root"`
ReadOnly bool `json:"readOnly"`
// Mounts 为多个目录,每个目录以其名称作为一个共享,可单独设为只读
Mounts []mountfs.Mount `json:"mounts,omitempty"`
// Remark 为备注(例如账号的用途),只在管理界面展示
Remark string `json:"remark,omitempty"`
// Disabled 为 true 时暂停该用户,不能登录,同名(不区分大小写)的共享用户也不能登录;旧配置没有该字段,即为启用
Disabled bool `json:"disabled,omitempty"`
}
User 是一个 SMB 账号,结构与 FTP、WebDAV 的用户一致。