We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 03e871b commit 5bd241dCopy full SHA for 5bd241d
convert.go
@@ -68,14 +68,16 @@ func parseBasicNetMaddr(maddr ma.Multiaddr) (net.Addr, error) {
68
69
// FromIP converts a net.IP type to a Multiaddr.
70
func FromIP(ip net.IP) (ma.Multiaddr, error) {
71
+ var proto string
72
switch {
73
case ip.To4() != nil:
- return ma.NewMultiaddr("/ip4/" + ip.String())
74
+ proto = "ip4"
75
case ip.To16() != nil:
- return ma.NewMultiaddr("/ip6/" + ip.String())
76
+ proto = "ip6"
77
default:
78
return nil, errIncorrectNetAddr
79
}
80
+ return ma.NewComponent(proto, ip.String())
81
82
83
// DialArgs is a convenience function returning arguments for use in net.Dial
0 commit comments