common

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Feb 24, 2026 License: GPL-3.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const (
	SERVICENAME        = "rde"
	VERSION            = "0.1.0"
	BODY               = " "
	RANW_NAME          = "RDE-RemoteAccess"
	REMOTE_VERSION_URL = "https://api.github.com/repos/ruizi-store/rde/releases/latest"
)

Variables

View Source
var EventTypes = []EventType{
	{Name: "rde:system:utilization", SourceID: SERVICENAME, PropertyTypeList: []string{}},
	{Name: "rde:file:recover", SourceID: SERVICENAME, PropertyTypeList: []string{}},
	{Name: "rde:file:operate", SourceID: SERVICENAME, PropertyTypeList: []string{}},
}

事件类型列表

Functions

func CheckPathChainAccess

func CheckPathChainAccess(username, path string) bool

CheckPathChainAccess 检查从根目录到目标路径的每一级目录是否都有 x 权限 Linux 访问 /home/user/Documents 需要 / , /home, /home/user, /home/user/Documents 每层都有 x

func CheckUserDirAccess

func CheckUserDirAccess(username, path string) bool

CheckUserDirAccess 检查用户是否能访问(进入并列出)目录 目录需要 r+x 权限

func CheckUserPermission

func CheckUserPermission(username, path string, perm FilePermission) bool

CheckUserPermission 检查指定用户对文件/目录是否有指定权限 模拟 Linux 文件权限检查逻辑(owner → group → other) 对于目录,进入需要 r+x 权限

func CheckUserReadAccess

func CheckUserReadAccess(username, path string) bool

CheckUserReadAccess 检查用户是否能读取文件

func CheckUserWriteAccess

func CheckUserWriteAccess(username, path string) bool

CheckUserWriteAccess 检查用户是否能写入文件/目录

func GetAllowedRoots

func GetAllowedRoots() []string

GetAllowedRoots 获取允许访问的根目录列表

func GetDataRootPath

func GetDataRootPath() string

GetDataRootPath 获取用户存储根目录(保留兼容)

func GetVolumesPath

func GetVolumesPath() string

GetVolumesPath 获取挂载卷路径

func IsPathAllowed

func IsPathAllowed(path string, ctx *VirtualPathContext) bool

IsPathAllowed 检查路径是否允许访问(不包含敏感目录检查,敏感目录由 handler 层处理)

func IsSensitivePath

func IsSensitivePath(path string) bool

IsSensitivePath 检查路径是否为系统敏感目录(/proc, /sys, /dev, /run) 敏感目录需要管理员提权后才能访问

func ListVirtualRoot

func ListVirtualRoot(ctx *VirtualPathContext) []string

ListVirtualRoot 列出允许的根目录(保留兼容)

func ResolvePath

func ResolvePath(path string) string

ResolvePath 解析并清理路径,返回安全的绝对路径

func ResolveVirtualPath

func ResolveVirtualPath(path string) string

ResolveVirtualPath 解析路径(保留兼容,现在直接返回真实路径)

func ResolveVirtualPathWithContext

func ResolveVirtualPathWithContext(path string, ctx *VirtualPathContext) string

ResolveVirtualPathWithContext 解析路径(保留兼容)

func SetAllowedRoots

func SetAllowedRoots(roots []string)

SetAllowedRoots 设置允许访问的根目录列表

func SetDataRootResolver

func SetDataRootResolver(resolver DataRootResolver)

SetDataRootResolver 设置数据根目录解析器

func ToVirtualPath

func ToVirtualPath(realPath string) string

ToVirtualPath 转换路径(保留兼容,现在直接返回原路径)

func ToVirtualPathWithContext

func ToVirtualPathWithContext(realPath string, ctx *VirtualPathContext) string

ToVirtualPathWithContext 转换路径(保留兼容)

Types

type DataRootResolver

type DataRootResolver interface {
	GetDataRoot() string
}

DataRootResolver 数据根目录解析器(保留兼容)

type EventType

type EventType struct {
	Name             string   `json:"name"`
	SourceID         string   `json:"source_id"`
	PropertyTypeList []string `json:"property_type_list"`
}

EventType 事件类型定义

type FilePermission

type FilePermission int

FilePermission 文件权限检查模式

const (
	PermRead    FilePermission = 4 // r
	PermWrite   FilePermission = 2 // w
	PermExecute FilePermission = 1 // x
)

type VirtualPathContext

type VirtualPathContext struct {
	Username string
	IsAdmin  bool
}

VirtualPathContext 路径解析上下文(保留兼容,但不再用于虚拟路径转换)

Jump to

Keyboard shortcuts

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