fix unix path handling on windows

* Convert to windows paths when converting from a multiaddr to a net.Addr
* Convert from windows paths when converting from a net.Addr to a multiaddr

Also, don't "clean". `filepath.Clean` is _usually_ correct but not _technically_
correct in all cases. We should leave cleaning to the application.
This commit is contained in:
Steven Allen 2019-09-19 08:59:17 -07:00
parent 1b2246d7be
commit d66032c340

View File

@ -192,7 +192,7 @@ func DialArgs(m ma.Multiaddr) (string, string, error) {
}
return network, "[" + ip + "]" + ":" + port, nil
case "unix":
return network, ip, nil
return network, filepath.FromSlash(ip), nil
default:
return "", "", fmt.Errorf("%s is not a 'thin waist' address", m)
}
@ -263,6 +263,6 @@ func parseUnixNetAddr(a net.Addr) (ma.Multiaddr, error) {
if !ok {
return nil, errIncorrectNetAddr
}
cleaned := filepath.Clean(ac.Name)
return ma.NewComponent("unix", cleaned)
return ma.NewComponent("unix", filepath.ToSlash(ac.Name))
}