浏览代码

vendor golang.org/x/net v0.0.0-20200707034311-ab3426394381

Signed-off-by: Jintao Zhang <zhangjintao9020@gmail.com>
Jintao Zhang 5 年之前
父节点
当前提交
2ee753a28f

+ 1 - 1
vendor.conf

@@ -12,7 +12,7 @@ github.com/creack/pty                               3a6a957789163cacdfe0e291617a
 github.com/konsorten/go-windows-terminal-sequences  edb144dfd453055e1e49a3d8b410a660b5a87613 # v1.0.3
 github.com/konsorten/go-windows-terminal-sequences  edb144dfd453055e1e49a3d8b410a660b5a87613 # v1.0.3
 github.com/sirupsen/logrus                          60c74ad9be0d874af0ab0daef6ab07c5c5911f0d # v1.6.0
 github.com/sirupsen/logrus                          60c74ad9be0d874af0ab0daef6ab07c5c5911f0d # v1.6.0
 github.com/tchap/go-patricia                        a7f0089c6f496e8e70402f61733606daa326cac5 # v2.3.0
 github.com/tchap/go-patricia                        a7f0089c6f496e8e70402f61733606daa326cac5 # v2.3.0
-golang.org/x/net                                    0de0cce0169b09b364e001f108dc0399ea8630b3
+golang.org/x/net                                    ab34263943818b32f575efc978a3d24e80b04bd7
 golang.org/x/sys                                    9dae0f8f577553e0f21298e18926efc9644c281d
 golang.org/x/sys                                    9dae0f8f577553e0f21298e18926efc9644c281d
 github.com/docker/go-units                          519db1ee28dcc9fd2474ae59fca29a810482bfb1 # v0.4.0
 github.com/docker/go-units                          519db1ee28dcc9fd2474ae59fca29a810482bfb1 # v0.4.0
 github.com/docker/go-connections                    7395e3f8aa162843a74ed6d48e79627d9792ac55 # v0.4.0
 github.com/docker/go-connections                    7395e3f8aa162843a74ed6d48e79627d9792ac55 # v0.4.0

+ 2 - 2
vendor/golang.org/x/net/go.mod

@@ -3,7 +3,7 @@ module golang.org/x/net
 go 1.11
 go 1.11
 
 
 require (
 require (
-	golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2
-	golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a
+	golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9
+	golang.org/x/sys v0.0.0-20200323222414-85ca7c5b95cd
 	golang.org/x/text v0.3.0
 	golang.org/x/text v0.3.0
 )
 )

+ 2 - 6
vendor/golang.org/x/net/http2/client_conn_pool.go

@@ -107,6 +107,7 @@ func (p *clientConnPool) getClientConn(req *http.Request, addr string, dialOnMis
 
 
 // dialCall is an in-flight Transport dial call to a host.
 // dialCall is an in-flight Transport dial call to a host.
 type dialCall struct {
 type dialCall struct {
+	_    incomparable
 	p    *clientConnPool
 	p    *clientConnPool
 	done chan struct{} // closed when done
 	done chan struct{} // closed when done
 	res  *ClientConn   // valid after done is closed
 	res  *ClientConn   // valid after done is closed
@@ -180,6 +181,7 @@ func (p *clientConnPool) addConnIfNeeded(key string, t *Transport, c *tls.Conn)
 }
 }
 
 
 type addConnCall struct {
 type addConnCall struct {
+	_    incomparable
 	p    *clientConnPool
 	p    *clientConnPool
 	done chan struct{} // closed when done
 	done chan struct{} // closed when done
 	err  error
 	err  error
@@ -200,12 +202,6 @@ func (c *addConnCall) run(t *Transport, key string, tc *tls.Conn) {
 	close(c.done)
 	close(c.done)
 }
 }
 
 
-func (p *clientConnPool) addConn(key string, cc *ClientConn) {
-	p.mu.Lock()
-	p.addConnLocked(key, cc)
-	p.mu.Unlock()
-}
-
 // p.mu must be held
 // p.mu must be held
 func (p *clientConnPool) addConnLocked(key string, cc *ClientConn) {
 func (p *clientConnPool) addConnLocked(key string, cc *ClientConn) {
 	for _, v := range p.conns[key] {
 	for _, v := range p.conns[key] {

+ 2 - 0
vendor/golang.org/x/net/http2/flow.go

@@ -8,6 +8,8 @@ package http2
 
 
 // flow is the flow control window's size.
 // flow is the flow control window's size.
 type flow struct {
 type flow struct {
+	_ incomparable
+
 	// n is the number of DATA bytes we're allowed to send.
 	// n is the number of DATA bytes we're allowed to send.
 	// A flow is kept both on a conn and a per-stream.
 	// A flow is kept both on a conn and a per-stream.
 	n int32
 	n int32

+ 7 - 0
vendor/golang.org/x/net/http2/hpack/huffman.go

@@ -105,7 +105,14 @@ func huffmanDecode(buf *bytes.Buffer, maxLen int, v []byte) error {
 	return nil
 	return nil
 }
 }
 
 
+// incomparable is a zero-width, non-comparable type. Adding it to a struct
+// makes that struct also non-comparable, and generally doesn't add
+// any size (as long as it's first).
+type incomparable [0]func()
+
 type node struct {
 type node struct {
+	_ incomparable
+
 	// children is non-nil for internal nodes
 	// children is non-nil for internal nodes
 	children *[256]*node
 	children *[256]*node
 
 

+ 7 - 0
vendor/golang.org/x/net/http2/http2.go

@@ -241,6 +241,7 @@ func (cw closeWaiter) Wait() {
 // Its buffered writer is lazily allocated as needed, to minimize
 // Its buffered writer is lazily allocated as needed, to minimize
 // idle memory usage with many connections.
 // idle memory usage with many connections.
 type bufferedWriter struct {
 type bufferedWriter struct {
+	_  incomparable
 	w  io.Writer     // immutable
 	w  io.Writer     // immutable
 	bw *bufio.Writer // non-nil when data is buffered
 	bw *bufio.Writer // non-nil when data is buffered
 }
 }
@@ -313,6 +314,7 @@ func bodyAllowedForStatus(status int) bool {
 }
 }
 
 
 type httpError struct {
 type httpError struct {
+	_       incomparable
 	msg     string
 	msg     string
 	timeout bool
 	timeout bool
 }
 }
@@ -376,3 +378,8 @@ func (s *sorter) SortStrings(ss []string) {
 func validPseudoPath(v string) bool {
 func validPseudoPath(v string) bool {
 	return (len(v) > 0 && v[0] == '/') || v == "*"
 	return (len(v) > 0 && v[0] == '/') || v == "*"
 }
 }
+
+// incomparable is a zero-width, non-comparable type. Adding it to a struct
+// makes that struct also non-comparable, and generally doesn't add
+// any size (as long as it's first).
+type incomparable [0]func()

+ 5 - 3
vendor/golang.org/x/net/http2/server.go

@@ -761,6 +761,7 @@ func (sc *serverConn) readFrames() {
 
 
 // frameWriteResult is the message passed from writeFrameAsync to the serve goroutine.
 // frameWriteResult is the message passed from writeFrameAsync to the serve goroutine.
 type frameWriteResult struct {
 type frameWriteResult struct {
+	_   incomparable
 	wr  FrameWriteRequest // what was written (or attempted)
 	wr  FrameWriteRequest // what was written (or attempted)
 	err error             // result of the writeFrame call
 	err error             // result of the writeFrame call
 }
 }
@@ -771,7 +772,7 @@ type frameWriteResult struct {
 // serverConn.
 // serverConn.
 func (sc *serverConn) writeFrameAsync(wr FrameWriteRequest) {
 func (sc *serverConn) writeFrameAsync(wr FrameWriteRequest) {
 	err := wr.write.writeFrame(sc)
 	err := wr.write.writeFrame(sc)
-	sc.wroteFrameCh <- frameWriteResult{wr, err}
+	sc.wroteFrameCh <- frameWriteResult{wr: wr, err: err}
 }
 }
 
 
 func (sc *serverConn) closeAllStreamsOnConnClose() {
 func (sc *serverConn) closeAllStreamsOnConnClose() {
@@ -1161,7 +1162,7 @@ func (sc *serverConn) startFrameWrite(wr FrameWriteRequest) {
 	if wr.write.staysWithinBuffer(sc.bw.Available()) {
 	if wr.write.staysWithinBuffer(sc.bw.Available()) {
 		sc.writingFrameAsync = false
 		sc.writingFrameAsync = false
 		err := wr.write.writeFrame(sc)
 		err := wr.write.writeFrame(sc)
-		sc.wroteFrame(frameWriteResult{wr, err})
+		sc.wroteFrame(frameWriteResult{wr: wr, err: err})
 	} else {
 	} else {
 		sc.writingFrameAsync = true
 		sc.writingFrameAsync = true
 		go sc.writeFrameAsync(wr)
 		go sc.writeFrameAsync(wr)
@@ -2057,7 +2058,7 @@ func (sc *serverConn) newWriterAndRequestNoBody(st *stream, rp requestParam) (*r
 	var trailer http.Header
 	var trailer http.Header
 	for _, v := range rp.header["Trailer"] {
 	for _, v := range rp.header["Trailer"] {
 		for _, key := range strings.Split(v, ",") {
 		for _, key := range strings.Split(v, ",") {
-			key = http.CanonicalHeaderKey(strings.TrimSpace(key))
+			key = http.CanonicalHeaderKey(textproto.TrimString(key))
 			switch key {
 			switch key {
 			case "Transfer-Encoding", "Trailer", "Content-Length":
 			case "Transfer-Encoding", "Trailer", "Content-Length":
 				// Bogus. (copy of http1 rules)
 				// Bogus. (copy of http1 rules)
@@ -2275,6 +2276,7 @@ func (sc *serverConn) sendWindowUpdate32(st *stream, n int32) {
 // requestBody is the Handler's Request.Body type.
 // requestBody is the Handler's Request.Body type.
 // Read and Close may be called concurrently.
 // Read and Close may be called concurrently.
 type requestBody struct {
 type requestBody struct {
+	_             incomparable
 	stream        *stream
 	stream        *stream
 	conn          *serverConn
 	conn          *serverConn
 	closed        bool  // for use by Close only
 	closed        bool  // for use by Close only

+ 81 - 16
vendor/golang.org/x/net/http2/transport.go

@@ -108,6 +108,19 @@ type Transport struct {
 	// waiting for their turn.
 	// waiting for their turn.
 	StrictMaxConcurrentStreams bool
 	StrictMaxConcurrentStreams bool
 
 
+	// ReadIdleTimeout is the timeout after which a health check using ping
+	// frame will be carried out if no frame is received on the connection.
+	// Note that a ping response will is considered a received frame, so if
+	// there is no other traffic on the connection, the health check will
+	// be performed every ReadIdleTimeout interval.
+	// If zero, no health check is performed.
+	ReadIdleTimeout time.Duration
+
+	// PingTimeout is the timeout after which the connection will be closed
+	// if a response to Ping is not received.
+	// Defaults to 15s.
+	PingTimeout time.Duration
+
 	// t1, if non-nil, is the standard library Transport using
 	// t1, if non-nil, is the standard library Transport using
 	// this transport. Its settings are used (but not its
 	// this transport. Its settings are used (but not its
 	// RoundTrip method, etc).
 	// RoundTrip method, etc).
@@ -131,6 +144,14 @@ func (t *Transport) disableCompression() bool {
 	return t.DisableCompression || (t.t1 != nil && t.t1.DisableCompression)
 	return t.DisableCompression || (t.t1 != nil && t.t1.DisableCompression)
 }
 }
 
 
+func (t *Transport) pingTimeout() time.Duration {
+	if t.PingTimeout == 0 {
+		return 15 * time.Second
+	}
+	return t.PingTimeout
+
+}
+
 // ConfigureTransport configures a net/http HTTP/1 Transport to use HTTP/2.
 // ConfigureTransport configures a net/http HTTP/1 Transport to use HTTP/2.
 // It returns an error if t1 has already been HTTP/2-enabled.
 // It returns an error if t1 has already been HTTP/2-enabled.
 func ConfigureTransport(t1 *http.Transport) error {
 func ConfigureTransport(t1 *http.Transport) error {
@@ -675,6 +696,20 @@ func (t *Transport) newClientConn(c net.Conn, singleUse bool) (*ClientConn, erro
 	return cc, nil
 	return cc, nil
 }
 }
 
 
+func (cc *ClientConn) healthCheck() {
+	pingTimeout := cc.t.pingTimeout()
+	// We don't need to periodically ping in the health check, because the readLoop of ClientConn will
+	// trigger the healthCheck again if there is no frame received.
+	ctx, cancel := context.WithTimeout(context.Background(), pingTimeout)
+	defer cancel()
+	err := cc.Ping(ctx)
+	if err != nil {
+		cc.closeForLostPing()
+		cc.t.connPool().MarkDead(cc)
+		return
+	}
+}
+
 func (cc *ClientConn) setGoAway(f *GoAwayFrame) {
 func (cc *ClientConn) setGoAway(f *GoAwayFrame) {
 	cc.mu.Lock()
 	cc.mu.Lock()
 	defer cc.mu.Unlock()
 	defer cc.mu.Unlock()
@@ -846,14 +881,12 @@ func (cc *ClientConn) sendGoAway() error {
 	return nil
 	return nil
 }
 }
 
 
-// Close closes the client connection immediately.
-//
-// In-flight requests are interrupted. For a graceful shutdown, use Shutdown instead.
-func (cc *ClientConn) Close() error {
+// closes the client connection immediately. In-flight requests are interrupted.
+// err is sent to streams.
+func (cc *ClientConn) closeForError(err error) error {
 	cc.mu.Lock()
 	cc.mu.Lock()
 	defer cc.cond.Broadcast()
 	defer cc.cond.Broadcast()
 	defer cc.mu.Unlock()
 	defer cc.mu.Unlock()
-	err := errors.New("http2: client connection force closed via ClientConn.Close")
 	for id, cs := range cc.streams {
 	for id, cs := range cc.streams {
 		select {
 		select {
 		case cs.resc <- resAndError{err: err}:
 		case cs.resc <- resAndError{err: err}:
@@ -866,6 +899,20 @@ func (cc *ClientConn) Close() error {
 	return cc.tconn.Close()
 	return cc.tconn.Close()
 }
 }
 
 
+// Close closes the client connection immediately.
+//
+// In-flight requests are interrupted. For a graceful shutdown, use Shutdown instead.
+func (cc *ClientConn) Close() error {
+	err := errors.New("http2: client connection force closed via ClientConn.Close")
+	return cc.closeForError(err)
+}
+
+// closes the client connection immediately. In-flight requests are interrupted.
+func (cc *ClientConn) closeForLostPing() error {
+	err := errors.New("http2: client connection lost")
+	return cc.closeForError(err)
+}
+
 const maxAllocFrameSize = 512 << 10
 const maxAllocFrameSize = 512 << 10
 
 
 // frameBuffer returns a scratch buffer suitable for writing DATA frames.
 // frameBuffer returns a scratch buffer suitable for writing DATA frames.
@@ -916,7 +963,7 @@ func commaSeparatedTrailers(req *http.Request) (string, error) {
 		k = http.CanonicalHeaderKey(k)
 		k = http.CanonicalHeaderKey(k)
 		switch k {
 		switch k {
 		case "Transfer-Encoding", "Trailer", "Content-Length":
 		case "Transfer-Encoding", "Trailer", "Content-Length":
-			return "", &badStringError{"invalid Trailer key", k}
+			return "", fmt.Errorf("invalid Trailer key %q", k)
 		}
 		}
 		keys = append(keys, k)
 		keys = append(keys, k)
 	}
 	}
@@ -1394,13 +1441,6 @@ func (cs *clientStream) awaitFlowControl(maxBytes int) (taken int32, err error)
 	}
 	}
 }
 }
 
 
-type badStringError struct {
-	what string
-	str  string
-}
-
-func (e *badStringError) Error() string { return fmt.Sprintf("%s %q", e.what, e.str) }
-
 // requires cc.mu be held.
 // requires cc.mu be held.
 func (cc *ClientConn) encodeHeaders(req *http.Request, addGzipHeader bool, trailers string, contentLength int64) ([]byte, error) {
 func (cc *ClientConn) encodeHeaders(req *http.Request, addGzipHeader bool, trailers string, contentLength int64) ([]byte, error) {
 	cc.hbuf.Reset()
 	cc.hbuf.Reset()
@@ -1616,6 +1656,7 @@ func (cc *ClientConn) writeHeader(name, value string) {
 }
 }
 
 
 type resAndError struct {
 type resAndError struct {
+	_   incomparable
 	res *http.Response
 	res *http.Response
 	err error
 	err error
 }
 }
@@ -1663,6 +1704,7 @@ func (cc *ClientConn) streamByID(id uint32, andRemove bool) *clientStream {
 
 
 // clientConnReadLoop is the state owned by the clientConn's frame-reading readLoop.
 // clientConnReadLoop is the state owned by the clientConn's frame-reading readLoop.
 type clientConnReadLoop struct {
 type clientConnReadLoop struct {
+	_             incomparable
 	cc            *ClientConn
 	cc            *ClientConn
 	closeWhenIdle bool
 	closeWhenIdle bool
 }
 }
@@ -1742,8 +1784,17 @@ func (rl *clientConnReadLoop) run() error {
 	rl.closeWhenIdle = cc.t.disableKeepAlives() || cc.singleUse
 	rl.closeWhenIdle = cc.t.disableKeepAlives() || cc.singleUse
 	gotReply := false // ever saw a HEADERS reply
 	gotReply := false // ever saw a HEADERS reply
 	gotSettings := false
 	gotSettings := false
+	readIdleTimeout := cc.t.ReadIdleTimeout
+	var t *time.Timer
+	if readIdleTimeout != 0 {
+		t = time.AfterFunc(readIdleTimeout, cc.healthCheck)
+		defer t.Stop()
+	}
 	for {
 	for {
 		f, err := cc.fr.ReadFrame()
 		f, err := cc.fr.ReadFrame()
+		if t != nil {
+			t.Reset(readIdleTimeout)
+		}
 		if err != nil {
 		if err != nil {
 			cc.vlogf("http2: Transport readFrame error on conn %p: (%T) %v", cc, err, err)
 			cc.vlogf("http2: Transport readFrame error on conn %p: (%T) %v", cc, err, err)
 		}
 		}
@@ -1892,7 +1943,9 @@ func (rl *clientConnReadLoop) handleResponse(cs *clientStream, f *MetaHeadersFra
 		return nil, errors.New("malformed response from server: malformed non-numeric status pseudo header")
 		return nil, errors.New("malformed response from server: malformed non-numeric status pseudo header")
 	}
 	}
 
 
-	header := make(http.Header)
+	regularFields := f.RegularFields()
+	strs := make([]string, len(regularFields))
+	header := make(http.Header, len(regularFields))
 	res := &http.Response{
 	res := &http.Response{
 		Proto:      "HTTP/2.0",
 		Proto:      "HTTP/2.0",
 		ProtoMajor: 2,
 		ProtoMajor: 2,
@@ -1900,7 +1953,7 @@ func (rl *clientConnReadLoop) handleResponse(cs *clientStream, f *MetaHeadersFra
 		StatusCode: statusCode,
 		StatusCode: statusCode,
 		Status:     status + " " + http.StatusText(statusCode),
 		Status:     status + " " + http.StatusText(statusCode),
 	}
 	}
-	for _, hf := range f.RegularFields() {
+	for _, hf := range regularFields {
 		key := http.CanonicalHeaderKey(hf.Name)
 		key := http.CanonicalHeaderKey(hf.Name)
 		if key == "Trailer" {
 		if key == "Trailer" {
 			t := res.Trailer
 			t := res.Trailer
@@ -1912,7 +1965,18 @@ func (rl *clientConnReadLoop) handleResponse(cs *clientStream, f *MetaHeadersFra
 				t[http.CanonicalHeaderKey(v)] = nil
 				t[http.CanonicalHeaderKey(v)] = nil
 			})
 			})
 		} else {
 		} else {
-			header[key] = append(header[key], hf.Value)
+			vv := header[key]
+			if vv == nil && len(strs) > 0 {
+				// More than likely this will be a single-element key.
+				// Most headers aren't multi-valued.
+				// Set the capacity on strs[0] to 1, so any future append
+				// won't extend the slice into the other strings.
+				vv, strs = strs[:1:1], strs[1:]
+				vv[0] = hf.Value
+				header[key] = vv
+			} else {
+				header[key] = append(vv, hf.Value)
+			}
 		}
 		}
 	}
 	}
 
 
@@ -2466,6 +2530,7 @@ func (rt erringRoundTripper) RoundTrip(*http.Request) (*http.Response, error) {
 // gzipReader wraps a response body so it can lazily
 // gzipReader wraps a response body so it can lazily
 // call gzip.NewReader on the first call to Read
 // call gzip.NewReader on the first call to Read
 type gzipReader struct {
 type gzipReader struct {
+	_    incomparable
 	body io.ReadCloser // underlying Response.Body
 	body io.ReadCloser // underlying Response.Body
 	zr   *gzip.Reader  // lazily-initialized gzip reader
 	zr   *gzip.Reader  // lazily-initialized gzip reader
 	zerr error         // sticky error
 	zerr error         // sticky error

+ 2 - 3
vendor/golang.org/x/net/ipv4/header.go

@@ -14,9 +14,8 @@ import (
 )
 )
 
 
 const (
 const (
-	Version      = 4  // protocol version
-	HeaderLen    = 20 // header length without extension headers
-	maxHeaderLen = 60 // sensible default, revisit if later RFCs define new usage of version and header length fields
+	Version   = 4  // protocol version
+	HeaderLen = 20 // header length without extension headers
 )
 )
 
 
 type HeaderFlags int
 type HeaderFlags int