Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

registry: isCIDRMatch: avoid performing DNS lookups if not needed #48999

Merged
merged 3 commits into from
Dec 3, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions registry/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -289,6 +289,10 @@ func (config *serviceConfig) isSecureIndex(indexName string) bool {
// where the `host` part can be either a domain name or an IP address. If it is a domain name, then it will be
// resolved to IP addresses for matching. If resolution fails, false is returned.
func isCIDRMatch(cidrs []*registry.NetIPNet, URLHost string) bool {
if len(cidrs) == 0 {
return false
}
Comment on lines +292 to +294
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sadly this currently doesn't help, as we're unconditionally initialising RepoInfo with localhost CIDRs; while that's relevant for some uses of RepoInfo, it's not for others, and I'll look for follow-ups to split those use-cases.


host, _, err := net.SplitHostPort(URLHost)
if err != nil {
// Assume URLHost is of the form `host` without the port and go on.
Expand Down