Enhance integration tests
* refactor: remove unused code. * refactor: factorize Traefik cmd start. * refactor(whitelist): minor change. * refactor(accesslog): better use of checker. * refactor(errorpages): factorize containers IP variables. * refactor(integration): refactor cmdTraefikWithConfigFile.
This commit is contained in:
parent
bbb133d94c
commit
2e84b1e556
20 changed files with 109 additions and 231 deletions
|
@ -18,12 +18,13 @@ type IPWhitelister struct {
|
|||
|
||||
// NewIPWhitelister builds a new IPWhitelister given a list of CIDR-Strings to whitelist
|
||||
func NewIPWhitelister(whitelistStrings []string) (*IPWhitelister, error) {
|
||||
whitelister := IPWhitelister{}
|
||||
|
||||
if len(whitelistStrings) == 0 {
|
||||
return nil, errors.New("no whitelists provided")
|
||||
}
|
||||
|
||||
whitelister := IPWhitelister{}
|
||||
|
||||
for _, whitelistString := range whitelistStrings {
|
||||
_, whitelist, err := net.ParseCIDR(whitelistString)
|
||||
if err != nil {
|
||||
|
@ -65,6 +66,7 @@ func reject(w http.ResponseWriter) {
|
|||
w.WriteHeader(statusCode)
|
||||
w.Write([]byte(http.StatusText(statusCode)))
|
||||
}
|
||||
|
||||
func ipFromRemoteAddr(addr string) (*net.IP, error) {
|
||||
ip, _, err := net.SplitHostPort(addr)
|
||||
if err != nil {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue