lib/connections: Update quic (#6591)

* lib/connections: Update quic

* Fix freebsd builds?

* Undo x/sys and gopsutil update

* Update quic_dial.go

* Update quic_listen.go
This commit is contained in:
Audrius Butkevicius
2020-05-01 08:14:28 +01:00
committed by GitHub
parent bdb25f9ba5
commit ac7338f1f2
5 changed files with 203 additions and 16 deletions
+1 -1
View File
@@ -80,7 +80,7 @@ func (d *quicDialer) Dial(ctx context.Context, _ protocol.DeviceID, uri *url.URL
stream, err := session.OpenStreamSync(ctx)
if err != nil {
// It's ok to close these, this does not close the underlying packetConn.
_ = session.Close()
_ = session.CloseWithError(1, err.Error())
if createdConn != nil {
_ = createdConn.Close()
}
+1 -1
View File
@@ -145,7 +145,7 @@ func (t *quicListener) serve(ctx context.Context) error {
cancel()
if err != nil {
l.Debugf("failed to accept stream from %s: %v", session.RemoteAddr(), err)
_ = session.Close()
_ = session.CloseWithError(1, err.Error())
continue
}
+20 -1
View File
@@ -9,6 +9,7 @@
package connections
import (
"crypto/tls"
"net"
"github.com/lucas-clemente/quic-go"
@@ -30,7 +31,7 @@ type quicTlsConn struct {
func (q *quicTlsConn) Close() error {
sterr := q.Stream.Close()
seerr := q.Session.Close()
seerr := q.Session.CloseWithError(0, "closing")
var pcerr error
if q.createdConn != nil {
pcerr = q.createdConn.Close()
@@ -44,6 +45,24 @@ func (q *quicTlsConn) Close() error {
return pcerr
}
func (q *quicTlsConn) ConnectionState() tls.ConnectionState {
qcs := q.Session.ConnectionState()
return tls.ConnectionState{
Version: qcs.Version,
HandshakeComplete: qcs.HandshakeComplete,
DidResume: qcs.DidResume,
CipherSuite: qcs.CipherSuite,
NegotiatedProtocol: qcs.NegotiatedProtocol,
NegotiatedProtocolIsMutual: qcs.NegotiatedProtocolIsMutual,
ServerName: qcs.ServerName,
PeerCertificates: qcs.PeerCertificates,
VerifiedChains: qcs.VerifiedChains,
SignedCertificateTimestamps: qcs.SignedCertificateTimestamps,
OCSPResponse: qcs.OCSPResponse,
TLSUnique: qcs.TLSUnique,
}
}
// Sort available packet connections by ip address, preferring unspecified local address.
func packetConnLess(i interface{}, j interface{}) bool {
iIsUnspecified := false