瀏覽代碼

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

Jakob Borg 11 年之前
父節點
當前提交
6bbf1f9355
共有 3 個文件被更改,包括 14 次插入0 次删除
  1. 4 0
      cmd/syncthing/main.go
  2. 6 0
      events/events.go
  3. 4 0
      model/model.go

+ 4 - 0
cmd/syncthing/main.go

@@ -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()
 	}

+ 6 - 0
events/events.go

@@ -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"
 	}

+ 4 - 0
model/model.go

@@ -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
 	}