MCPcopy Index your code
hub / github.com/coder/coder / Nodes

Function Nodes

coderd/devtunnel/servers.go:50–73  ·  view source on GitHub ↗

Nodes returns a list of nodes to use for the tunnel. It will pick a random node from each region. If a customNode is provided, it will be returned as the only node with ID 9999.

(customTunnelHost string)

Source from the content-addressed store, hash-verified

48// If a customNode is provided, it will be returned as the only node with ID
49// 9999.
50func Nodes(customTunnelHost string) ([]Node, error) {
51 nodes := []Node{}
52
53 if customTunnelHost != "" {
54 return []Node{
55 {
56 ID: 9999,
57 RegionID: 9999,
58 HostnameHTTPS: customTunnelHost,
59 },
60 }, nil
61 }
62
63 for _, region := range Regions {
64 // Pick a random node from each region.
65 i, err := cryptorand.Intn(len(region.Nodes))
66 if err != nil {
67 return []Node{}, err
68 }
69 nodes = append(nodes, region.Nodes[i])
70 }
71
72 return nodes, nil
73}
74
75// FindClosestNode pings each node and returns the one with the lowest latency.
76func FindClosestNode(nodes []Node) (Node, error) {

Callers 1

GenerateConfigFunction · 0.85

Calls 1

IntnFunction · 0.92

Tested by

no test coverage detected