mirror of
https://github.com/bitsocialnet/5chan.git
synced 2026-08-03 07:41:04 +02:00
26 lines
869 B
TypeScript
26 lines
869 B
TypeScript
export const P2P_BROWSER_PKC_OPTIONS = {
|
|
libp2pJsClientsOptions: [{ key: 'libp2pjs' }],
|
|
httpRoutersOptions: ['https://peers.pleb.bot', 'https://peers.forumindex.com'],
|
|
};
|
|
|
|
type P2PBrowserConfigWindow = {
|
|
location: Pick<Location, 'hostname'>;
|
|
defaultPkcOptions?: Record<string, unknown>;
|
|
};
|
|
|
|
export const isP2PBrowserHostname = (hostname: string) => hostname.toLowerCase().startsWith('p2p.');
|
|
|
|
export const configureP2PBrowserPkcOptions = (targetWindow: P2PBrowserConfigWindow = window) => {
|
|
if (!isP2PBrowserHostname(targetWindow.location.hostname)) {
|
|
return false;
|
|
}
|
|
|
|
targetWindow.defaultPkcOptions = {
|
|
...targetWindow.defaultPkcOptions,
|
|
libp2pJsClientsOptions: P2P_BROWSER_PKC_OPTIONS.libp2pJsClientsOptions.map((options) => ({ ...options })),
|
|
httpRoutersOptions: [...P2P_BROWSER_PKC_OPTIONS.httpRoutersOptions],
|
|
};
|
|
|
|
return true;
|
|
};
|