valueobject

package
v0.2.50 Latest Latest
Warning

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

Go to latest
Published: Apr 17, 2026 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CheckPassword

func CheckPassword(hash, password, salt []byte) error

CheckPassword compares the hash with the salted password. A nil return means the password is correct, but an error could mean either the password is not correct, or the salt process failed - indicated in logs

func FmtBytes

func FmtBytes(size float64) string

FmtBytes converts the numeric byte size value to the appropriate magnitude size in KB, MB, GB, TB, PB, or EB.

func FmtTime

func FmtTime(t int64) string

FmtTime shows a human readable time based on the timestamp

func HashPassword

func HashPassword(password, salt []byte) ([]byte, error)

HashPassword encrypts the salted password using bcrypt

func NewEtag

func NewEtag() string

NewEtag generates a new Etag for response caching

func RandSalt

func RandSalt() ([]byte, error)

RandSalt generates 16 * 8 bits of data for a random salt

Types

type Config

type Config struct {
	contentVO.Item

	Name                    string   `json:"name"`
	Domain                  string   `json:"domain"`
	CouchDBSubDomain        string   `json:"couchdb_subdomain"`
	HugoverseSubDomain      string   `json:"hugoverse_subdomain"`
	Netlify                 string   `json:"netlify"`
	BindAddress             string   `json:"bind_addr"`
	HTTPPort                string   `json:"http_port"`          // Hugoverse 内部监听端口 (如 1314)
	HTTPSPort               string   `json:"https_port"`         // HTTPS 端口 (如 443)
	ExternalHTTPPort        string   `json:"external_http_port"` // Caddy 对外 HTTP 端口 (如 80 或 8080)
	DevHTTPSPort            string   `json:"dev_https_port"`
	AdminEmail              string   `json:"admin_email"`
	ClientSecret            string   `json:"client_secret"`
	Etag                    string   `json:"etag"`
	DisableCORS             bool     `json:"cors_disabled"`
	DisableGZIP             bool     `json:"gzip_disabled"`
	DisableHTTPCache        bool     `json:"cache_disabled"`
	CacheMaxAge             int64    `json:"cache_max_age"`
	CacheInvalidate         []string `json:"cache"`
	BackupBasicAuthUser     string   `json:"backup_basic_auth_user"`
	BackupBasicAuthPassword string   `json:"backup_basic_auth_password"`

	// CouchDB 配置
	URL       string `json:"url"`        // CouchDB 服务器地址 (如 http://localhost:5984)
	AdminUser string `json:"admin_user"` // 管理员用户名
	AdminPass string `json:"admin_pass"` // 管理员密码
	DBPrefix  string `json:"db_prefix"`  // 用户数据库前缀 (如 userdb-)

	// Caddy 配置
	CaddyHost string `json:"caddy_host"` // Caddy 服务器地址 (如 localhost)
	CaddyPort string `json:"caddy_port"` // Caddy 服务器端口 (如 8080)

	// 服务器 IP 配置
	ServerIP string `json:"server_ip"` // 服务器公网 IP (用于域名检测)

	// GitHub 配置
	GithubHookSecret string `json:"github_hook_secret"` // GitHub Webhook Secret (用于验证 webhook 签名)
	GithubToken      string `json:"github_token"`       // GitHub Personal Access Token (用于下载私有仓库)
	GithubTargetRepo string `json:"github_target_repo"` // GitHub 目标仓库全名 (如 mdfriday/obsidian-friday-plugin)

	// SMTP 配置
	SMTPHost     string `json:"smtp_host"`     // SMTP 服务器地址 (如 smtp.gmail.com)
	SMTPPort     int    `json:"smtp_port"`     // SMTP 端口 (如 587 for TLS, 465 for SSL)
	SMTPUsername string `json:"smtp_username"` // SMTP 用户名 (通常是邮箱地址)
	SMTPPassword string `json:"smtp_password"` // SMTP 密码或应用专用密码
	SMTPFrom     string `json:"smtp_from"`     // 发件人邮箱地址
	SMTPUseTLS   bool   `json:"smtp_use_tls"`  // 是否使用 TLS (STARTTLS)
}

func (*Config) Convert

func (c *Config) Convert(data url.Values) (*Config, error)

func (*Config) IsCacheInvalidate

func (c *Config) IsCacheInvalidate() bool

func (*Config) Marshal

func (c *Config) Marshal() ([]byte, error)

func (*Config) MarshalEditor

func (c *Config) MarshalEditor() ([]byte, error)

MarshalEditor writes a buffer of html to edit a Post and partially implements editor.Editable

func (*Config) Update

func (c *Config) Update(key string, value any) (*Config, error)

type FileUpload

type FileUpload struct {
	contentVO.Item

	Name          string `json:"name"`
	Path          string `json:"path"`
	ContentLength int64  `json:"content_length"`
	ContentType   string `json:"content_type"`
}

FileUpload represents the file uploaded to the system

func (*FileUpload) FilePath

func (f *FileUpload) FilePath() string

func (*FileUpload) MarshalEditor

func (f *FileUpload) MarshalEditor() ([]byte, error)

MarshalEditor writes a buffer of html to edit a Post and partially implements editor.Editable

func (*FileUpload) Push

func (f *FileUpload) Push() []string

func (*FileUpload) String

func (f *FileUpload) String() string

String partially implements item.Identifiable and overrides Item's String()

type User

type User struct {
	Id    uint64 `json:"id"`
	Email string `json:"email"`
	Hash  string `json:"hash"`
	Salt  string `json:"salt"`
}

func (*User) ID

func (u *User) ID() uint64

func (*User) Name

func (u *User) Name() string

Jump to

Keyboard shortcuts

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