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.
Этот коммит содержится в:
коммит произвёл
GitHub
родитель
d23ca07133
Коммит
65cd447a61
@@ -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)
|
||||
}
|
||||
|
||||
|
||||
Ссылка в новой задаче
Block a user