MCPcopy Create free account
hub / github.com/PasarGuard/node / getWireGuardVersion

Function getWireGuardVersion

backend/wireguard/wireguard.go:71–92  ·  view source on GitHub ↗

getWireGuardVersion fetches the wireguard-tools version

()

Source from the content-addressed store, hash-verified

69
70// getWireGuardVersion fetches the wireguard-tools version
71func getWireGuardVersion() string {
72 cmd := exec.Command("wg", "--version")
73 output, err := cmd.Output()
74 if err != nil {
75 log.Printf("failed to get wireguard version: %v", err)
76 return "unknown"
77 }
78
79 // Parse the version from output
80 // Expected format: "wireguard-tools v1.0.20200513 - https://git.zx2c4.com/wireguard-tools/"
81 lines := strings.Split(string(output), "\n")
82 if len(lines) > 0 {
83 firstLine := strings.TrimSpace(lines[0])
84 // Extract version from "wireguard-tools v1.0.20200513 - ..."
85 parts := strings.Fields(firstLine)
86 if len(parts) >= 2 {
87 return parts[1] // Returns "v1.0.20200513"
88 }
89 }
90
91 return "unknown"
92}
93
94func lifecycleReadinessError(state lifecycleState) error {
95 switch state {

Callers 1

newWithManagerFactoryFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected