Skip to content
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

fix: filter for wss in libp2p websocket transport #1989

Merged
merged 1 commit into from
May 6, 2024

Conversation

adklempner
Copy link
Member

@adklempner adklempner commented Apr 27, 2024

Problem

Current libp2p transport filter allows all connections. This is fine for testing, but in production we want to limit transports to secure WebSockets (wss or tls/ws).

Solution

Allow all transport types when running tests by setting process.env.NODE_ENV=test but otherwise use the libp2p filter for secure websockets peers

Notes

Contribution checklist:

  • covered by unit tests;
  • covered by e2e test;
  • add ! in title if breaks public API;

@adklempner adklempner requested a review from a team as a code owner April 27, 2024 00:55
@adklempner adklempner marked this pull request as draft April 27, 2024 00:55
Copy link

github-actions bot commented Apr 27, 2024

size-limit report 📦

Path Size Loading time (3g) Running time (snapdragon) Total time
Waku node 181.21 KB (-0.01% 🔽) 3.7 s (-0.01% 🔽) 21.6 s (-0.07% 🔽) 25.3 s
Waku Simple Light Node 181.21 KB (-0.06% 🔽) 3.7 s (-0.06% 🔽) 18.1 s (-34.75% 🔽) 21.7 s
ECIES encryption 23.08 KB (0%) 462 ms (0%) 7.6 s (-18.92% 🔽) 8 s
Symmetric encryption 22.55 KB (0%) 452 ms (0%) 5.6 s (-25.74% 🔽) 6.1 s
DNS discovery 72.42 KB (0%) 1.5 s (0%) 15.1 s (-25.88% 🔽) 16.6 s
Peer Exchange discovery 74.1 KB (0%) 1.5 s (0%) 11.7 s (+11.62% 🔺) 13.2 s
Local Peer Cache Discovery 67.64 KB (0%) 1.4 s (0%) 11.5 s (-6.51% 🔽) 12.8 s
Privacy preserving protocols 38.87 KB (0%) 778 ms (0%) 11.1 s (+55.2% 🔺) 11.8 s
Waku Filter 111.79 KB (0%) 2.3 s (0%) 15.4 s (+2.39% 🔺) 17.6 s
Waku LightPush 110.15 KB (0%) 2.3 s (0%) 9 s (-55.85% 🔽) 11.2 s
History retrieval protocols 110.74 KB (0%) 2.3 s (0%) 13.9 s (-35.64% 🔽) 16.1 s
Deterministic Message Hashing 7.25 KB (0%) 145 ms (0%) 2.2 s (+19.82% 🔺) 2.3 s

@adklempner adklempner marked this pull request as ready for review April 30, 2024 18:25
@@ -64,11 +64,16 @@ export async function defaultLibp2p(
? { metadata: wakuMetadata(shardInfo) }
: {};

const filter =
typeof process !== "undefined" && process?.env?.NODE_ENV === "test"
Copy link
Collaborator

@weboko weboko Apr 30, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

let's handle this the same way it happens here -

"process?.env?.NODE_ENV": JSON.stringify("production")

this way we don't need to worry about process not being defined or even passing process.env.NODE_ENV

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

updated. tested it in light-js by making a release from this branch and made sure the replacement works

@adklempner adklempner merged commit 21aa22f into master May 6, 2024
10 of 11 checks passed
@adklempner adklempner deleted the fix/transport-filter-wss branch May 6, 2024 23:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

only allow secure websockets on transport
2 participants