mirror of
https://github.com/octoleo/syncthing.git
synced 2024-11-08 22:31:04 +00:00
Close on version mismatch
This commit is contained in:
parent
f5987fba32
commit
8d3aa97047
@ -192,6 +192,10 @@ func (c *Connection) readerLoop() {
|
||||
c.close()
|
||||
break
|
||||
}
|
||||
if hdr.version != 0 {
|
||||
c.close()
|
||||
break
|
||||
}
|
||||
|
||||
c.wLock.Lock()
|
||||
c.lastReceive = time.Now()
|
||||
|
@ -135,3 +135,25 @@ func TestRequestResponseErr(t *testing.T) {
|
||||
t.Error("Never passed")
|
||||
}
|
||||
}
|
||||
|
||||
func TestVersionErr(t *testing.T) {
|
||||
m0 := &TestModel{}
|
||||
m1 := &TestModel{}
|
||||
|
||||
ar, aw := io.Pipe()
|
||||
br, bw := io.Pipe()
|
||||
|
||||
c0 := NewConnection("c0", ar, bw, m0)
|
||||
NewConnection("c1", br, aw, m1)
|
||||
|
||||
c0.mwriter.writeHeader(header{
|
||||
version: 2,
|
||||
msgID: 0,
|
||||
msgType: 0,
|
||||
})
|
||||
c0.flush()
|
||||
|
||||
if !m1.closed {
|
||||
t.Error("Connection should close due to unknown version")
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user