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

fix: normalize catch-all listeners to loopback #2287

Merged
merged 2 commits into from
Nov 7, 2024
Merged
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
6 changes: 4 additions & 2 deletions src/bundles/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -91,9 +91,11 @@ function getURLFromAddress (name, config) {
if (!config) return null

try {
const address = Array.isArray(config.Addresses[name])
const address = (Array.isArray(config.Addresses[name])
? config.Addresses[name][0]
: config.Addresses[name]
: config.Addresses[name])
.replace(/\/0\.0\.0\.0\//, '/127.0.0.1/') // fix for https://github.com/ipfs/ipfs-webui/issues/1821
.replace(/\/::\//, '/::1/')
Comment on lines +94 to +98
Copy link
Member

Choose a reason for hiding this comment

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

should we take this chance to more gracefully handle the array of addresses if it exists? do we always want the first one, or do we want the local one if one is found?

Copy link
Member Author

Choose a reason for hiding this comment

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

in practice, virtually all users will have only one listener, but the field in Kubo can be either a string or list of strings, so I think its ok as-is (not worth extra time/code).

const url = toUri(address, { assumeHttp: true })
if (new URL(url).port === 0) throw Error('port set to 0, not deterministic')
return url
Expand Down
Loading