Skip to content

net(metrics): rename unspecified host to localhost#711

Merged
mmatczuk merged 3 commits intomainfrom
hg/fix_dial_host_label
Feb 23, 2024
Merged

net(metrics): rename unspecified host to localhost#711
mmatczuk merged 3 commits intomainfrom
hg/fix_dial_host_label

Conversation

@Choraden
Copy link
Contributor

No description provided.

@Choraden Choraden requested a review from a team as a code owner February 22, 2024 13:12
net_metrics.go Outdated
return "unknown"
}

if host == "0.0.0.0" || host == "::" {
Copy link
Contributor

@mmatczuk mmatczuk Feb 22, 2024

Choose a reason for hiding this comment

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

Let's refactor and use isLocalhost(req *http.Request) bool from HTTPProxy

@Choraden Choraden force-pushed the hg/fix_dial_host_label branch 4 times, most recently from f30905b to 9802431 Compare February 23, 2024 13:52
The nopResolver would not ever dial. The idea had some potential however, it would allocate lots of memory.
This happend as the resolver didn't know the dial function was nop. It was allocating memory for new DNS requests that would never be sent.

This patch utilizes lookupStaticHost[1] - an internal function from net package.
The function watches /etc/hosts file and looks up hosts there.

Fixes #628

[1] https://github.com/golang/go/blob/master/src/net/hosts.go#L129
@Choraden Choraden force-pushed the hg/fix_dial_host_label branch from 9802431 to 819b429 Compare February 23, 2024 13:54
@mmatczuk
Copy link
Contributor

Love it.

@mmatczuk mmatczuk merged commit 454af44 into main Feb 23, 2024
@mmatczuk mmatczuk deleted the hg/fix_dial_host_label branch February 23, 2024 14:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants