// getIPTablesVersionString runs "iptables --version" to get the version string
// in the form "X.X.X"
764872
func getIPTablesVersionString(exec utilexec.Interface, protocol Protocol) (string, error) {
	// this doesn't access mutable state so we don't need to use the interface / runner
	iptablesCmd := iptablesCommand(protocol)
	bytes, err := exec.Command(iptablesCmd, "--version").CombinedOutput()
	if err != nil {
		return "", err
	}
	versionMatcher := regexp.MustCompile("v([0-9]+(\\.[0-9]+)+)")
	match := versionMatcher.FindStringSubmatch(string(bytes))
	if match == nil {
		return "", fmt.Errorf("no iptables version found in string: %s", bytes)
	}
	return match[1], nil
}
1169961
func (g *GistCommit) GetVersion() string {
	if g == nil || g.Version == nil {
		return ""
	}
	return *g.Version
}
953143
func getOSImageVersion() (string, error) {
	productName, err := getCurrentVersionVal("ProductName")
	if err != nil {
		return "", nil
	}

	return productName, nil
}
457751
func GetVersion(uuid []byte) Version {
	ver := uuid[6] >> 4
	if ver > 0 && ver < 6 {
		return Version(ver)
	}

	return VersionUnknown
}
732754
func CheckVersionOption() ServeOption {
	daemonVersion := version.ApiVersion

	return ServeOption(func(n *core.IpfsNode, l net.Listener, parent *http.ServeMux) (*http.ServeMux, error) {
		mux := http.NewServeMux()
		parent.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
			if strings.HasPrefix(r.URL.Path, APIPath) {
				cmdqry := r.URL.Path[len(APIPath):]
				pth := path.SplitList(cmdqry)

				// backwards compatibility to previous version check
				if len(pth) >= 2 && pth[1] != "version" {
					clientVersion := r.UserAgent()
					// skips check if client is not go-ipfs
					if strings.Contains(clientVersion, "/go-ipfs/") && daemonVersion != clientVersion {
						http.Error(w, fmt.Sprintf("%s (%s != %s)", errAPIVersionMismatch, daemonVersion, clientVersion), http.StatusBadRequest)
						return
					}
				}
			}

			mux.ServeHTTP(w, r)
		})

		return mux, nil
	})
}
8803
func GetDNSVersion(dnsType kubeadmapi.DNSAddOnType) string {
	switch dnsType {
	case kubeadmapi.KubeDNS:
		return KubeDNSVersion
	default:
		return CoreDNSVersion
	}
}
220326
func GetCiliumVersionString(epCHeaderFilePath string) (string, error) {
	f, err := os.Open(epCHeaderFilePath)
	if err != nil {
		return "", err
	}
	br := bufio.NewReader(f)
	defer f.Close()
	for {
		s, err := br.ReadString('\n')
		if err == io.EOF {
			return "", nil
		}
		if err != nil {
			return "", err
		}
		if strings.Contains(s, CiliumCHeaderPrefix) {
			return s, nil
		}
	}
}
153483
func FilterIncorrectIPVersion(ipStrings []string, isIPv6Mode bool) ([]string, []string) {
	return filterWithCondition(ipStrings, isIPv6Mode, utilnet.IsIPv6String)
}
818956
func getIptablesCommandSupport(v1 int, v2 int, v3 int) (bool, bool, bool) {
	return iptablesHasCheckCommand(v1, v2, v3), iptablesHasWaitCommand(v1, v2, v3), iptablesHasRandomFully(v1, v2, v3)
}
611750
func (p *Peer) ProtocolVersion() uint32 {
	p.flagsMtx.Lock()
	protocolVersion := p.protocolVersion
	p.flagsMtx.Unlock()

	return protocolVersion
}
1014454
func getIptablesWaitFlag(vstring string) []string {
	version, err := semver.NewVersion(vstring)
	if err != nil {
		glog.Errorf("vstring (%s) is not a valid version string: %v", vstring, err)
		return nil
	}

	minVersion, err := semver.NewVersion(MinWaitVersion)
	if err != nil {
		glog.Errorf("MinWaitVersion (%s) is not a valid version string: %v", MinWaitVersion, err)
		return nil
	}
	if version.LessThan(*minVersion) {
		return nil
	}

	minVersion, err = semver.NewVersion(MinWait2Version)
	if err != nil {
		glog.Errorf("MinWait2Version (%s) is not a valid version string: %v", MinWait2Version, err)
		return nil
	}
	if version.LessThan(*minVersion) {
		return []string{"-w"}
	} else {
		return []string{"-w2"}
	}
}
1137471
func getDBVersion(tx *sql.Tx) (int, error) {
	var version int
	rows, err := tx.Query("SELECT version FROM version")
	if err != nil {
		return -1, err
	}
	defer rows.Close()
	found := false
	for rows.Next() {
		if err := rows.Scan(&version); err != nil {
			return -1, err
		}
		found = true
		break
	}
	if err := rows.Err(); err != nil {
		return -1, err
	}
	if !found {
		return -1, fmt.Errorf("db version table empty")
	}
	return version, nil
}
1362997
func RetrievePGVersion(db *sql.DB) (ver string, err error) {
	err = db.QueryRow(internal.RetrievePGVersion).Scan(&ver)
	return
}
445698
func (version *Version) GetVersion(property *Property, getVersion int) error {
	if getVersion == 0 {
		getVersion = property.LatestVersion
	}

	req, err := client.NewRequest(
		Config,
		"GET",
		fmt.Sprintf(
			"/papi/v1/properties/%s/versions/%d",
			property.PropertyID,
			getVersion,
		),
		nil,
	)
	if err != nil {
		return err
	}

	res, err := client.Do(Config, req)
	if err != nil {
		return err
	}

	if client.IsError(res) {
		return client.NewAPIError(res)
	}

	newVersions := NewVersions()
	if err := client.BodyJSON(res, newVersions); err != nil {
		return err
	}

	version.PropertyVersion = newVersions.Versions.Items[0].PropertyVersion
	version.UpdatedByUser = newVersions.Versions.Items[0].UpdatedByUser
	version.UpdatedDate = newVersions.Versions.Items[0].UpdatedDate
	version.ProductionStatus = newVersions.Versions.Items[0].ProductionStatus
	version.StagingStatus = newVersions.Versions.Items[0].StagingStatus
	version.Etag = newVersions.Versions.Items[0].Etag
	version.ProductID = newVersions.Versions.Items[0].ProductID
	version.Note = newVersions.Versions.Items[0].Note
	version.CreateFromVersion = newVersions.Versions.Items[0].CreateFromVersion
	version.CreateFromVersionEtag = newVersions.Versions.Items[0].CreateFromVersionEtag

	return nil
}
10981
func (c *ClusterInfo) GetVersion(addr string) (semver.Version, error) {
	endpoint := fmt.Sprintf("http://%s/info", addr)
	var resp struct {
		Version string `json:"version"`
	}
	err := c.client.GETV1(endpoint, &resp)
	if err != nil {
		return semver.Version{}, err
	}
	if resp.Version == "" {
		resp.Version = "unknown"
	}
	return semver.Parse(resp.Version)
}
162377
func (runner *runner) GetVersion() (string, error) {
	return getIPTablesVersionString(runner.exec, runner.protocol)
}
159355
func GetVersion() Version {
	var versionStr string
	if gitCommit != "" && gitTag != "" && gitTreeState == "clean" {
		// if we have a clean tree state and the current commit is tagged,
		// this is an official release.
		versionStr = gitTag
	} else {
		// otherwise formulate a version string based on as much metadata
		// information we have available.
		versionStr = "v" + version
		if len(gitCommit) >= 7 {
			versionStr += "+" + gitCommit[0:7]
			if gitTreeState != "clean" {
				versionStr += ".dirty"
			}
		} else {
			versionStr += "+unknown"
		}
	}
	return Version{
		Version:      versionStr,
		BuildDate:    buildDate,
		GitCommit:    gitCommit,
		GitTag:       gitTag,
		GitTreeState: gitTreeState,
		GoVersion:    runtime.Version(),
		Compiler:     runtime.Compiler,
		Platform:     fmt.Sprintf("%s/%s", runtime.GOOS, runtime.GOARCH),
	}
}