policy, mapper, capver, hscontrol: remove dead code

This commit is contained in:
Kristoffer Dalby
2026-06-15 09:53:18 +00:00
parent f49f27adf8
commit ed6596f9d7
6 changed files with 38 additions and 118 deletions
-38
View File
@@ -3,7 +3,6 @@ package capver
//go:generate go run ../../tools/capver/main.go
import (
"slices"
"sort"
"strings"
@@ -32,13 +31,6 @@ func tailscaleVersSorted() []string {
return vers
}
func capVersSorted() []tailcfg.CapabilityVersion {
capVers := xmaps.Keys(capVerToTailscaleVer)
slices.Sort(capVers)
return capVers
}
// TailscaleVersion returns the Tailscale version for the given [tailcfg.CapabilityVersion].
func TailscaleVersion(ver tailcfg.CapabilityVersion) string {
return capVerToTailscaleVer[ver]
@@ -66,21 +58,6 @@ func CapabilityVersion(ver string) tailcfg.CapabilityVersion {
return 0
}
// TailscaleLatest returns the n latest Tailscale versions.
func TailscaleLatest(n int) []string {
if n <= 0 {
return nil
}
tsSorted := tailscaleVersSorted()
if n > len(tsSorted) {
return tsSorted
}
return tsSorted[len(tsSorted)-n:]
}
// TailscaleLatestMajorMinor returns the n latest Tailscale versions (e.g. 1.80).
func TailscaleLatestMajorMinor(n int, stripV bool) []string {
if n <= 0 {
@@ -107,18 +84,3 @@ func TailscaleLatestMajorMinor(n int, stripV bool) []string {
return majorSl[len(majorSl)-n:]
}
// CapVerLatest returns the n latest [tailcfg.CapabilityVersion] values.
func CapVerLatest(n int) []tailcfg.CapabilityVersion {
if n <= 0 {
return nil
}
s := capVersSorted()
if n > len(s) {
return s
}
return s[len(s)-n:]
}
-6
View File
@@ -51,12 +51,6 @@ type mapper struct {
created time.Time
}
//nolint:unused
type patch struct {
timestamp time.Time
change *tailcfg.PeerChange
}
func newMapper(
cfg *types.Config,
state *state.State,
+38
View File
@@ -0,0 +1,38 @@
package matcher
import (
"github.com/juanfont/headscale/hscontrol/util"
"go4.org/netipx"
)
// MatchFromStrings builds a [Match] from raw source and destination
// strings. Unparseable entries are silently dropped (fail-open): the
// resulting [Match] is narrower than the input described, but never
// wider. Callers that need strict validation should pre-validate
// their inputs via [util.ParseIPSet].
func MatchFromStrings(sources, destinations []string) Match {
srcs := new(netipx.IPSetBuilder)
dests := new(netipx.IPSetBuilder)
for _, srcIP := range sources {
set, _ := util.ParseIPSet(srcIP, nil)
srcs.AddSet(set)
}
for _, dest := range destinations {
set, _ := util.ParseIPSet(dest, nil)
dests.AddSet(set)
}
srcsSet, _ := srcs.IPSet()
destsSet, _ := dests.IPSet()
match := Match{
srcs: srcsSet,
dests: destsSet,
}
return match
}
-32
View File
@@ -80,38 +80,6 @@ func MatchFromFilterRule(rule tailcfg.FilterRule) Match {
}
}
// MatchFromStrings builds a [Match] from raw source and destination
// strings. Unparseable entries are silently dropped (fail-open): the
// resulting [Match] is narrower than the input described, but never
// wider. Callers that need strict validation should pre-validate
// their inputs via [util.ParseIPSet].
func MatchFromStrings(sources, destinations []string) Match {
srcs := new(netipx.IPSetBuilder)
dests := new(netipx.IPSetBuilder)
for _, srcIP := range sources {
set, _ := util.ParseIPSet(srcIP, nil)
srcs.AddSet(set)
}
for _, dest := range destinations {
set, _ := util.ParseIPSet(dest, nil)
dests.AddSet(set)
}
srcsSet, _ := srcs.IPSet()
destsSet, _ := dests.IPSet()
match := Match{
srcs: srcsSet,
dests: destsSet,
}
return match
}
func (m *Match) SrcsContainsIPs(ips ...netip.Addr) bool {
return slices.ContainsFunc(ips, m.srcs.Contains)
}
-38
View File
@@ -1747,44 +1747,6 @@ func (p *Protocol) String() string {
return string(*p)
}
// Description returns the human-readable description of the [Protocol].
func (p *Protocol) Description() string {
switch *p {
case ProtocolNameICMP:
return "Internet Control Message Protocol"
case ProtocolNameIGMP:
return "Internet Group Management Protocol"
case ProtocolNameIPv4:
return "IPv4 encapsulation"
case ProtocolNameTCP:
return "Transmission Control Protocol"
case ProtocolNameEGP:
return "Exterior Gateway Protocol"
case ProtocolNameIGP:
return "Interior Gateway Protocol"
case ProtocolNameUDP:
return "User Datagram Protocol"
case ProtocolNameGRE:
return "Generic Routing Encapsulation"
case ProtocolNameESP:
return "Encapsulating Security Payload"
case ProtocolNameAH:
return "Authentication Header"
case ProtocolNameIPv6ICMP:
return "Internet Control Message Protocol for IPv6"
case ProtocolNameSCTP:
return "Stream Control Transmission Protocol"
case ProtocolNameFC:
return "Fibre Channel"
case ProtocolNameIPInIP:
return "IP-in-IP Encapsulation"
case ProtocolNameWildcard:
return "Wildcard (not supported - use specific protocol)"
default:
return "Unknown Protocol"
}
}
// toIANAProtocolNumbers converts a [Protocol] to its IANA protocol numbers.
// Since validation happens during [Protocol.UnmarshalJSON], this method should not fail for valid [Protocol] values.
func (p *Protocol) toIANAProtocolNumbers() []int {
-4
View File
@@ -38,9 +38,6 @@ func runTailSQLService(ctx context.Context, logf logger.Logf, stateDir, dbPath s
Hostname: opts.Hostname,
Logf: logger.Discard,
}
// if *doDebugLog {
// tsNode.Logf = logf
// }
defer tsNode.Close()
logf("Starting tailscale (hostname=%q)", opts.Hostname)
@@ -87,7 +84,6 @@ func runTailSQLService(ctx context.Context, logf logger.Logf, stateDir, dbPath s
http.Redirect(w, r, target, http.StatusPermanentRedirect) //nolint:gosec // G710: target prefixed by trusted base URL
}))
}()
// log.Printf("Redirecting HTTP to HTTPS at %q", base)
// For the real service, start a separate listener.
// Note: Replaces the port 80 listener.