diff options
author | Martin Kraft <mkraft@users.noreply.github.com> | 2018-07-30 14:59:08 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-07-30 14:59:08 -0400 |
commit | 65cd447a61efa852da2c0e7db25f385c2436e236 (patch) | |
tree | 15954e1f0a1405cb916e19462174c7186684e7b2 /model/config.go | |
parent | d23ca07133e9bc5eed14d87af563471b4ef963cd (diff) | |
download | chat-65cd447a61efa852da2c0e7db25f385c2436e236.tar.gz chat-65cd447a61efa852da2c0e7db25f385c2436e236.tar.bz2 chat-65cd447a61efa852da2c0e7db25f385c2436e236.zip |
MM-11301: Validates listen address config value. (#9138)
* MM-11301: Validates listen address config value.
* MM-11301: Adds some invalid port test cases.
* MM-11301: Accept domain names.
* MM-11301: Fix for max port.
Diffstat (limited to 'model/config.go')
-rw-r--r-- | model/config.go | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/model/config.go b/model/config.go index 1d0f40901..aa7900279 100644 --- a/model/config.go +++ b/model/config.go @@ -6,9 +6,12 @@ package model import ( "encoding/json" "io" + "math" + "net" "net/http" "net/url" "regexp" + "strconv" "strings" "time" ) @@ -2352,7 +2355,15 @@ func (ss *ServiceSettings) isValid() *AppError { } } - if len(*ss.ListenAddress) == 0 { + host, port, err := net.SplitHostPort(*ss.ListenAddress) + var isValidHost bool + if host == "" { + isValidHost = true + } else { + isValidHost = (net.ParseIP(host) != nil) || IsDomainName(host) + } + portInt, err := strconv.Atoi(port) + if err != nil || !isValidHost || portInt < 0 || portInt > math.MaxUint16 { return NewAppError("Config.IsValid", "model.config.is_valid.listen_address.app_error", nil, "", http.StatusBadRequest) } |