diff options
author | Christopher Speller <crspeller@gmail.com> | 2016-10-03 16:03:15 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2016-10-03 16:03:15 -0400 |
commit | 8f91c777559748fa6e857d9fc1f4ae079a532813 (patch) | |
tree | 190f7cef373764a0d47a91045fdb486ee3d6781d /model | |
parent | 5f8e5c401bd96cba9a98b2db02d72f9cbacb0103 (diff) | |
download | chat-8f91c777559748fa6e857d9fc1f4ae079a532813.tar.gz chat-8f91c777559748fa6e857d9fc1f4ae079a532813.tar.bz2 chat-8f91c777559748fa6e857d9fc1f4ae079a532813.zip |
Adding ability to serve TLS directly from Mattermost server (#4119)
Diffstat (limited to 'model')
-rw-r--r-- | model/config.go | 60 |
1 files changed, 60 insertions, 0 deletions
diff --git a/model/config.go b/model/config.go index 514260d09..12f833b89 100644 --- a/model/config.go +++ b/model/config.go @@ -57,6 +57,14 @@ const ( type ServiceSettings struct { SiteURL *string ListenAddress string + ConnectionSecurity *string + TLSCertFile *string + TLSKeyFile *string + UseLetsEncrypt *bool + LetsEncryptCertificateCacheFile *string + Forward80To443 *bool + ReadTimeout *int + WriteTimeout *int MaximumLoginAttempts int SegmentDeveloperKey string GoogleDeveloperKey string @@ -905,6 +913,46 @@ func (o *Config) SetDefaults() { *o.RateLimitSettings.MaxBurst = 100 } + if o.ServiceSettings.ConnectionSecurity == nil { + o.ServiceSettings.ConnectionSecurity = new(string) + *o.ServiceSettings.ConnectionSecurity = "" + } + + if o.ServiceSettings.TLSKeyFile == nil { + o.ServiceSettings.TLSKeyFile = new(string) + *o.ServiceSettings.TLSKeyFile = "" + } + + if o.ServiceSettings.TLSCertFile == nil { + o.ServiceSettings.TLSCertFile = new(string) + *o.ServiceSettings.TLSCertFile = "" + } + + if o.ServiceSettings.UseLetsEncrypt == nil { + o.ServiceSettings.UseLetsEncrypt = new(bool) + *o.ServiceSettings.UseLetsEncrypt = false + } + + if o.ServiceSettings.LetsEncryptCertificateCacheFile == nil { + o.ServiceSettings.LetsEncryptCertificateCacheFile = new(string) + *o.ServiceSettings.LetsEncryptCertificateCacheFile = "./config/letsencrypt.cache" + } + + if o.ServiceSettings.ReadTimeout == nil { + o.ServiceSettings.ReadTimeout = new(int) + *o.ServiceSettings.ReadTimeout = 30 + } + + if o.ServiceSettings.WriteTimeout == nil { + o.ServiceSettings.WriteTimeout = new(int) + *o.ServiceSettings.WriteTimeout = 60 + } + + if o.ServiceSettings.Forward80To443 == nil { + o.ServiceSettings.Forward80To443 = new(bool) + *o.ServiceSettings.Forward80To443 = false + } + o.defaultWebrtcSettings() } @@ -1116,6 +1164,18 @@ func (o *Config) IsValid() *AppError { return err } + if !(*o.ServiceSettings.ConnectionSecurity == CONN_SECURITY_NONE || *o.ServiceSettings.ConnectionSecurity == CONN_SECURITY_TLS) { + return NewLocAppError("Config.IsValid", "model.config.is_valid.webserver_security.app_error", nil, "") + } + + if *o.ServiceSettings.ReadTimeout <= 0 { + return NewLocAppError("Config.IsValid", "model.config.is_valid.read_timeout.app_error", nil, "") + } + + if *o.ServiceSettings.WriteTimeout <= 0 { + return NewLocAppError("Config.IsValid", "model.config.is_valid.write_timeout.app_error", nil, "") + } + return nil } |