lib/connections: Skip and warn on malformed URLs (fixes #6697) (#6699)

This commit is contained in:
Jakob Borg 2020-06-02 10:19:51 +01:00 committed by GitHub
parent 1f8e6c55f6
commit d9cb7e2739
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 16 additions and 5 deletions

View File

@ -601,14 +601,25 @@ func (s *service) CommitConfiguration(from, to config.Configuration) bool {
continue
}
if _, ok := s.listeners[addr]; ok {
seen[addr] = struct{}{}
uri, err := url.Parse(addr)
if err != nil {
l.Warnf("Skipping malformed listener URL %q: %v", addr, err)
continue
}
uri, err := url.Parse(addr)
if err != nil {
l.Infof("Parsing listener address %s: %v", addr, err)
// Make sure we always have the canonical representation of the URL.
// This is for consistency as we use it as a map key, but also to
// avoid misunderstandings. We do not just use the canonicalized
// version, because an URL that looks very similar to a human might
// mean something entirely different to the computer (e.g.,
// tcp:/127.0.0.1:22000 in fact being equivalent to tcp://:22000).
if canonical := uri.String(); canonical != addr {
l.Warnf("Skipping malformed listener URL %q (not canonical)", addr)
continue
}
if _, ok := s.listeners[addr]; ok {
seen[addr] = struct{}{}
continue
}