Documentation ¶
Overview ¶
Package testcontrol contains a minimal control plane server for testing purposes.
Index ¶
- type AuthPath
- type MasqueradePair
- type Server
- func (s *Server) AddFakeNode()
- func (s *Server) AddPingRequest(nodeKeyDst key.NodePublic, pr *tailcfg.PingRequest) bool
- func (s *Server) AllNodes() (nodes []*tailcfg.Node)
- func (s *Server) AllUsers() (users []*tailcfg.User)
- func (s *Server) AwaitNodeInMapRequest(ctx context.Context, k key.NodePublic) error
- func (s *Server) BaseURL() string
- func (s *Server) CompleteAuth(authPathOrURL string) bool
- func (s *Server) InServeMap() int
- func (s *Server) MapResponse(req *tailcfg.MapRequest) (res *tailcfg.MapResponse, err error)
- func (s *Server) Node(nodeKey key.NodePublic) *tailcfg.Node
- func (s *Server) NumNodes() int
- func (s *Server) ServeHTTP(w http.ResponseWriter, r *http.Request)
- func (s *Server) SetExpireAllNodes(expired bool)
- func (s *Server) SetMasqueradeAddresses(pairs []MasqueradePair)
- func (s *Server) UpdateNode(n *tailcfg.Node) (peersToUpdate []tailcfg.NodeID)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AuthPath ¶ added in v1.10.0
type AuthPath struct {
// contains filtered or unexported fields
}
func (*AuthPath) CompleteSuccessfully ¶ added in v1.10.0
func (ap *AuthPath) CompleteSuccessfully()
CompleteSuccessfully completes the login path successfully, as if the user did the whole auth dance.
type MasqueradePair ¶ added in v1.40.0
type MasqueradePair struct { Node key.NodePublic Peer key.NodePublic NodeMasqueradesAs netip.Addr }
MasqueradePair is a pair of nodes and the IP address that the Node masquerades as for the Peer.
Setting this will have future MapResponses for Node to have Peer.SelfNodeV4MasqAddrForThisPeer set to NodeMasqueradesAs. MapResponses for the Peer will now see Node.Addresses as NodeMasqueradesAs.
type Server ¶
type Server struct { Logf logger.Logf // nil means to use the log package DERPMap *tailcfg.DERPMap // nil means to use prod DERP map RequireAuth bool Verbose bool DNSConfig *tailcfg.DNSConfig // nil means no DNS config MagicDNSDomain string // ExplicitBaseURL or HTTPTestServer must be set. ExplicitBaseURL string // e.g. "http://127.0.0.1:1234" with no trailing URL HTTPTestServer *httptest.Server // if non-nil, used to get BaseURL // contains filtered or unexported fields }
Server is a control plane server. Its zero value is ready for use. Everything is stored in-memory in one tailnet.
func (*Server) AddFakeNode ¶ added in v1.14.0
func (s *Server) AddFakeNode()
AddFakeNode injects a fake node into the server.
func (*Server) AddPingRequest ¶ added in v1.10.0
func (s *Server) AddPingRequest(nodeKeyDst key.NodePublic, pr *tailcfg.PingRequest) bool
AddPingRequest sends the ping pr to nodeKeyDst. It reports whether it did so. That is, it reports whether nodeKeyDst was connected.
func (*Server) AwaitNodeInMapRequest ¶ added in v1.10.0
AwaitNodeInMapRequest waits for node k to be stuck in a map poll. It returns an error if and only if the context is done first.
func (*Server) BaseURL ¶ added in v1.10.0
BaseURL returns the server's base URL, without trailing slash.
func (*Server) CompleteAuth ¶ added in v1.10.0
CompleteAuth marks the provided path or URL (containing "/auth/...") as successfully authenticated, unblocking any requests blocked on that in serveRegister.
func (*Server) InServeMap ¶ added in v1.12.0
InServeMap returns the number of clients currently in a MapRequest HTTP handler.
func (*Server) MapResponse ¶
func (s *Server) MapResponse(req *tailcfg.MapRequest) (res *tailcfg.MapResponse, err error)
MapResponse generates a MapResponse for a MapRequest.
No updates to s are done here.
func (*Server) Node ¶
func (s *Server) Node(nodeKey key.NodePublic) *tailcfg.Node
Node returns the node for nodeKey. It's always nil or cloned memory.
func (*Server) NumNodes ¶ added in v1.10.0
NumNodes returns the number of nodes in the testcontrol server.
This is useful when connecting a bunch of virtual machines to a testcontrol server to see how many of them connected successfully.
func (*Server) SetExpireAllNodes ¶ added in v1.18.0
Mark the Node key of every node as expired
func (*Server) SetMasqueradeAddresses ¶ added in v1.40.0
func (s *Server) SetMasqueradeAddresses(pairs []MasqueradePair)
SetMasqueradeAddresses sets the masquerade addresses for the server. See MasqueradePair for more details.