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

fix redundant WindowsDNS #1456

Merged
merged 2 commits into from
Aug 20, 2024
Merged

fix redundant WindowsDNS #1456

merged 2 commits into from
Aug 20, 2024

Conversation

ForestL18
Copy link

When using system to get Windows system DNS, mihomo always get three same DNS. It's unnecessary and redundant, so just reserve unique one.

servers = append(servers, ip.String())

ipStr := ip.String()
if !seenIPs[ipStr] {
Copy link
Collaborator

@Skyxim Skyxim Aug 18, 2024

Choose a reason for hiding this comment

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

Just store it in the map and get it from the map key. Map can be used as a set to store unique values, without having to judge once

@Larvan2
Copy link
Collaborator

Larvan2 commented Aug 18, 2024

These address would be unique after going through:

if _, ok := c.dnsClients[addr]; !ok {

@ForestL18
Copy link
Author

ForestL18 commented Aug 18, 2024

These address would be unique after going through:

if _, ok := c.dnsClients[addr]; !ok {

But log.Debugln("[DNS] system dns update to %s", nameservers)will display redundant log, considering effectivity and clarity, I think eliminating the redundant result of dnsReadConfig() is necessary.

@Larvan2 Larvan2 merged commit 58efe08 into MetaCubeX:Alpha Aug 20, 2024
Larvan2 added a commit that referenced this pull request Aug 20, 2024
Co-authored-by: ForestL<45709305+forestl18@users.noreply.github.com>
Larvan2 added a commit that referenced this pull request Aug 20, 2024
Co-authored-by: ForestL <45709305+forestl18@users.noreply.github.com>
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.

3 participants