filebrowser

package
v0.6.8 Latest Latest
Warning

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

Go to latest
Published: Nov 17, 2026 License: Apache-2.0 Imports: 22 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 filebrowser 托管 FileBrowser Quantum(gtsteffaniak/filebrowser)文件管理器: 在界面中维护实例(监听地址、共享目录、登录方式、管理员账号),生成配置文件并守护外部进程。

原版 filebrowser/filebrowser 已于 2026 年归档、不再修复安全问题,因此托管的是仍在维护的 Quantum 分支。

Index

Constants

View Source
const (
	// AuthPassword 使用 File Browser 自己的账号密码登录
	AuthPassword = "password"
	// AuthProxy 信任反向代理传入的用户名请求头,配合 Web 服务的转发认证使用
	AuthProxy = "proxy"
	// AuthNone 不需要登录,所有访问者都以管理员身份操作
	AuthNone = "noauth"
)

登录方式。

View Source
const ID = "filebrowser"

ID 是模块标识。

Variables

This section is empty.

Functions

This section is empty.

Types

type Instance

type Instance struct {
	Key  string `json:"key"`
	Name string `json:"name"`
	// Group 为列表中的分组名称,只影响管理界面的展示,留空为未分组
	Group  string `json:"group"`
	Enable bool   `json:"enable"`
	// ListenIP 为空表示监听全部 IPv4 地址
	ListenIP string `json:"listenIp"`
	Port     int    `json:"port"`
	// BaseURL 是访问路径前缀,在 Web 服务中按路径反向代理时使用,默认 /
	BaseURL string   `json:"baseUrl"`
	Sources []Source `json:"sources"`
	// AuthMethod 为 password、proxy 或 noauth
	AuthMethod string `json:"authMethod"`
	// ProxyHeader 为 AuthProxy 读取用户名的请求头,默认 Remote-User
	ProxyHeader string `json:"proxyHeader"`
	// AdminUser 是由 Gately 管理的管理员账号名,默认 admin
	AdminUser string `json:"adminUser"`
	// AdminPassword 在每次启动时同步到管理员账号,以 Gately 中的设置为准
	AdminPassword string `json:"adminPassword"`
	// TrustProxyHeaders 为 true 时信任 X-Forwarded-* 与 X-Real-IP,仅应在反向代理之后开启
	TrustProxyHeaders bool `json:"trustProxyHeaders"`
	// DisableWebDAV 关闭 File Browser 自带的 WebDAV 接口
	DisableWebDAV bool `json:"disableWebDav"`
	// Locale 是新用户的默认界面语言,留空使用上游默认(英文)
	Locale string `json:"locale"`
	// TokenHours 是登录会话的有效期(小时),0 表示默认 2 小时
	TokenHours int `json:"tokenHours"`
	// AccessURLs 是用户填写的浏览器访问地址(例如经 Web 服务反向代理的域名),可填多个;
	// 为空时界面按监听地址与端口推测。第一个地址的协议、主机与端口作为 File Browser 的外部地址,
	// 用于生成分享链接
	AccessURLs []string `json:"accessUrls"`
	Remark     string   `json:"remark"`
}

Instance 是一个 File Browser 实例。

func (*Instance) Config

func (i *Instance) Config(dataDir string) ([]byte, error)

Config 生成实例的 FileBrowser Quantum 配置文件内容,dataDir 存放数据库与缓存。 管理员密码不写入配置文件,由 Env 通过环境变量传给进程。

func (*Instance) Env

func (i *Instance) Env() []string

Env 返回启动进程时追加的环境变量。管理员密码经环境变量传递,不出现在配置文件与进程列表中, FileBrowser Quantum 每次启动都会把它同步到管理员账号。

func (*Instance) Validate

func (i *Instance) Validate() error

Validate 校验并规范化实例配置。

type InstanceView

type InstanceView struct {
	Instance
	State proc.State `json:"state"`
	Error string     `json:"error"`
}

InstanceView 是界面展示的实例。

type Module

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

Module 是 File Browser 模块。

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) ProgramInstallers added in v0.6.4

func (m *Module) ProgramInstallers() []*binstall.Installer

ProgramInstallers 返回模块托管的程序安装器,供 Gately 自动检查更新时一并检查托管程序。

func (*Module) Routes

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

Routes 实现 module.Module。

func (*Module) SetHTTPClient

func (m *Module) SetHTTPClient(fn func() *http.Client)

SetHTTPClient 实现 module.HTTPClientAware。

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) Summary

func (m *Module) Summary() []module.SummaryItem

Summary 实现 module.Summarizer。

func (*Module) Title

func (m *Module) Title() string

Title 实现 module.Module。

type Settings

type Settings struct {
	// BinPath 为空时依次在配置目录 bin 与 PATH 下查找 filebrowser
	BinPath string `json:"binPath"`
}

Settings 是模块级配置。

type Source

type Source struct {
	Path string `json:"path"`
	// Name 是界面中显示的名称,留空时使用目录名
	Name     string `json:"name"`
	ReadOnly bool   `json:"readOnly"`
}

Source 是实例共享的一个目录。

Jump to

Keyboard shortcuts

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