[Nfd-dev] YaNFD cannot create TCP face
郝广宇
haoguangyu at chorustek.com
Wed Sep 21 02:56:07 PDT 2022
I have a YaNFD issue of that failed with "nfdc face create remote tcp4://X.X.X.X:6363", I read the source code that not tcp supported, the following is the code.
No case of tcpURI?
// Canonize attempts to canonize the URI, if not already canonical.
func (u *URI) Canonize() error {
switch u.uriType {
case devURI, fdURI:
// Nothing to do to canonize these
case ethernetURI:
mac, err := net.ParseMAC(strings.Trim(u.path, "[]"))
if err != nil {
return core.ErrNotCanonical
}
u.scheme = "ether"
u.path = mac.String()
u.port = 0
case udpURI:
path := u.path
zone := ""
if strings.Contains(u.path, "%") {
// Has zone, so separate out
path = u.PathHost()
zone = "%" + u.PathZone()
}
ip := net.ParseIP(strings.Trim(path, "[]"))
if ip == nil {
// Resolve DNS
resolvedIPs, err := net.LookupHost(path)
if err != nil || len(resolvedIPs) == 0 {
return core.ErrNotCanonical
}
ip = net.ParseIP(resolvedIPs[0])
if ip == nil {
return core.ErrNotCanonical
}
}
if ip.To4() != nil {
u.scheme = "udp4"
u.path = ip.String() + zone
} else if ip.To16() != nil {
u.scheme = "udp6"
u.path = ip.String() + zone
} else {
return core.ErrNotCanonical
}
case unixURI:
u.scheme = "unix"
testPath := "/" + u.path
if runtime.GOOS == "windows" {
testPath = u.path
}
fileInfo, err := os.Stat(testPath)
if err != nil && !os.IsNotExist(err) {
// File couldn't be opened, but not just because it doesn't exist
return core.ErrNotCanonical
} else if err == nil && fileInfo.IsDir() {
// File is a directory
return core.ErrNotCanonical
}
u.port = 0
default:
return core.ErrNotCanonical
}
return nil
}
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.lists.cs.ucla.edu/pipermail/nfd-dev/attachments/20220921/82384db3/attachment.html>
More information about the Nfd-dev
mailing list