Skip to content

DNS multiaddr format support missing: /dns/hostname/https #121

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

Closed
NikolasHaimerl opened this issue Mar 13, 2025 · 0 comments · Fixed by #122
Closed

DNS multiaddr format support missing: /dns/hostname/https #121

NikolasHaimerl opened this issue Mar 13, 2025 · 0 comments · Fixed by #122
Assignees

Comments

@NikolasHaimerl
Copy link
Contributor

NikolasHaimerl commented Mar 13, 2025

Description

The multiaddrToHttpUrl function fails to correctly parse DNS-based multiaddresses that don't include a TCP port segment, which is a valid format according to the multiaddr spec.

When attempting to parse addresses like /dns/f03303347-market.duckdns.org/https, the function throws an error because it expects a TCP protocol and port before the HTTP/HTTPS scheme.

Reproduction Steps

This issue occurs when processing retrieval requests from certain providers that use the direct DNS format in their multiaddresses. For example, when attempting to fetch content identified by CID bafyreiaxqptvdcxmyiwhb5kpvkmaxv5e3svniomf6ptvxvl7ypnmlrs22a from a provider using this address format, we see the following error:

Error: Cannot parse "/dns/f03303347-market.duckdns.org/https": unsupported protocol "https"

Expected Behavior

For a multiaddr like /dns/f03303347-market.duckdns.org/https, the function should return the URL https://f03303347-market.duckdns.org.

Proposed Solution

Add support for DNS-based direct HTTP/HTTPS format by modifying the multiaddrToHttpUrl function to handle this case. The solution should:

  1. Detect when a multiaddr contains a DNS host (/dns/, /dns4/, or /dns6/) followed directly by an HTTP or HTTPS protocol identifier
  2. Correctly extract the scheme and host in this case, without requiring the TCP port segment
  3. Build and return the appropriate URL

Additional Test Cases

To verify the solution, we should add test cases for this direct format:

// Direct DNS format tests
['/dns/meridian.space/https', 'https://meridian.space'],
['/dns/meridian.space/http', 'http://meridian.space']

These would complement our existing tests for the TCP-based format and HTTP path format.

Related to #112 and CheckerNetwork/roadmap#231

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

1 participant