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")
|
||||
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)
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue