all: apply formatter changes
This commit is contained in:
parent
814226f327
commit
93860a5c06
16 changed files with 72 additions and 64 deletions
|
|
@ -69,7 +69,7 @@ func (s *State) DebugOverview() string {
|
|||
sb.WriteString("=== Headscale State Overview ===\n\n")
|
||||
|
||||
// Node statistics
|
||||
sb.WriteString(fmt.Sprintf("Nodes: %d total\n", allNodes.Len()))
|
||||
fmt.Fprintf(&sb, "Nodes: %d total\n", allNodes.Len())
|
||||
|
||||
userNodeCounts := make(map[string]int)
|
||||
onlineCount := 0
|
||||
|
|
@ -97,26 +97,26 @@ func (s *State) DebugOverview() string {
|
|||
}
|
||||
}
|
||||
|
||||
sb.WriteString(fmt.Sprintf(" - Online: %d\n", onlineCount))
|
||||
sb.WriteString(fmt.Sprintf(" - Expired: %d\n", expiredCount))
|
||||
sb.WriteString(fmt.Sprintf(" - Ephemeral: %d\n", ephemeralCount))
|
||||
fmt.Fprintf(&sb, " - Online: %d\n", onlineCount)
|
||||
fmt.Fprintf(&sb, " - Expired: %d\n", expiredCount)
|
||||
fmt.Fprintf(&sb, " - Ephemeral: %d\n", ephemeralCount)
|
||||
sb.WriteString("\n")
|
||||
|
||||
// User statistics
|
||||
sb.WriteString(fmt.Sprintf("Users: %d total\n", len(users)))
|
||||
fmt.Fprintf(&sb, "Users: %d total\n", len(users))
|
||||
|
||||
for userName, nodeCount := range userNodeCounts {
|
||||
sb.WriteString(fmt.Sprintf(" - %s: %d nodes\n", userName, nodeCount))
|
||||
fmt.Fprintf(&sb, " - %s: %d nodes\n", userName, nodeCount)
|
||||
}
|
||||
|
||||
sb.WriteString("\n")
|
||||
|
||||
// Policy information
|
||||
sb.WriteString("Policy:\n")
|
||||
sb.WriteString(fmt.Sprintf(" - Mode: %s\n", s.cfg.Policy.Mode))
|
||||
fmt.Fprintf(&sb, " - Mode: %s\n", s.cfg.Policy.Mode)
|
||||
|
||||
if s.cfg.Policy.Mode == types.PolicyModeFile {
|
||||
sb.WriteString(fmt.Sprintf(" - Path: %s\n", s.cfg.Policy.Path))
|
||||
fmt.Fprintf(&sb, " - Path: %s\n", s.cfg.Policy.Path)
|
||||
}
|
||||
|
||||
sb.WriteString("\n")
|
||||
|
|
@ -124,7 +124,7 @@ func (s *State) DebugOverview() string {
|
|||
// DERP information
|
||||
derpMap := s.derpMap.Load()
|
||||
if derpMap != nil {
|
||||
sb.WriteString(fmt.Sprintf("DERP: %d regions configured\n", len(derpMap.Regions)))
|
||||
fmt.Fprintf(&sb, "DERP: %d regions configured\n", len(derpMap.Regions))
|
||||
} else {
|
||||
sb.WriteString("DERP: not configured\n")
|
||||
}
|
||||
|
|
@ -137,7 +137,7 @@ func (s *State) DebugOverview() string {
|
|||
routeCount = 0
|
||||
}
|
||||
|
||||
sb.WriteString(fmt.Sprintf("Primary Routes: %d active\n", routeCount))
|
||||
fmt.Fprintf(&sb, "Primary Routes: %d active\n", routeCount)
|
||||
sb.WriteString("\n")
|
||||
|
||||
// Registration cache
|
||||
|
|
@ -163,18 +163,18 @@ func (s *State) DebugDERPMap() string {
|
|||
|
||||
sb.WriteString("=== DERP Map Configuration ===\n\n")
|
||||
|
||||
sb.WriteString(fmt.Sprintf("Total Regions: %d\n\n", len(derpMap.Regions)))
|
||||
fmt.Fprintf(&sb, "Total Regions: %d\n\n", len(derpMap.Regions))
|
||||
|
||||
for regionID, region := range derpMap.Regions {
|
||||
sb.WriteString(fmt.Sprintf("Region %d: %s\n", regionID, region.RegionName))
|
||||
sb.WriteString(fmt.Sprintf(" - Nodes: %d\n", len(region.Nodes)))
|
||||
fmt.Fprintf(&sb, "Region %d: %s\n", regionID, region.RegionName)
|
||||
fmt.Fprintf(&sb, " - Nodes: %d\n", len(region.Nodes))
|
||||
|
||||
for _, node := range region.Nodes {
|
||||
sb.WriteString(fmt.Sprintf(" - %s (%s:%d)\n",
|
||||
node.Name, node.HostName, node.DERPPort))
|
||||
fmt.Fprintf(&sb, " - %s (%s:%d)\n",
|
||||
node.Name, node.HostName, node.DERPPort)
|
||||
|
||||
if node.STUNPort != 0 {
|
||||
sb.WriteString(fmt.Sprintf(" STUN: %d\n", node.STUNPort))
|
||||
fmt.Fprintf(&sb, " STUN: %d\n", node.STUNPort)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -526,8 +526,8 @@ func (s *NodeStore) DebugString() string {
|
|||
sb.WriteString("=== NodeStore Debug Information ===\n\n")
|
||||
|
||||
// Basic counts
|
||||
sb.WriteString(fmt.Sprintf("Total Nodes: %d\n", len(snapshot.nodesByID)))
|
||||
sb.WriteString(fmt.Sprintf("Users with Nodes: %d\n", len(snapshot.nodesByUser)))
|
||||
fmt.Fprintf(&sb, "Total Nodes: %d\n", len(snapshot.nodesByID))
|
||||
fmt.Fprintf(&sb, "Users with Nodes: %d\n", len(snapshot.nodesByUser))
|
||||
sb.WriteString("\n")
|
||||
|
||||
// User distribution (shows internal UserID tracking, not display owner)
|
||||
|
|
@ -541,7 +541,7 @@ func (s *NodeStore) DebugString() string {
|
|||
userName = nodes[0].User().Name()
|
||||
}
|
||||
|
||||
sb.WriteString(fmt.Sprintf(" - User %d (%s): %d nodes\n", userID, userName, len(nodes)))
|
||||
fmt.Fprintf(&sb, " - User %d (%s): %d nodes\n", userID, userName, len(nodes))
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -557,20 +557,20 @@ func (s *NodeStore) DebugString() string {
|
|||
|
||||
totalPeers += peerCount
|
||||
if node, exists := snapshot.nodesByID[nodeID]; exists {
|
||||
sb.WriteString(fmt.Sprintf(" - Node %d (%s): %d peers\n",
|
||||
nodeID, node.Hostname, peerCount))
|
||||
fmt.Fprintf(&sb, " - Node %d (%s): %d peers\n",
|
||||
nodeID, node.Hostname, peerCount)
|
||||
}
|
||||
}
|
||||
|
||||
if len(snapshot.peersByNode) > 0 {
|
||||
avgPeers := float64(totalPeers) / float64(len(snapshot.peersByNode))
|
||||
sb.WriteString(fmt.Sprintf(" - Average peers per node: %.1f\n", avgPeers))
|
||||
fmt.Fprintf(&sb, " - Average peers per node: %.1f\n", avgPeers)
|
||||
}
|
||||
|
||||
sb.WriteString("\n")
|
||||
|
||||
// Node key index
|
||||
sb.WriteString(fmt.Sprintf("NodeKey Index: %d entries\n", len(snapshot.nodesByNodeKey)))
|
||||
fmt.Fprintf(&sb, "NodeKey Index: %d entries\n", len(snapshot.nodesByNodeKey))
|
||||
sb.WriteString("\n")
|
||||
|
||||
return sb.String()
|
||||
|
|
|
|||
|
|
@ -1790,10 +1790,12 @@ func (s *State) HandleNodeFromAuthPath(
|
|||
// the initial Hostinfo from the cached client-supplied Hostinfo (or
|
||||
// an empty stub if the client did not send one).
|
||||
hostname := regData.Hostname
|
||||
|
||||
hostinfo := &tailcfg.Hostinfo{}
|
||||
if regData.Hostinfo != nil {
|
||||
hostinfo = regData.Hostinfo.Clone()
|
||||
}
|
||||
|
||||
hostinfo.Hostname = hostname
|
||||
|
||||
// Lookup existing nodes
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue