added todo

This commit is contained in:
Pasha 2024-11-27 18:07:41 +03:00
parent 03d8af8332
commit 2eff1775f9
2 changed files with 22 additions and 4 deletions

@ -9,7 +9,6 @@ import (
"github.com/gofiber/fiber/v2" "github.com/gofiber/fiber/v2"
"github.com/twmb/franz-go/pkg/kgo" "github.com/twmb/franz-go/pkg/kgo"
"log" "log"
"net"
"regexp" "regexp"
"time" "time"
) )
@ -77,9 +76,10 @@ func validateURLs(urls []string) error {
return fmt.Errorf("empty url, index: %d", index) return fmt.Errorf("empty url, index: %d", index)
} }
if ip := net.ParseIP(u); ip == nil { // todo проверять урлы
return fmt.Errorf("invalid url: %s", u) //if ip := net.Pa(u); ip == nil {
} // return fmt.Errorf("invalid url: %s", u)
//}
// todo check the liveness of these URLs, many services do not support // todo check the liveness of these URLs, many services do not support
} }
return nil return nil

@ -20,3 +20,21 @@ func TestValidateMail(t *testing.T) {
}) })
assert.NoError(t, err) assert.NoError(t, err)
} }
func TestValidateURLs(t *testing.T) {
urls := []string{
"http://10.8.0.6:59300",
"http://10.8.0.6:59303",
"http://10.8.0.6:3131",
"10.8.0.6:9001",
"10.8.0.6:9085",
"http://10.8.0.6:7036",
"http://10.6.0.17",
"https://api.smtp.bz/v1/smtp/send",
"10.8.0.6:59665",
"https://sadmin.pena",
"10.8.0.15:7113",
}
err := validateURLs(urls)
assert.NoError(t, err)
}