mirror of
https://github.com/octoleo/syncthing.git
synced 2024-11-12 16:26:37 +00:00
vendor: Update kcp, removes closeConn (fixes #4343)
This commit is contained in:
parent
49bddfbe53
commit
9e6a1fdcd4
@ -38,7 +38,7 @@ func (d *kcpDialer) Dial(id protocol.DeviceID, uri *url.URL) (internalConn, erro
|
|||||||
// Try to dial via an existing listening connection
|
// Try to dial via an existing listening connection
|
||||||
// giving better changes punching through NAT.
|
// giving better changes punching through NAT.
|
||||||
if f := getDialingFilter(); f != nil {
|
if f := getDialingFilter(); f != nil {
|
||||||
conn, err = kcp.NewConn(uri.Host, nil, 0, 0, f.NewConn(kcpConversationFilterPriority, &kcpConversationFilter{}), false)
|
conn, err = kcp.NewConn(uri.Host, nil, 0, 0, f.NewConn(kcpConversationFilterPriority, &kcpConversationFilter{}))
|
||||||
l.Debugf("dial %s using existing conn on %s", uri.String(), conn.LocalAddr())
|
l.Debugf("dial %s using existing conn on %s", uri.String(), conn.LocalAddr())
|
||||||
} else {
|
} else {
|
||||||
conn, err = kcp.DialWithOptions(uri.Host, nil, 0, 0)
|
conn, err = kcp.DialWithOptions(uri.Host, nil, 0, 0)
|
||||||
|
14
vendor/github.com/AudriusButkevicius/kcp-go/sess.go
generated
vendored
14
vendor/github.com/AudriusButkevicius/kcp-go/sess.go
generated
vendored
@ -68,7 +68,6 @@ type (
|
|||||||
UDPSession struct {
|
UDPSession struct {
|
||||||
updaterIdx int // record slice index in updater
|
updaterIdx int // record slice index in updater
|
||||||
conn net.PacketConn // the underlying packet connection
|
conn net.PacketConn // the underlying packet connection
|
||||||
closeConn bool // Should we close the underlying conn once UDPSession is closed.
|
|
||||||
kcp *KCP // KCP ARQ protocol
|
kcp *KCP // KCP ARQ protocol
|
||||||
l *Listener // point to the Listener if it's accepted by Listener
|
l *Listener // point to the Listener if it's accepted by Listener
|
||||||
block BlockCrypt // block encryption
|
block BlockCrypt // block encryption
|
||||||
@ -113,7 +112,7 @@ type (
|
|||||||
)
|
)
|
||||||
|
|
||||||
// newUDPSession create a new udp session for client or server
|
// newUDPSession create a new udp session for client or server
|
||||||
func newUDPSession(conv uint32, dataShards, parityShards int, l *Listener, conn net.PacketConn, remote net.Addr, block BlockCrypt, closeConn bool) *UDPSession {
|
func newUDPSession(conv uint32, dataShards, parityShards int, l *Listener, conn net.PacketConn, remote net.Addr, block BlockCrypt) *UDPSession {
|
||||||
sess := new(UDPSession)
|
sess := new(UDPSession)
|
||||||
sess.die = make(chan struct{})
|
sess.die = make(chan struct{})
|
||||||
sess.chReadEvent = make(chan struct{}, 1)
|
sess.chReadEvent = make(chan struct{}, 1)
|
||||||
@ -121,7 +120,6 @@ func newUDPSession(conv uint32, dataShards, parityShards int, l *Listener, conn
|
|||||||
sess.chErrorEvent = make(chan error, 1)
|
sess.chErrorEvent = make(chan error, 1)
|
||||||
sess.remote = remote
|
sess.remote = remote
|
||||||
sess.conn = conn
|
sess.conn = conn
|
||||||
sess.closeConn = closeConn
|
|
||||||
sess.l = l
|
sess.l = l
|
||||||
sess.block = block
|
sess.block = block
|
||||||
sess.recvbuf = make([]byte, mtuLimit)
|
sess.recvbuf = make([]byte, mtuLimit)
|
||||||
@ -320,7 +318,7 @@ func (s *UDPSession) Close() error {
|
|||||||
close(s.die)
|
close(s.die)
|
||||||
s.isClosed = true
|
s.isClosed = true
|
||||||
atomic.AddUint64(&DefaultSnmp.CurrEstab, ^uint64(0))
|
atomic.AddUint64(&DefaultSnmp.CurrEstab, ^uint64(0))
|
||||||
if s.l == nil && s.closeConn { // client socket close
|
if s.l == nil { // client socket close
|
||||||
return s.conn.Close()
|
return s.conn.Close()
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
@ -746,7 +744,7 @@ func (l *Listener) monitor() {
|
|||||||
|
|
||||||
if !ok { // new session
|
if !ok { // new session
|
||||||
if len(l.chAccepts) < cap(l.chAccepts) && len(l.sessions) < 4096 { // do not let new session overwhelm accept queue and connection count
|
if len(l.chAccepts) < cap(l.chAccepts) && len(l.sessions) < 4096 { // do not let new session overwhelm accept queue and connection count
|
||||||
s := newUDPSession(conv, l.dataShards, l.parityShards, l, l.conn, from, l.block, false)
|
s := newUDPSession(conv, l.dataShards, l.parityShards, l, l.conn, from, l.block)
|
||||||
s.kcpInput(data)
|
s.kcpInput(data)
|
||||||
l.sessions[key] = s
|
l.sessions[key] = s
|
||||||
l.chAccepts <- s
|
l.chAccepts <- s
|
||||||
@ -928,11 +926,11 @@ func DialWithOptions(raddr string, block BlockCrypt, dataShards, parityShards in
|
|||||||
return nil, errors.Wrap(err, "net.DialUDP")
|
return nil, errors.Wrap(err, "net.DialUDP")
|
||||||
}
|
}
|
||||||
|
|
||||||
return NewConn(raddr, block, dataShards, parityShards, &connectedUDPConn{udpconn}, true)
|
return NewConn(raddr, block, dataShards, parityShards, &connectedUDPConn{udpconn})
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewConn establishes a session and talks KCP protocol over a packet connection.
|
// NewConn establishes a session and talks KCP protocol over a packet connection.
|
||||||
func NewConn(raddr string, block BlockCrypt, dataShards, parityShards int, conn net.PacketConn, closeConn bool) (*UDPSession, error) {
|
func NewConn(raddr string, block BlockCrypt, dataShards, parityShards int, conn net.PacketConn) (*UDPSession, error) {
|
||||||
udpaddr, err := net.ResolveUDPAddr("udp", raddr)
|
udpaddr, err := net.ResolveUDPAddr("udp", raddr)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, errors.Wrap(err, "net.ResolveUDPAddr")
|
return nil, errors.Wrap(err, "net.ResolveUDPAddr")
|
||||||
@ -940,7 +938,7 @@ func NewConn(raddr string, block BlockCrypt, dataShards, parityShards int, conn
|
|||||||
|
|
||||||
var convid uint32
|
var convid uint32
|
||||||
binary.Read(rand.Reader, binary.LittleEndian, &convid)
|
binary.Read(rand.Reader, binary.LittleEndian, &convid)
|
||||||
return newUDPSession(convid, dataShards, parityShards, nil, conn, udpaddr, block, closeConn), nil
|
return newUDPSession(convid, dataShards, parityShards, nil, conn, udpaddr, block), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// returns current time in milliseconds
|
// returns current time in milliseconds
|
||||||
|
2
vendor/manifest
vendored
2
vendor/manifest
vendored
@ -21,7 +21,7 @@
|
|||||||
"importpath": "github.com/AudriusButkevicius/kcp-go",
|
"importpath": "github.com/AudriusButkevicius/kcp-go",
|
||||||
"repository": "https://github.com/AudriusButkevicius/kcp-go",
|
"repository": "https://github.com/AudriusButkevicius/kcp-go",
|
||||||
"vcs": "git",
|
"vcs": "git",
|
||||||
"revision": "0ccc04f3b8a7bdf53e2d4d6d0769adbc7cb3851a",
|
"revision": "d17218ba2121268b854dd84f2bb54679541c4048",
|
||||||
"branch": "master",
|
"branch": "master",
|
||||||
"notests": true
|
"notests": true
|
||||||
},
|
},
|
||||||
|
Loading…
Reference in New Issue
Block a user