| 50 | } |
| 51 | |
| 52 | func 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 |
| 75 | func NewAgent(ctx context.Context, t testing.TB, coord tailnet.CoordinatorV2, name string) *Peer { |