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

Parsing IPFS daemon multiaddress is falsely presumptuous #719

Open
machawk1 opened this issue Oct 8, 2020 · 1 comment
Open

Parsing IPFS daemon multiaddress is falsely presumptuous #719

machawk1 opened this issue Oct 8, 2020 · 1 comment
Labels

Comments

@machawk1
Copy link
Member

machawk1 commented Oct 8, 2020

In util.py, the IPFS daemon API endpoint is read form ~/.ipfs/config and parsed through

(scheme, host, protocol, port) = (
        ipfs_json['Addresses']['API'][1:].split('/')
    )

Per https://multiformats.io/multiaddr/, other addresses might be used beyond the default /ip4/127.0.0.1/tcp/5001 that might have more or less than four parts split by /, e.g., /ip4/127.0.0.1/tcp/80/http.

x = '/ip4/127.0.0.1/tcp/80/http'
x[1:].split('/')
ValueError: too many values to unpack (expected 4)

Additionally, the named values do not seem to match that which is parsed, e.g., ip4 is not the "scheme".

This code should be remedied to be more adaptive to the extent of the variants of mutliaddresses. Does the base library provide any semantic getters of these values rather than trying to parse them?

@machawk1 machawk1 added the bug label Oct 8, 2020
@machawk1
Copy link
Member Author

machawk1 commented Oct 8, 2020

This relates to #718 in that while reviewing the PR with @ibnesayeed, noticed the rudimentary, potentially unreliable parsing procedure. The code would be better informed with some test cases, as enumerated in the multiaddr URI above.

@gador gador mentioned this issue Oct 9, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant