getWireGuardVersion fetches the wireguard-tools version
()
| 69 | |
| 70 | // getWireGuardVersion fetches the wireguard-tools version |
| 71 | func 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 | |
| 94 | func lifecycleReadinessError(state lifecycleState) error { |
| 95 | switch state { |
no outgoing calls
no test coverage detected