span

package
v0.0.0-...-ab4823f Latest Latest
Warning

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

Go to latest
Published: Aug 3, 2023 License: MIT Imports: 26 Imported by: 0

Documentation

Index

Constants

View Source
const FILE_MODE fs.FileMode = 0600

Variables

View Source
var Name string = "span"
View Source
var Version string = "unkown"

Functions

func AesCbcDecrypt

func AesCbcDecrypt(key, iv []byte, ciphertext []byte) ([]byte, error)

func AesCbcEncrypt

func AesCbcEncrypt(key, iv []byte, plaintext []byte) ([]byte, error)

func AesCtrDecrypt

func AesCtrDecrypt(key, iv []byte, ciphertext []byte) ([]byte, error)

func AesCtrEncrypt

func AesCtrEncrypt(key, iv []byte, plaintext []byte) ([]byte, error)

func AesEcbDecrypt

func AesEcbDecrypt(key []byte, ciphertext []byte) ([]byte, error)

func AesEcbEncrypt

func AesEcbEncrypt(key []byte, plaintext []byte) ([]byte, error)

func AesGcmDecrypt

func AesGcmDecrypt(key, nonce []byte, ciphertext []byte) ([]byte, error)

func AesGcmEncrypt

func AesGcmEncrypt(key, nonce []byte, plaintext []byte) ([]byte, error)

func Base64DecodeString

func Base64DecodeString(s string) ([]byte, error)

func Base64EncodeToString

func Base64EncodeToString(src []byte) string

func DecryptFileContent

func DecryptFileContent(masterKey, iv, encryptFileContent []byte) ([]byte, error)

func DecryptFileKey

func DecryptFileKey(masterKey, encryptFileKey []byte) ([]byte, error)

func DecryptFileName

func DecryptFileName(masterKey, encryptFileName []byte) ([]byte, error)

func DecryptMasterKey

func DecryptMasterKey(encryptKey, encryptMasterKey []byte) ([]byte, error)

*

  • 解密获取 masterKey

func EncryptFileContent

func EncryptFileContent(masterKey, iv, content []byte) ([]byte, error)

func EncryptFileKey

func EncryptFileKey(masterKey, fileKey []byte) ([]byte, error)

func EncryptFileName

func EncryptFileName(masterKey, fileName []byte) ([]byte, error)

func EncryptMasterKey

func EncryptMasterKey(encryptKey, masterKey []byte) ([]byte, error)

*

  • masterKey 加密后存储在本地

func GenEncryptKeyAndAuthKeyFromPassword

func GenEncryptKeyAndAuthKeyFromPassword(password string, salt []byte) (encryptKey, authKey []byte)

func HashAuthKey

func HashAuthKey(authKey []byte) []byte

*

  • 对 authKey 进行 sha256,结果存储在本地,用于下次登录密码验证

func InitBolt

func InitBolt(path string) error

func IsPasswordTooWeak

func IsPasswordTooWeak(password string) bool

*

  • 检测密码强度

func MustAesCbcDecrypt

func MustAesCbcDecrypt(key, iv []byte, ciphertext []byte) []byte

func MustAesCbcEncrypt

func MustAesCbcEncrypt(key, iv []byte, plaintext []byte) []byte

func MustDecryptFileName

func MustDecryptFileName(masterKey, encryptFileName []byte) []byte

func MustDecryptMasterKey

func MustDecryptMasterKey(encryptKey, encryptMasterKey []byte) []byte

func MustEncryptFileName

func MustEncryptFileName(masterKey, fileName []byte) []byte

func MustEncryptMasterKey

func MustEncryptMasterKey(encryptKey, masterKey []byte) []byte

func MustRandomMasterKey

func MustRandomMasterKey() []byte

func MustRandomSalt

func MustRandomSalt() []byte

func NewFileInfo

func NewFileInfo(masterKey []byte, fi os.FileInfo) os.FileInfo

func NewFileSystem

func NewFileSystem(client *gowebdav.Client, masterKey []byte) webdav.FileSystem

func Pkcs5Padding

func Pkcs5Padding(b []byte) []byte

func Pkcs5UnPadding

func Pkcs5UnPadding(b []byte) []byte

func RandomFileKey

func RandomFileKey() ([]byte, error)

func ReadBolt

func ReadBolt() (salt, encryptMasterKey, authKey []byte, err error)

func ReadPassword

func ReadPassword(promt string) (string, error)

func Sha256

func Sha256(in []byte) []byte

func ShowVersion

func ShowVersion()

func WriteBolt

func WriteBolt(salt, encryptMasterKey, authKey []byte) error

Types

type Config

type Config struct {
	Logger Logger `json:"logger" yaml:"logger"`

	Password string `json:"password" yaml:"password"`

	Webdav WebdavConfig `json:"webdav" yaml:"webdav"`

	Upstream UpstreamConfig `json:"upstream" yaml:"upstream"`
}

func GetConfig

func GetConfig() *Config

type FileInfo

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

func (FileInfo) IsDir

func (fi FileInfo) IsDir() bool

func (FileInfo) ModTime

func (fi FileInfo) ModTime() time.Time

func (FileInfo) Mode

func (fi FileInfo) Mode() os.FileMode

func (FileInfo) Name

func (fi FileInfo) Name() string

func (FileInfo) Size

func (fi FileInfo) Size() int64

func (FileInfo) Sys

func (fi FileInfo) Sys() any

type FileSystem

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

func (*FileSystem) Mkdir

func (fs *FileSystem) Mkdir(ctx context.Context, name string, perm os.FileMode) (err error)

func (*FileSystem) OpenFile

func (fs *FileSystem) OpenFile(ctx context.Context, name string, flag int, perm os.FileMode) (result webdav.File, err error)

func (*FileSystem) ReadDir

func (fs *FileSystem) ReadDir(ctx context.Context, name string) (fis []fs.FileInfo, err error)

func (*FileSystem) RemoveAll

func (fs *FileSystem) RemoveAll(ctx context.Context, name string) (err error)

func (*FileSystem) Rename

func (fs *FileSystem) Rename(ctx context.Context, oldName, newName string) (err error)

func (*FileSystem) Stat

func (fs *FileSystem) Stat(ctx context.Context, name string) (fi os.FileInfo, err error)

type Logger

type Logger struct {
	Format logger.LogFormat `json:"format" yaml:"format"`
	Level  string           `json:"level" yaml:"level"`
}

type ReadableFile

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

func NewReadableFile

func NewReadableFile(fs *FileSystem, masterKey []byte, path string) *ReadableFile

func (*ReadableFile) Close

func (file *ReadableFile) Close() error

func (*ReadableFile) Read

func (file *ReadableFile) Read(p []byte) (n int, err error)

func (*ReadableFile) Readdir

func (file *ReadableFile) Readdir(count int) (fis []fs.FileInfo, err error)

func (*ReadableFile) Seek

func (file *ReadableFile) Seek(offset int64, whence int) (n int64, err error)

func (*ReadableFile) Stat

func (file *ReadableFile) Stat() (fi fs.FileInfo, err error)

func (*ReadableFile) Write

func (file *ReadableFile) Write(p []byte) (n int, err error)

type UpstreamConfig

type UpstreamConfig struct {
	Webdav UpstreamWebdavConfig `json:"webdav" yaml:"webdav"`
}

type UpstreamWebdavConfig

type UpstreamWebdavConfig struct {
	Url      string `json:"url" yaml:"url"`
	User     string `json:"user" yaml:"user"`
	Password string `json:"password" yaml:"password"`
}

type WebdavConfig

type WebdavConfig struct {
	Prefix   string `json:"prefix" yaml:"prefix"`
	User     string `json:"user" yaml:"user"`
	Password string `json:"password" yaml:"password"`
}

type WritableFile

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

func NewWritableFile

func NewWritableFile(fs *FileSystem, masterKey []byte, path string) *WritableFile

func (*WritableFile) Close

func (file *WritableFile) Close() (err error)

func (*WritableFile) IsDir

func (file *WritableFile) IsDir() bool

func (*WritableFile) ModTime

func (file *WritableFile) ModTime() time.Time

func (*WritableFile) Mode

func (file *WritableFile) Mode() fs.FileMode

func (*WritableFile) Name

func (file *WritableFile) Name() string

func (*WritableFile) Read

func (file *WritableFile) Read(p []byte) (n int, err error)

func (*WritableFile) Readdir

func (file *WritableFile) Readdir(count int) ([]fs.FileInfo, error)

func (*WritableFile) Seek

func (file *WritableFile) Seek(offset int64, whence int) (int64, error)

func (*WritableFile) Size

func (file *WritableFile) Size() int64

func (*WritableFile) Stat

func (file *WritableFile) Stat() (fs.FileInfo, error)

func (*WritableFile) Sys

func (file *WritableFile) Sys() any

func (*WritableFile) Write

func (file *WritableFile) Write(p []byte) (n int, err error)

Jump to

Keyboard shortcuts

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