Skip to content

fix(ipfs): expose kubo swarm port so nodes are browser-dialable#45

Merged
Rinse12 merged 2 commits into
masterfrom
fix/expose-kubo-swarm-port
May 20, 2026
Merged

fix(ipfs): expose kubo swarm port so nodes are browser-dialable#45
Rinse12 merged 2 commits into
masterfrom
fix/expose-kubo-swarm-port

Conversation

@Rinse12
Copy link
Copy Markdown
Member

@Rinse12 Rinse12 commented May 20, 2026

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 /.bitsocial-cli.ipfs/config Swarm entries and restart.

Refs #44

Summary by CodeRabbit

  • Infrastructure

    • Added port 4001 (TCP and UDP) exposure for IPFS Swarm networking across all deployment configurations.
    • Updated IPFS Gateway configuration to refine address mappings.
  • Tests

    • Enhanced test coverage for IPFS configuration defaults.

Review Change Stack

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
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 20, 2026

Warning

Rate limit exceeded

@Rinse12 has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 40 minutes and 2 seconds before requesting another review.

You’ve run out of usage credits. Purchase more in the billing tab.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 1c5a402e-1163-4f04-81c9-ec0a70bad9fa

📥 Commits

Reviewing files that changed from the base of the PR and between 83d6c2d and 4342f68.

📒 Files selected for processing (3)
  • test/helpers/daemon-helpers.ts
  • test/helpers/kubo-helpers.ts
  • test/kubo/kuboRpcGateway.integration.test.ts
📝 Walkthrough

Walkthrough

Port 4001 is added to Docker infrastructure for Kubo Swarm networking across CI, production, and example configurations. Concurrently, IPFS configuration defaults are refactored to remove Swarm settings from the Gateway section, and tests are updated to assert against a defined Kubo default Swarm array.

Changes

Kubo Swarm Networking Port Exposure and Configuration

Layer / File(s) Summary
Docker infrastructure port exposure
Dockerfile, docker-compose.yml, .github/docker-compose.ci.yml, docker-compose.example.yml
Port 4001 (TCP and UDP) is added to the Dockerfile EXPOSE instruction and all Docker Compose port mappings, with inline documentation for Kubo Swarm protocol support.
IPFS config defaults and test alignment
src/ipfs/startIpfs.ts, test/kubo/mergeCliDefaultsIntoIpfsConfig.test.ts
Default Swarm addresses are removed from the Addresses.Gateway section in mergeCliDefaultsIntoIpfsConfig, and the test now defines and asserts against a kuboDefaultSwarm constant instead of hardcoded values.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

Possibly related issues

Poem

🐰 A port to share, port four-zero-one,
Through Swarm and Quic, the data flows as one,
Default clean-up, tests aligned just right,
Docker and config dance in network light! 🌐

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately reflects the main objective: exposing kubo's swarm port (port 4001) to enable browser-dialable nodes, which aligns with all the substantive changes across Docker configurations and IPFS configuration code.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/expose-kubo-swarm-port

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@test/kubo/mergeCliDefaultsIntoIpfsConfig.test.ts`:
- Around line 20-29: The test suite failure is caused by missing test dependency
"decompress" when running npm run test:cli; run npm run test:cli locally, add
the missing package to devDependencies (install "decompress") and re-run the
tests until all tests in mergeCliDefaultsIntoIpfsConfig.test.ts (which defines
kuboDefaultSwarm) pass, then commit the updated package.json/package-lock.json
so CI verification succeeds.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 7bbe3323-d4a3-4545-8479-9501d0734002

📥 Commits

Reviewing files that changed from the base of the PR and between f3f987e and 83d6c2d.

📒 Files selected for processing (6)
  • .github/docker-compose.ci.yml
  • Dockerfile
  • docker-compose.example.yml
  • docker-compose.yml
  • src/ipfs/startIpfs.ts
  • test/kubo/mergeCliDefaultsIntoIpfsConfig.test.ts

Comment on lines +20 to +29
const kuboDefaultSwarm = [
"/ip4/0.0.0.0/tcp/4001",
"/ip6/::/tcp/4001",
"/ip4/0.0.0.0/udp/4001/webrtc-direct",
"/ip4/0.0.0.0/udp/4001/quic-v1",
"/ip4/0.0.0.0/udp/4001/quic-v1/webtransport",
"/ip6/::/udp/4001/webrtc-direct",
"/ip6/::/udp/4001/quic-v1",
"/ip6/::/udp/4001/quic-v1/webtransport"
];
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🔴 Critical

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
npm run test:cli

Repository: bitsocialnet/bitsocial-cli

Length of output: 1321


Verify the test suite passes in your local environment before merging.

The npm run test:cli command failed to execute in the verification environment due to missing dependencies (decompress package). Please ensure you have run npm run test:cli in your local environment and that all tests pass before committing.

Per coding guidelines: "**/*.test.ts: MUST run tests with npm run test:cli to verify all tests pass before committing"

Also applies to: lines 32-32, 43-43

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@test/kubo/mergeCliDefaultsIntoIpfsConfig.test.ts` around lines 20 - 29, The
test suite failure is caused by missing test dependency "decompress" when
running npm run test:cli; run npm run test:cli locally, add the missing package
to devDependencies (install "decompress") and re-run the tests until all tests
in mergeCliDefaultsIntoIpfsConfig.test.ts (which defines kuboDefaultSwarm) pass,
then commit the updated package.json/package-lock.json so CI verification
succeeds.

…'t collide on 4001

Before this branch, mergeCliDefaultsIntoIpfsConfig overrode Swarm to /tcp/0
which (incidentally) gave each test daemon a kernel-assigned port. Now that
production preserves kubo's default Swarm (port 4001), parallel test
daemons spawned by vitest fileParallelism race for the same port and fail
with "IPFS Swarm port 0.0.0.0:4001 already in use".

Add a test helper that pre-initializes the kubo repo, applies bitsocial
defaults, and rewrites Swarm to ephemeral addresses. The daemon's own
`ipfs init` then bails because the config already exists, mergeCliDefaults
is skipped, and kubo binds to per-process kernel-assigned ports.

Refs #44
@Rinse12 Rinse12 merged commit 7d4f543 into master May 20, 2026
4 checks passed
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.

1 participant