|
@@ -313,26 +313,6 @@ func IsGIT(str string) bool {
|
|
return strings.HasPrefix(str, "git://") || strings.HasPrefix(str, "github.com/") || strings.HasPrefix(str, "git@github.com:") || (strings.HasSuffix(str, ".git") && IsURL(str))
|
|
return strings.HasPrefix(str, "git://") || strings.HasPrefix(str, "github.com/") || strings.HasPrefix(str, "git@github.com:") || (strings.HasSuffix(str, ".git") && IsURL(str))
|
|
}
|
|
}
|
|
|
|
|
|
-// CheckLocalDns looks into the /etc/resolv.conf,
|
|
|
|
-// it returns true if there is a local nameserver or if there is no nameserver.
|
|
|
|
-func CheckLocalDns(resolvConf []byte) bool {
|
|
|
|
- for _, line := range GetLines(resolvConf, []byte("#")) {
|
|
|
|
- if !bytes.Contains(line, []byte("nameserver")) {
|
|
|
|
- continue
|
|
|
|
- }
|
|
|
|
- for _, ip := range [][]byte{
|
|
|
|
- []byte("127.0.0.1"),
|
|
|
|
- []byte("127.0.1.1"),
|
|
|
|
- } {
|
|
|
|
- if bytes.Contains(line, ip) {
|
|
|
|
- return true
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- return false
|
|
|
|
- }
|
|
|
|
- return true
|
|
|
|
-}
|
|
|
|
-
|
|
|
|
var (
|
|
var (
|
|
localHostRx = regexp.MustCompile(`(?m)^nameserver 127[^\n]+\n*`)
|
|
localHostRx = regexp.MustCompile(`(?m)^nameserver 127[^\n]+\n*`)
|
|
)
|
|
)
|
|
@@ -343,21 +323,6 @@ func RemoveLocalDns(resolvConf []byte) []byte {
|
|
return localHostRx.ReplaceAll(resolvConf, []byte{})
|
|
return localHostRx.ReplaceAll(resolvConf, []byte{})
|
|
}
|
|
}
|
|
|
|
|
|
-// GetLines parses input into lines and strips away comments.
|
|
|
|
-func GetLines(input []byte, commentMarker []byte) [][]byte {
|
|
|
|
- lines := bytes.Split(input, []byte("\n"))
|
|
|
|
- var output [][]byte
|
|
|
|
- for _, currentLine := range lines {
|
|
|
|
- var commentIndex = bytes.Index(currentLine, commentMarker)
|
|
|
|
- if commentIndex == -1 {
|
|
|
|
- output = append(output, currentLine)
|
|
|
|
- } else {
|
|
|
|
- output = append(output, currentLine[:commentIndex])
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- return output
|
|
|
|
-}
|
|
|
|
-
|
|
|
|
// An StatusError reports an unsuccessful exit by a command.
|
|
// An StatusError reports an unsuccessful exit by a command.
|
|
type StatusError struct {
|
|
type StatusError struct {
|
|
Status string
|
|
Status string
|