🐛Remove trailing and leading spaces between each IP or range (#68)

This commit is contained in:
mathieuHa
2022-12-29 10:30:19 +01:00
committed by GitHub
parent 1e82ecd1b9
commit aff7c496c2
+2
View File
@@ -24,6 +24,8 @@ func NewChecker(trustedIPs []string) (*Checker, error) {
checker := &Checker{} checker := &Checker{}
for _, ipMask := range trustedIPs { for _, ipMask := range trustedIPs {
// remove leading and trailing spaces
ipMask = strings.TrimSpace(ipMask)
if ipAddr := net.ParseIP(ipMask); ipAddr != nil { if ipAddr := net.ParseIP(ipMask); ipAddr != nil {
checker.authorizedIPs = append(checker.authorizedIPs, &ipAddr) checker.authorizedIPs = append(checker.authorizedIPs, &ipAddr)
logger.Debug(fmt.Sprintf("IP %v is trusted", ipAddr)) logger.Debug(fmt.Sprintf("IP %v is trusted", ipAddr))