@@ -12,14 +12,22 @@ import (
1212 "tailscale.com/util/set"
1313)
1414
15+ const (
16+ // minVersionParts is the minimum number of version parts needed for major.minor.
17+ minVersionParts = 2
18+
19+ // legacyDERPCapVer is the capability version when LegacyDERP can be cleaned up.
20+ legacyDERPCapVer = 111
21+ )
22+
1523// CanOldCodeBeCleanedUp is intended to be called on startup to see if
1624// there are old code that can ble cleaned up, entries should contain
1725// a CapVer where something can be cleaned up and a panic if it can.
1826// This is only intended to catch things in tests.
1927//
2028// All uses of Capability version checks should be listed here.
2129func CanOldCodeBeCleanedUp () {
22- if MinSupportedCapabilityVersion >= 111 {
30+ if MinSupportedCapabilityVersion >= legacyDERPCapVer {
2331 panic ("LegacyDERP can be cleaned up in tail.go" )
2432 }
2533}
@@ -44,12 +52,25 @@ func TailscaleVersion(ver tailcfg.CapabilityVersion) string {
4452}
4553
4654// CapabilityVersion returns the CapabilityVersion for the given Tailscale version.
55+ // It accepts both full versions (v1.90.1) and minor versions (v1.90).
4756func CapabilityVersion (ver string ) tailcfg.CapabilityVersion {
4857 if ! strings .HasPrefix (ver , "v" ) {
4958 ver = "v" + ver
5059 }
5160
52- return tailscaleToCapVer [ver ]
61+ // Try direct lookup first (works for minor versions like v1.90)
62+ if cv , ok := tailscaleToCapVer [ver ]; ok {
63+ return cv
64+ }
65+
66+ // Try extracting minor version from full version (v1.90.1 -> v1.90)
67+ parts := strings .Split (strings .TrimPrefix (ver , "v" ), "." )
68+ if len (parts ) >= minVersionParts {
69+ minor := "v" + parts [0 ] + "." + parts [1 ]
70+ return tailscaleToCapVer [minor ]
71+ }
72+
73+ return 0
5374}
5475
5576// TailscaleLatest returns the n latest Tailscale versions.
0 commit comments