Merge pull request #4391 from filecoin-project/feat/https-api

Add support for /https, /http, /wss API multiaddresses.
This commit is contained in:
Łukasz Magiera 2020-10-14 18:22:29 +02:00 committed by GitHub
commit d3d304bfd7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -44,7 +44,22 @@ func (a APIInfo) DialArgs() (string, error) {
return "", err return "", err
} }
return "ws://" + addr + "/rpc/v0", nil protocol := "ws"
// If the user specifies the multiaddress as
// /something/tcp/1234/http or/something/tcp/1234/https
// or /something/tcp/1234/wss then honor that.
for _, p := range []int{
multiaddr.P_HTTP,
multiaddr.P_HTTPS,
multiaddr.P_WSS,
} {
if _, err := ma.ValueForProtocol(p); err == nil {
protocol = multiaddr.ProtocolWithCode(p).Name
break
}
}
return protocol + "://" + addr + "/rpc/v0", nil
} }
_, err = url.Parse(a.Addr) _, err = url.Parse(a.Addr)