Merge pull request #1218 from anfernee/master

Trivial fixes in core/pkg/net
This commit is contained in:
Manuel Alejandro de Brito Fontes 2017-08-22 16:01:44 -04:00 committed by GitHub
commit 3463ddb3bd
3 changed files with 5 additions and 9 deletions

View file

@ -38,7 +38,7 @@ func GetSystemNameServers() ([]net.IP, error) {
lines := strings.Split(string(file), "\n")
for l := range lines {
trimmed := strings.TrimSpace(lines[l])
if strings.HasPrefix(trimmed, "#") {
if len(trimmed) == 0 || trimmed[0] == '#' || trimmed[0] == ';' {
continue
}
fields := strings.Fields(trimmed)

View file

@ -40,6 +40,8 @@ func TestGetDNSServers(t *testing.T) {
defer os.Remove(file.Name())
ioutil.WriteFile(file.Name(), []byte(`
# comment
; comment
nameserver 2001:4860:4860::8844
nameserver 2001:4860:4860::8888
nameserver 8.8.8.8

View file

@ -16,15 +16,9 @@ limitations under the License.
package net
import (
_net "net"
"strings"
)
import _net "net"
// IsIPV6 checks if the input contains a valid IPV6 address
func IsIPV6(ip _net.IP) bool {
if dp := strings.Index(ip.String(), ":"); dp != -1 {
return true
}
return false
return ip.To4() == nil
}