|
|
@@ -7,6 +7,7 @@ package version
|
|
|
import (
|
|
|
"fmt"
|
|
|
"runtime/debug"
|
|
|
+ "strconv"
|
|
|
"strings"
|
|
|
|
|
|
tailscaleroot "tailscale.com"
|
|
|
@@ -169,3 +170,42 @@ func majorMinorPatch() string {
|
|
|
ret, _, _ := strings.Cut(Short(), "-")
|
|
|
return ret
|
|
|
}
|
|
|
+
|
|
|
+func isValidLongWithTwoRepos(v string) bool {
|
|
|
+ s := strings.Split(v, "-")
|
|
|
+ if len(s) != 3 {
|
|
|
+ return false
|
|
|
+ }
|
|
|
+ hexChunk := func(s string) bool {
|
|
|
+ if len(s) < 6 {
|
|
|
+ return false
|
|
|
+ }
|
|
|
+ for i := range len(s) {
|
|
|
+ b := s[i]
|
|
|
+ if (b < '0' || b > '9') && (b < 'a' || b > 'f') {
|
|
|
+ return false
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return true
|
|
|
+ }
|
|
|
+
|
|
|
+ v, t, g := s[0], s[1], s[2]
|
|
|
+ if !strings.HasPrefix(t, "t") || !strings.HasPrefix(g, "g") ||
|
|
|
+ !hexChunk(t[1:]) || !hexChunk(g[1:]) {
|
|
|
+ return false
|
|
|
+ }
|
|
|
+ nums := strings.Split(v, ".")
|
|
|
+ if len(nums) != 3 {
|
|
|
+ return false
|
|
|
+ }
|
|
|
+ for i, n := range nums {
|
|
|
+ bits := 8
|
|
|
+ if i == 2 {
|
|
|
+ bits = 16
|
|
|
+ }
|
|
|
+ if _, err := strconv.ParseUint(n, 10, bits); err != nil {
|
|
|
+ return false
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return true
|
|
|
+}
|