-
Notifications
You must be signed in to change notification settings - Fork 4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Local Polykey Node Discovery #584
Conversation
When i encapsulate my IPv6 addresses in brackets (i.e [::1]), they are not recognized as hosts by When i don't encapsulate my IPv6 addresses in brackets, they are recognized as hosts by
See #584 (comment) |
If it only fixes a portion of #537, don't say |
Is the bracket encapsulated format the correct format? If so, just align on that, and then just update |
QUIC definitely supports ipv6. Try testing with non-link local IPv6 addresses first. |
The square braces should only come into play with URIs, generally speaking none of internal network code should be using square braced hosts. So it should not be expected to work. |
The only time we use square braces is on input and output, like for example the seed node configuration. |
Can you check if maybe a scoped ipv6 address is needed, and if so, perhaps that needs to be passed all the way down. In that case the |
it seems that |
it turns out there were two issues with MDNS integration that showed up on attempting to connect to a node via ipv6.
|
5c5c7ca
to
364a503
Compare
See #585, @tegefaulkes any fixes relating to multi-connection? So how are you working around ip-num support? |
364a503
to
d7ec6c7
Compare
Can you explain the result of this PR? What changes to the behaviour to agent startup? You should expand the spec, since this is a rather large major feature. |
I'll do a proper review tomorrow. |
i copied over the fixes yeah |
You can rebase now, since it has been merged to staging. |
c0f0fa6
to
3f3e6df
Compare
Are all the tasks there still todo, and are there more tasks to do? When can @tegefaulkes review this? |
7128daf
to
ae8b5f8
Compare
I think review should be ready, although I have to make the MDNS tests to be more concise, and haven't tested it in a local network over multiple devices yet. |
Are you going to tick off the tasks then? |
Can you elaborate on the current problem atm. |
9a82784
to
51627bc
Compare
i mean iterating over every address is a bit inefficient, especially because i have to do it twice, once when turning the queried MDNS services into NodeAddresses, and the second time here |
d0ce5a3
to
78f01a2
Compare
let timeoutDivisions = 0;
const addressGroups: { local: Array<NodeAddress>, external: Array<NodeAddress> } = { local: [], external: [] };
for (const address of addresses) {
let scope = address.scopes.includes('local') ? 'local' : 'external';
// If this is the first time an addressGroup has had an address added, the timeout divisions must be incremented.
if (addressGroups[scope].length === 0) {
timeoutDivisions++;
}
addressGroups[scope].push(address);
}
this.logger.debug(`Getting NodeConnection for ${targetNodeIdEncoded}`);
return await this.connectionLocks
.withF([targetNodeIdString, Lock, ctx], async () => {
this.logger.debug(`acquired lock for ${targetNodeIdEncoded}`);
// Attempting a multi-connection for the target node using local addresses
const timeout = ctx.timer.getTimeout() / timeoutDivisions;
let results: Map<NodeIdString, ConnectionAndTimer> | undefined;
if (addressGroups.local.length !== 0) {
results = await this.establishMultiConnection(
[targetNodeId],
addressGroups.local,
{
signal: ctx.signal,
timer: timeout
},
);
}
// If there are no results from the attempted local connections, attempt a multi-connection for the target node using external addresses
if (results == null || results.size === 0) {
results = await this.establishMultiConnection(
[targetNodeId],
addressGroups.external,
{
signal: ctx.signal,
timer: timeout
},
);
}
// Should be a single result.
for (const [, connAndTimer] of results) {
return connAndTimer;
}
// Should throw before reaching here
utils.never();
}) i've fixed this |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some small things but otherwise seems fine.
Don't forget to lint, I saw an unused import somewhere and linting should catch that.
If all the tests pass then you can merge.
baf982c
to
5c4e258
Compare
I need a better spec for scopes. What is meaning and consequences of it? What is external? What is local? Why is there no "global"? What can this be expanded to? Copy content to #537. |
5c4e258
to
c34cede
Compare
7518a30
to
08c579e
Compare
fix: changed NodeAddress type and added ability for `NodeConnectionManager.findNodes` to use MDNS chore: updated @matrixiai/mdns to 1.1.2 fix: temporarily removed IPv6 addresses from MDNS NodeAddress data fix: `NodeConnectionManager.findNodes` has been separated into 3 methods to not have NodeGraph-related methods interfere with MDNS-based discovery fix: paramaritized the enabling of the MDNS stack within NodeConnectionManager and disabled use of MDNS in all unrelated NodeConnectionManager tests fix: added back IPv6 addresses in MDNS NodeAddress data fix: NCM getMultiConnection was failing when more than one NodeAddress was provided fix: `NodeConnectionManager.seednodes.test.ts` now includes scopes for node addresses fix: renamed findNodeLocal and findNodeAll to be less ambiguous chore: inline documentation for `NodeConnectionManager.findNodeLocal` feat: created `agentMdnsGroups` and `agneMdnsPort` MDNS configuration in `config.defaultsSystem` chore: bump `@matrixai/mdns` to `v1.1.6` feat: better handling of disabling iceProm for `local` `NodeAddress`s in `NodeConnectionManager.establishSingleConnection` fix: client handler input types for `NodesFind` reverted fix: errors are now thrown if a connection is attempted with no addresses provided fix `networkUtils.isHost` is now able to validate link-local addresses fix: temporarily disabled connecting to link-local addresses with `NodeConnection` chore: bump `@matrixai/mdns` to `v1.2.0` fix: reduce `any` typecasts in `NodeConnectionManager.findNodeLocal` fix: broken jest tests due to mandatory `scopes` property of `NodeAddress` [ci-skip]
…ected dep to `NodeConnectionManager` fix: `PolyKeyAgent` now correctly injects `mdns` into the constructor of `NodeConnectionManager` fix: await mdns.start fix: `MDNS`ids are now determined by first 16 bits of node id [ci-skip]
…d `mdnsPort` [ci-skip]
08c579e
to
97ea38e
Compare
97ea38e
to
66e4916
Compare
…not conflict with existing PolykeyAgents on host [ci-skip]
…efaulted` for `PolykeyAgent.start` [ci-skip]
…NS queries, so that connectivity liveness is preserved fix `NodeConnectionManager.findNodeAll` has been given a default time out of `NodeConnectionManager.connectionConnectTimeoutTIme` [ci-skip]
…ated into multiple stages so that if connecting with `local` `NodeAddress`s succeeds, `external` `NodeAddress`s will be ignored fix: `NodeConnectionManager.getConnectionWithAddresses` now attempts connections with `local` scoped addresses before `external` scoped addresses fix: correct typing on `establishMultiConnection` for `ctx` param [ci-skip]
[ci-skip]
66e4916
to
e698dfd
Compare
Description
This PR integrates MDNS into the NodeConnectionManager to allow for the discovery of nodes on the local network, as well as disable holepunching for connections to local network addresses.
This PR should only focus on the Step 1 of #537 spec, as modifying the node graph to accept multiple IP addresses will require ACL changes that default disable the sharing of local addresses with seed nodes, as well as expansion to support multiple IP addresses.
This PR will encapsulate MDNS in the NodeConnectionManager, as well as make methods such as
getConnection
to be able to query MDNS for known hosts through the newly addedfindNodesAll
andfindNodesLocal
methods.findNodesAll
is a method that calls both the originalfindNode
andfindNodesLocal
to aggregate a list of all NodeAddresses. This is notably only used in connection-related methods rather than those related to Kademlia (NodeGraph).When the NodeConnectionManager is started, MDNS will be started, with a Polykey service registered, and a query for Polykey services started.
When the NodeConnectionManager is stopped, MDNS will be stopped alongside all pending queries, and deregistering all registered services.
Current scopes:
external
andlocal
.Issues Related
MDNS
integration andNodeGraph
structure expansion #537Tasks
getConnectionWithAddress
getConnection
Final checklist