guumaster / hostctl

Your dev tool to manage /etc/hosts like a pro!
http://guumaster.github.io/hostctl
MIT License
1.08k stars 47 forks source link

Windows 11 profiles are not set #83

Open nick81nrw opened 2 years ago

nick81nrw commented 2 years ago

Describe the bug On Windows 11 hostctl do not set or list profiles when use "add/list" command. It seems to be a parsing error in hosts file.

I use Netmaker on Windows and hostctl sets every few minutes new entries in hosts file. Netmaker gets other peers IP addresses over mqtt and set hosts entries with hostctl

To Reproduce Steps to reproduce the behavior:

hostctl.exe add TEST1 -f hosts.txt OR hostctl.exe add domains TEST1 test.loc --ip 10.10.10.10

hosts (looks correct):

##################################################################
# Content under this line is handled by hostctl. DO NOT EDIT.
##################################################################

# profile.on TEST1
10.10.10.10 test.loc
# end

hostctl.exe list No profile is shown

+---------+--------+-----------------+-------------------+
| PROFILE | STATUS |       IP        |      DOMAIN       |  
+---------+--------+-----------------+-------------------+  
| default | off    | 102.54.94.97    | rhino.acme.com    |  
| default | off    | 38.25.63.10     | x.acme.com        |  
| default | off    | 127.0.0.1       | localhost         |  
| default | off    | ::1             | localhost         |  
| default | on     | 10.10.10.10     | test.loc          |  
+---------+--------+-----------------+-------------------+

hostctl.exe add domains TEST2 test2.loc --ip 10.10.10.11 hosts file seams not correct parsed. Profile name is set. Content-block is set under first profile.

# profile.on TEST1
10.10.10.10 test.loc

##################################################################
# Content under this line is handled by hostctl. DO NOT EDIT.
##################################################################

# profile.on TEST2
10.10.10.11 test2.loc
# end

hostctl.exe list No profile

+---------+--------+---------------+-------------------+
| PROFILE | STATUS |      IP       |      DOMAIN       |
+---------+--------+---------------+-------------------+
| default | off    | 102.54.94.97  | rhino.acme.com    |
| default | off    | 38.25.63.10   | x.acme.com        |
| default | off    | 127.0.0.1     | localhost         |
| default | off    | ::1           | localhost         |
| default | on     | 10.10.10.10   | test.loc          |
| default | on     | 10.10.10.11   | test2.loc         |
+---------+--------+---------------+-------------------+

hostctl do not find profiles

hostctl.exe disable TEST2
[×] error: unknown profile name
hostctl.exe disable TEST
[×] error: unknown profile name

Expected behavior Set and list profiles under windows

System (please complete the following information):