Merge pull request #1218 from anfernee/master
Trivial fixes in core/pkg/net
This commit is contained in:
commit
3463ddb3bd
3 changed files with 5 additions and 9 deletions
|
@ -38,7 +38,7 @@ func GetSystemNameServers() ([]net.IP, error) {
|
||||||
lines := strings.Split(string(file), "\n")
|
lines := strings.Split(string(file), "\n")
|
||||||
for l := range lines {
|
for l := range lines {
|
||||||
trimmed := strings.TrimSpace(lines[l])
|
trimmed := strings.TrimSpace(lines[l])
|
||||||
if strings.HasPrefix(trimmed, "#") {
|
if len(trimmed) == 0 || trimmed[0] == '#' || trimmed[0] == ';' {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
fields := strings.Fields(trimmed)
|
fields := strings.Fields(trimmed)
|
||||||
|
|
|
@ -40,6 +40,8 @@ func TestGetDNSServers(t *testing.T) {
|
||||||
defer os.Remove(file.Name())
|
defer os.Remove(file.Name())
|
||||||
|
|
||||||
ioutil.WriteFile(file.Name(), []byte(`
|
ioutil.WriteFile(file.Name(), []byte(`
|
||||||
|
# comment
|
||||||
|
; comment
|
||||||
nameserver 2001:4860:4860::8844
|
nameserver 2001:4860:4860::8844
|
||||||
nameserver 2001:4860:4860::8888
|
nameserver 2001:4860:4860::8888
|
||||||
nameserver 8.8.8.8
|
nameserver 8.8.8.8
|
||||||
|
|
|
@ -16,15 +16,9 @@ limitations under the License.
|
||||||
|
|
||||||
package net
|
package net
|
||||||
|
|
||||||
import (
|
import _net "net"
|
||||||
_net "net"
|
|
||||||
"strings"
|
|
||||||
)
|
|
||||||
|
|
||||||
// IsIPV6 checks if the input contains a valid IPV6 address
|
// IsIPV6 checks if the input contains a valid IPV6 address
|
||||||
func IsIPV6(ip _net.IP) bool {
|
func IsIPV6(ip _net.IP) bool {
|
||||||
if dp := strings.Index(ip.String(), ":"); dp != -1 {
|
return ip.To4() == nil
|
||||||
return true
|
|
||||||
}
|
|
||||||
return false
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue