Skip to content

Commit

Permalink
fix: Update libp2p deps (#419)
Browse files Browse the repository at this point in the history
* Update libp2p packages

* Try another libp2p version

* Add test resolutions

* Bump ver

* remove override

* redo removing override

* fix

* Fix

* Fix

* Fix

* Fix

* Deny connections from internal nox network

* Fix eslint

* Fix review
  • Loading branch information
Akim authored Jan 19, 2024
1 parent 5696e3b commit a8a1473
Show file tree
Hide file tree
Showing 4 changed files with 3,087 additions and 3,987 deletions.
1 change: 1 addition & 0 deletions .eslintrc.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{
"root": true,
"parser": "@typescript-eslint/parser",
"parserOptions": {
"ecmaVersion": 2022,
Expand Down
19 changes: 10 additions & 9 deletions packages/core/js-client/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,28 +30,29 @@
"author": "Fluence Labs",
"license": "Apache-2.0",
"dependencies": {
"@libp2p/utils": "5.2.2",
"@chainsafe/libp2p-noise": "14.0.0",
"@chainsafe/libp2p-yamux": "6.0.1",
"@fluencelabs/avm": "0.55.0",
"@fluencelabs/interfaces": "workspace:*",
"@fluencelabs/js-client-isomorphic": "workspace:*",
"@fluencelabs/marine-worker": "0.5.1",
"@fluencelabs/threads": "^2.0.0",
"@libp2p/crypto": "3.0.1",
"@libp2p/identify": "1.0.4",
"@libp2p/interface": "1.0.1",
"@libp2p/peer-id": "4.0.1",
"@libp2p/peer-id-factory": "4.0.0",
"@libp2p/ping": "1.0.4",
"@libp2p/websockets": "8.0.5",
"@multiformats/multiaddr": "11.3.0",
"@libp2p/crypto": "4.0.1",
"@libp2p/identify": "1.0.11",
"@libp2p/interface": "1.1.2",
"@libp2p/peer-id": "4.0.5",
"@libp2p/peer-id-factory": "4.0.5",
"@libp2p/ping": "1.0.10",
"@libp2p/websockets": "8.0.12",
"@multiformats/multiaddr": "12.1.12",
"bs58": "5.0.0",
"debug": "4.3.4",
"it-length-prefixed": "9.0.3",
"it-map": "3.0.5",
"it-pipe": "3.0.1",
"js-base64": "3.7.5",
"libp2p": "1.0.7",
"libp2p": "1.2.0",
"multiformats": "11.0.1",
"rxjs": "7.5.5",
"uint8arrays": "4.0.3",
Expand Down
28 changes: 25 additions & 3 deletions packages/core/js-client/src/connection/RelayConnection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,23 @@ export interface RelayConnectionConfig {
maxOutboundStreams: number;
}

type DenyCondition = (ma: Multiaddr) => boolean;

const dockerNoxDenyCondition: DenyCondition = (ma) => {
const [routingProtocol] = ma.stringTuples();
const host = routingProtocol?.[1];

// Nox proposes 3 multiaddr to discover when used inside docker network,
// e.g.: [/dns/nox-1, /ip4/10.50.10.10, /ip4/127.0.0.1]
// First 2 of them are unreachable outside the docker network
// Libp2p cannot handle these scenarios correctly, creating interruptions which affect e2e tests execution.
return (
host === undefined || host.startsWith("nox-") || host.startsWith("10.50.10")
);
};

const denyConditions = [dockerNoxDenyCondition];

/**
* Implementation for JS peers which connects to Fluence through relay node
*/
Expand Down Expand Up @@ -128,13 +145,18 @@ export class RelayConnection implements IConnection {
...(this.config.dialTimeoutMs !== undefined
? {
dialTimeout: this.config.dialTimeoutMs,
autoDialInterval: 0,
}
: {}),
},
connectionGater: {
// By default, this function forbids connections to private peers. For example multiaddr with ip 127.0.0.1 isn't allowed
denyDialMultiaddr: () => {
return Promise.resolve(false);
// By default, this function forbids connections to private peers. For example, multiaddr with ip 127.0.0.1 isn't allowed
denyDialMultiaddr: (ma: Multiaddr) => {
return Promise.resolve(
denyConditions.some((dc) => {
return dc(ma);
}),
);
},
},
services: {
Expand Down
Loading

0 comments on commit a8a1473

Please sign in to comment.