conf

package
v0.0.0-...-c7a3bb2 Latest Latest
Warning

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

Go to latest
Published: Jun 26, 2023 License: MIT Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	BuildTime   string
	BuildCommit string
)

Build time and commit information.

⚠️ WARNING: should only be set by "-ldflags".

View Source
var (
	App struct {
		// ⚠️ WARNING: Should only be set by the main package (i.e. "imail.go").
		Version string `ini:"-"`

		Name      string
		BrandName string
		RunUser   string
		RunMode   string

		PublicFs embed.FS
	}

	// log
	Log struct {
		Format   string
		RootPath string
	}

	// Cache settings
	Cache struct {
		Adapter  string
		Interval int
		Host     string
	}

	// web settings
	Web struct {
		HttpAddr                 string `ini:"http_addr"`
		HttpPort                 int    `ini:"http_port"`
		Domain                   string
		AppDataPath              string
		AccessControlAllowOrigin string

		ExternalURL          string `ini:"EXTERNAL_URL"`
		Protocol             string
		CertFile             string
		KeyFile              string
		TLSMinVersion        string `ini:"TLS_MIN_VERSION"`
		UnixSocketPermission string
		LocalRootURL         string `ini:"LOCAL_ROOT_URL"`

		OfflineMode      bool
		DisableRouterLog bool
		EnableGzip       bool

		LoadAssetsFromDisk bool

		LandingURL string `ini:"LANDING_URL"`

		// Derived from other static values
		URL            *url.URL    `ini:"-"` // Parsed URL object of ExternalURL.
		Subpath        string      `ini:"-"` // Subpath found the ExternalURL. Should be empty when not found.
		SubpathDepth   int         `ini:"-"` // The number of slashes found in the Subpath.
		UnixSocketMode os.FileMode `ini:"-"` // Parsed file mode of UnixSocketPermission.

		MailSaveMode string
	}

	// Authentication settings
	Auth struct {
		ActivateCodeLives         int
		ResetPasswordCodeLives    int
		RequireEmailConfirmation  bool
		RequireSigninView         bool
		DisableRegistration       bool
		EnableRegistrationCaptcha bool

		EnableReverseProxyAuthentication   bool
		EnableReverseProxyAutoRegistration bool
		ReverseProxyAuthenticationHeader   string
	}

	// Session settings
	Session struct {
		Provider       string
		ProviderConfig string
		CookieName     string
		CookieSecure   bool
		GCInterval     int64 `ini:"gc_interval"`
		MaxLifeTime    int64
		CSRFCookieName string `ini:"csrf_cookie_name"`
	}

	// Smtp settings
	Smtp struct {
		Port      int
		Enable    bool
		Debug     bool
		SslEnable bool
		SslPort   int
		ModeIn    bool
	}

	// Pop settings
	Pop3 struct {
		Port      int
		Enable    bool
		Debug     bool
		SslEnable bool
		SslPort   int
		ModeIn    bool
	}

	// Imap settings
	Imap struct {
		Port      int
		Enable    bool
		Debug     bool
		SslEnable bool
		SslPort   int
		ModeIn    bool
	}

	//rspamd
	Rspamd struct {
		Enable                bool
		Domain                string
		Password              string
		RecjectConditionScore float64
	}

	//ssl
	Ssl struct {
		Enable   bool
		Debug    bool
		CertFile string
		KeyFile  string
	}

	//Hook
	Hook struct {
		Enable        bool
		ReceiveScript string
		SendScript    string
	}

	// Security settings
	Security struct {
		InstallLock             bool
		SecretKey               string
		LoginRememberDays       int
		CookieRememberName      string
		CookieUsername          string
		CookieSecure            bool
		EnableLoginStatusCookie bool
		LoginStatusCookieName   string
	}

	// Other settings
	Other struct {
		ShowFooterBranding         bool
		ShowFooterTemplateLoadTime bool
	}

	// Global setting
	HasRobotsTxt bool
)
View Source
var CustomConf string

CustomConf returns the absolute path of custom configuration file that is used.

View Source
var File *ini.File

File is the configuration object.

View Source
var I18n *i18nConf

I18n settings

Functions

func AppPath

func AppPath() string

AppPath returns the absolute path of the application's binary.

func Asset

func Asset(name string) ([]byte, error)

Asset is a wrapper for getting conf assets.

func AssetDir

func AssetDir(name string) ([]string, error)

AssetDir is a wrapper for getting conf assets.

func CheckRunUser

func CheckRunUser(runUser string) (string, bool)

CheckRunUser returns false if configured run user does not match actual user that runs the app. The first return value is the actual user name. This check is ignored under Windows since SSH remote login is not the main method to login on Windows.

func CurrentUsername

func CurrentUsername() string

CurrentUsername returns the username of the current user.

func CustomDir

func CustomDir() string

CustomDir returns the absolute path of the custom directory that contains local overrides. It reads the value of environment variable GOGS_CUSTOM. When not set, it uses the work directory returned by WorkDir function.

func HomeDir

func HomeDir() string

HomeDir returns the home directory by reading environment variables. It may return empty string when environment variables are not set.

func Init

func Init(customConf string) error

func IsProdMode

func IsProdMode() bool

IsProdMode returns true if the application is running in production mode.

func IsWindowsRuntime

func IsWindowsRuntime() bool

IsWindowsRuntime returns true if the current runtime in Windows.

func MustAsset

func MustAsset(name string) []byte

MustAsset is a wrapper for getting conf assets.

func WorkDir

func WorkDir() string

WorkDir returns the absolute path of work directory. It reads the value of environment variable IMAIL_WORK_DIR. When not set, it uses the directory where the application's binary is located.

Types

type DatabaseOpts

type DatabaseOpts struct {
	Type         string
	Host         string
	Name         string
	User         string
	Password     string
	SslMode      string `ini:"ssl_mode"`
	Path         string
	Prefix       string
	Charset      string
	Timezone     string
	MaxOpenConns int
	MaxIdleConns int
}
var Database DatabaseOpts

Database settings

Jump to

Keyboard shortcuts

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