Emit Node/Repo Rejected events on unknown nodes / repos.

This commit is contained in:
Jakob Borg 2014-08-18 23:34:03 +02:00
parent b221e4d445
commit 6bbf1f9355
3 changed files with 14 additions and 0 deletions

View File

@ -846,6 +846,10 @@ next:
}
}
events.Default.Log(events.NodeRejected, map[string]string{
"node": remoteID.String(),
"address": conn.RemoteAddr().String(),
})
l.Infof("Connection from %s with unknown node ID %s; ignoring", conn.RemoteAddr(), remoteID)
conn.Close()
}

View File

@ -20,10 +20,12 @@ const (
NodeDiscovered
NodeConnected
NodeDisconnected
NodeRejected
LocalIndexUpdated
RemoteIndexUpdated
ItemStarted
StateChanged
RepoRejected
AllEvents = ^EventType(0)
)
@ -42,6 +44,8 @@ func (t EventType) String() string {
return "NodeConnected"
case NodeDisconnected:
return "NodeDisconnected"
case NodeRejected:
return "NodeRejected"
case LocalIndexUpdated:
return "LocalIndexUpdated"
case RemoteIndexUpdated:
@ -50,6 +54,8 @@ func (t EventType) String() string {
return "ItemStarted"
case StateChanged:
return "StateChanged"
case RepoRejected:
return "RepoRejected"
default:
return "Unknown"
}

View File

@ -332,6 +332,10 @@ func (m *Model) Index(nodeID protocol.NodeID, repo string, fs []protocol.FileInf
}
if !m.repoSharedWith(repo, nodeID) {
events.Default.Log(events.RepoRejected, map[string]string{
"repo": repo,
"node": nodeID.String(),
})
l.Warnf("Unexpected repository ID %q sent from node %q; ensure that the repository exists and that this node is selected under \"Share With\" in the repository configuration.", repo, nodeID)
return
}