Skip to content

Commit

Permalink
Merge pull request #79 from named-data/localuni
Browse files Browse the repository at this point in the history
fix(mgmt): allow loopback unicast face (fix #78)
  • Loading branch information
pulsejet authored Dec 22, 2024
2 parents 8b2d1e8 + 1e02a90 commit e195ffe
Showing 1 changed file with 26 additions and 6 deletions.
32 changes: 26 additions & 6 deletions mgmt/face.go
Original file line number Diff line number Diff line change
Expand Up @@ -123,15 +123,24 @@ func (f *FaceModule) create(interest *spec.Interest, pitToken []byte, inFace uin
var linkService *face.NDNLPLinkService

if URI.Scheme() == "udp4" || URI.Scheme() == "udp6" {
// Check that remote endpoint is not a unicast address
if remoteAddr := net.ParseIP(URI.Path()); remoteAddr != nil && !remoteAddr.IsGlobalUnicast() &&
!remoteAddr.IsLinkLocalUnicast() {
// Validate that remote endpoint is an IP address
remoteAddr := net.ParseIP(URI.Path())
if remoteAddr == nil {
core.LogWarn(f, "Cannot create face with non-IP remote address ", URI)
response = makeControlResponse(406, "URI must be IP", nil)
f.manager.sendResponse(response, interest, pitToken, inFace)
return
}

// Validate that remote endpoint is a unicast address
if !(remoteAddr.IsGlobalUnicast() || remoteAddr.IsLinkLocalUnicast() || remoteAddr.IsLoopback()) {
core.LogWarn(f, "Cannot create unicast UDP face to non-unicast address ", URI)
response = makeControlResponse(406, "URI must be unicast", nil)
f.manager.sendResponse(response, interest, pitToken, inFace)
return
}

// Check face persistency
persistency := face.PersistencyPersistent
if params.FacePersistency != nil && (*params.FacePersistency == uint64(face.PersistencyPersistent) ||
*params.FacePersistency == uint64(face.PersistencyPermanent)) {
Expand All @@ -144,6 +153,7 @@ func (f *FaceModule) create(interest *spec.Interest, pitToken []byte, inFace uin
return
}

// Check congestion control
baseCongestionMarkingInterval := 100 * time.Millisecond
if params.BaseCongestionMarkInterval != nil {
baseCongestionMarkingInterval = time.Duration(*params.BaseCongestionMarkInterval) * time.Nanosecond
Expand Down Expand Up @@ -203,15 +213,24 @@ func (f *FaceModule) create(interest *spec.Interest, pitToken []byte, inFace uin
linkService = face.MakeNDNLPLinkService(transport, options)
linkService.Run(nil)
} else if URI.Scheme() == "tcp4" || URI.Scheme() == "tcp6" {
// Check that remote endpoint is not a unicast address
if remoteAddr := net.ParseIP(URI.Path()); remoteAddr != nil && !remoteAddr.IsGlobalUnicast() &&
!remoteAddr.IsLinkLocalUnicast() {
// Validate that remote endpoint is an IP address
remoteAddr := net.ParseIP(URI.Path())
if remoteAddr == nil {
core.LogWarn(f, "Cannot create face with non-IP remote address ", URI)
response = makeControlResponse(406, "URI must be IP", nil)
f.manager.sendResponse(response, interest, pitToken, inFace)
return
}

// Validate that remote endpoint is a unicast address
if !(remoteAddr.IsGlobalUnicast() || remoteAddr.IsLinkLocalUnicast() || remoteAddr.IsLoopback()) {
core.LogWarn(f, "Cannot create unicast TCP face to non-unicast address ", URI)
response = makeControlResponse(406, "URI must be unicast", nil)
f.manager.sendResponse(response, interest, pitToken, inFace)
return
}

// Check face persistency
persistency := face.PersistencyPersistent
if params.FacePersistency != nil && (*params.FacePersistency == uint64(face.PersistencyPersistent) ||
*params.FacePersistency == uint64(face.PersistencyPermanent)) {
Expand All @@ -224,6 +243,7 @@ func (f *FaceModule) create(interest *spec.Interest, pitToken []byte, inFace uin
return
}

// Check congestion control
baseCongestionMarkingInterval := 100 * time.Millisecond
if params.BaseCongestionMarkInterval != nil {
baseCongestionMarkingInterval = time.Duration(*params.BaseCongestionMarkInterval) * time.Nanosecond
Expand Down

0 comments on commit e195ffe

Please sign in to comment.