common

package
v0.0.0-...-439bbf7 Latest Latest
Warning

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

Go to latest
Published: Feb 9, 2026 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// HTTP Query parameters
	QueryAction    = "action"
	QueryPath      = "path"
	QueryOld       = "old"
	QueryNew       = "new"
	QueryRecursive = "recursive"

	// Action values
	ActionList     = "list"
	ActionChecksum = "checksum"
	ActionDownload = "download"
	ActionUpload   = "upload"
	ActionDelete   = "delete"
	ActionMkdir    = "mkdir"
	ActionRename   = "rename"
	ActionCompress = "compress"
	ActionExtract  = "extract"
	ActionEdit     = "edit"
)
View Source
const (
	MethodGet    = "GET"
	MethodPost   = "POST"
	MethodPut    = "PUT"
	MethodDelete = "DELETE"
)

HTTP methods

View Source
const (
	Salt = "kcp-file-transfer"
)

定义加密盐值

Variables

This section is empty.

Functions

func CompressToTarGz

func CompressToTarGz(srcPath, dstPath string) error

CompressToTarGz compresses a file or folder to tar.gz format srcPath: source file or folder path dstPath: destination .tar.gz file path (should end with .tar.gz)

func ConfigKCP

func ConfigKCP(sess *kcp.UDPSession)

配置 KCP 连接参数 (参考 kcptun fast3 模式)

func DecompressFromTarGz

func DecompressFromTarGz(srcPath, dstPath string) error

DecompressFromTarGz decompresses a tar.gz file to destination folder srcPath: source .tar.gz file path dstPath: destination folder path (will be created if not exists)

func GetBlockCrypt

func GetBlockCrypt(key string) (kcp.BlockCrypt, error)

生成加密块

func IsTarGzFile

func IsTarGzFile(filePath string) bool

IsTarGzFile checks if a file is a tar.gz archive

func ShouldCompressFile

func ShouldCompressFile(filePath string, thresholdBytes int64) bool

ShouldCompressFile returns true if file size exceeds threshold

func SmuxConfig

func SmuxConfig() *smux.Config

Smux 配置

func ValidateKey

func ValidateKey(key string) error

ValidateKey 验证密钥是否有效

Types

type SmuxListener

type SmuxListener struct {
	Session *smux.Session
}

适配器:将 smux.Session 适配为 net.Listener 接口,以便 http.Serve 使用

func (*SmuxListener) Accept

func (l *SmuxListener) Accept() (net.Conn, error)

func (*SmuxListener) Addr

func (l *SmuxListener) Addr() net.Addr

func (*SmuxListener) Close

func (l *SmuxListener) Close() error

Jump to

Keyboard shortcuts

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