mirror of
https://github.com/octoleo/syncthing.git
synced 2025-02-02 11:58:28 +00:00
Reject index for existing repo from unshared node (fixes #342)
This commit is contained in:
parent
6d24e4f122
commit
b2f66cfb60
@ -260,6 +260,11 @@ func (m *Model) Index(nodeID string, repo string, fs []protocol.FileInfo) {
|
|||||||
l.Debugf("IDX(in): %s %q: %d files", nodeID, repo, len(fs))
|
l.Debugf("IDX(in): %s %q: %d files", nodeID, repo, len(fs))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if !m.repoSharedWith(repo, nodeID) {
|
||||||
|
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
|
||||||
|
}
|
||||||
|
|
||||||
var files = make([]scanner.File, len(fs))
|
var files = make([]scanner.File, len(fs))
|
||||||
for i := range fs {
|
for i := range fs {
|
||||||
f := fs[i]
|
f := fs[i]
|
||||||
@ -279,7 +284,7 @@ func (m *Model) Index(nodeID string, repo string, fs []protocol.FileInfo) {
|
|||||||
if r, ok := m.repoFiles[repo]; ok {
|
if r, ok := m.repoFiles[repo]; ok {
|
||||||
r.Replace(id, files)
|
r.Replace(id, files)
|
||||||
} else {
|
} else {
|
||||||
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)
|
l.Fatalf("Index for nonexistant repo %q", repo)
|
||||||
}
|
}
|
||||||
m.rmut.RUnlock()
|
m.rmut.RUnlock()
|
||||||
}
|
}
|
||||||
@ -291,6 +296,11 @@ func (m *Model) IndexUpdate(nodeID string, repo string, fs []protocol.FileInfo)
|
|||||||
l.Debugf("IDXUP(in): %s / %q: %d files", nodeID, repo, len(fs))
|
l.Debugf("IDXUP(in): %s / %q: %d files", nodeID, repo, len(fs))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if !m.repoSharedWith(repo, nodeID) {
|
||||||
|
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
|
||||||
|
}
|
||||||
|
|
||||||
var files = make([]scanner.File, len(fs))
|
var files = make([]scanner.File, len(fs))
|
||||||
for i := range fs {
|
for i := range fs {
|
||||||
f := fs[i]
|
f := fs[i]
|
||||||
@ -310,11 +320,22 @@ func (m *Model) IndexUpdate(nodeID string, repo string, fs []protocol.FileInfo)
|
|||||||
if r, ok := m.repoFiles[repo]; ok {
|
if r, ok := m.repoFiles[repo]; ok {
|
||||||
r.Update(id, files)
|
r.Update(id, files)
|
||||||
} else {
|
} else {
|
||||||
l.Warnf("Index update from %s for nonexistant repo %q; dropping", nodeID, repo)
|
l.Fatalf("IndexUpdate for nonexistant repo %q", repo)
|
||||||
}
|
}
|
||||||
m.rmut.RUnlock()
|
m.rmut.RUnlock()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (m *Model) repoSharedWith(repo, nodeID string) bool {
|
||||||
|
m.rmut.RLock()
|
||||||
|
defer m.rmut.RUnlock()
|
||||||
|
for _, nrepo := range m.nodeRepos[nodeID] {
|
||||||
|
if nrepo == repo {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
func (m *Model) ClusterConfig(nodeID string, config protocol.ClusterConfigMessage) {
|
func (m *Model) ClusterConfig(nodeID string, config protocol.ClusterConfigMessage) {
|
||||||
compErr := compareClusterConfig(m.clusterConfig(nodeID), config)
|
compErr := compareClusterConfig(m.clusterConfig(nodeID), config)
|
||||||
if debug {
|
if debug {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user