Skip to content

Commit 83d6c2d

Browse files
committed
fix(ipfs): expose kubo swarm port so nodes are browser-dialable
Stop overriding kubo's Swarm addresses (was pinning to ephemeral /tcp/0) and forward port 4001 (TCP + UDP) in all compose files. Without this, no fixed reachable swarm port means AutoTLS cannot mint a libp2p.direct cert, and browser pure-p2p clients only get relayed limited connections that libp2p refuses for identify/gossipsub/bitswap. Existing installs are NOT auto-migrated -- operators need to delete or hand-edit <data>/.bitsocial-cli.ipfs/config Swarm entries and restart. Refs #44
1 parent f3f987e commit 83d6c2d

6 files changed

Lines changed: 26 additions & 25 deletions

File tree

.github/docker-compose.ci.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ services:
99
- "9138:9138"
1010
- "50019:50019"
1111
- "6473:6473"
12+
- "4001:4001"
13+
- "4001:4001/udp"
1214
volumes:
1315
- bitsocial-data:/data
1416
- bitsocial-logs:/logs

Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ ENV XDG_STATE_HOME=/logs
5858
ENV KUBO_RPC_URL="http://0.0.0.0:50019/api/v0"
5959
ENV IPFS_GATEWAY_URL="http://0.0.0.0:6473"
6060

61-
EXPOSE 9138 50019 6473
61+
EXPOSE 9138 50019 6473 4001
6262

6363
VOLUME ["/data", "/logs"]
6464

docker-compose.example.yml

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,11 @@ services:
1818
container_name: bitsocial
1919
restart: unless-stopped
2020
ports:
21-
- "9138:9138" # Plebbit RPC + Web UI
22-
- "50019:50019" # Kubo IPFS API
23-
- "6473:6473" # IPFS Gateway
21+
- "9138:9138" # Plebbit RPC + Web UI
22+
- "50019:50019" # Kubo IPFS API
23+
- "6473:6473" # IPFS Gateway
24+
- "4001:4001" # Kubo Swarm (TCP)
25+
- "4001:4001/udp" # Kubo Swarm (QUIC + WebTransport + WebRTC-direct)
2426
volumes:
2527
- bitsocial-data:/data
2628
- bitsocial-logs:/logs

docker-compose.yml

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,11 @@ services:
1919
restart: unless-stopped
2020
stop_grace_period: 30s
2121
ports:
22-
- "9138:9138" # Plebbit RPC + Web UI
23-
- "50019:50019" # Kubo IPFS API
24-
- "6473:6473" # IPFS Gateway
22+
- "9138:9138" # Plebbit RPC + Web UI
23+
- "50019:50019" # Kubo IPFS API
24+
- "6473:6473" # IPFS Gateway
25+
- "4001:4001" # Kubo Swarm (TCP)
26+
- "4001:4001/udp" # Kubo Swarm (QUIC + WebTransport + WebRTC-direct)
2527
volumes:
2628
- bitsocial-data:/data
2729
- bitsocial-logs:/logs

src/ipfs/startIpfs.ts

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -56,15 +56,7 @@ export async function mergeCliDefaultsIntoIpfsConfig(log: any, ipfsConfigPath: s
5656
Addresses: {
5757
...(currentIpfsConfigFile["Addresses"] ?? {}),
5858
Gateway: `/ip4/${gatewayUrl.hostname}/tcp/${gatewayUrl.port}`,
59-
API: `/ip4/${apiUrl.hostname}/tcp/${apiUrl.port}`,
60-
Swarm: [
61-
"/ip4/0.0.0.0/tcp/0",
62-
"/ip6/::/tcp/0",
63-
"/ip4/0.0.0.0/udp/0/quic-v1",
64-
"/ip4/0.0.0.0/udp/0/quic-v1/webtransport",
65-
"/ip6/::/udp/0/quic-v1",
66-
"/ip6/::/udp/0/quic-v1/webtransport"
67-
]
59+
API: `/ip4/${apiUrl.hostname}/tcp/${apiUrl.port}`
6860
},
6961
AutoTLS: {
7062
...(currentIpfsConfigFile["AutoTLS"] ?? {}),

test/kubo/mergeCliDefaultsIntoIpfsConfig.test.ts

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,19 @@ const writeConfigToTempFile = async (config: Record<string, any>) => {
1717

1818
describe("mergeCliDefaultsIntoIpfsConfig", () => {
1919
it("overrides core defaults on freshly initialized config", async () => {
20+
const kuboDefaultSwarm = [
21+
"/ip4/0.0.0.0/tcp/4001",
22+
"/ip6/::/tcp/4001",
23+
"/ip4/0.0.0.0/udp/4001/webrtc-direct",
24+
"/ip4/0.0.0.0/udp/4001/quic-v1",
25+
"/ip4/0.0.0.0/udp/4001/quic-v1/webtransport",
26+
"/ip6/::/udp/4001/webrtc-direct",
27+
"/ip6/::/udp/4001/quic-v1",
28+
"/ip6/::/udp/4001/quic-v1/webtransport"
29+
];
2030
const initialConfig = {
2131
Addresses: {
22-
Swarm: ["/ip4/0.0.0.0/tcp/4001"],
32+
Swarm: kuboDefaultSwarm,
2333
Gateway: "/ip4/0.0.0.0/tcp/8080"
2434
}
2535
};
@@ -30,14 +40,7 @@ describe("mergeCliDefaultsIntoIpfsConfig", () => {
3040
const mergedConfig = JSON.parse(await fs.readFile(configPath, "utf-8"));
3141
expect(mergedConfig.Addresses.API).toBe("/ip4/127.0.0.1/tcp/5001");
3242
expect(mergedConfig.Addresses.Gateway).toBe("/ip4/127.0.0.1/tcp/8080");
33-
expect(mergedConfig.Addresses.Swarm).toEqual([
34-
"/ip4/0.0.0.0/tcp/0",
35-
"/ip6/::/tcp/0",
36-
"/ip4/0.0.0.0/udp/0/quic-v1",
37-
"/ip4/0.0.0.0/udp/0/quic-v1/webtransport",
38-
"/ip6/::/udp/0/quic-v1",
39-
"/ip6/::/udp/0/quic-v1/webtransport"
40-
]);
43+
expect(mergedConfig.Addresses.Swarm).toEqual(kuboDefaultSwarm);
4144
expect(mergedConfig.AutoTLS.Enabled).toBe(true);
4245
});
4346

0 commit comments

Comments
 (0)