[GH-ISSUE #12] Goodhosts don't remove duplicates #5

Closed
opened 2026-03-02 05:09:05 +03:00 by kerem · 10 comments
Owner

Originally created by @Mte90 on GitHub (Sep 1, 2020).
Original GitHub issue: https://github.com/goodhosts/cli/issues/12

Originally assigned to: @luthermonson on GitHub.

We are facing some issues with the vagrant plugin that when we add new hosts, they are added creating things like:

192.168.50.4 vvv vvv.test boilerplate.test woocommerce.test glossary.test tideways.vvv.test xhgui.vvv.test vvv vvv.test boilerplate.test woocommerce.test 503702305c22.ngrok.io glossary.test tideways.vvv.test xhgui.vvv.test vvv vvv.test boilerplate.test woocommerce.test 503702305c22.ngrok.io glossary.test tideways.vvv.test xhgui.vvv.test vvv vvv.test boilerplate.test woocommerce.test 503702305c22.ngrok.io glossary.test tideways.vvv.test xhgui.vvv.test vvv vvv.test boilerplate.test woocommerce.test 503702305c22.ngrok.io glossary.test tideways.vvv.test xhgui.vvv.test vvv vvv.test boilerplate.test woocommerce.test 503702305c22.ngrok.io glossary.test tideways.vvv.test xhgui.vvv.test vvv vvv.test boilerplate.test woocommerce.test 503702305c22.ngrok.io glossary.test tideways.vvv.test xhgui.vvv.test vvv vvv.test boilerplate.test woocommerce.test 503702305c22.ngrok.io auto.test glossary.test tideways.vvv.test xhgui.vvv.test vvv vvv.test boilerplate.test woocommerce.test 503702305c22.ngrok.io auto.test glossary.test tideways.vvv.test xhgui.vvv.test vvv vvv.test boilerplate.test woocommerce.test 503702305c22.ngrok.io auto.test glossary.test tideways.vvv.test xhgui.vvv.test vvv vvv.test boilerplate.test woocommerce.test 503702305c22.ngrok.io auto.test glossary.test tideways.vvv.test xhgui.vvv.test vvv vvv.test boilerplate.test woocommerce.test 503702305c22.ngrok.io auto.test glossary.test tideways.vvv.test xhgui.vvv.test vvv vvv.test boilerplate.test woocommerce.test 503702305c22.ngrok.io auto.test glossary.test tideways.vvv.test xhgui.vvv.test vvv vvv.test boilerplate.test woocommerce.test 503702305c22.ngrok.io auto.test glossary.test tideways.vvv.test xhgui.vvv.test vvv vvv.test boilerplate.test woocommerce.test 503702305c22.ngrok.io auto.test glossary.test tideways.vvv.test xhgui.vvv.test vvv vvv.test woocommerce.test 503702305c22.ngrok.io auto.test glossary.test src.wordpress-develop.test build.wordpress-develop.test tideways.vvv.test xhgui.vvv.test vvv vvv.test woocommerce.test 503702305c22.ngrok.io auto.test glossary.test src.wordpress-develop.test build.wordpress-develop.test tideways.vvv.test xhgui.vvv.test vvv vvv.test woocommerce.test 503702305c22.ngrok.io auto.test glossary.test src.wordpress-develop.test build.wordpress-develop.test tideways.vvv.test xhgui.vvv.test vvv vvv.test woocommerce.test 503702305c22.ngrok.io auto.test glossary.test src.wordpress-develop.test build.wordpress-develop.test tideways.vvv.test xhgui.vvv.test
Originally created by @Mte90 on GitHub (Sep 1, 2020). Original GitHub issue: https://github.com/goodhosts/cli/issues/12 Originally assigned to: @luthermonson on GitHub. We are facing some issues with the vagrant plugin that when we add new hosts, they are added creating things like: ``` 192.168.50.4 vvv vvv.test boilerplate.test woocommerce.test glossary.test tideways.vvv.test xhgui.vvv.test vvv vvv.test boilerplate.test woocommerce.test 503702305c22.ngrok.io glossary.test tideways.vvv.test xhgui.vvv.test vvv vvv.test boilerplate.test woocommerce.test 503702305c22.ngrok.io glossary.test tideways.vvv.test xhgui.vvv.test vvv vvv.test boilerplate.test woocommerce.test 503702305c22.ngrok.io glossary.test tideways.vvv.test xhgui.vvv.test vvv vvv.test boilerplate.test woocommerce.test 503702305c22.ngrok.io glossary.test tideways.vvv.test xhgui.vvv.test vvv vvv.test boilerplate.test woocommerce.test 503702305c22.ngrok.io glossary.test tideways.vvv.test xhgui.vvv.test vvv vvv.test boilerplate.test woocommerce.test 503702305c22.ngrok.io glossary.test tideways.vvv.test xhgui.vvv.test vvv vvv.test boilerplate.test woocommerce.test 503702305c22.ngrok.io auto.test glossary.test tideways.vvv.test xhgui.vvv.test vvv vvv.test boilerplate.test woocommerce.test 503702305c22.ngrok.io auto.test glossary.test tideways.vvv.test xhgui.vvv.test vvv vvv.test boilerplate.test woocommerce.test 503702305c22.ngrok.io auto.test glossary.test tideways.vvv.test xhgui.vvv.test vvv vvv.test boilerplate.test woocommerce.test 503702305c22.ngrok.io auto.test glossary.test tideways.vvv.test xhgui.vvv.test vvv vvv.test boilerplate.test woocommerce.test 503702305c22.ngrok.io auto.test glossary.test tideways.vvv.test xhgui.vvv.test vvv vvv.test boilerplate.test woocommerce.test 503702305c22.ngrok.io auto.test glossary.test tideways.vvv.test xhgui.vvv.test vvv vvv.test boilerplate.test woocommerce.test 503702305c22.ngrok.io auto.test glossary.test tideways.vvv.test xhgui.vvv.test vvv vvv.test boilerplate.test woocommerce.test 503702305c22.ngrok.io auto.test glossary.test tideways.vvv.test xhgui.vvv.test vvv vvv.test woocommerce.test 503702305c22.ngrok.io auto.test glossary.test src.wordpress-develop.test build.wordpress-develop.test tideways.vvv.test xhgui.vvv.test vvv vvv.test woocommerce.test 503702305c22.ngrok.io auto.test glossary.test src.wordpress-develop.test build.wordpress-develop.test tideways.vvv.test xhgui.vvv.test vvv vvv.test woocommerce.test 503702305c22.ngrok.io auto.test glossary.test src.wordpress-develop.test build.wordpress-develop.test tideways.vvv.test xhgui.vvv.test vvv vvv.test woocommerce.test 503702305c22.ngrok.io auto.test glossary.test src.wordpress-develop.test build.wordpress-develop.test tideways.vvv.test xhgui.vvv.test ```
kerem 2026-03-02 05:09:05 +03:00
  • closed this issue
  • added the
    bug
    label
Author
Owner

@luthermonson commented on GitHub (Sep 5, 2020):

hi @Mte90 ran some scenarios in my head while walking through code and im not sure how you ended up getting this result. if you look here: https://github.com/goodhosts/hostsfile/blob/master/hosts.go#L117 it skips dupes in the hostsfile library and here: https://github.com/goodhosts/cli/blob/master/cmd/add.go#L37-L43 in the cli it pulls dupes from the args passed.

even the remove call should take out dupes... any ideas how this could have happened? I'm currently at a loss.

<!-- gh-comment-id:687660642 --> @luthermonson commented on GitHub (Sep 5, 2020): hi @Mte90 ran some scenarios in my head while walking through code and im not sure how you ended up getting this result. if you look here: https://github.com/goodhosts/hostsfile/blob/master/hosts.go#L117 it skips dupes in the hostsfile library and here: https://github.com/goodhosts/cli/blob/master/cmd/add.go#L37-L43 in the cli it pulls dupes from the args passed. even the remove call should take out dupes... any ideas how this could have happened? I'm currently at a loss.
Author
Owner

@Mte90 commented on GitHub (Sep 7, 2020):

Hi @luthermonson we saw various users of the vagrant plugin with the issue.
The plugin run add on boot and remove on halt but can happen that you turn of the host machine without turning off the virtual machine so the remove command is not executed.

The fact that identify the right ip address and enqueue them is good but is not detecting in the line that domain already exists so it is appended anyway. Maybe the issue is in the domain detection in a long line?

I think that you can do some tests with that line that I shared to you but I am here for debugging also to compile the tool if needed.

<!-- gh-comment-id:688229850 --> @Mte90 commented on GitHub (Sep 7, 2020): Hi @luthermonson we saw various users of the vagrant plugin with the issue. The plugin run add on boot and remove on halt but can happen that you turn of the host machine without turning off the virtual machine so the remove command is not executed. The fact that identify the right ip address and enqueue them is good but is not detecting in the line that domain already exists so it is appended anyway. Maybe the issue is in the domain detection in a long line? I think that you can do some tests with that line that I shared to you but I am here for debugging also to compile the tool if needed.
Author
Owner

@luthermonson commented on GitHub (Sep 7, 2020):

i added a clean command and ran it across your line and it improves things, perhaps we can run this before every flush in add/remove. Give it a try: https://github.com/goodhosts/cli/releases/tag/v1.0.4

<!-- gh-comment-id:688500431 --> @luthermonson commented on GitHub (Sep 7, 2020): i added a clean command and ran it across your line and it improves things, perhaps we can run this before every flush in add/remove. Give it a try: https://github.com/goodhosts/cli/releases/tag/v1.0.4
Author
Owner

@luthermonson commented on GitHub (Sep 7, 2020):

PS C:\Users\luthe\goodhosts\hostsfile> goodhosts -f ./hosts clean
PS C:\Users\luthe\goodhosts\hostsfile> type hosts
192.168.50.4 503702305c22.ngrok.io auto.test boilerplate.test build.wordpress-develop.test glossary.test src.wordpress-develop.test tideways.vvv.test vvv vvv.test woocommerce.test xhgui.vvv.test

I just can't seem to get the add to not strip out dupes.

PS C:\Users\luthe\goodhosts\hostsfile> goodhosts -f ./hosts add 192.168.50.4 503702305c22.ngrok.io auto.test boilerplate.test build.wordpress-develop.test glossary.test src.wordpress-develop.test tideways.vvv.test vvv vvv.test woocommerce.test xhgui.vvv.test
hosts entry added: 192.168.50.4 vvv.test woocommerce.test auto.test build.wordpress-develop.test vvv src.wordpress-develop.test tideways.vvv.test xhgui.vvv.test 503702305c22.ngrok.io boilerplate.test glossary.test
PS C:\Users\luthe\goodhosts\hostsfile> type hosts
192.168.50.4 503702305c22.ngrok.io auto.test boilerplate.test build.wordpress-develop.test glossary.test src.wordpress-develop.test tideways.vvv.test vvv vvv.test woocommerce.test xhgui.vvv.test
<!-- gh-comment-id:688501720 --> @luthermonson commented on GitHub (Sep 7, 2020): ``` PS C:\Users\luthe\goodhosts\hostsfile> goodhosts -f ./hosts clean PS C:\Users\luthe\goodhosts\hostsfile> type hosts 192.168.50.4 503702305c22.ngrok.io auto.test boilerplate.test build.wordpress-develop.test glossary.test src.wordpress-develop.test tideways.vvv.test vvv vvv.test woocommerce.test xhgui.vvv.test ``` I just can't seem to get the add to not strip out dupes. ``` PS C:\Users\luthe\goodhosts\hostsfile> goodhosts -f ./hosts add 192.168.50.4 503702305c22.ngrok.io auto.test boilerplate.test build.wordpress-develop.test glossary.test src.wordpress-develop.test tideways.vvv.test vvv vvv.test woocommerce.test xhgui.vvv.test hosts entry added: 192.168.50.4 vvv.test woocommerce.test auto.test build.wordpress-develop.test vvv src.wordpress-develop.test tideways.vvv.test xhgui.vvv.test 503702305c22.ngrok.io boilerplate.test glossary.test PS C:\Users\luthe\goodhosts\hostsfile> type hosts 192.168.50.4 503702305c22.ngrok.io auto.test boilerplate.test build.wordpress-develop.test glossary.test src.wordpress-develop.test tideways.vvv.test vvv vvv.test woocommerce.test xhgui.vvv.test ```
Author
Owner

@Mte90 commented on GitHub (Sep 8, 2020):

Seems that clean that line rightly, this command can be executed on adding/removing?

<!-- gh-comment-id:688780993 --> @Mte90 commented on GitHub (Sep 8, 2020): Seems that clean that line rightly, this command can be executed on adding/removing?
Author
Owner

@Mte90 commented on GitHub (Sep 24, 2020):

any updates?

<!-- gh-comment-id:698303703 --> @Mte90 commented on GitHub (Sep 24, 2020): any updates?
Author
Owner

@luthermonson commented on GitHub (Oct 15, 2020):

Sorry for delay, v1.0.5 now has all this.

<!-- gh-comment-id:709030443 --> @luthermonson commented on GitHub (Oct 15, 2020): Sorry for delay, v1.0.5 now has all this.
Author
Owner

@Mte90 commented on GitHub (Oct 15, 2020):

Hi @luthermonson, it is not clear to me a thing.
It is possible to do the clean on adding or remove? I am trying just to optimize the thing and avoid executing 2 commands.

<!-- gh-comment-id:709033572 --> @Mte90 commented on GitHub (Oct 15, 2020): Hi @luthermonson, it is not clear to me a thing. It is possible to do the clean on adding or remove? I am trying just to optimize the thing and avoid executing 2 commands.
Author
Owner

@luthermonson commented on GitHub (Oct 15, 2020):

yes, there is a --clean or -c you can use on add/remove now

<!-- gh-comment-id:709041714 --> @luthermonson commented on GitHub (Oct 15, 2020): yes, there is a `--clean` or `-c` you can use on add/remove now
Author
Owner

@Mte90 commented on GitHub (Oct 15, 2020):

Ok so I can combine them in the same command.
Thanks

<!-- gh-comment-id:709048991 --> @Mte90 commented on GitHub (Oct 15, 2020): Ok so I can combine them in the same command. Thanks
Sign in to join this conversation.
No labels
bug
bug
bug
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/cli#5
No description provided.