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

Function NewPeer

tailnet/test/peer.go:52–72  ·  view source on GitHub ↗
(ctx context.Context, t testing.TB, coord tailnet.CoordinatorV2, name string, opts ...PeerOption)

Source from the content-addressed store, hash-verified

50}
51
52func NewPeer(ctx context.Context, t testing.TB, coord tailnet.CoordinatorV2, name string, opts ...PeerOption) *Peer {
53 p := &Peer{
54 t: t,
55 name: name,
56 peers: make(map[uuid.UUID]PeerStatus),
57 peerUpdates: make(map[uuid.UUID][]*proto.CoordinateResponse_PeerUpdate),
58 ID: uuid.New(),
59 // SingleTailnetCoordinateeAuth allows connections to arbitrary peers
60 auth: tailnet.SingleTailnetCoordinateeAuth{},
61 // required for converting to and from protobuf, so we always include them
62 nodeKey: key.NewNode().Public(),
63 discoKey: key.NewDisco().Public(),
64 }
65 p.ctx, p.cancel = context.WithCancel(ctx)
66 for _, opt := range opts {
67 opt(p)
68 }
69
70 p.reqs, p.resps = coord.Coordinate(p.ctx, p.ID, name, p.auth)
71 return p
72}
73
74// NewAgent is a wrapper around NewPeer, creating a peer with Agent auth tied to its ID
75func NewAgent(ctx context.Context, t testing.TB, coord tailnet.CoordinatorV2, name string) *Peer {

Callers 8

TestCoordinatorFunction · 0.92
GracefulDisconnectTestFunction · 0.85
LostTestFunction · 0.85
BidirectionalTunnelsFunction · 0.85
ReadyForHandshakeTestFunction · 0.85
NewAgentFunction · 0.85
NewClientFunction · 0.85

Calls 2

NewMethod · 0.65
CoordinateMethod · 0.65

Tested by 1

TestCoordinatorFunction · 0.74