Skip to content
This repository was archived by the owner on Feb 3, 2023. It is now read-only.

Commit 99df9b0

Browse files
author
ingbyr
committed
add support for windows
1 parent a2027e8 commit 99df9b0

File tree

2 files changed

+22
-17
lines changed

2 files changed

+22
-17
lines changed

host/manager.go

Lines changed: 2 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -298,7 +298,7 @@ func (m *manager) ApplyGroup(group string, simulate bool) {
298298
return
299299
}
300300
hosts = append(hosts, m.baseHost)
301-
combinedHostContent := m.combineHosts(hosts, "# Auto generated from group "+group)
301+
combinedHostContent := m.combineHosts(hosts, "# Auto generated from "+group)
302302

303303
// just print
304304
if simulate {
@@ -389,19 +389,6 @@ func (m *manager) printHosts() {
389389
}
390390
}
391391

392-
func (m *manager) printGroups() {
393-
if len(m._groups) != len(m.groups) {
394-
panic("the size of _groups and groups is not equal")
395-
}
396-
fmt.Printf("All Groups\n")
397-
for _, group := range m._groups {
398-
fmt.Println("\t[group]", group)
399-
for _, host := range m.groups[group] {
400-
fmt.Printf("\t\t[host] %+v\n", host)
401-
}
402-
}
403-
}
404-
405392
func (m *manager) combineHosts(hosts []*Host, head string) []byte {
406393
var b bytes.Buffer
407394
b.WriteString(head)
@@ -412,7 +399,7 @@ func (m *manager) combineHosts(hosts []*Host, head string) []byte {
412399
display.Panic("can not combine host", err)
413400
}
414401
scanner := bufio.NewScanner(file)
415-
b.WriteString("# Host section from " + host.Name + NewLine)
402+
b.WriteString("# " + host.Name + NewLine)
416403
for scanner.Scan() {
417404
b.Write(scanner.Bytes())
418405
b.WriteString(NewLine)

readme.md

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,27 @@
33
![test](https://github.com/ingbyr/gohost/actions/workflows/test.yml/badge.svg)
44
![release](https://github.com/ingbyr/gohost/actions/workflows/release.yml/badge.svg)
55

6-
Gohost is a simple host switcher tool supporting Linux and macOS.
6+
Gohost is a simple host switcher tool supporting Windows, Linux and macOS.
7+
8+
**To modify the system host file gohost need running in root mode**
9+
10+
- For Windows user: open console in admin mode.
11+
- For Linux and macOS user: use `sudo gohost` or login as root
12+
13+
14+
## For Windows User
15+
16+
If new hosts not working, you probably need disable `DNS Client Service` by excuting below command in powershell (admin mode) and reboot your compouter.
17+
```powershell
18+
REG add "HKLM\SYSTEM\CurrentControlSet\services\dnscache" /v Start /t REG_DWORD /d 4 /f
19+
```
20+
21+
Also you can enbale `DNS Client Service` again by excuting in powershell (admin mode).
22+
23+
```powershell
24+
REG add "HKLM\SYSTEM\CurrentControlSet\services\dnscache" /v Start /t REG_DWORD /d 2 /f
25+
```
726

8-
**To modify the system host file gohost need running in root mode, such as `sudo gohost`.**
927

1028
## Usage
1129

0 commit comments

Comments
 (0)