GithubHelp home page GithubHelp logo

Comments (15)

jd4u avatar jd4u commented on August 28, 2024

The issue seems to be in goodhosts/cli project. With or without "--clean" flag, cli is performing clean process. See Issue Comment

The cli project seems to be handling bool value incorrectly. Explicitly setting default bool value may help.

from hostsfile.

tomjn avatar tomjn commented on August 28, 2024

Note that I cannot reproduce this on MacOS, this is very likely Windows related.

We need to confirm what the command is doing to the hosts file in addition to stripping out comments to eliminate options, my current theory is that this has nothing to do with the clean parameters, but due to the attempt to workaround a Windows bug where more than 8 hosts on a line breaks the hosts file.

We can confirm this if we had examples that can be used to see if it's sorting the hosts file, merging lines that were previously separate, etc

from hostsfile.

tomjn avatar tomjn commented on August 28, 2024

@luthermonson is it possible that this is all because of the Ip de-duplication at the top of that function?

func (h *Hosts) HostsPerLine(count int) {
	// restacks everything into 1 ip again so we can do the split, do this even if count is -1 so it can reset the slice
	h.RemoveDuplicateIps()

from hostsfile.

tomjn avatar tomjn commented on August 28, 2024

For context @jd4u is reporting that comments were stripped from their hosts file on use regardless of wether the clean parameter was specified or not. They're a WIndows user so HostsPerLine would be running to cap the lines at 8 hosts, is the RemoveDuplicateIps really necessary?

from hostsfile.

jd4u avatar jd4u commented on August 28, 2024

Yes @tomjn, you may be pointing right place.

  • RemoveDuplicateIps is called within Clean along with HostsPerLine
  • Clean function does Sort before making HostsPerLine.
  • RemoveDuplicateIps is called from HostsPerLine too.
  • So even someone just calls HostsPerLine, RemoveDuplicateIps are called.

from hostsfile.

jd4u avatar jd4u commented on August 28, 2024

Just for note,

  • in VVV config, only 6 active sites present.
  • And none of the IP had or have more than 4 hostnames in machine hosts file.

from hostsfile.

rfay avatar rfay commented on August 28, 2024

Comments are stripped regardless of the cli.

This is easy to demonstrate with https://github.com/rfay/goodhostsbug

from hostsfile.

rfay avatar rfay commented on August 28, 2024

One improvement here would be to respect "important" standard lines like "localhost". A longer-term improvement would be to add separate lines for goodhosts-managed lines (probably marked with a comment before and after).

from hostsfile.

rfay avatar rfay commented on August 28, 2024

I've seen some good maintenance going on in this area lately, thanks! Has this one been addressed yet?

from hostsfile.

luthermonson avatar luthermonson commented on August 28, 2024

ya all that stuff got refactored to index the lookup hashmaps better. i bet your example repo works against latest main, give it a check and report back findings and ill fix if still broke

from hostsfile.

rfay avatar rfay commented on August 28, 2024

No, it still makes a pretty big mess. Comments are mostly destroyed and misplaced. I updated https://github.com/rfay/goodhostsbug and its readme to show more how to demonstrate it.

Bottom line is that

##
# Host Database
#
# localhost is used to configure the loopback interface
# when the system is booting.  Do not change this entry.
##
127.0.0.1	localhost
255.255.255.255	broadcasthost
::1             localhost

gets transformed to

127.0.0.1 localhost xxx.ddev.site
255.255.255.255 broadcasthost
::1 localhost
  # Host Database

from hostsfile.

luthermonson avatar luthermonson commented on August 28, 2024

im sorry i wasted your time... I forgot I hadn't released the changes here #46

please try with v0.1.4 as with a test off latest main i got the following...

func Test_rfay(t *testing.T) {
	hosts := newMacOSXDefault()
	assert.Nil(t, hosts.Add("127.0.0.1", "xxx.ddev.site"))
	hosts.HostsPerLine(8)
	fmt.Println(hosts.String())
}
##
# Host Database
#
# localhost is used to configure the loopback interface
# when the system is booting.  Do not change this entry.
##
127.0.0.1 localhost xxx.ddev.site
255.255.255.255 broadcasthost
::1 localhost

from hostsfile.

rfay avatar rfay commented on August 28, 2024

Yay, it's working great! This issue can be closed (at least about the comments), thanks so much!

from hostsfile.

luthermonson avatar luthermonson commented on August 28, 2024

My pleasure! Glad it's working

from hostsfile.

rfay avatar rfay commented on August 28, 2024

Thanks so much for your maintenance of this! Reopened

from hostsfile.

Related Issues (17)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.