-
Notifications
You must be signed in to change notification settings - Fork 5
Description
Specification
The Polykey agent needs a way to join a network. The target network can either be a public or a private one. To do this, the agent will perform the following steps:
- Perform DNS resolution to get details of the target seednode. An agent can connect to a seednode within a private network even while being unauthenticated.
- Attempt to switch the currently-active network to the target network's seednode
- If switching worked, then a network access claim already existed. If switching failed, attempt to create a new network access claim.
The network claiming and switching should automatically handle stuff like switching authentication and connection code to align with the new network.
The network join can be triggered at any time in the agent's lifecycle. The two main candidates for this are the polykey nodes join command, which can allow a running agent to connect to a said network, or polykey agent start --network to start the agent by attempting connection to the provided network.
Additional context
A dummy private network has not been created yet. Thus, tests need to be written for testing the validity of the new logic. The test called a node can join a public network without permissions under NodeManager.test.ts contains logic for attempting connection to a private seednode and issuing network access and authority tokens. It can be used as a template for writing tests for this issue. The tests will need to mock DNS resolution, as the seednode is running locally.
Tasks
- Update the
NodeManager.claimNetworkfunction to check for an existing claim first instead of creating duplicate access tokens - Update the
syncNodeGraphand/orsyncNodeGraphHandlerto add this step - Create a RPC handler for the network joining logic