config

package
v2.6.12 Latest Latest
Warning

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

Go to latest
Published: Feb 20, 2025 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DebugMode     = "debug"
	ReleaseMode   = "release"
	DefaultConfig = "conf/config.yaml"
)
View Source
const (
	TypeSqlite = "sqlite"
	TypeMysql  = "mysql"
)
View Source
const (
	DefaultIdServerPort    = 21116
	DefaultRelayServerPort = 21117
)

Variables

This section is empty.

Functions

func Init

func Init(rowVal *Config, path string) *viper.Viper

Init 初始化配置

func ReadEnv

func ReadEnv(rowVal interface{}) *viper.Viper

ReadEnv 读取环境变量

Types

type Admin

type Admin struct {
	Title     string `mapstructure:"title"`
	Hello     string `mapstructure:"hello"`
	HelloFile string `mapstructure:"hello-file"`
}

type App

type App struct {
	WebClient       int           `mapstructure:"web-client"`
	Register        bool          `mapstructure:"register"`
	ShowSwagger     int           `mapstructure:"show-swagger"`
	TokenExpire     time.Duration `mapstructure:"token-expire"`
	WebSso          bool          `mapstructure:"web-sso"`
	DisablePwdLogin bool          `mapstructure:"disable-pwd-login"`
}

type Cache

type Cache struct {
	Type      string
	RedisAddr string `mapstructure:"redis-addr"`
	RedisPwd  string `mapstructure:"redis-pwd"`
	RedisDb   int    `mapstructure:"redis-db"`
	FileDir   string `mapstructure:"file-dir"`
}

type Config

type Config struct {
	Lang     string `mapstructure:"lang"`
	App      App
	Admin    Admin
	Gorm     Gorm
	Mysql    Mysql
	Gin      Gin
	Logger   Logger
	Redis    Redis
	Cache    Cache
	Oss      Oss
	Jwt      Jwt
	Rustdesk Rustdesk
	Proxy    Proxy
	Ldap     Ldap
}

type Gin

type Gin struct {
	ApiAddr       string `mapstructure:"api-addr"`
	AdminAddr     string `mapstructure:"admin-addr"`
	Mode          string
	ResourcesPath string `mapstructure:"resources-path"`
	TrustProxy    string `mapstructure:"trust-proxy"`
}

type GithubOauth

type GithubOauth struct {
	ClientId     string `mapstructure:"client-id"`
	ClientSecret string `mapstructure:"client-secret"`
	RedirectUrl  string `mapstructure:"redirect-url"`
}

type GoogleOauth

type GoogleOauth struct {
	ClientId     string `mapstructure:"client-id"`
	ClientSecret string `mapstructure:"client-secret"`
	RedirectUrl  string `mapstructure:"redirect-url"`
}

type Gorm

type Gorm struct {
	Type         string `mapstructure:"type"`
	MaxIdleConns int    `mapstructure:"max-idle-conns"`
	MaxOpenConns int    `mapstructure:"max-open-conns"`
}

type Jwt

type Jwt struct {
	Key            string        `mapstructure:"key"`
	ExpireDuration time.Duration `mapstructure:"expire-duration"`
}

type Ldap

type Ldap struct {
	Enable       bool     `mapstructure:"enable"`
	Url          string   `mapstructure:"url"`
	TLS          bool     `mapstructure:"tls"`
	TlsVerify    bool     `mapstructure:"tls-verify"`
	BaseDn       string   `mapstructure:"base-dn"`
	BindDn       string   `mapstructure:"bind-dn"`
	BindPassword string   `mapstructure:"bind-password"`
	User         LdapUser `mapstructure:"user"`
}

type LdapUser

type LdapUser struct {
	BaseDn          string `mapstructure:"base-dn"`           // The base DN of the user for searching
	EnableAttr      string `mapstructure:"enable-attr"`       // The attribute name of the user for enabling, in AD it is "userAccountControl", empty means no enable attribute, all users are enabled
	EnableAttrValue string `mapstructure:"enable-attr-value"` // The value of the enable attribute when the user is enabled. If you are using AD, just leave it random str, it will be ignored.
	Filter          string `mapstructure:"filter"`
	Username        string `mapstructure:"username"`
	Email           string `mapstructure:"email"`
	FirstName       string `mapstructure:"first-name"`
	LastName        string `mapstructure:"last-name"`
	Sync            bool   `mapstructure:"sync"`        // Will sync the user's information to the internal database
	AdminGroup      string `mapstructure:"admin-group"` // Which group is the admin group
}

type Logger

type Logger struct {
	Path         string
	Level        string
	ReportCaller bool `mapstructure:"report-caller"`
}

type Mysql

type Mysql struct {
	Addr     string `mapstructure:"addr"`
	Username string `mapstructure:"username"`
	Password string `mapstructure:"password"`
	Dbname   string `mapstructure:"dbname"`
}

type OidcOauth

type OidcOauth struct {
	Issuer       string `mapstructure:"issuer"`
	ClientId     string `mapstructure:"client-id"`
	ClientSecret string `mapstructure:"client-secret"`
	RedirectUrl  string `mapstructure:"redirect-url"`
}

type Oss

type Oss struct {
	AccessKeyId     string `mapstructure:"access-key-id"`
	AccessKeySecret string `mapstructure:"access-key-secret"`
	Host            string `mapstructure:"host"`
	CallbackUrl     string `mapstructure:"callback-url"`
	ExpireTime      int64  `mapstructure:"expire-time"`
	MaxByte         int64  `mapstructure:"max-byte"`
}

type Proxy

type Proxy struct {
	Enable bool   `mapstructure:"enable"`
	Host   string `mapstructure:"host"`
}

type Redis

type Redis struct {
	Addr     string
	Password string
	Db       int
}

type Rustdesk

type Rustdesk struct {
	IdServer        string `mapstructure:"id-server"`
	IdServerPort    int    `mapstructure:"-"`
	RelayServer     string `mapstructure:"relay-server"`
	RelayServerPort int    `mapstructure:"-"`
	ApiServer       string `mapstructure:"api-server"`
	Key             string `mapstructure:"key"`
	KeyFile         string `mapstructure:"key-file"`
	Personal        int    `mapstructure:"personal"`
	//webclient-magic-queryonline
	WebclientMagicQueryonline int `mapstructure:"webclient-magic-queryonline"`
}

func (*Rustdesk) LoadKeyFile

func (rd *Rustdesk) LoadKeyFile()

func (*Rustdesk) ParsePort

func (rd *Rustdesk) ParsePort()

Jump to

Keyboard shortcuts

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