Skip to content

MatchLocalhost should match 127.12.34.56 #5129

@AkihiroSuda

Description

@AkihiroSuda

Description

MatchLocalhost should use net.IP.IsLoopback to match addresses like "127.12.34.56".

https://github.com/containerd/containerd/blob/v1.5.0-beta.3/remotes/docker/registry.go#L202-L212

// MatchLocalhost is a host match function which returns true for
// localhost.
func MatchLocalhost(host string) (bool, error) {
	for _, s := range []string{"localhost", "127.0.0.1", "[::1]"} {
		if len(host) >= len(s) && host[0:len(s)] == s && (len(host) == len(s) || host[len(s)] == ':') {
			return true, nil
		}
	}
	return host == "::1", nil

}

Describe the results you received:
MatchLocalhost should match addresses like "127.12.34.56"

Describe the results you expected:
MatchLocalhost only matches "localhost", "127.0.0.1", and "[::1]".

What version of containerd are you using:
v1.5.0-beta.3


Related: #5100 (CRI only)

Metadata

Metadata

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions