-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #26 from goodhosts/win-hosts
fix windows hosts per line problem
- Loading branch information
Showing
69 changed files
with
23,038 additions
and
82 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,15 @@ | ||
github.com/asaskevich/govalidator v0.0.0-20210307081110-f21760c49a8d h1:Byv0BzEl3/e6D5CLfI0j/7hiIEtvGVFPCZ7Ei2oq8iQ= | ||
github.com/asaskevich/govalidator v0.0.0-20210307081110-f21760c49a8d/go.mod h1:WaHUgvxTVq04UNunO+XhnAqY/wQc+bxr74GqbsZ/Jqw= | ||
github.com/davecgh/go-spew v1.1.0 h1:ZDRjVQ15GmhC3fiQ8ni8+OwkZQO4DARzQgrnXU1Liz8= | ||
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= | ||
github.com/dimchansky/utfbom v1.1.1 h1:vV6w1AhK4VMnhBno/TPVCoK9U/LP0PkLCS9tbxHdi/U= | ||
github.com/dimchansky/utfbom v1.1.1/go.mod h1:SxdoEBH5qIqFocHMyGOXVAybYJdr71b1Q/j0mACtrfE= | ||
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= | ||
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= | ||
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= | ||
github.com/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5CcY= | ||
github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= | ||
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM= | ||
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= | ||
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c h1:dUUwHk2QECo/6vqA44rthZ8ie2QXMNeKRTHCNY2nXvo= | ||
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
package hostsfile | ||
|
||
func itemInSlice(item string, list []string) bool { | ||
for _, i := range list { | ||
if i == item { | ||
return true | ||
} | ||
} | ||
|
||
return false | ||
} | ||
|
||
func removeFromSlice(s string, slice []string) []string { | ||
pos := findPositionInSlice(s, slice) | ||
for pos > -1 { | ||
slice = append(slice[:pos], slice[pos+1:]...) | ||
pos = findPositionInSlice(s, slice) | ||
} | ||
return slice | ||
} | ||
|
||
func findPositionInSlice(s string, slice []string) int { | ||
for index, v := range slice { | ||
if v == s { | ||
return index | ||
} | ||
} | ||
return -1 | ||
} |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,52 +1,11 @@ | ||
//go:build !windows | ||
|
||
package hostsfile | ||
|
||
import ( | ||
"fmt" | ||
const ( | ||
HostsPerLine = -1 // unlimited | ||
HostsFilePath = "/etc/hosts" | ||
eol = "\n" | ||
) | ||
|
||
func itemInSlice(item string, list []string) bool { | ||
for _, i := range list { | ||
if i == item { | ||
return true | ||
} | ||
} | ||
|
||
return false | ||
} | ||
|
||
func removeFromSlice(s string, slice []string) []string { | ||
pos := findPositionInSlice(s, slice) | ||
for pos > -1 { | ||
slice = append(slice[:pos], slice[pos+1:]...) | ||
pos = findPositionInSlice(s, slice) | ||
} | ||
return slice | ||
} | ||
|
||
func findPositionInSlice(s string, slice []string) int { | ||
for index, v := range slice { | ||
if v == s { | ||
return index | ||
} | ||
} | ||
return -1 | ||
} | ||
|
||
//func sliceContainsItem(item string, list []string) bool { | ||
// for _, i := range list { | ||
// if strings.Contains(i, item) { | ||
// return true | ||
// } | ||
// } | ||
// | ||
// return false | ||
//} | ||
|
||
func buildRawLine(ip string, hosts []string) string { | ||
output := ip | ||
for _, host := range hosts { | ||
output = fmt.Sprintf("%s %s", output, host) | ||
} | ||
|
||
return output | ||
} | ||
func (h *Hosts) preFlushClean() {} // no op |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
package hostsfile | ||
|
||
const ( | ||
HostsFilePath = "${SystemRoot}/System32/drivers/etc/hosts" | ||
HostsPerLine = 9 | ||
eol = "\r\n" | ||
) | ||
|
||
func (h *Hosts) preFlushClean() { | ||
// need to force hosts per line always on windows see https://github.com/goodhosts/hostsfile/issues/18 | ||
h.HostsPerLine(HostsPerLine) | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Oops, something went wrong.