Comments (15)
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.
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.
@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.
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.
Yes @tomjn, you may be pointing right place.
RemoveDuplicateIps
is called withinClean
along withHostsPerLine
Clean
function does Sort before makingHostsPerLine
.RemoveDuplicateIps
is called fromHostsPerLine
too.- So even someone just calls
HostsPerLine
,RemoveDuplicateIps
are called.
from hostsfile.
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.
Comments are stripped regardless of the cli.
This is easy to demonstrate with https://github.com/rfay/goodhostsbug
from hostsfile.
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.
I've seen some good maintenance going on in this area lately, thanks! Has this one been addressed yet?
from hostsfile.
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.
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.
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.
Yay, it's working great! This issue can be closed (at least about the comments), thanks so much!
from hostsfile.
My pleasure! Glad it's working
from hostsfile.
Thanks so much for your maintenance of this! Reopened
from hostsfile.
Related Issues (17)
- Please keep commit history and versioning! HOT 1
- Larger list of hosts per ip is not working in Windows HOT 3
- Q: Why is the position of a host on the line used? HOT 2
- Add/Remove/Contains functions for HostsLine
- Multiple hosts per line added on Windows causes problems HOT 3
- License? HOT 1
- Github action golang ci no longer found HOT 1
- Deputize maintainers/reviewers/testers HOT 2
- Duplicate lines in hostsfile after `Flush()` HOT 1
- Bug: Adding a host can add duplicates with differing IPs
- Regression - panic when calling Clear and then Add
- Panic: goodhosts does not check slice length during removal HOT 6
- Calling HostsPerLine() before Add() results in a panic with plain vanilla macOS hosts file
- Limiting hosts per line works for first line, but after that each item goes on its own line HOT 10
- Feature Request: Method to Create Hostsfile from String HOT 2
- Comments are not published on Flush HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from hostsfile.