smb

package
v0.6.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 2, 2026 License: Apache-2.0 Imports: 28 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package smb 实现 SMB 文件服务:多用户,每个用户映射到一个或多个目录,每个目录作为一个共享,可设为只读。 协议实现来自内置的 gosamba(internal/gosamba),支持 SMB 2.0.2 ~ 3.1.1、NTLMv2 认证、签名与加密。

Index

Constants

View Source
const (
	IssueName   = "name"   // 用户名含有 SMB 不允许的字符
	IssueBcrypt = "bcrypt" // 密码是 bcrypt 哈希,NTLM 需要明文
	IssueShare  = "share"  // 某个目录的名称不能作为共享名或重复
)

共享用户无法登录 SMB 的原因,界面按代码显示对应语言的说明。

View Source
const DefaultPort = 445

DefaultPort 是 SMB 的标准端口。Windows 只会连接这个端口。

View Source
const ID = "smb"

ID 是模块标识。

Variables

This section is empty.

Functions

This section is empty.

Types

type Issue added in v0.5.9

type Issue = fileusers.Issue

Issue 是一个无法登录 SMB 的共享用户及原因代码,显示在共享用户页面、SMB 页面与运行日志中。

type Module

type Module struct {
	// contains filtered or unexported fields
}

Module 是 SMB 模块。

func New

func New() *Module

New 创建模块。

func (*Module) ID

func (m *Module) ID() string

ID 实现 module.Module。

func (*Module) Init

func (m *Module) Init(env module.Env) error

Init 实现 module.Module。

func (*Module) Routes

func (m *Module) Routes(r module.Router)

Routes 实现 module.Module。

func (*Module) Start

func (m *Module) Start(context.Context) error

Start 实现 module.Module。

func (*Module) Stop

func (m *Module) Stop() error

Stop 实现 module.Module。

func (*Module) Title

func (m *Module) Title() string

Title 实现 module.Module。

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 为 true 时文件服务共享用户(见 fileusers 包)也可登录,与本地用户同名(不区分大小写)时只按本地用户校验
	SharedUsers bool `json:"sharedUsers"`
}

Settings 是模块配置。

func (*Settings) Validate

func (s *Settings) Validate() error

Validate 校验并规范化配置。

type Share

type Share struct {
	Name     string `json:"name"`
	Path     string `json:"path"`
	ReadOnly bool   `json:"readOnly"`
}

Share 是用户可见的一个共享。

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"`
}

User 是一个 SMB 账号,结构与 FTP、WebDAV 的用户一致。

func (User) Shares

func (u User) Shares() []Share

Shares 返回用户的共享列表:单目录模式下只有一个以用户名命名的共享,多目录模式下每个目录一个共享。

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL