This commit is contained in:
parent
98191fd098
commit
d272fa90b4
20 changed files with 574 additions and 27 deletions
|
@ -50,6 +50,7 @@ type ConfigAdmin struct {
|
|||
// The password has to be supplied in the `password` GET form value for all requests
|
||||
// to /profiling/*
|
||||
ProfilingPassword string `toml:"profiling_password"`
|
||||
AllowRegistration bool `toml:"allow_registration"`
|
||||
}
|
||||
|
||||
type ConfigStorage struct {
|
||||
|
@ -71,6 +72,9 @@ type ConfigStorage struct {
|
|||
// Key used for encrypting sensitive information in the db
|
||||
// DO NOT CHANGE THIS AFTER SETUP
|
||||
EncryptionKey string `toml:"encryption_key"`
|
||||
// Maximum number of reconnection attempts if the connection to the db
|
||||
// breaks for some reason. Server will exit if the last attempt fails
|
||||
MaxReconnectAttempts int `toml:"max_reconnect_attempts"`
|
||||
}
|
||||
|
||||
type ConfigS3 struct {
|
||||
|
@ -131,6 +135,7 @@ var defaultConfig Config = Config{
|
|||
Username: "server-admin",
|
||||
FirstTimeSetupOTP: "Example otp password",
|
||||
ProfilingPassword: "Example profiling password",
|
||||
AllowRegistration: true,
|
||||
},
|
||||
Webauthn: ConfigWebAuthn{
|
||||
DisplayName: "Linstrom",
|
||||
|
@ -149,6 +154,7 @@ var defaultConfig Config = Config{
|
|||
MaxInMemoryCacheTTL: 5,
|
||||
MaxRedisCacheTTL: nil,
|
||||
EncryptionKey: "Encryption key for sensitive information. DO NOT CHANGE THIS AFTER SETUP",
|
||||
MaxReconnectAttempts: 3,
|
||||
},
|
||||
Mail: ConfigMail{
|
||||
Host: "localhost",
|
||||
|
@ -182,11 +188,11 @@ func (gc *ConfigGeneral) GetFullDomain() string {
|
|||
}
|
||||
|
||||
func (gc *ConfigGeneral) GetFullPublicUrl() string {
|
||||
str := gc.Protocol + gc.GetFullDomain()
|
||||
str := gc.Protocol + "://" + gc.GetFullDomain()
|
||||
if gc.PublicPort != nil {
|
||||
str += fmt.Sprint(*gc.PublicPort)
|
||||
str += generatePortAppender(gc.Protocol, *gc.PublicPort)
|
||||
} else {
|
||||
str += fmt.Sprint(gc.PrivatePort)
|
||||
str += generatePortAppender(gc.Protocol, gc.PrivatePort)
|
||||
}
|
||||
return str
|
||||
}
|
||||
|
@ -269,3 +275,13 @@ func ReadAndWriteToGlobal(fileName string) error {
|
|||
log.Info().Str("config-file", fileName).Msg("Read and applied config file")
|
||||
return nil
|
||||
}
|
||||
|
||||
func generatePortAppender(protocol string, portNum int) string {
|
||||
if protocol == "http" && portNum == 80 {
|
||||
return ""
|
||||
} else if protocol == "https" && portNum == 443 {
|
||||
return ""
|
||||
} else {
|
||||
return fmt.Sprintf(":%d", portNum)
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue