fix: add delegatedContentRouting back for now
This commit is contained in:
parent
cb162f5135
commit
6298d8e914
|
@ -15,6 +15,24 @@ import { hypercoreTransport } from "./libp2p/transport.js";
|
||||||
import { MultiSocketProxy } from "@lumeweb/libhyperproxy";
|
import { MultiSocketProxy } from "@lumeweb/libhyperproxy";
|
||||||
import { ipniContentRouting } from "@libp2p/ipni-content-routing";
|
import { ipniContentRouting } from "@libp2p/ipni-content-routing";
|
||||||
import { reframeContentRouting } from "@libp2p/reframe-content-routing";
|
import { reframeContentRouting } from "@libp2p/reframe-content-routing";
|
||||||
|
import { multiaddr } from "@multiformats/multiaddr";
|
||||||
|
import { create as createIpfsHttpClient } from "ipfs-http-client";
|
||||||
|
import { delegatedContentRouting } from "@libp2p/delegated-content-routing";
|
||||||
|
import { DELEGATE_LIST } from "./constants.js";
|
||||||
|
|
||||||
|
function getDelegateConfig(): any {
|
||||||
|
const delegateString =
|
||||||
|
DELEGATE_LIST[Math.floor(Math.random() * DELEGATE_LIST.length)];
|
||||||
|
const delegateAddr = multiaddr(delegateString).toOptions();
|
||||||
|
|
||||||
|
return {
|
||||||
|
// @ts-ignore
|
||||||
|
host: delegateAddr.host,
|
||||||
|
// @ts-ignore
|
||||||
|
protocol: parseInt(delegateAddr.port) === 443 ? "https" : "http",
|
||||||
|
port: delegateAddr.port,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
export function libp2pConfig(proxy: MultiSocketProxy): Libp2pOptions<{
|
export function libp2pConfig(proxy: MultiSocketProxy): Libp2pOptions<{
|
||||||
dht: DualKadDHT;
|
dht: DualKadDHT;
|
||||||
|
@ -22,6 +40,8 @@ export function libp2pConfig(proxy: MultiSocketProxy): Libp2pOptions<{
|
||||||
identify: unknown;
|
identify: unknown;
|
||||||
autoNAT: unknown;
|
autoNAT: unknown;
|
||||||
}> {
|
}> {
|
||||||
|
const client = createIpfsHttpClient(getDelegateConfig());
|
||||||
|
|
||||||
return {
|
return {
|
||||||
addresses: {
|
addresses: {
|
||||||
listen: [],
|
listen: [],
|
||||||
|
@ -31,6 +51,7 @@ export function libp2pConfig(proxy: MultiSocketProxy): Libp2pOptions<{
|
||||||
streamMuxers: [yamux(), mplex()],
|
streamMuxers: [yamux(), mplex()],
|
||||||
peerDiscovery: [bootstrap(bootstrapConfig)],
|
peerDiscovery: [bootstrap(bootstrapConfig)],
|
||||||
contentRouters: [
|
contentRouters: [
|
||||||
|
delegatedContentRouting(client),
|
||||||
ipniContentRouting("https://cid.contact"),
|
ipniContentRouting("https://cid.contact"),
|
||||||
reframeContentRouting("https://cid.contact/reframe"),
|
reframeContentRouting("https://cid.contact/reframe"),
|
||||||
],
|
],
|
||||||
|
|
|
@ -1 +1,8 @@
|
||||||
export const PROTOCOL = "lumeweb.proxy.ipfs";
|
export const PROTOCOL = "lumeweb.proxy.ipfs";
|
||||||
|
|
||||||
|
export const DELEGATE_LIST = [
|
||||||
|
"/dns4/node0.delegate.ipfs.io/tcp/443/https",
|
||||||
|
"/dns4/node1.delegate.ipfs.io/tcp/443/https",
|
||||||
|
"/dns4/node2.delegate.ipfs.io/tcp/443/https",
|
||||||
|
"/dns4/node3.delegate.ipfs.io/tcp/443/https",
|
||||||
|
];
|
||||||
|
|
Loading…
Reference in New Issue