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

Innernet writes /etc/hosts when only the order of mappings in a section has changed, not the mappings themselves #233

Open
kevenwyld opened this issue Sep 12, 2022 · 5 comments

Comments

@kevenwyld
Copy link

Currently /etc/hosts is written very frequently, nearly every minute, because innernet writes the contents of each section as it is received. Apparently those checkins, or whatever is triggering HostsBuilder to run, is receiving the list of hosts in the order they respond which is not always the same. This order is carried through to the order mappings appear in the hosts file.

Would it be possible to sort the list of hosts in each section before checking to see if /etc/hosts requires updating? This would, I think, change the behavior so that updating /etc/hosts only happens when there is actually an ip/hostname update required and make it much less frequent.

Thanks!

@strohel
Copy link
Member

strohel commented Sep 12, 2022

Hi @kevenwyld, sorting the lines added to hosts file would be a good idea!

I'm looking at the code, it should be a matter of changing HostsBuilder's HashMap to BTreeMap:

hostname_map: HashMap<IpAddr, Vec<String>>,

However, even when the hostname list is sorted, it seems that there is currently no detection of `hostname file is already the same as we want to write", so we'd need to add that too (I think we should).

Do you want to try contributing such improvement?

@kevenwyld
Copy link
Author

Thanks @strohel . I am up for trying to trying to contribute however this would be my first experience with rust. I will see what I can come up with but it may take me a few days.

@kevenwyld
Copy link
Author

Hey, just wanted to say that I'm still working on this, sorry for the silence. @mcginty helped me out a bit getting up to speed.

@evaporei
Copy link
Contributor

Hey @kevenwyld ! Since this seems inactive and the change is pretty simple, I decided to open a PR. #259

@kevenwyld
Copy link
Author

Hey thanks @evaporei! Life happened and I didn't have time to get it done.

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

No branches or pull requests

3 participants