config

package
v1.11.0 Latest Latest
Warning

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

Go to latest
Published: Jun 30, 2025 License: MIT Imports: 10 Imported by: 2

Documentation

Index

Constants

View Source
const ConfigFileName = "config.json"

Variables

View Source
var DefaultConfigJsonByte []byte

Functions

This section is empty.

Types

type Address

type Address struct {
	Ip   string `json:"ip"`
	Port string `json:"port"`
}

type AuthConfig added in v1.9.0

type AuthConfig struct {
	Password        string `json:"password"`        // 认证密码
	JwtSecret       string `json:"jwtSecret"`       // JWT密钥
	TokenExpiration int    `json:"tokenExpiration"` // 令牌过期时间(小时)
}

AuthConfig 认证配置结构体

type Config

type Config struct {
	Port                string          `json:"port"`
	Debug               bool            `json:"debug"`
	NotAllowedDeleteLog bool            `json:"notAllowedDeleteLog"`
	RpcAddress          []*Address      `json:"rpcAddress"`
	SelfRpcAddress      *Address        `json:"selfRpcAddress"`
	CorsConfig          *CorsConfig     `json:"corsConfig"`
	StorageConfig       *StorageConfig  `json:"storageConfig"`
	DatabaseConfig      *DatabaseConfig `json:"databaseConfig"`
	MaxRoomNumber       int             `json:"maxRoomNumber"`
	// max log file size, unit is mb
	MaxLogFileSizeOfMB int64 `json:"maxLogFileSizeOfMB"`
	// max log file size, unit is day
	MaxLogLifeTimeOfHour int64       `json:"maxLogLifeTimeOfHour"`
	AuthConfig           *AuthConfig `json:"authConfig"`
}

Config 应用配置结构体

func LoadConfig

func LoadConfig() (*Config, error)

func (*Config) GetLogDir added in v1.9.0

func (c *Config) GetLogDir() string

func (*Config) GetMaxLogFileSizeOfMB

func (c *Config) GetMaxLogFileSizeOfMB() int64

func (*Config) GetMaxLogLifeTimeOfHour

func (c *Config) GetMaxLogLifeTimeOfHour() int64

func (*Config) GetMaxRoomNumber

func (c *Config) GetMaxRoomNumber() int

func (*Config) IsRemoteStorage

func (c *Config) IsRemoteStorage() bool

func (*Config) Save added in v1.9.0

func (c *Config) Save() error

保存配置到文件

type CorsConfig

type CorsConfig struct {
	AllowOrigins  []string `json:"allowOrigins"`
	AllowMethods  []string `json:"allowMethods"`
	AllowHeaders  []string `json:"allowHeaders"`
	ExposeHeaders []string `json:"exposeHeaders"`
}

type DatabaseConfig added in v1.10.0

type DatabaseConfig struct {
	MySQLURL string `json:"mysqlUrl"` // MySQL connection URL, if empty use SQLite
}

type StaticConfig

type StaticConfig struct {
	DirName string
	Files   fs.FS
	GitHash string
	Version string
}

type StorageConfig

type StorageConfig struct {
	LogDirName       string `json:"logDir"`
	BaseDir          string `json:"baseDir"`
	KeyId            string `json:"keyId"`
	Secret           string `json:"secret"`
	Region           string `json:"region"`
	Endpoint         string `json:"endpoint"`
	Bucket           string `json:"bucket"`
	S3ForcePathStyle bool   `json:"s3ForcePathStyle"`
}

func (*StorageConfig) GetLogDir added in v1.7.2

func (s *StorageConfig) GetLogDir() string

Jump to

Keyboard shortcuts

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