Add the error message why an IP claim is denied

This commit is contained in:
Bryan Boreham committed 2019-10-25 17:13:59 +00:00
1 parent e8fcd21baa
commit a43bd88ddd
2 files changed
+7 -3

No files matched your search

+1 -1
View File
@@ -275,7 +275,7 @@ func (alloc *Allocator) spaceRequestDenied(sender mesh.PeerName, r address.Range
for i := 0; i < len(alloc.pendingClaims); {
claim := alloc.pendingClaims[i].(*claim)
if r.Contains(claim.cidr.Addr) {
claim.deniedBy(alloc, sender)
claim.deniedBy(alloc, sender, nil)
alloc.pendingClaims = append(alloc.pendingClaims[:i], alloc.pendingClaims[i+1:]...)
continue
}
+6 -2
View File
@@ -135,12 +135,16 @@ func (c *claim) Try(alloc *Allocator) bool {
return true
}
func (c *claim) deniedBy(alloc *Allocator, owner mesh.PeerName) {
func (c *claim) deniedBy(alloc *Allocator, owner mesh.PeerName, err error) {
name, found := alloc.nicknames[owner]
if found {
name = " (" + name + ")"
}
c.sendResult(fmt.Errorf("address %s is owned by other peer %s%s", c.cidr.String(), owner, name))
reason := ""
if err != nil {
reason = fmt.Sprintf(" - %s", err)
}
c.sendResult(fmt.Errorf("address %s is owned by other peer %s%s%s", c.cidr.String(), owner, name, reason))
}
func (c *claim) Cancel() {