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

chore: enable back filterAll if set by consumer #2103

Merged
merged 1 commit into from
Aug 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions packages/interfaces/src/libp2p.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,9 @@ export type CreateLibp2pOptions = Libp2pOptions & {
*/
hideWebSocketInfo?: boolean;
pingMaxInboundStreams?: number;
/**
* Applies secure web socket filters.
* @default true
*/
filterMultiaddrs?: boolean;
Copy link
Collaborator

Choose a reason for hiding this comment

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

nit:

Suggested change
filterMultiaddrs?: boolean;
onlyWssMultiaddrs?: boolean;

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I would stick to libp2p terminology with filters as we might apply other filtration in future. Not sure tbh

};
7 changes: 5 additions & 2 deletions packages/sdk/src/create/libp2p.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,13 +64,16 @@
? { metadata: wakuMetadata(pubsubTopics) }
: {};

const filter = process?.env?.NODE_ENV === "test" ? filterAll : wss;
const filter =
options?.filterMultiaddrs === false || process?.env?.NODE_ENV === "test"
? filterAll
: wss;

return createLibp2p({
connectionManager: {
minConnections: 1
},
transports: [webSockets({ filter })],
transports: [webSockets({ filter: filter })],
streamMuxers: [mplex()],
connectionEncryption: [noise()],
...options,
Expand All @@ -86,7 +89,7 @@
...pubsubService,
...options?.services
}
}) as any as Libp2p; // TODO: make libp2p include it;

Check warning on line 92 in packages/sdk/src/create/libp2p.ts

View workflow job for this annotation

GitHub Actions / check

Unexpected any. Specify a different type

Check warning on line 92 in packages/sdk/src/create/libp2p.ts

View workflow job for this annotation

GitHub Actions / proto

Unexpected any. Specify a different type
}

export async function createLibp2pAndUpdateOptions(
Expand Down
Loading