mirror of
https://github.com/chai2010/advanced-go-programming-book.git
synced 2025-05-24 20:52:22 +00:00
vendor: 添加缺少的包
This commit is contained in:
parent
32fe1c2833
commit
6e33b20110
0
vendor/golang.org/x/net/http2/Dockerfile
generated
vendored
Executable file → Normal file
0
vendor/golang.org/x/net/http2/Dockerfile
generated
vendored
Executable file → Normal file
0
vendor/golang.org/x/net/http2/Makefile
generated
vendored
Executable file → Normal file
0
vendor/golang.org/x/net/http2/Makefile
generated
vendored
Executable file → Normal file
0
vendor/golang.org/x/net/http2/README
generated
vendored
Executable file → Normal file
0
vendor/golang.org/x/net/http2/README
generated
vendored
Executable file → Normal file
0
vendor/golang.org/x/net/http2/ciphers.go
generated
vendored
Executable file → Normal file
0
vendor/golang.org/x/net/http2/ciphers.go
generated
vendored
Executable file → Normal file
0
vendor/golang.org/x/net/http2/ciphers_test.go
generated
vendored
Executable file → Normal file
0
vendor/golang.org/x/net/http2/ciphers_test.go
generated
vendored
Executable file → Normal file
28
vendor/golang.org/x/net/http2/client_conn_pool.go
generated
vendored
Executable file → Normal file
28
vendor/golang.org/x/net/http2/client_conn_pool.go
generated
vendored
Executable file → Normal file
@ -52,9 +52,31 @@ const (
|
|||||||
noDialOnMiss = false
|
noDialOnMiss = false
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// shouldTraceGetConn reports whether getClientConn should call any
|
||||||
|
// ClientTrace.GetConn hook associated with the http.Request.
|
||||||
|
//
|
||||||
|
// This complexity is needed to avoid double calls of the GetConn hook
|
||||||
|
// during the back-and-forth between net/http and x/net/http2 (when the
|
||||||
|
// net/http.Transport is upgraded to also speak http2), as well as support
|
||||||
|
// the case where x/net/http2 is being used directly.
|
||||||
|
func (p *clientConnPool) shouldTraceGetConn(st clientConnIdleState) bool {
|
||||||
|
// If our Transport wasn't made via ConfigureTransport, always
|
||||||
|
// trace the GetConn hook if provided, because that means the
|
||||||
|
// http2 package is being used directly and it's the one
|
||||||
|
// dialing, as opposed to net/http.
|
||||||
|
if _, ok := p.t.ConnPool.(noDialClientConnPool); !ok {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
// Otherwise, only use the GetConn hook if this connection has
|
||||||
|
// been used previously for other requests. For fresh
|
||||||
|
// connections, the net/http package does the dialing.
|
||||||
|
return !st.freshConn
|
||||||
|
}
|
||||||
|
|
||||||
func (p *clientConnPool) getClientConn(req *http.Request, addr string, dialOnMiss bool) (*ClientConn, error) {
|
func (p *clientConnPool) getClientConn(req *http.Request, addr string, dialOnMiss bool) (*ClientConn, error) {
|
||||||
if isConnectionCloseRequest(req) && dialOnMiss {
|
if isConnectionCloseRequest(req) && dialOnMiss {
|
||||||
// It gets its own connection.
|
// It gets its own connection.
|
||||||
|
traceGetConn(req, addr)
|
||||||
const singleUse = true
|
const singleUse = true
|
||||||
cc, err := p.t.dialClientConn(addr, singleUse)
|
cc, err := p.t.dialClientConn(addr, singleUse)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -64,7 +86,10 @@ func (p *clientConnPool) getClientConn(req *http.Request, addr string, dialOnMis
|
|||||||
}
|
}
|
||||||
p.mu.Lock()
|
p.mu.Lock()
|
||||||
for _, cc := range p.conns[addr] {
|
for _, cc := range p.conns[addr] {
|
||||||
if cc.CanTakeNewRequest() {
|
if st := cc.idleState(); st.canTakeNewRequest {
|
||||||
|
if p.shouldTraceGetConn(st) {
|
||||||
|
traceGetConn(req, addr)
|
||||||
|
}
|
||||||
p.mu.Unlock()
|
p.mu.Unlock()
|
||||||
return cc, nil
|
return cc, nil
|
||||||
}
|
}
|
||||||
@ -73,6 +98,7 @@ func (p *clientConnPool) getClientConn(req *http.Request, addr string, dialOnMis
|
|||||||
p.mu.Unlock()
|
p.mu.Unlock()
|
||||||
return nil, ErrNoCachedConn
|
return nil, ErrNoCachedConn
|
||||||
}
|
}
|
||||||
|
traceGetConn(req, addr)
|
||||||
call := p.getStartDialLocked(addr)
|
call := p.getStartDialLocked(addr)
|
||||||
p.mu.Unlock()
|
p.mu.Unlock()
|
||||||
<-call.done
|
<-call.done
|
||||||
|
8
vendor/golang.org/x/net/http2/configure_transport.go
generated
vendored
Executable file → Normal file
8
vendor/golang.org/x/net/http2/configure_transport.go
generated
vendored
Executable file → Normal file
@ -57,7 +57,7 @@ func configureTransport(t1 *http.Transport) (*Transport, error) {
|
|||||||
|
|
||||||
// registerHTTPSProtocol calls Transport.RegisterProtocol but
|
// registerHTTPSProtocol calls Transport.RegisterProtocol but
|
||||||
// converting panics into errors.
|
// converting panics into errors.
|
||||||
func registerHTTPSProtocol(t *http.Transport, rt http.RoundTripper) (err error) {
|
func registerHTTPSProtocol(t *http.Transport, rt noDialH2RoundTripper) (err error) {
|
||||||
defer func() {
|
defer func() {
|
||||||
if e := recover(); e != nil {
|
if e := recover(); e != nil {
|
||||||
err = fmt.Errorf("%v", e)
|
err = fmt.Errorf("%v", e)
|
||||||
@ -69,10 +69,12 @@ func registerHTTPSProtocol(t *http.Transport, rt http.RoundTripper) (err error)
|
|||||||
|
|
||||||
// noDialH2RoundTripper is a RoundTripper which only tries to complete the request
|
// noDialH2RoundTripper is a RoundTripper which only tries to complete the request
|
||||||
// if there's already has a cached connection to the host.
|
// if there's already has a cached connection to the host.
|
||||||
type noDialH2RoundTripper struct{ t *Transport }
|
// (The field is exported so it can be accessed via reflect from net/http; tested
|
||||||
|
// by TestNoDialH2RoundTripperType)
|
||||||
|
type noDialH2RoundTripper struct{ *Transport }
|
||||||
|
|
||||||
func (rt noDialH2RoundTripper) RoundTrip(req *http.Request) (*http.Response, error) {
|
func (rt noDialH2RoundTripper) RoundTrip(req *http.Request) (*http.Response, error) {
|
||||||
res, err := rt.t.RoundTrip(req)
|
res, err := rt.Transport.RoundTrip(req)
|
||||||
if isNoCachedConnError(err) {
|
if isNoCachedConnError(err) {
|
||||||
return nil, http.ErrSkipAltProtocol
|
return nil, http.ErrSkipAltProtocol
|
||||||
}
|
}
|
||||||
|
0
vendor/golang.org/x/net/http2/databuffer.go
generated
vendored
Executable file → Normal file
0
vendor/golang.org/x/net/http2/databuffer.go
generated
vendored
Executable file → Normal file
0
vendor/golang.org/x/net/http2/databuffer_test.go
generated
vendored
Executable file → Normal file
0
vendor/golang.org/x/net/http2/databuffer_test.go
generated
vendored
Executable file → Normal file
0
vendor/golang.org/x/net/http2/errors.go
generated
vendored
Executable file → Normal file
0
vendor/golang.org/x/net/http2/errors.go
generated
vendored
Executable file → Normal file
0
vendor/golang.org/x/net/http2/errors_test.go
generated
vendored
Executable file → Normal file
0
vendor/golang.org/x/net/http2/errors_test.go
generated
vendored
Executable file → Normal file
0
vendor/golang.org/x/net/http2/flow.go
generated
vendored
Executable file → Normal file
0
vendor/golang.org/x/net/http2/flow.go
generated
vendored
Executable file → Normal file
0
vendor/golang.org/x/net/http2/flow_test.go
generated
vendored
Executable file → Normal file
0
vendor/golang.org/x/net/http2/flow_test.go
generated
vendored
Executable file → Normal file
0
vendor/golang.org/x/net/http2/frame.go
generated
vendored
Executable file → Normal file
0
vendor/golang.org/x/net/http2/frame.go
generated
vendored
Executable file → Normal file
0
vendor/golang.org/x/net/http2/frame_test.go
generated
vendored
Executable file → Normal file
0
vendor/golang.org/x/net/http2/frame_test.go
generated
vendored
Executable file → Normal file
26
vendor/golang.org/x/net/http2/go111.go
generated
vendored
Normal file
26
vendor/golang.org/x/net/http2/go111.go
generated
vendored
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
// Copyright 2018 The Go Authors. All rights reserved.
|
||||||
|
// Use of this source code is governed by a BSD-style
|
||||||
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
|
// +build go1.11
|
||||||
|
|
||||||
|
package http2
|
||||||
|
|
||||||
|
import "net/textproto"
|
||||||
|
|
||||||
|
func traceHasWroteHeaderField(trace *clientTrace) bool {
|
||||||
|
return trace != nil && trace.WroteHeaderField != nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func traceWroteHeaderField(trace *clientTrace, k, v string) {
|
||||||
|
if trace != nil && trace.WroteHeaderField != nil {
|
||||||
|
trace.WroteHeaderField(k, []string{v})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func traceGot1xxResponseFunc(trace *clientTrace) func(int, textproto.MIMEHeader) error {
|
||||||
|
if trace != nil {
|
||||||
|
return trace.Got1xxResponse
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
0
vendor/golang.org/x/net/http2/go16.go
generated
vendored
Executable file → Normal file
0
vendor/golang.org/x/net/http2/go16.go
generated
vendored
Executable file → Normal file
15
vendor/golang.org/x/net/http2/go17.go
generated
vendored
Executable file → Normal file
15
vendor/golang.org/x/net/http2/go17.go
generated
vendored
Executable file → Normal file
@ -18,6 +18,8 @@ type contextContext interface {
|
|||||||
context.Context
|
context.Context
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var errCanceled = context.Canceled
|
||||||
|
|
||||||
func serverConnBaseContext(c net.Conn, opts *ServeConnOpts) (ctx contextContext, cancel func()) {
|
func serverConnBaseContext(c net.Conn, opts *ServeConnOpts) (ctx contextContext, cancel func()) {
|
||||||
ctx, cancel = context.WithCancel(context.Background())
|
ctx, cancel = context.WithCancel(context.Background())
|
||||||
ctx = context.WithValue(ctx, http.LocalAddrContextKey, c.LocalAddr())
|
ctx = context.WithValue(ctx, http.LocalAddrContextKey, c.LocalAddr())
|
||||||
@ -48,6 +50,14 @@ func (t *Transport) idleConnTimeout() time.Duration {
|
|||||||
|
|
||||||
func setResponseUncompressed(res *http.Response) { res.Uncompressed = true }
|
func setResponseUncompressed(res *http.Response) { res.Uncompressed = true }
|
||||||
|
|
||||||
|
func traceGetConn(req *http.Request, hostPort string) {
|
||||||
|
trace := httptrace.ContextClientTrace(req.Context())
|
||||||
|
if trace == nil || trace.GetConn == nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
trace.GetConn(hostPort)
|
||||||
|
}
|
||||||
|
|
||||||
func traceGotConn(req *http.Request, cc *ClientConn) {
|
func traceGotConn(req *http.Request, cc *ClientConn) {
|
||||||
trace := httptrace.ContextClientTrace(req.Context())
|
trace := httptrace.ContextClientTrace(req.Context())
|
||||||
if trace == nil || trace.GotConn == nil {
|
if trace == nil || trace.GotConn == nil {
|
||||||
@ -104,3 +114,8 @@ func requestTrace(req *http.Request) *clientTrace {
|
|||||||
func (cc *ClientConn) Ping(ctx context.Context) error {
|
func (cc *ClientConn) Ping(ctx context.Context) error {
|
||||||
return cc.ping(ctx)
|
return cc.ping(ctx)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Shutdown gracefully closes the client connection, waiting for running streams to complete.
|
||||||
|
func (cc *ClientConn) Shutdown(ctx context.Context) error {
|
||||||
|
return cc.shutdown(ctx)
|
||||||
|
}
|
||||||
|
0
vendor/golang.org/x/net/http2/go17_not18.go
generated
vendored
Executable file → Normal file
0
vendor/golang.org/x/net/http2/go17_not18.go
generated
vendored
Executable file → Normal file
0
vendor/golang.org/x/net/http2/go18.go
generated
vendored
Executable file → Normal file
0
vendor/golang.org/x/net/http2/go18.go
generated
vendored
Executable file → Normal file
0
vendor/golang.org/x/net/http2/go18_test.go
generated
vendored
Executable file → Normal file
0
vendor/golang.org/x/net/http2/go18_test.go
generated
vendored
Executable file → Normal file
0
vendor/golang.org/x/net/http2/go19.go
generated
vendored
Executable file → Normal file
0
vendor/golang.org/x/net/http2/go19.go
generated
vendored
Executable file → Normal file
0
vendor/golang.org/x/net/http2/go19_test.go
generated
vendored
Executable file → Normal file
0
vendor/golang.org/x/net/http2/go19_test.go
generated
vendored
Executable file → Normal file
0
vendor/golang.org/x/net/http2/gotrack.go
generated
vendored
Executable file → Normal file
0
vendor/golang.org/x/net/http2/gotrack.go
generated
vendored
Executable file → Normal file
0
vendor/golang.org/x/net/http2/gotrack_test.go
generated
vendored
Executable file → Normal file
0
vendor/golang.org/x/net/http2/gotrack_test.go
generated
vendored
Executable file → Normal file
0
vendor/golang.org/x/net/http2/h2demo/.gitignore
generated
vendored
Executable file → Normal file
0
vendor/golang.org/x/net/http2/h2demo/.gitignore
generated
vendored
Executable file → Normal file
0
vendor/golang.org/x/net/http2/h2demo/Dockerfile
generated
vendored
Executable file → Normal file
0
vendor/golang.org/x/net/http2/h2demo/Dockerfile
generated
vendored
Executable file → Normal file
0
vendor/golang.org/x/net/http2/h2demo/Dockerfile.0
generated
vendored
Executable file → Normal file
0
vendor/golang.org/x/net/http2/h2demo/Dockerfile.0
generated
vendored
Executable file → Normal file
0
vendor/golang.org/x/net/http2/h2demo/Makefile
generated
vendored
Executable file → Normal file
0
vendor/golang.org/x/net/http2/h2demo/Makefile
generated
vendored
Executable file → Normal file
0
vendor/golang.org/x/net/http2/h2demo/README
generated
vendored
Executable file → Normal file
0
vendor/golang.org/x/net/http2/h2demo/README
generated
vendored
Executable file → Normal file
0
vendor/golang.org/x/net/http2/h2demo/deployment-prod.yaml
generated
vendored
Executable file → Normal file
0
vendor/golang.org/x/net/http2/h2demo/deployment-prod.yaml
generated
vendored
Executable file → Normal file
0
vendor/golang.org/x/net/http2/h2demo/h2demo.go
generated
vendored
Executable file → Normal file
0
vendor/golang.org/x/net/http2/h2demo/h2demo.go
generated
vendored
Executable file → Normal file
0
vendor/golang.org/x/net/http2/h2demo/launch.go
generated
vendored
Executable file → Normal file
0
vendor/golang.org/x/net/http2/h2demo/launch.go
generated
vendored
Executable file → Normal file
0
vendor/golang.org/x/net/http2/h2demo/rootCA.key
generated
vendored
Executable file → Normal file
0
vendor/golang.org/x/net/http2/h2demo/rootCA.key
generated
vendored
Executable file → Normal file
0
vendor/golang.org/x/net/http2/h2demo/rootCA.pem
generated
vendored
Executable file → Normal file
0
vendor/golang.org/x/net/http2/h2demo/rootCA.pem
generated
vendored
Executable file → Normal file
0
vendor/golang.org/x/net/http2/h2demo/rootCA.srl
generated
vendored
Executable file → Normal file
0
vendor/golang.org/x/net/http2/h2demo/rootCA.srl
generated
vendored
Executable file → Normal file
0
vendor/golang.org/x/net/http2/h2demo/server.crt
generated
vendored
Executable file → Normal file
0
vendor/golang.org/x/net/http2/h2demo/server.crt
generated
vendored
Executable file → Normal file
0
vendor/golang.org/x/net/http2/h2demo/server.key
generated
vendored
Executable file → Normal file
0
vendor/golang.org/x/net/http2/h2demo/server.key
generated
vendored
Executable file → Normal file
0
vendor/golang.org/x/net/http2/h2demo/service.yaml
generated
vendored
Executable file → Normal file
0
vendor/golang.org/x/net/http2/h2demo/service.yaml
generated
vendored
Executable file → Normal file
0
vendor/golang.org/x/net/http2/h2demo/tmpl.go
generated
vendored
Executable file → Normal file
0
vendor/golang.org/x/net/http2/h2demo/tmpl.go
generated
vendored
Executable file → Normal file
0
vendor/golang.org/x/net/http2/h2i/README.md
generated
vendored
Executable file → Normal file
0
vendor/golang.org/x/net/http2/h2i/README.md
generated
vendored
Executable file → Normal file
2
vendor/golang.org/x/net/http2/h2i/h2i.go
generated
vendored
Executable file → Normal file
2
vendor/golang.org/x/net/http2/h2i/h2i.go
generated
vendored
Executable file → Normal file
@ -2,7 +2,7 @@
|
|||||||
// Use of this source code is governed by a BSD-style
|
// Use of this source code is governed by a BSD-style
|
||||||
// license that can be found in the LICENSE file.
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
// +build !plan9,!solaris
|
// +build !js,!nacl,!plan9,!solaris
|
||||||
|
|
||||||
/*
|
/*
|
||||||
The h2i command is an interactive HTTP/2 console.
|
The h2i command is an interactive HTTP/2 console.
|
||||||
|
0
vendor/golang.org/x/net/http2/headermap.go
generated
vendored
Executable file → Normal file
0
vendor/golang.org/x/net/http2/headermap.go
generated
vendored
Executable file → Normal file
0
vendor/golang.org/x/net/http2/hpack/encode.go
generated
vendored
Executable file → Normal file
0
vendor/golang.org/x/net/http2/hpack/encode.go
generated
vendored
Executable file → Normal file
0
vendor/golang.org/x/net/http2/hpack/encode_test.go
generated
vendored
Executable file → Normal file
0
vendor/golang.org/x/net/http2/hpack/encode_test.go
generated
vendored
Executable file → Normal file
0
vendor/golang.org/x/net/http2/hpack/hpack.go
generated
vendored
Executable file → Normal file
0
vendor/golang.org/x/net/http2/hpack/hpack.go
generated
vendored
Executable file → Normal file
0
vendor/golang.org/x/net/http2/hpack/hpack_test.go
generated
vendored
Executable file → Normal file
0
vendor/golang.org/x/net/http2/hpack/hpack_test.go
generated
vendored
Executable file → Normal file
0
vendor/golang.org/x/net/http2/hpack/huffman.go
generated
vendored
Executable file → Normal file
0
vendor/golang.org/x/net/http2/hpack/huffman.go
generated
vendored
Executable file → Normal file
0
vendor/golang.org/x/net/http2/hpack/tables.go
generated
vendored
Executable file → Normal file
0
vendor/golang.org/x/net/http2/hpack/tables.go
generated
vendored
Executable file → Normal file
0
vendor/golang.org/x/net/http2/hpack/tables_test.go
generated
vendored
Executable file → Normal file
0
vendor/golang.org/x/net/http2/hpack/tables_test.go
generated
vendored
Executable file → Normal file
0
vendor/golang.org/x/net/http2/http2.go
generated
vendored
Executable file → Normal file
0
vendor/golang.org/x/net/http2/http2.go
generated
vendored
Executable file → Normal file
0
vendor/golang.org/x/net/http2/http2_test.go
generated
vendored
Executable file → Normal file
0
vendor/golang.org/x/net/http2/http2_test.go
generated
vendored
Executable file → Normal file
17
vendor/golang.org/x/net/http2/not_go111.go
generated
vendored
Normal file
17
vendor/golang.org/x/net/http2/not_go111.go
generated
vendored
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
// Copyright 2018 The Go Authors. All rights reserved.
|
||||||
|
// Use of this source code is governed by a BSD-style
|
||||||
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
|
// +build !go1.11
|
||||||
|
|
||||||
|
package http2
|
||||||
|
|
||||||
|
import "net/textproto"
|
||||||
|
|
||||||
|
func traceHasWroteHeaderField(trace *clientTrace) bool { return false }
|
||||||
|
|
||||||
|
func traceWroteHeaderField(trace *clientTrace, k, v string) {}
|
||||||
|
|
||||||
|
func traceGot1xxResponseFunc(trace *clientTrace) func(int, textproto.MIMEHeader) error {
|
||||||
|
return nil
|
||||||
|
}
|
0
vendor/golang.org/x/net/http2/not_go16.go
generated
vendored
Executable file → Normal file
0
vendor/golang.org/x/net/http2/not_go16.go
generated
vendored
Executable file → Normal file
8
vendor/golang.org/x/net/http2/not_go17.go
generated
vendored
Executable file → Normal file
8
vendor/golang.org/x/net/http2/not_go17.go
generated
vendored
Executable file → Normal file
@ -8,6 +8,7 @@ package http2
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"crypto/tls"
|
"crypto/tls"
|
||||||
|
"errors"
|
||||||
"net"
|
"net"
|
||||||
"net/http"
|
"net/http"
|
||||||
"time"
|
"time"
|
||||||
@ -18,6 +19,8 @@ type contextContext interface {
|
|||||||
Err() error
|
Err() error
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var errCanceled = errors.New("canceled")
|
||||||
|
|
||||||
type fakeContext struct{}
|
type fakeContext struct{}
|
||||||
|
|
||||||
func (fakeContext) Done() <-chan struct{} { return nil }
|
func (fakeContext) Done() <-chan struct{} { return nil }
|
||||||
@ -34,6 +37,7 @@ func setResponseUncompressed(res *http.Response) {
|
|||||||
type clientTrace struct{}
|
type clientTrace struct{}
|
||||||
|
|
||||||
func requestTrace(*http.Request) *clientTrace { return nil }
|
func requestTrace(*http.Request) *clientTrace { return nil }
|
||||||
|
func traceGetConn(*http.Request, string) {}
|
||||||
func traceGotConn(*http.Request, *ClientConn) {}
|
func traceGotConn(*http.Request, *ClientConn) {}
|
||||||
func traceFirstResponseByte(*clientTrace) {}
|
func traceFirstResponseByte(*clientTrace) {}
|
||||||
func traceWroteHeaders(*clientTrace) {}
|
func traceWroteHeaders(*clientTrace) {}
|
||||||
@ -84,4 +88,8 @@ func (cc *ClientConn) Ping(ctx contextContext) error {
|
|||||||
return cc.ping(ctx)
|
return cc.ping(ctx)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (cc *ClientConn) Shutdown(ctx contextContext) error {
|
||||||
|
return cc.shutdown(ctx)
|
||||||
|
}
|
||||||
|
|
||||||
func (t *Transport) idleConnTimeout() time.Duration { return 0 }
|
func (t *Transport) idleConnTimeout() time.Duration { return 0 }
|
||||||
|
0
vendor/golang.org/x/net/http2/not_go18.go
generated
vendored
Executable file → Normal file
0
vendor/golang.org/x/net/http2/not_go18.go
generated
vendored
Executable file → Normal file
0
vendor/golang.org/x/net/http2/not_go19.go
generated
vendored
Executable file → Normal file
0
vendor/golang.org/x/net/http2/not_go19.go
generated
vendored
Executable file → Normal file
0
vendor/golang.org/x/net/http2/pipe.go
generated
vendored
Executable file → Normal file
0
vendor/golang.org/x/net/http2/pipe.go
generated
vendored
Executable file → Normal file
0
vendor/golang.org/x/net/http2/pipe_test.go
generated
vendored
Executable file → Normal file
0
vendor/golang.org/x/net/http2/pipe_test.go
generated
vendored
Executable file → Normal file
13
vendor/golang.org/x/net/http2/server.go
generated
vendored
Executable file → Normal file
13
vendor/golang.org/x/net/http2/server.go
generated
vendored
Executable file → Normal file
@ -1575,6 +1575,12 @@ func (sc *serverConn) processData(f *DataFrame) error {
|
|||||||
// type PROTOCOL_ERROR."
|
// type PROTOCOL_ERROR."
|
||||||
return ConnectionError(ErrCodeProtocol)
|
return ConnectionError(ErrCodeProtocol)
|
||||||
}
|
}
|
||||||
|
// RFC 7540, sec 6.1: If a DATA frame is received whose stream is not in
|
||||||
|
// "open" or "half-closed (local)" state, the recipient MUST respond with a
|
||||||
|
// stream error (Section 5.4.2) of type STREAM_CLOSED.
|
||||||
|
if state == stateClosed {
|
||||||
|
return streamError(id, ErrCodeStreamClosed)
|
||||||
|
}
|
||||||
if st == nil || state != stateOpen || st.gotTrailerHeader || st.resetQueued {
|
if st == nil || state != stateOpen || st.gotTrailerHeader || st.resetQueued {
|
||||||
// This includes sending a RST_STREAM if the stream is
|
// This includes sending a RST_STREAM if the stream is
|
||||||
// in stateHalfClosedLocal (which currently means that
|
// in stateHalfClosedLocal (which currently means that
|
||||||
@ -1721,6 +1727,13 @@ func (sc *serverConn) processHeaders(f *MetaHeadersFrame) error {
|
|||||||
// processing this frame.
|
// processing this frame.
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
// RFC 7540, sec 5.1: If an endpoint receives additional frames, other than
|
||||||
|
// WINDOW_UPDATE, PRIORITY, or RST_STREAM, for a stream that is in
|
||||||
|
// this state, it MUST respond with a stream error (Section 5.4.2) of
|
||||||
|
// type STREAM_CLOSED.
|
||||||
|
if st.state == stateHalfClosedRemote {
|
||||||
|
return streamError(id, ErrCodeStreamClosed)
|
||||||
|
}
|
||||||
return st.processTrailerHeaders(f)
|
return st.processTrailerHeaders(f)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
0
vendor/golang.org/x/net/http2/server_push_test.go
generated
vendored
Executable file → Normal file
0
vendor/golang.org/x/net/http2/server_push_test.go
generated
vendored
Executable file → Normal file
51
vendor/golang.org/x/net/http2/server_test.go
generated
vendored
Executable file → Normal file
51
vendor/golang.org/x/net/http2/server_test.go
generated
vendored
Executable file → Normal file
@ -2396,9 +2396,6 @@ func TestServer_NoCrash_HandlerClose_Then_ClientClose(t *testing.T) {
|
|||||||
// it did before.
|
// it did before.
|
||||||
st.writeData(1, true, []byte("foo"))
|
st.writeData(1, true, []byte("foo"))
|
||||||
|
|
||||||
// Get our flow control bytes back, since the handler didn't get them.
|
|
||||||
st.wantWindowUpdate(0, uint32(len("foo")))
|
|
||||||
|
|
||||||
// Sent after a peer sends data anyway (admittedly the
|
// Sent after a peer sends data anyway (admittedly the
|
||||||
// previous RST_STREAM might've still been in-flight),
|
// previous RST_STREAM might've still been in-flight),
|
||||||
// but they'll get the more friendly 'cancel' code
|
// but they'll get the more friendly 'cancel' code
|
||||||
@ -3841,3 +3838,51 @@ func TestServerHandlerConnectionClose(t *testing.T) {
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestServer_Headers_HalfCloseRemote(t *testing.T) {
|
||||||
|
var st *serverTester
|
||||||
|
writeData := make(chan bool)
|
||||||
|
writeHeaders := make(chan bool)
|
||||||
|
leaveHandler := make(chan bool)
|
||||||
|
st = newServerTester(t, func(w http.ResponseWriter, r *http.Request) {
|
||||||
|
if st.stream(1) == nil {
|
||||||
|
t.Errorf("nil stream 1 in handler")
|
||||||
|
}
|
||||||
|
if got, want := st.streamState(1), stateOpen; got != want {
|
||||||
|
t.Errorf("in handler, state is %v; want %v", got, want)
|
||||||
|
}
|
||||||
|
writeData <- true
|
||||||
|
if n, err := r.Body.Read(make([]byte, 1)); n != 0 || err != io.EOF {
|
||||||
|
t.Errorf("body read = %d, %v; want 0, EOF", n, err)
|
||||||
|
}
|
||||||
|
if got, want := st.streamState(1), stateHalfClosedRemote; got != want {
|
||||||
|
t.Errorf("in handler, state is %v; want %v", got, want)
|
||||||
|
}
|
||||||
|
writeHeaders <- true
|
||||||
|
|
||||||
|
<-leaveHandler
|
||||||
|
})
|
||||||
|
st.greet()
|
||||||
|
|
||||||
|
st.writeHeaders(HeadersFrameParam{
|
||||||
|
StreamID: 1,
|
||||||
|
BlockFragment: st.encodeHeader(),
|
||||||
|
EndStream: false, // keep it open
|
||||||
|
EndHeaders: true,
|
||||||
|
})
|
||||||
|
<-writeData
|
||||||
|
st.writeData(1, true, nil)
|
||||||
|
|
||||||
|
<-writeHeaders
|
||||||
|
|
||||||
|
st.writeHeaders(HeadersFrameParam{
|
||||||
|
StreamID: 1,
|
||||||
|
BlockFragment: st.encodeHeader(),
|
||||||
|
EndStream: false, // keep it open
|
||||||
|
EndHeaders: true,
|
||||||
|
})
|
||||||
|
|
||||||
|
defer close(leaveHandler)
|
||||||
|
|
||||||
|
st.wantRSTStream(1, ErrCodeStreamClosed)
|
||||||
|
}
|
||||||
|
0
vendor/golang.org/x/net/http2/testdata/draft-ietf-httpbis-http2.xml
generated
vendored
Executable file → Normal file
0
vendor/golang.org/x/net/http2/testdata/draft-ietf-httpbis-http2.xml
generated
vendored
Executable file → Normal file
207
vendor/golang.org/x/net/http2/transport.go
generated
vendored
Executable file → Normal file
207
vendor/golang.org/x/net/http2/transport.go
generated
vendored
Executable file → Normal file
@ -21,6 +21,7 @@ import (
|
|||||||
mathrand "math/rand"
|
mathrand "math/rand"
|
||||||
"net"
|
"net"
|
||||||
"net/http"
|
"net/http"
|
||||||
|
"net/textproto"
|
||||||
"sort"
|
"sort"
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
@ -159,6 +160,7 @@ type ClientConn struct {
|
|||||||
cond *sync.Cond // hold mu; broadcast on flow/closed changes
|
cond *sync.Cond // hold mu; broadcast on flow/closed changes
|
||||||
flow flow // our conn-level flow control quota (cs.flow is per stream)
|
flow flow // our conn-level flow control quota (cs.flow is per stream)
|
||||||
inflow flow // peer's conn-level flow control
|
inflow flow // peer's conn-level flow control
|
||||||
|
closing bool
|
||||||
closed bool
|
closed bool
|
||||||
wantSettingsAck bool // we sent a SETTINGS frame and haven't heard back
|
wantSettingsAck bool // we sent a SETTINGS frame and haven't heard back
|
||||||
goAway *GoAwayFrame // if non-nil, the GoAwayFrame we received
|
goAway *GoAwayFrame // if non-nil, the GoAwayFrame we received
|
||||||
@ -211,9 +213,10 @@ type clientStream struct {
|
|||||||
done chan struct{} // closed when stream remove from cc.streams map; close calls guarded by cc.mu
|
done chan struct{} // closed when stream remove from cc.streams map; close calls guarded by cc.mu
|
||||||
|
|
||||||
// owned by clientConnReadLoop:
|
// owned by clientConnReadLoop:
|
||||||
firstByte bool // got the first response byte
|
firstByte bool // got the first response byte
|
||||||
pastHeaders bool // got first MetaHeadersFrame (actual headers)
|
pastHeaders bool // got first MetaHeadersFrame (actual headers)
|
||||||
pastTrailers bool // got optional second MetaHeadersFrame (trailers)
|
pastTrailers bool // got optional second MetaHeadersFrame (trailers)
|
||||||
|
num1xx uint8 // number of 1xx responses seen
|
||||||
|
|
||||||
trailer http.Header // accumulated trailers
|
trailer http.Header // accumulated trailers
|
||||||
resTrailer *http.Header // client's Response.Trailer
|
resTrailer *http.Header // client's Response.Trailer
|
||||||
@ -237,6 +240,17 @@ func awaitRequestCancel(req *http.Request, done <-chan struct{}) error {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var got1xxFuncForTests func(int, textproto.MIMEHeader) error
|
||||||
|
|
||||||
|
// get1xxTraceFunc returns the value of request's httptrace.ClientTrace.Got1xxResponse func,
|
||||||
|
// if any. It returns nil if not set or if the Go version is too old.
|
||||||
|
func (cs *clientStream) get1xxTraceFunc() func(int, textproto.MIMEHeader) error {
|
||||||
|
if fn := got1xxFuncForTests; fn != nil {
|
||||||
|
return fn
|
||||||
|
}
|
||||||
|
return traceGot1xxResponseFunc(cs.trace)
|
||||||
|
}
|
||||||
|
|
||||||
// awaitRequestCancel waits for the user to cancel a request, its context to
|
// awaitRequestCancel waits for the user to cancel a request, its context to
|
||||||
// expire, or for the request to be done (any way it might be removed from the
|
// expire, or for the request to be done (any way it might be removed from the
|
||||||
// cc.streams map: peer reset, successful completion, TCP connection breakage,
|
// cc.streams map: peer reset, successful completion, TCP connection breakage,
|
||||||
@ -423,27 +437,36 @@ func shouldRetryRequest(req *http.Request, err error, afterBodyWrite bool) (*htt
|
|||||||
if !canRetryError(err) {
|
if !canRetryError(err) {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
if !afterBodyWrite {
|
|
||||||
return req, nil
|
|
||||||
}
|
|
||||||
// If the Body is nil (or http.NoBody), it's safe to reuse
|
// If the Body is nil (or http.NoBody), it's safe to reuse
|
||||||
// this request and its Body.
|
// this request and its Body.
|
||||||
if req.Body == nil || reqBodyIsNoBody(req.Body) {
|
if req.Body == nil || reqBodyIsNoBody(req.Body) {
|
||||||
return req, nil
|
return req, nil
|
||||||
}
|
}
|
||||||
// Otherwise we depend on the Request having its GetBody
|
|
||||||
// func defined.
|
// If the request body can be reset back to its original
|
||||||
|
// state via the optional req.GetBody, do that.
|
||||||
getBody := reqGetBody(req) // Go 1.8: getBody = req.GetBody
|
getBody := reqGetBody(req) // Go 1.8: getBody = req.GetBody
|
||||||
if getBody == nil {
|
if getBody != nil {
|
||||||
return nil, fmt.Errorf("http2: Transport: cannot retry err [%v] after Request.Body was written; define Request.GetBody to avoid this error", err)
|
// TODO: consider a req.Body.Close here? or audit that all caller paths do?
|
||||||
|
body, err := getBody()
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
newReq := *req
|
||||||
|
newReq.Body = body
|
||||||
|
return &newReq, nil
|
||||||
}
|
}
|
||||||
body, err := getBody()
|
|
||||||
if err != nil {
|
// The Request.Body can't reset back to the beginning, but we
|
||||||
return nil, err
|
// don't seem to have started to read from it yet, so reuse
|
||||||
|
// the request directly. The "afterBodyWrite" means the
|
||||||
|
// bodyWrite process has started, which becomes true before
|
||||||
|
// the first Read.
|
||||||
|
if !afterBodyWrite {
|
||||||
|
return req, nil
|
||||||
}
|
}
|
||||||
newReq := *req
|
|
||||||
newReq.Body = body
|
return nil, fmt.Errorf("http2: Transport: cannot retry err [%v] after Request.Body was written; define Request.GetBody to avoid this error", err)
|
||||||
return &newReq, nil
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func canRetryError(err error) bool {
|
func canRetryError(err error) bool {
|
||||||
@ -630,12 +653,32 @@ func (cc *ClientConn) CanTakeNewRequest() bool {
|
|||||||
return cc.canTakeNewRequestLocked()
|
return cc.canTakeNewRequestLocked()
|
||||||
}
|
}
|
||||||
|
|
||||||
func (cc *ClientConn) canTakeNewRequestLocked() bool {
|
// clientConnIdleState describes the suitability of a client
|
||||||
|
// connection to initiate a new RoundTrip request.
|
||||||
|
type clientConnIdleState struct {
|
||||||
|
canTakeNewRequest bool
|
||||||
|
freshConn bool // whether it's unused by any previous request
|
||||||
|
}
|
||||||
|
|
||||||
|
func (cc *ClientConn) idleState() clientConnIdleState {
|
||||||
|
cc.mu.Lock()
|
||||||
|
defer cc.mu.Unlock()
|
||||||
|
return cc.idleStateLocked()
|
||||||
|
}
|
||||||
|
|
||||||
|
func (cc *ClientConn) idleStateLocked() (st clientConnIdleState) {
|
||||||
if cc.singleUse && cc.nextStreamID > 1 {
|
if cc.singleUse && cc.nextStreamID > 1 {
|
||||||
return false
|
return
|
||||||
}
|
}
|
||||||
return cc.goAway == nil && !cc.closed &&
|
st.canTakeNewRequest = cc.goAway == nil && !cc.closed && !cc.closing &&
|
||||||
int64(cc.nextStreamID)+int64(cc.pendingRequests) < math.MaxInt32
|
int64(cc.nextStreamID)+int64(cc.pendingRequests) < math.MaxInt32
|
||||||
|
st.freshConn = cc.nextStreamID == 1 && st.canTakeNewRequest
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
func (cc *ClientConn) canTakeNewRequestLocked() bool {
|
||||||
|
st := cc.idleStateLocked()
|
||||||
|
return st.canTakeNewRequest
|
||||||
}
|
}
|
||||||
|
|
||||||
// onIdleTimeout is called from a time.AfterFunc goroutine. It will
|
// onIdleTimeout is called from a time.AfterFunc goroutine. It will
|
||||||
@ -665,6 +708,88 @@ func (cc *ClientConn) closeIfIdle() {
|
|||||||
cc.tconn.Close()
|
cc.tconn.Close()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var shutdownEnterWaitStateHook = func() {}
|
||||||
|
|
||||||
|
// Shutdown gracefully close the client connection, waiting for running streams to complete.
|
||||||
|
// Public implementation is in go17.go and not_go17.go
|
||||||
|
func (cc *ClientConn) shutdown(ctx contextContext) error {
|
||||||
|
if err := cc.sendGoAway(); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
// Wait for all in-flight streams to complete or connection to close
|
||||||
|
done := make(chan error, 1)
|
||||||
|
cancelled := false // guarded by cc.mu
|
||||||
|
go func() {
|
||||||
|
cc.mu.Lock()
|
||||||
|
defer cc.mu.Unlock()
|
||||||
|
for {
|
||||||
|
if len(cc.streams) == 0 || cc.closed {
|
||||||
|
cc.closed = true
|
||||||
|
done <- cc.tconn.Close()
|
||||||
|
break
|
||||||
|
}
|
||||||
|
if cancelled {
|
||||||
|
break
|
||||||
|
}
|
||||||
|
cc.cond.Wait()
|
||||||
|
}
|
||||||
|
}()
|
||||||
|
shutdownEnterWaitStateHook()
|
||||||
|
select {
|
||||||
|
case err := <-done:
|
||||||
|
return err
|
||||||
|
case <-ctx.Done():
|
||||||
|
cc.mu.Lock()
|
||||||
|
// Free the goroutine above
|
||||||
|
cancelled = true
|
||||||
|
cc.cond.Broadcast()
|
||||||
|
cc.mu.Unlock()
|
||||||
|
return ctx.Err()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (cc *ClientConn) sendGoAway() error {
|
||||||
|
cc.mu.Lock()
|
||||||
|
defer cc.mu.Unlock()
|
||||||
|
cc.wmu.Lock()
|
||||||
|
defer cc.wmu.Unlock()
|
||||||
|
if cc.closing {
|
||||||
|
// GOAWAY sent already
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
// Send a graceful shutdown frame to server
|
||||||
|
maxStreamID := cc.nextStreamID
|
||||||
|
if err := cc.fr.WriteGoAway(maxStreamID, ErrCodeNo, nil); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
if err := cc.bw.Flush(); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
// Prevent new requests
|
||||||
|
cc.closing = true
|
||||||
|
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 {
|
||||||
|
cc.mu.Lock()
|
||||||
|
defer cc.cond.Broadcast()
|
||||||
|
defer cc.mu.Unlock()
|
||||||
|
err := errors.New("http2: client connection force closed via ClientConn.Close")
|
||||||
|
for id, cs := range cc.streams {
|
||||||
|
select {
|
||||||
|
case cs.resc <- resAndError{err: err}:
|
||||||
|
default:
|
||||||
|
}
|
||||||
|
cs.bufPipe.CloseWithError(err)
|
||||||
|
delete(cc.streams, id)
|
||||||
|
}
|
||||||
|
cc.closed = true
|
||||||
|
return cc.tconn.Close()
|
||||||
|
}
|
||||||
|
|
||||||
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.
|
||||||
@ -747,7 +872,7 @@ func checkConnHeaders(req *http.Request) error {
|
|||||||
if vv := req.Header["Transfer-Encoding"]; len(vv) > 0 && (len(vv) > 1 || vv[0] != "" && vv[0] != "chunked") {
|
if vv := req.Header["Transfer-Encoding"]; len(vv) > 0 && (len(vv) > 1 || vv[0] != "" && vv[0] != "chunked") {
|
||||||
return fmt.Errorf("http2: invalid Transfer-Encoding request header: %q", vv)
|
return fmt.Errorf("http2: invalid Transfer-Encoding request header: %q", vv)
|
||||||
}
|
}
|
||||||
if vv := req.Header["Connection"]; len(vv) > 0 && (len(vv) > 1 || vv[0] != "" && vv[0] != "close" && vv[0] != "keep-alive") {
|
if vv := req.Header["Connection"]; len(vv) > 0 && (len(vv) > 1 || vv[0] != "" && !strings.EqualFold(vv[0], "close") && !strings.EqualFold(vv[0], "keep-alive")) {
|
||||||
return fmt.Errorf("http2: invalid Connection request header: %q", vv)
|
return fmt.Errorf("http2: invalid Connection request header: %q", vv)
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
@ -1291,9 +1416,16 @@ func (cc *ClientConn) encodeHeaders(req *http.Request, addGzipHeader bool, trail
|
|||||||
return nil, errRequestHeaderListSize
|
return nil, errRequestHeaderListSize
|
||||||
}
|
}
|
||||||
|
|
||||||
|
trace := requestTrace(req)
|
||||||
|
traceHeaders := traceHasWroteHeaderField(trace)
|
||||||
|
|
||||||
// Header list size is ok. Write the headers.
|
// Header list size is ok. Write the headers.
|
||||||
enumerateHeaders(func(name, value string) {
|
enumerateHeaders(func(name, value string) {
|
||||||
cc.writeHeader(strings.ToLower(name), value)
|
name = strings.ToLower(name)
|
||||||
|
cc.writeHeader(name, value)
|
||||||
|
if traceHeaders {
|
||||||
|
traceWroteHeaderField(trace, name, value)
|
||||||
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
return cc.hbuf.Bytes(), nil
|
return cc.hbuf.Bytes(), nil
|
||||||
@ -1615,8 +1747,7 @@ func (rl *clientConnReadLoop) processHeaders(f *MetaHeadersFrame) error {
|
|||||||
// is the detail.
|
// is the detail.
|
||||||
//
|
//
|
||||||
// As a special case, handleResponse may return (nil, nil) to skip the
|
// As a special case, handleResponse may return (nil, nil) to skip the
|
||||||
// frame (currently only used for 100 expect continue). This special
|
// frame (currently only used for 1xx responses).
|
||||||
// case is going away after Issue 13851 is fixed.
|
|
||||||
func (rl *clientConnReadLoop) handleResponse(cs *clientStream, f *MetaHeadersFrame) (*http.Response, error) {
|
func (rl *clientConnReadLoop) handleResponse(cs *clientStream, f *MetaHeadersFrame) (*http.Response, error) {
|
||||||
if f.Truncated {
|
if f.Truncated {
|
||||||
return nil, errResponseHeaderListSize
|
return nil, errResponseHeaderListSize
|
||||||
@ -1631,15 +1762,6 @@ 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")
|
||||||
}
|
}
|
||||||
|
|
||||||
if statusCode == 100 {
|
|
||||||
traceGot100Continue(cs.trace)
|
|
||||||
if cs.on100 != nil {
|
|
||||||
cs.on100() // forces any write delay timer to fire
|
|
||||||
}
|
|
||||||
cs.pastHeaders = false // do it all again
|
|
||||||
return nil, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
header := make(http.Header)
|
header := make(http.Header)
|
||||||
res := &http.Response{
|
res := &http.Response{
|
||||||
Proto: "HTTP/2.0",
|
Proto: "HTTP/2.0",
|
||||||
@ -1664,6 +1786,27 @@ func (rl *clientConnReadLoop) handleResponse(cs *clientStream, f *MetaHeadersFra
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if statusCode >= 100 && statusCode <= 199 {
|
||||||
|
cs.num1xx++
|
||||||
|
const max1xxResponses = 5 // arbitrary bound on number of informational responses, same as net/http
|
||||||
|
if cs.num1xx > max1xxResponses {
|
||||||
|
return nil, errors.New("http2: too many 1xx informational responses")
|
||||||
|
}
|
||||||
|
if fn := cs.get1xxTraceFunc(); fn != nil {
|
||||||
|
if err := fn(statusCode, textproto.MIMEHeader(header)); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if statusCode == 100 {
|
||||||
|
traceGot100Continue(cs.trace)
|
||||||
|
if cs.on100 != nil {
|
||||||
|
cs.on100() // forces any write delay timer to fire
|
||||||
|
}
|
||||||
|
}
|
||||||
|
cs.pastHeaders = false // do it all again
|
||||||
|
return nil, nil
|
||||||
|
}
|
||||||
|
|
||||||
streamEnded := f.StreamEnded()
|
streamEnded := f.StreamEnded()
|
||||||
isHead := cs.req.Method == "HEAD"
|
isHead := cs.req.Method == "HEAD"
|
||||||
if !streamEnded || isHead {
|
if !streamEnded || isHead {
|
||||||
|
349
vendor/golang.org/x/net/http2/transport_test.go
generated
vendored
Executable file → Normal file
349
vendor/golang.org/x/net/http2/transport_test.go
generated
vendored
Executable file → Normal file
@ -18,6 +18,7 @@ import (
|
|||||||
"net"
|
"net"
|
||||||
"net/http"
|
"net/http"
|
||||||
"net/http/httptest"
|
"net/http/httptest"
|
||||||
|
"net/textproto"
|
||||||
"net/url"
|
"net/url"
|
||||||
"os"
|
"os"
|
||||||
"reflect"
|
"reflect"
|
||||||
@ -30,6 +31,7 @@ import (
|
|||||||
"testing"
|
"testing"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
"golang.org/x/net/context"
|
||||||
"golang.org/x/net/http2/hpack"
|
"golang.org/x/net/http2/hpack"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -41,12 +43,13 @@ var (
|
|||||||
|
|
||||||
var tlsConfigInsecure = &tls.Config{InsecureSkipVerify: true}
|
var tlsConfigInsecure = &tls.Config{InsecureSkipVerify: true}
|
||||||
|
|
||||||
type testContext struct{}
|
var canceledCtx context.Context
|
||||||
|
|
||||||
func (testContext) Done() <-chan struct{} { return make(chan struct{}) }
|
func init() {
|
||||||
func (testContext) Err() error { panic("should not be called") }
|
ctx, cancel := context.WithCancel(context.Background())
|
||||||
func (testContext) Deadline() (deadline time.Time, ok bool) { return time.Time{}, false }
|
cancel()
|
||||||
func (testContext) Value(key interface{}) interface{} { return nil }
|
canceledCtx = ctx
|
||||||
|
}
|
||||||
|
|
||||||
func TestTransportExternal(t *testing.T) {
|
func TestTransportExternal(t *testing.T) {
|
||||||
if !*extNet {
|
if !*extNet {
|
||||||
@ -1190,6 +1193,77 @@ func testTransportResPattern(t *testing.T, expect100Continue, resHeader headerTy
|
|||||||
ct.run()
|
ct.run()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Issue 26189, Issue 17739: ignore unknown 1xx responses
|
||||||
|
func TestTransportUnknown1xx(t *testing.T) {
|
||||||
|
var buf bytes.Buffer
|
||||||
|
defer func() { got1xxFuncForTests = nil }()
|
||||||
|
got1xxFuncForTests = func(code int, header textproto.MIMEHeader) error {
|
||||||
|
fmt.Fprintf(&buf, "code=%d header=%v\n", code, header)
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
ct := newClientTester(t)
|
||||||
|
ct.client = func() error {
|
||||||
|
req, _ := http.NewRequest("GET", "https://dummy.tld/", nil)
|
||||||
|
res, err := ct.tr.RoundTrip(req)
|
||||||
|
if err != nil {
|
||||||
|
return fmt.Errorf("RoundTrip: %v", err)
|
||||||
|
}
|
||||||
|
defer res.Body.Close()
|
||||||
|
if res.StatusCode != 204 {
|
||||||
|
return fmt.Errorf("status code = %v; want 204", res.StatusCode)
|
||||||
|
}
|
||||||
|
want := `code=110 header=map[Foo-Bar:[110]]
|
||||||
|
code=111 header=map[Foo-Bar:[111]]
|
||||||
|
code=112 header=map[Foo-Bar:[112]]
|
||||||
|
code=113 header=map[Foo-Bar:[113]]
|
||||||
|
code=114 header=map[Foo-Bar:[114]]
|
||||||
|
`
|
||||||
|
if got := buf.String(); got != want {
|
||||||
|
t.Errorf("Got trace:\n%s\nWant:\n%s", got, want)
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
ct.server = func() error {
|
||||||
|
ct.greet()
|
||||||
|
var buf bytes.Buffer
|
||||||
|
enc := hpack.NewEncoder(&buf)
|
||||||
|
|
||||||
|
for {
|
||||||
|
f, err := ct.fr.ReadFrame()
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
switch f := f.(type) {
|
||||||
|
case *WindowUpdateFrame, *SettingsFrame:
|
||||||
|
case *HeadersFrame:
|
||||||
|
for i := 110; i <= 114; i++ {
|
||||||
|
buf.Reset()
|
||||||
|
enc.WriteField(hpack.HeaderField{Name: ":status", Value: fmt.Sprint(i)})
|
||||||
|
enc.WriteField(hpack.HeaderField{Name: "foo-bar", Value: fmt.Sprint(i)})
|
||||||
|
ct.fr.WriteHeaders(HeadersFrameParam{
|
||||||
|
StreamID: f.StreamID,
|
||||||
|
EndHeaders: true,
|
||||||
|
EndStream: false,
|
||||||
|
BlockFragment: buf.Bytes(),
|
||||||
|
})
|
||||||
|
}
|
||||||
|
buf.Reset()
|
||||||
|
enc.WriteField(hpack.HeaderField{Name: ":status", Value: "204"})
|
||||||
|
ct.fr.WriteHeaders(HeadersFrameParam{
|
||||||
|
StreamID: f.StreamID,
|
||||||
|
EndHeaders: true,
|
||||||
|
EndStream: false,
|
||||||
|
BlockFragment: buf.Bytes(),
|
||||||
|
})
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
ct.run()
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
func TestTransportReceiveUndeclaredTrailer(t *testing.T) {
|
func TestTransportReceiveUndeclaredTrailer(t *testing.T) {
|
||||||
ct := newClientTester(t)
|
ct := newClientTester(t)
|
||||||
ct.client = func() error {
|
ct.client = func() error {
|
||||||
@ -2022,6 +2096,11 @@ func TestTransportRejectsConnHeaders(t *testing.T) {
|
|||||||
value: []string{"close"},
|
value: []string{"close"},
|
||||||
want: "Accept-Encoding,User-Agent",
|
want: "Accept-Encoding,User-Agent",
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
key: "Connection",
|
||||||
|
value: []string{"CLoSe"},
|
||||||
|
want: "Accept-Encoding,User-Agent",
|
||||||
|
},
|
||||||
{
|
{
|
||||||
key: "Connection",
|
key: "Connection",
|
||||||
value: []string{"close", "something-else"},
|
value: []string{"close", "something-else"},
|
||||||
@ -2032,6 +2111,11 @@ func TestTransportRejectsConnHeaders(t *testing.T) {
|
|||||||
value: []string{"keep-alive"},
|
value: []string{"keep-alive"},
|
||||||
want: "Accept-Encoding,User-Agent",
|
want: "Accept-Encoding,User-Agent",
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
key: "Connection",
|
||||||
|
value: []string{"Keep-ALIVE"},
|
||||||
|
want: "Accept-Encoding,User-Agent",
|
||||||
|
},
|
||||||
{
|
{
|
||||||
key: "Proxy-Connection", // just deleted and ignored
|
key: "Proxy-Connection", // just deleted and ignored
|
||||||
value: []string{"keep-alive"},
|
value: []string{"keep-alive"},
|
||||||
@ -3044,7 +3128,7 @@ func TestClientConnPing(t *testing.T) {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
if err = cc.Ping(testContext{}); err != nil {
|
if err = cc.Ping(context.Background()); err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -3846,3 +3930,256 @@ func BenchmarkClientRequestHeaders(b *testing.B) {
|
|||||||
b.Run(" 100 Headers", func(b *testing.B) { benchSimpleRoundTrip(b, 100) })
|
b.Run(" 100 Headers", func(b *testing.B) { benchSimpleRoundTrip(b, 100) })
|
||||||
b.Run("1000 Headers", func(b *testing.B) { benchSimpleRoundTrip(b, 1000) })
|
b.Run("1000 Headers", func(b *testing.B) { benchSimpleRoundTrip(b, 1000) })
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func activeStreams(cc *ClientConn) int {
|
||||||
|
cc.mu.Lock()
|
||||||
|
defer cc.mu.Unlock()
|
||||||
|
return len(cc.streams)
|
||||||
|
}
|
||||||
|
|
||||||
|
type closeMode int
|
||||||
|
|
||||||
|
const (
|
||||||
|
closeAtHeaders closeMode = iota
|
||||||
|
closeAtBody
|
||||||
|
shutdown
|
||||||
|
shutdownCancel
|
||||||
|
)
|
||||||
|
|
||||||
|
// See golang.org/issue/17292
|
||||||
|
func testClientConnClose(t *testing.T, closeMode closeMode) {
|
||||||
|
clientDone := make(chan struct{})
|
||||||
|
defer close(clientDone)
|
||||||
|
handlerDone := make(chan struct{})
|
||||||
|
closeDone := make(chan struct{})
|
||||||
|
beforeHeader := func() {}
|
||||||
|
bodyWrite := func(w http.ResponseWriter) {}
|
||||||
|
st := newServerTester(t, func(w http.ResponseWriter, r *http.Request) {
|
||||||
|
defer close(handlerDone)
|
||||||
|
beforeHeader()
|
||||||
|
w.WriteHeader(http.StatusOK)
|
||||||
|
w.(http.Flusher).Flush()
|
||||||
|
bodyWrite(w)
|
||||||
|
select {
|
||||||
|
case <-w.(http.CloseNotifier).CloseNotify():
|
||||||
|
// client closed connection before completion
|
||||||
|
if closeMode == shutdown || closeMode == shutdownCancel {
|
||||||
|
t.Error("expected request to complete")
|
||||||
|
}
|
||||||
|
case <-clientDone:
|
||||||
|
if closeMode == closeAtHeaders || closeMode == closeAtBody {
|
||||||
|
t.Error("expected connection closed by client")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}, optOnlyServer)
|
||||||
|
defer st.Close()
|
||||||
|
tr := &Transport{TLSClientConfig: tlsConfigInsecure}
|
||||||
|
defer tr.CloseIdleConnections()
|
||||||
|
cc, err := tr.dialClientConn(st.ts.Listener.Addr().String(), false)
|
||||||
|
req, err := http.NewRequest("GET", st.ts.URL, nil)
|
||||||
|
if err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
if closeMode == closeAtHeaders {
|
||||||
|
beforeHeader = func() {
|
||||||
|
if err := cc.Close(); err != nil {
|
||||||
|
t.Error(err)
|
||||||
|
}
|
||||||
|
close(closeDone)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
var sendBody chan struct{}
|
||||||
|
if closeMode == closeAtBody {
|
||||||
|
sendBody = make(chan struct{})
|
||||||
|
bodyWrite = func(w http.ResponseWriter) {
|
||||||
|
<-sendBody
|
||||||
|
b := make([]byte, 32)
|
||||||
|
w.Write(b)
|
||||||
|
w.(http.Flusher).Flush()
|
||||||
|
if err := cc.Close(); err != nil {
|
||||||
|
t.Errorf("unexpected ClientConn close error: %v", err)
|
||||||
|
}
|
||||||
|
close(closeDone)
|
||||||
|
w.Write(b)
|
||||||
|
w.(http.Flusher).Flush()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
res, err := cc.RoundTrip(req)
|
||||||
|
if res != nil {
|
||||||
|
defer res.Body.Close()
|
||||||
|
}
|
||||||
|
if closeMode == closeAtHeaders {
|
||||||
|
got := fmt.Sprint(err)
|
||||||
|
want := "http2: client connection force closed via ClientConn.Close"
|
||||||
|
if got != want {
|
||||||
|
t.Fatalf("RoundTrip error = %v, want %v", got, want)
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if err != nil {
|
||||||
|
t.Fatalf("RoundTrip: %v", err)
|
||||||
|
}
|
||||||
|
if got, want := activeStreams(cc), 1; got != want {
|
||||||
|
t.Errorf("got %d active streams, want %d", got, want)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
switch closeMode {
|
||||||
|
case shutdownCancel:
|
||||||
|
if err = cc.Shutdown(canceledCtx); err != errCanceled {
|
||||||
|
t.Errorf("got %v, want %v", err, errCanceled)
|
||||||
|
}
|
||||||
|
if cc.closing == false {
|
||||||
|
t.Error("expected closing to be true")
|
||||||
|
}
|
||||||
|
if cc.CanTakeNewRequest() == true {
|
||||||
|
t.Error("CanTakeNewRequest to return false")
|
||||||
|
}
|
||||||
|
if v, want := len(cc.streams), 1; v != want {
|
||||||
|
t.Errorf("expected %d active streams, got %d", want, v)
|
||||||
|
}
|
||||||
|
clientDone <- struct{}{}
|
||||||
|
<-handlerDone
|
||||||
|
case shutdown:
|
||||||
|
wait := make(chan struct{})
|
||||||
|
shutdownEnterWaitStateHook = func() {
|
||||||
|
close(wait)
|
||||||
|
shutdownEnterWaitStateHook = func() {}
|
||||||
|
}
|
||||||
|
defer func() { shutdownEnterWaitStateHook = func() {} }()
|
||||||
|
shutdown := make(chan struct{}, 1)
|
||||||
|
go func() {
|
||||||
|
if err = cc.Shutdown(context.Background()); err != nil {
|
||||||
|
t.Error(err)
|
||||||
|
}
|
||||||
|
close(shutdown)
|
||||||
|
}()
|
||||||
|
// Let the shutdown to enter wait state
|
||||||
|
<-wait
|
||||||
|
cc.mu.Lock()
|
||||||
|
if cc.closing == false {
|
||||||
|
t.Error("expected closing to be true")
|
||||||
|
}
|
||||||
|
cc.mu.Unlock()
|
||||||
|
if cc.CanTakeNewRequest() == true {
|
||||||
|
t.Error("CanTakeNewRequest to return false")
|
||||||
|
}
|
||||||
|
if got, want := activeStreams(cc), 1; got != want {
|
||||||
|
t.Errorf("got %d active streams, want %d", got, want)
|
||||||
|
}
|
||||||
|
// Let the active request finish
|
||||||
|
clientDone <- struct{}{}
|
||||||
|
// Wait for the shutdown to end
|
||||||
|
select {
|
||||||
|
case <-shutdown:
|
||||||
|
case <-time.After(2 * time.Second):
|
||||||
|
t.Fatal("expected server connection to close")
|
||||||
|
}
|
||||||
|
case closeAtHeaders, closeAtBody:
|
||||||
|
if closeMode == closeAtBody {
|
||||||
|
go close(sendBody)
|
||||||
|
if _, err := io.Copy(ioutil.Discard, res.Body); err == nil {
|
||||||
|
t.Error("expected a Copy error, got nil")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
<-closeDone
|
||||||
|
if got, want := activeStreams(cc), 0; got != want {
|
||||||
|
t.Errorf("got %d active streams, want %d", got, want)
|
||||||
|
}
|
||||||
|
// wait for server to get the connection close notice
|
||||||
|
select {
|
||||||
|
case <-handlerDone:
|
||||||
|
case <-time.After(2 * time.Second):
|
||||||
|
t.Fatal("expected server connection to close")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// The client closes the connection just after the server got the client's HEADERS
|
||||||
|
// frame, but before the server sends its HEADERS response back. The expected
|
||||||
|
// result is an error on RoundTrip explaining the client closed the connection.
|
||||||
|
func TestClientConnCloseAtHeaders(t *testing.T) {
|
||||||
|
testClientConnClose(t, closeAtHeaders)
|
||||||
|
}
|
||||||
|
|
||||||
|
// The client closes the connection between two server's response DATA frames.
|
||||||
|
// The expected behavior is a response body io read error on the client.
|
||||||
|
func TestClientConnCloseAtBody(t *testing.T) {
|
||||||
|
testClientConnClose(t, closeAtBody)
|
||||||
|
}
|
||||||
|
|
||||||
|
// The client sends a GOAWAY frame before the server finished processing a request.
|
||||||
|
// We expect the connection not to close until the request is completed.
|
||||||
|
func TestClientConnShutdown(t *testing.T) {
|
||||||
|
testClientConnClose(t, shutdown)
|
||||||
|
}
|
||||||
|
|
||||||
|
// The client sends a GOAWAY frame before the server finishes processing a request,
|
||||||
|
// but cancels the passed context before the request is completed. The expected
|
||||||
|
// behavior is the client closing the connection after the context is canceled.
|
||||||
|
func TestClientConnShutdownCancel(t *testing.T) {
|
||||||
|
testClientConnClose(t, shutdownCancel)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Issue 25009: use Request.GetBody if present, even if it seems like
|
||||||
|
// we might not need it. Apparently something else can still read from
|
||||||
|
// the original request body. Data race? In any case, rewinding
|
||||||
|
// unconditionally on retry is a nicer model anyway and should
|
||||||
|
// simplify code in the future (after the Go 1.11 freeze)
|
||||||
|
func TestTransportUsesGetBodyWhenPresent(t *testing.T) {
|
||||||
|
calls := 0
|
||||||
|
someBody := func() io.ReadCloser {
|
||||||
|
return struct{ io.ReadCloser }{ioutil.NopCloser(bytes.NewReader(nil))}
|
||||||
|
}
|
||||||
|
req := &http.Request{
|
||||||
|
Body: someBody(),
|
||||||
|
GetBody: func() (io.ReadCloser, error) {
|
||||||
|
calls++
|
||||||
|
return someBody(), nil
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
afterBodyWrite := false // pretend we haven't read+written the body yet
|
||||||
|
req2, err := shouldRetryRequest(req, errClientConnUnusable, afterBodyWrite)
|
||||||
|
if err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
if calls != 1 {
|
||||||
|
t.Errorf("Calls = %d; want 1", calls)
|
||||||
|
}
|
||||||
|
if req2 == req {
|
||||||
|
t.Error("req2 changed")
|
||||||
|
}
|
||||||
|
if req2 == nil {
|
||||||
|
t.Fatal("req2 is nil")
|
||||||
|
}
|
||||||
|
if req2.Body == nil {
|
||||||
|
t.Fatal("req2.Body is nil")
|
||||||
|
}
|
||||||
|
if req2.GetBody == nil {
|
||||||
|
t.Fatal("req2.GetBody is nil")
|
||||||
|
}
|
||||||
|
if req2.Body == req.Body {
|
||||||
|
t.Error("req2.Body unchanged")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Issue 22891: verify that the "https" altproto we register with net/http
|
||||||
|
// is a certain type: a struct with one field with our *http2.Transport in it.
|
||||||
|
func TestNoDialH2RoundTripperType(t *testing.T) {
|
||||||
|
t1 := new(http.Transport)
|
||||||
|
t2 := new(Transport)
|
||||||
|
rt := noDialH2RoundTripper{t2}
|
||||||
|
if err := registerHTTPSProtocol(t1, rt); err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
rv := reflect.ValueOf(rt)
|
||||||
|
if rv.Type().Kind() != reflect.Struct {
|
||||||
|
t.Fatalf("kind = %v; net/http expects struct", rv.Type().Kind())
|
||||||
|
}
|
||||||
|
if n := rv.Type().NumField(); n != 1 {
|
||||||
|
t.Fatalf("fields = %d; net/http expects 1", n)
|
||||||
|
}
|
||||||
|
v := rv.Field(0)
|
||||||
|
if _, ok := v.Interface().(*Transport); !ok {
|
||||||
|
t.Fatalf("wrong kind %T; want *Transport", v.Interface())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
0
vendor/golang.org/x/net/http2/write.go
generated
vendored
Executable file → Normal file
0
vendor/golang.org/x/net/http2/write.go
generated
vendored
Executable file → Normal file
0
vendor/golang.org/x/net/http2/writesched.go
generated
vendored
Executable file → Normal file
0
vendor/golang.org/x/net/http2/writesched.go
generated
vendored
Executable file → Normal file
0
vendor/golang.org/x/net/http2/writesched_priority.go
generated
vendored
Executable file → Normal file
0
vendor/golang.org/x/net/http2/writesched_priority.go
generated
vendored
Executable file → Normal file
0
vendor/golang.org/x/net/http2/writesched_priority_test.go
generated
vendored
Executable file → Normal file
0
vendor/golang.org/x/net/http2/writesched_priority_test.go
generated
vendored
Executable file → Normal file
0
vendor/golang.org/x/net/http2/writesched_random.go
generated
vendored
Executable file → Normal file
0
vendor/golang.org/x/net/http2/writesched_random.go
generated
vendored
Executable file → Normal file
0
vendor/golang.org/x/net/http2/writesched_random_test.go
generated
vendored
Executable file → Normal file
0
vendor/golang.org/x/net/http2/writesched_random_test.go
generated
vendored
Executable file → Normal file
0
vendor/golang.org/x/net/http2/writesched_test.go
generated
vendored
Executable file → Normal file
0
vendor/golang.org/x/net/http2/writesched_test.go
generated
vendored
Executable file → Normal file
0
vendor/golang.org/x/net/http2/z_spec_test.go
generated
vendored
Executable file → Normal file
0
vendor/golang.org/x/net/http2/z_spec_test.go
generated
vendored
Executable file → Normal file
223
vendor/golang.org/x/net/internal/iana/const.go
generated
vendored
Normal file
223
vendor/golang.org/x/net/internal/iana/const.go
generated
vendored
Normal file
@ -0,0 +1,223 @@
|
|||||||
|
// go generate gen.go
|
||||||
|
// Code generated by the command above; DO NOT EDIT.
|
||||||
|
|
||||||
|
// Package iana provides protocol number resources managed by the Internet Assigned Numbers Authority (IANA).
|
||||||
|
package iana // import "golang.org/x/net/internal/iana"
|
||||||
|
|
||||||
|
// Differentiated Services Field Codepoints (DSCP), Updated: 2018-05-04
|
||||||
|
const (
|
||||||
|
DiffServCS0 = 0x00 // CS0
|
||||||
|
DiffServCS1 = 0x20 // CS1
|
||||||
|
DiffServCS2 = 0x40 // CS2
|
||||||
|
DiffServCS3 = 0x60 // CS3
|
||||||
|
DiffServCS4 = 0x80 // CS4
|
||||||
|
DiffServCS5 = 0xa0 // CS5
|
||||||
|
DiffServCS6 = 0xc0 // CS6
|
||||||
|
DiffServCS7 = 0xe0 // CS7
|
||||||
|
DiffServAF11 = 0x28 // AF11
|
||||||
|
DiffServAF12 = 0x30 // AF12
|
||||||
|
DiffServAF13 = 0x38 // AF13
|
||||||
|
DiffServAF21 = 0x48 // AF21
|
||||||
|
DiffServAF22 = 0x50 // AF22
|
||||||
|
DiffServAF23 = 0x58 // AF23
|
||||||
|
DiffServAF31 = 0x68 // AF31
|
||||||
|
DiffServAF32 = 0x70 // AF32
|
||||||
|
DiffServAF33 = 0x78 // AF33
|
||||||
|
DiffServAF41 = 0x88 // AF41
|
||||||
|
DiffServAF42 = 0x90 // AF42
|
||||||
|
DiffServAF43 = 0x98 // AF43
|
||||||
|
DiffServEF = 0xb8 // EF
|
||||||
|
DiffServVOICEADMIT = 0xb0 // VOICE-ADMIT
|
||||||
|
NotECNTransport = 0x00 // Not-ECT (Not ECN-Capable Transport)
|
||||||
|
ECNTransport1 = 0x01 // ECT(1) (ECN-Capable Transport(1))
|
||||||
|
ECNTransport0 = 0x02 // ECT(0) (ECN-Capable Transport(0))
|
||||||
|
CongestionExperienced = 0x03 // CE (Congestion Experienced)
|
||||||
|
)
|
||||||
|
|
||||||
|
// Protocol Numbers, Updated: 2017-10-13
|
||||||
|
const (
|
||||||
|
ProtocolIP = 0 // IPv4 encapsulation, pseudo protocol number
|
||||||
|
ProtocolHOPOPT = 0 // IPv6 Hop-by-Hop Option
|
||||||
|
ProtocolICMP = 1 // Internet Control Message
|
||||||
|
ProtocolIGMP = 2 // Internet Group Management
|
||||||
|
ProtocolGGP = 3 // Gateway-to-Gateway
|
||||||
|
ProtocolIPv4 = 4 // IPv4 encapsulation
|
||||||
|
ProtocolST = 5 // Stream
|
||||||
|
ProtocolTCP = 6 // Transmission Control
|
||||||
|
ProtocolCBT = 7 // CBT
|
||||||
|
ProtocolEGP = 8 // Exterior Gateway Protocol
|
||||||
|
ProtocolIGP = 9 // any private interior gateway (used by Cisco for their IGRP)
|
||||||
|
ProtocolBBNRCCMON = 10 // BBN RCC Monitoring
|
||||||
|
ProtocolNVPII = 11 // Network Voice Protocol
|
||||||
|
ProtocolPUP = 12 // PUP
|
||||||
|
ProtocolEMCON = 14 // EMCON
|
||||||
|
ProtocolXNET = 15 // Cross Net Debugger
|
||||||
|
ProtocolCHAOS = 16 // Chaos
|
||||||
|
ProtocolUDP = 17 // User Datagram
|
||||||
|
ProtocolMUX = 18 // Multiplexing
|
||||||
|
ProtocolDCNMEAS = 19 // DCN Measurement Subsystems
|
||||||
|
ProtocolHMP = 20 // Host Monitoring
|
||||||
|
ProtocolPRM = 21 // Packet Radio Measurement
|
||||||
|
ProtocolXNSIDP = 22 // XEROX NS IDP
|
||||||
|
ProtocolTRUNK1 = 23 // Trunk-1
|
||||||
|
ProtocolTRUNK2 = 24 // Trunk-2
|
||||||
|
ProtocolLEAF1 = 25 // Leaf-1
|
||||||
|
ProtocolLEAF2 = 26 // Leaf-2
|
||||||
|
ProtocolRDP = 27 // Reliable Data Protocol
|
||||||
|
ProtocolIRTP = 28 // Internet Reliable Transaction
|
||||||
|
ProtocolISOTP4 = 29 // ISO Transport Protocol Class 4
|
||||||
|
ProtocolNETBLT = 30 // Bulk Data Transfer Protocol
|
||||||
|
ProtocolMFENSP = 31 // MFE Network Services Protocol
|
||||||
|
ProtocolMERITINP = 32 // MERIT Internodal Protocol
|
||||||
|
ProtocolDCCP = 33 // Datagram Congestion Control Protocol
|
||||||
|
Protocol3PC = 34 // Third Party Connect Protocol
|
||||||
|
ProtocolIDPR = 35 // Inter-Domain Policy Routing Protocol
|
||||||
|
ProtocolXTP = 36 // XTP
|
||||||
|
ProtocolDDP = 37 // Datagram Delivery Protocol
|
||||||
|
ProtocolIDPRCMTP = 38 // IDPR Control Message Transport Proto
|
||||||
|
ProtocolTPPP = 39 // TP++ Transport Protocol
|
||||||
|
ProtocolIL = 40 // IL Transport Protocol
|
||||||
|
ProtocolIPv6 = 41 // IPv6 encapsulation
|
||||||
|
ProtocolSDRP = 42 // Source Demand Routing Protocol
|
||||||
|
ProtocolIPv6Route = 43 // Routing Header for IPv6
|
||||||
|
ProtocolIPv6Frag = 44 // Fragment Header for IPv6
|
||||||
|
ProtocolIDRP = 45 // Inter-Domain Routing Protocol
|
||||||
|
ProtocolRSVP = 46 // Reservation Protocol
|
||||||
|
ProtocolGRE = 47 // Generic Routing Encapsulation
|
||||||
|
ProtocolDSR = 48 // Dynamic Source Routing Protocol
|
||||||
|
ProtocolBNA = 49 // BNA
|
||||||
|
ProtocolESP = 50 // Encap Security Payload
|
||||||
|
ProtocolAH = 51 // Authentication Header
|
||||||
|
ProtocolINLSP = 52 // Integrated Net Layer Security TUBA
|
||||||
|
ProtocolNARP = 54 // NBMA Address Resolution Protocol
|
||||||
|
ProtocolMOBILE = 55 // IP Mobility
|
||||||
|
ProtocolTLSP = 56 // Transport Layer Security Protocol using Kryptonet key management
|
||||||
|
ProtocolSKIP = 57 // SKIP
|
||||||
|
ProtocolIPv6ICMP = 58 // ICMP for IPv6
|
||||||
|
ProtocolIPv6NoNxt = 59 // No Next Header for IPv6
|
||||||
|
ProtocolIPv6Opts = 60 // Destination Options for IPv6
|
||||||
|
ProtocolCFTP = 62 // CFTP
|
||||||
|
ProtocolSATEXPAK = 64 // SATNET and Backroom EXPAK
|
||||||
|
ProtocolKRYPTOLAN = 65 // Kryptolan
|
||||||
|
ProtocolRVD = 66 // MIT Remote Virtual Disk Protocol
|
||||||
|
ProtocolIPPC = 67 // Internet Pluribus Packet Core
|
||||||
|
ProtocolSATMON = 69 // SATNET Monitoring
|
||||||
|
ProtocolVISA = 70 // VISA Protocol
|
||||||
|
ProtocolIPCV = 71 // Internet Packet Core Utility
|
||||||
|
ProtocolCPNX = 72 // Computer Protocol Network Executive
|
||||||
|
ProtocolCPHB = 73 // Computer Protocol Heart Beat
|
||||||
|
ProtocolWSN = 74 // Wang Span Network
|
||||||
|
ProtocolPVP = 75 // Packet Video Protocol
|
||||||
|
ProtocolBRSATMON = 76 // Backroom SATNET Monitoring
|
||||||
|
ProtocolSUNND = 77 // SUN ND PROTOCOL-Temporary
|
||||||
|
ProtocolWBMON = 78 // WIDEBAND Monitoring
|
||||||
|
ProtocolWBEXPAK = 79 // WIDEBAND EXPAK
|
||||||
|
ProtocolISOIP = 80 // ISO Internet Protocol
|
||||||
|
ProtocolVMTP = 81 // VMTP
|
||||||
|
ProtocolSECUREVMTP = 82 // SECURE-VMTP
|
||||||
|
ProtocolVINES = 83 // VINES
|
||||||
|
ProtocolTTP = 84 // Transaction Transport Protocol
|
||||||
|
ProtocolIPTM = 84 // Internet Protocol Traffic Manager
|
||||||
|
ProtocolNSFNETIGP = 85 // NSFNET-IGP
|
||||||
|
ProtocolDGP = 86 // Dissimilar Gateway Protocol
|
||||||
|
ProtocolTCF = 87 // TCF
|
||||||
|
ProtocolEIGRP = 88 // EIGRP
|
||||||
|
ProtocolOSPFIGP = 89 // OSPFIGP
|
||||||
|
ProtocolSpriteRPC = 90 // Sprite RPC Protocol
|
||||||
|
ProtocolLARP = 91 // Locus Address Resolution Protocol
|
||||||
|
ProtocolMTP = 92 // Multicast Transport Protocol
|
||||||
|
ProtocolAX25 = 93 // AX.25 Frames
|
||||||
|
ProtocolIPIP = 94 // IP-within-IP Encapsulation Protocol
|
||||||
|
ProtocolSCCSP = 96 // Semaphore Communications Sec. Pro.
|
||||||
|
ProtocolETHERIP = 97 // Ethernet-within-IP Encapsulation
|
||||||
|
ProtocolENCAP = 98 // Encapsulation Header
|
||||||
|
ProtocolGMTP = 100 // GMTP
|
||||||
|
ProtocolIFMP = 101 // Ipsilon Flow Management Protocol
|
||||||
|
ProtocolPNNI = 102 // PNNI over IP
|
||||||
|
ProtocolPIM = 103 // Protocol Independent Multicast
|
||||||
|
ProtocolARIS = 104 // ARIS
|
||||||
|
ProtocolSCPS = 105 // SCPS
|
||||||
|
ProtocolQNX = 106 // QNX
|
||||||
|
ProtocolAN = 107 // Active Networks
|
||||||
|
ProtocolIPComp = 108 // IP Payload Compression Protocol
|
||||||
|
ProtocolSNP = 109 // Sitara Networks Protocol
|
||||||
|
ProtocolCompaqPeer = 110 // Compaq Peer Protocol
|
||||||
|
ProtocolIPXinIP = 111 // IPX in IP
|
||||||
|
ProtocolVRRP = 112 // Virtual Router Redundancy Protocol
|
||||||
|
ProtocolPGM = 113 // PGM Reliable Transport Protocol
|
||||||
|
ProtocolL2TP = 115 // Layer Two Tunneling Protocol
|
||||||
|
ProtocolDDX = 116 // D-II Data Exchange (DDX)
|
||||||
|
ProtocolIATP = 117 // Interactive Agent Transfer Protocol
|
||||||
|
ProtocolSTP = 118 // Schedule Transfer Protocol
|
||||||
|
ProtocolSRP = 119 // SpectraLink Radio Protocol
|
||||||
|
ProtocolUTI = 120 // UTI
|
||||||
|
ProtocolSMP = 121 // Simple Message Protocol
|
||||||
|
ProtocolPTP = 123 // Performance Transparency Protocol
|
||||||
|
ProtocolISIS = 124 // ISIS over IPv4
|
||||||
|
ProtocolFIRE = 125 // FIRE
|
||||||
|
ProtocolCRTP = 126 // Combat Radio Transport Protocol
|
||||||
|
ProtocolCRUDP = 127 // Combat Radio User Datagram
|
||||||
|
ProtocolSSCOPMCE = 128 // SSCOPMCE
|
||||||
|
ProtocolIPLT = 129 // IPLT
|
||||||
|
ProtocolSPS = 130 // Secure Packet Shield
|
||||||
|
ProtocolPIPE = 131 // Private IP Encapsulation within IP
|
||||||
|
ProtocolSCTP = 132 // Stream Control Transmission Protocol
|
||||||
|
ProtocolFC = 133 // Fibre Channel
|
||||||
|
ProtocolRSVPE2EIGNORE = 134 // RSVP-E2E-IGNORE
|
||||||
|
ProtocolMobilityHeader = 135 // Mobility Header
|
||||||
|
ProtocolUDPLite = 136 // UDPLite
|
||||||
|
ProtocolMPLSinIP = 137 // MPLS-in-IP
|
||||||
|
ProtocolMANET = 138 // MANET Protocols
|
||||||
|
ProtocolHIP = 139 // Host Identity Protocol
|
||||||
|
ProtocolShim6 = 140 // Shim6 Protocol
|
||||||
|
ProtocolWESP = 141 // Wrapped Encapsulating Security Payload
|
||||||
|
ProtocolROHC = 142 // Robust Header Compression
|
||||||
|
ProtocolReserved = 255 // Reserved
|
||||||
|
)
|
||||||
|
|
||||||
|
// Address Family Numbers, Updated: 2018-04-02
|
||||||
|
const (
|
||||||
|
AddrFamilyIPv4 = 1 // IP (IP version 4)
|
||||||
|
AddrFamilyIPv6 = 2 // IP6 (IP version 6)
|
||||||
|
AddrFamilyNSAP = 3 // NSAP
|
||||||
|
AddrFamilyHDLC = 4 // HDLC (8-bit multidrop)
|
||||||
|
AddrFamilyBBN1822 = 5 // BBN 1822
|
||||||
|
AddrFamily802 = 6 // 802 (includes all 802 media plus Ethernet "canonical format")
|
||||||
|
AddrFamilyE163 = 7 // E.163
|
||||||
|
AddrFamilyE164 = 8 // E.164 (SMDS, Frame Relay, ATM)
|
||||||
|
AddrFamilyF69 = 9 // F.69 (Telex)
|
||||||
|
AddrFamilyX121 = 10 // X.121 (X.25, Frame Relay)
|
||||||
|
AddrFamilyIPX = 11 // IPX
|
||||||
|
AddrFamilyAppletalk = 12 // Appletalk
|
||||||
|
AddrFamilyDecnetIV = 13 // Decnet IV
|
||||||
|
AddrFamilyBanyanVines = 14 // Banyan Vines
|
||||||
|
AddrFamilyE164withSubaddress = 15 // E.164 with NSAP format subaddress
|
||||||
|
AddrFamilyDNS = 16 // DNS (Domain Name System)
|
||||||
|
AddrFamilyDistinguishedName = 17 // Distinguished Name
|
||||||
|
AddrFamilyASNumber = 18 // AS Number
|
||||||
|
AddrFamilyXTPoverIPv4 = 19 // XTP over IP version 4
|
||||||
|
AddrFamilyXTPoverIPv6 = 20 // XTP over IP version 6
|
||||||
|
AddrFamilyXTPnativemodeXTP = 21 // XTP native mode XTP
|
||||||
|
AddrFamilyFibreChannelWorldWidePortName = 22 // Fibre Channel World-Wide Port Name
|
||||||
|
AddrFamilyFibreChannelWorldWideNodeName = 23 // Fibre Channel World-Wide Node Name
|
||||||
|
AddrFamilyGWID = 24 // GWID
|
||||||
|
AddrFamilyL2VPN = 25 // AFI for L2VPN information
|
||||||
|
AddrFamilyMPLSTPSectionEndpointID = 26 // MPLS-TP Section Endpoint Identifier
|
||||||
|
AddrFamilyMPLSTPLSPEndpointID = 27 // MPLS-TP LSP Endpoint Identifier
|
||||||
|
AddrFamilyMPLSTPPseudowireEndpointID = 28 // MPLS-TP Pseudowire Endpoint Identifier
|
||||||
|
AddrFamilyMTIPv4 = 29 // MT IP: Multi-Topology IP version 4
|
||||||
|
AddrFamilyMTIPv6 = 30 // MT IPv6: Multi-Topology IP version 6
|
||||||
|
AddrFamilyEIGRPCommonServiceFamily = 16384 // EIGRP Common Service Family
|
||||||
|
AddrFamilyEIGRPIPv4ServiceFamily = 16385 // EIGRP IPv4 Service Family
|
||||||
|
AddrFamilyEIGRPIPv6ServiceFamily = 16386 // EIGRP IPv6 Service Family
|
||||||
|
AddrFamilyLISPCanonicalAddressFormat = 16387 // LISP Canonical Address Format (LCAF)
|
||||||
|
AddrFamilyBGPLS = 16388 // BGP-LS
|
||||||
|
AddrFamily48bitMAC = 16389 // 48-bit MAC
|
||||||
|
AddrFamily64bitMAC = 16390 // 64-bit MAC
|
||||||
|
AddrFamilyOUI = 16391 // OUI
|
||||||
|
AddrFamilyMACFinal24bits = 16392 // MAC/24
|
||||||
|
AddrFamilyMACFinal40bits = 16393 // MAC/40
|
||||||
|
AddrFamilyIPv6Initial64bits = 16394 // IPv6/64
|
||||||
|
AddrFamilyRBridgePortID = 16395 // RBridge Port ID
|
||||||
|
AddrFamilyTRILLNickname = 16396 // TRILL Nickname
|
||||||
|
)
|
383
vendor/golang.org/x/net/internal/iana/gen.go
generated
vendored
Normal file
383
vendor/golang.org/x/net/internal/iana/gen.go
generated
vendored
Normal file
@ -0,0 +1,383 @@
|
|||||||
|
// Copyright 2013 The Go Authors. All rights reserved.
|
||||||
|
// Use of this source code is governed by a BSD-style
|
||||||
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
|
// +build ignore
|
||||||
|
|
||||||
|
//go:generate go run gen.go
|
||||||
|
|
||||||
|
// This program generates internet protocol constants and tables by
|
||||||
|
// reading IANA protocol registries.
|
||||||
|
package main
|
||||||
|
|
||||||
|
import (
|
||||||
|
"bytes"
|
||||||
|
"encoding/xml"
|
||||||
|
"fmt"
|
||||||
|
"go/format"
|
||||||
|
"io"
|
||||||
|
"io/ioutil"
|
||||||
|
"net/http"
|
||||||
|
"os"
|
||||||
|
"strconv"
|
||||||
|
"strings"
|
||||||
|
)
|
||||||
|
|
||||||
|
var registries = []struct {
|
||||||
|
url string
|
||||||
|
parse func(io.Writer, io.Reader) error
|
||||||
|
}{
|
||||||
|
{
|
||||||
|
"https://www.iana.org/assignments/dscp-registry/dscp-registry.xml",
|
||||||
|
parseDSCPRegistry,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"https://www.iana.org/assignments/protocol-numbers/protocol-numbers.xml",
|
||||||
|
parseProtocolNumbers,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"https://www.iana.org/assignments/address-family-numbers/address-family-numbers.xml",
|
||||||
|
parseAddrFamilyNumbers,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
func main() {
|
||||||
|
var bb bytes.Buffer
|
||||||
|
fmt.Fprintf(&bb, "// go generate gen.go\n")
|
||||||
|
fmt.Fprintf(&bb, "// Code generated by the command above; DO NOT EDIT.\n\n")
|
||||||
|
fmt.Fprintf(&bb, "// Package iana provides protocol number resources managed by the Internet Assigned Numbers Authority (IANA).\n")
|
||||||
|
fmt.Fprintf(&bb, `package iana // import "golang.org/x/net/internal/iana"`+"\n\n")
|
||||||
|
for _, r := range registries {
|
||||||
|
resp, err := http.Get(r.url)
|
||||||
|
if err != nil {
|
||||||
|
fmt.Fprintln(os.Stderr, err)
|
||||||
|
os.Exit(1)
|
||||||
|
}
|
||||||
|
defer resp.Body.Close()
|
||||||
|
if resp.StatusCode != http.StatusOK {
|
||||||
|
fmt.Fprintf(os.Stderr, "got HTTP status code %v for %v\n", resp.StatusCode, r.url)
|
||||||
|
os.Exit(1)
|
||||||
|
}
|
||||||
|
if err := r.parse(&bb, resp.Body); err != nil {
|
||||||
|
fmt.Fprintln(os.Stderr, err)
|
||||||
|
os.Exit(1)
|
||||||
|
}
|
||||||
|
fmt.Fprintf(&bb, "\n")
|
||||||
|
}
|
||||||
|
b, err := format.Source(bb.Bytes())
|
||||||
|
if err != nil {
|
||||||
|
fmt.Fprintln(os.Stderr, err)
|
||||||
|
os.Exit(1)
|
||||||
|
}
|
||||||
|
if err := ioutil.WriteFile("const.go", b, 0644); err != nil {
|
||||||
|
fmt.Fprintln(os.Stderr, err)
|
||||||
|
os.Exit(1)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func parseDSCPRegistry(w io.Writer, r io.Reader) error {
|
||||||
|
dec := xml.NewDecoder(r)
|
||||||
|
var dr dscpRegistry
|
||||||
|
if err := dec.Decode(&dr); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
fmt.Fprintf(w, "// %s, Updated: %s\n", dr.Title, dr.Updated)
|
||||||
|
fmt.Fprintf(w, "const (\n")
|
||||||
|
for _, dr := range dr.escapeDSCP() {
|
||||||
|
fmt.Fprintf(w, "DiffServ%s = %#02x", dr.Name, dr.Value)
|
||||||
|
fmt.Fprintf(w, "// %s\n", dr.OrigName)
|
||||||
|
}
|
||||||
|
for _, er := range dr.escapeECN() {
|
||||||
|
fmt.Fprintf(w, "%s = %#02x", er.Descr, er.Value)
|
||||||
|
fmt.Fprintf(w, "// %s\n", er.OrigDescr)
|
||||||
|
}
|
||||||
|
fmt.Fprintf(w, ")\n")
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
type dscpRegistry struct {
|
||||||
|
XMLName xml.Name `xml:"registry"`
|
||||||
|
Title string `xml:"title"`
|
||||||
|
Updated string `xml:"updated"`
|
||||||
|
Note string `xml:"note"`
|
||||||
|
Registries []struct {
|
||||||
|
Title string `xml:"title"`
|
||||||
|
Registries []struct {
|
||||||
|
Title string `xml:"title"`
|
||||||
|
Records []struct {
|
||||||
|
Name string `xml:"name"`
|
||||||
|
Space string `xml:"space"`
|
||||||
|
} `xml:"record"`
|
||||||
|
} `xml:"registry"`
|
||||||
|
Records []struct {
|
||||||
|
Value string `xml:"value"`
|
||||||
|
Descr string `xml:"description"`
|
||||||
|
} `xml:"record"`
|
||||||
|
} `xml:"registry"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type canonDSCPRecord struct {
|
||||||
|
OrigName string
|
||||||
|
Name string
|
||||||
|
Value int
|
||||||
|
}
|
||||||
|
|
||||||
|
func (drr *dscpRegistry) escapeDSCP() []canonDSCPRecord {
|
||||||
|
var drs []canonDSCPRecord
|
||||||
|
for _, preg := range drr.Registries {
|
||||||
|
if !strings.Contains(preg.Title, "Differentiated Services Field Codepoints") {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
for _, reg := range preg.Registries {
|
||||||
|
if !strings.Contains(reg.Title, "Pool 1 Codepoints") {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
drs = make([]canonDSCPRecord, len(reg.Records))
|
||||||
|
sr := strings.NewReplacer(
|
||||||
|
"+", "",
|
||||||
|
"-", "",
|
||||||
|
"/", "",
|
||||||
|
".", "",
|
||||||
|
" ", "",
|
||||||
|
)
|
||||||
|
for i, dr := range reg.Records {
|
||||||
|
s := strings.TrimSpace(dr.Name)
|
||||||
|
drs[i].OrigName = s
|
||||||
|
drs[i].Name = sr.Replace(s)
|
||||||
|
n, err := strconv.ParseUint(dr.Space, 2, 8)
|
||||||
|
if err != nil {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
drs[i].Value = int(n) << 2
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return drs
|
||||||
|
}
|
||||||
|
|
||||||
|
type canonECNRecord struct {
|
||||||
|
OrigDescr string
|
||||||
|
Descr string
|
||||||
|
Value int
|
||||||
|
}
|
||||||
|
|
||||||
|
func (drr *dscpRegistry) escapeECN() []canonECNRecord {
|
||||||
|
var ers []canonECNRecord
|
||||||
|
for _, reg := range drr.Registries {
|
||||||
|
if !strings.Contains(reg.Title, "ECN Field") {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
ers = make([]canonECNRecord, len(reg.Records))
|
||||||
|
sr := strings.NewReplacer(
|
||||||
|
"Capable", "",
|
||||||
|
"Not-ECT", "",
|
||||||
|
"ECT(1)", "",
|
||||||
|
"ECT(0)", "",
|
||||||
|
"CE", "",
|
||||||
|
"(", "",
|
||||||
|
")", "",
|
||||||
|
"+", "",
|
||||||
|
"-", "",
|
||||||
|
"/", "",
|
||||||
|
".", "",
|
||||||
|
" ", "",
|
||||||
|
)
|
||||||
|
for i, er := range reg.Records {
|
||||||
|
s := strings.TrimSpace(er.Descr)
|
||||||
|
ers[i].OrigDescr = s
|
||||||
|
ss := strings.Split(s, " ")
|
||||||
|
if len(ss) > 1 {
|
||||||
|
ers[i].Descr = strings.Join(ss[1:], " ")
|
||||||
|
} else {
|
||||||
|
ers[i].Descr = ss[0]
|
||||||
|
}
|
||||||
|
ers[i].Descr = sr.Replace(er.Descr)
|
||||||
|
n, err := strconv.ParseUint(er.Value, 2, 8)
|
||||||
|
if err != nil {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
ers[i].Value = int(n)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return ers
|
||||||
|
}
|
||||||
|
|
||||||
|
func parseProtocolNumbers(w io.Writer, r io.Reader) error {
|
||||||
|
dec := xml.NewDecoder(r)
|
||||||
|
var pn protocolNumbers
|
||||||
|
if err := dec.Decode(&pn); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
prs := pn.escape()
|
||||||
|
prs = append([]canonProtocolRecord{{
|
||||||
|
Name: "IP",
|
||||||
|
Descr: "IPv4 encapsulation, pseudo protocol number",
|
||||||
|
Value: 0,
|
||||||
|
}}, prs...)
|
||||||
|
fmt.Fprintf(w, "// %s, Updated: %s\n", pn.Title, pn.Updated)
|
||||||
|
fmt.Fprintf(w, "const (\n")
|
||||||
|
for _, pr := range prs {
|
||||||
|
if pr.Name == "" {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
fmt.Fprintf(w, "Protocol%s = %d", pr.Name, pr.Value)
|
||||||
|
s := pr.Descr
|
||||||
|
if s == "" {
|
||||||
|
s = pr.OrigName
|
||||||
|
}
|
||||||
|
fmt.Fprintf(w, "// %s\n", s)
|
||||||
|
}
|
||||||
|
fmt.Fprintf(w, ")\n")
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
type protocolNumbers struct {
|
||||||
|
XMLName xml.Name `xml:"registry"`
|
||||||
|
Title string `xml:"title"`
|
||||||
|
Updated string `xml:"updated"`
|
||||||
|
RegTitle string `xml:"registry>title"`
|
||||||
|
Note string `xml:"registry>note"`
|
||||||
|
Records []struct {
|
||||||
|
Value string `xml:"value"`
|
||||||
|
Name string `xml:"name"`
|
||||||
|
Descr string `xml:"description"`
|
||||||
|
} `xml:"registry>record"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type canonProtocolRecord struct {
|
||||||
|
OrigName string
|
||||||
|
Name string
|
||||||
|
Descr string
|
||||||
|
Value int
|
||||||
|
}
|
||||||
|
|
||||||
|
func (pn *protocolNumbers) escape() []canonProtocolRecord {
|
||||||
|
prs := make([]canonProtocolRecord, len(pn.Records))
|
||||||
|
sr := strings.NewReplacer(
|
||||||
|
"-in-", "in",
|
||||||
|
"-within-", "within",
|
||||||
|
"-over-", "over",
|
||||||
|
"+", "P",
|
||||||
|
"-", "",
|
||||||
|
"/", "",
|
||||||
|
".", "",
|
||||||
|
" ", "",
|
||||||
|
)
|
||||||
|
for i, pr := range pn.Records {
|
||||||
|
if strings.Contains(pr.Name, "Deprecated") ||
|
||||||
|
strings.Contains(pr.Name, "deprecated") {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
prs[i].OrigName = pr.Name
|
||||||
|
s := strings.TrimSpace(pr.Name)
|
||||||
|
switch pr.Name {
|
||||||
|
case "ISIS over IPv4":
|
||||||
|
prs[i].Name = "ISIS"
|
||||||
|
case "manet":
|
||||||
|
prs[i].Name = "MANET"
|
||||||
|
default:
|
||||||
|
prs[i].Name = sr.Replace(s)
|
||||||
|
}
|
||||||
|
ss := strings.Split(pr.Descr, "\n")
|
||||||
|
for i := range ss {
|
||||||
|
ss[i] = strings.TrimSpace(ss[i])
|
||||||
|
}
|
||||||
|
if len(ss) > 1 {
|
||||||
|
prs[i].Descr = strings.Join(ss, " ")
|
||||||
|
} else {
|
||||||
|
prs[i].Descr = ss[0]
|
||||||
|
}
|
||||||
|
prs[i].Value, _ = strconv.Atoi(pr.Value)
|
||||||
|
}
|
||||||
|
return prs
|
||||||
|
}
|
||||||
|
|
||||||
|
func parseAddrFamilyNumbers(w io.Writer, r io.Reader) error {
|
||||||
|
dec := xml.NewDecoder(r)
|
||||||
|
var afn addrFamilylNumbers
|
||||||
|
if err := dec.Decode(&afn); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
afrs := afn.escape()
|
||||||
|
fmt.Fprintf(w, "// %s, Updated: %s\n", afn.Title, afn.Updated)
|
||||||
|
fmt.Fprintf(w, "const (\n")
|
||||||
|
for _, afr := range afrs {
|
||||||
|
if afr.Name == "" {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
fmt.Fprintf(w, "AddrFamily%s = %d", afr.Name, afr.Value)
|
||||||
|
fmt.Fprintf(w, "// %s\n", afr.Descr)
|
||||||
|
}
|
||||||
|
fmt.Fprintf(w, ")\n")
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
type addrFamilylNumbers struct {
|
||||||
|
XMLName xml.Name `xml:"registry"`
|
||||||
|
Title string `xml:"title"`
|
||||||
|
Updated string `xml:"updated"`
|
||||||
|
RegTitle string `xml:"registry>title"`
|
||||||
|
Note string `xml:"registry>note"`
|
||||||
|
Records []struct {
|
||||||
|
Value string `xml:"value"`
|
||||||
|
Descr string `xml:"description"`
|
||||||
|
} `xml:"registry>record"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type canonAddrFamilyRecord struct {
|
||||||
|
Name string
|
||||||
|
Descr string
|
||||||
|
Value int
|
||||||
|
}
|
||||||
|
|
||||||
|
func (afn *addrFamilylNumbers) escape() []canonAddrFamilyRecord {
|
||||||
|
afrs := make([]canonAddrFamilyRecord, len(afn.Records))
|
||||||
|
sr := strings.NewReplacer(
|
||||||
|
"IP version 4", "IPv4",
|
||||||
|
"IP version 6", "IPv6",
|
||||||
|
"Identifier", "ID",
|
||||||
|
"-", "",
|
||||||
|
"-", "",
|
||||||
|
"/", "",
|
||||||
|
".", "",
|
||||||
|
" ", "",
|
||||||
|
)
|
||||||
|
for i, afr := range afn.Records {
|
||||||
|
if strings.Contains(afr.Descr, "Unassigned") ||
|
||||||
|
strings.Contains(afr.Descr, "Reserved") {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
afrs[i].Descr = afr.Descr
|
||||||
|
s := strings.TrimSpace(afr.Descr)
|
||||||
|
switch s {
|
||||||
|
case "IP (IP version 4)":
|
||||||
|
afrs[i].Name = "IPv4"
|
||||||
|
case "IP6 (IP version 6)":
|
||||||
|
afrs[i].Name = "IPv6"
|
||||||
|
case "AFI for L2VPN information":
|
||||||
|
afrs[i].Name = "L2VPN"
|
||||||
|
case "E.164 with NSAP format subaddress":
|
||||||
|
afrs[i].Name = "E164withSubaddress"
|
||||||
|
case "MT IP: Multi-Topology IP version 4":
|
||||||
|
afrs[i].Name = "MTIPv4"
|
||||||
|
case "MAC/24":
|
||||||
|
afrs[i].Name = "MACFinal24bits"
|
||||||
|
case "MAC/40":
|
||||||
|
afrs[i].Name = "MACFinal40bits"
|
||||||
|
case "IPv6/64":
|
||||||
|
afrs[i].Name = "IPv6Initial64bits"
|
||||||
|
default:
|
||||||
|
n := strings.Index(s, "(")
|
||||||
|
if n > 0 {
|
||||||
|
s = s[:n]
|
||||||
|
}
|
||||||
|
n = strings.Index(s, ":")
|
||||||
|
if n > 0 {
|
||||||
|
s = s[:n]
|
||||||
|
}
|
||||||
|
afrs[i].Name = sr.Replace(s)
|
||||||
|
}
|
||||||
|
afrs[i].Value, _ = strconv.Atoi(afr.Value)
|
||||||
|
}
|
||||||
|
return afrs
|
||||||
|
}
|
53
vendor/golang.org/x/net/internal/nettest/helper_bsd.go
generated
vendored
Normal file
53
vendor/golang.org/x/net/internal/nettest/helper_bsd.go
generated
vendored
Normal file
@ -0,0 +1,53 @@
|
|||||||
|
// Copyright 2016 The Go Authors. All rights reserved.
|
||||||
|
// Use of this source code is governed by a BSD-style
|
||||||
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
|
// +build darwin dragonfly freebsd netbsd openbsd
|
||||||
|
|
||||||
|
package nettest
|
||||||
|
|
||||||
|
import (
|
||||||
|
"runtime"
|
||||||
|
"strconv"
|
||||||
|
"strings"
|
||||||
|
"syscall"
|
||||||
|
)
|
||||||
|
|
||||||
|
var darwinVersion int
|
||||||
|
|
||||||
|
func init() {
|
||||||
|
if runtime.GOOS == "darwin" {
|
||||||
|
// See http://support.apple.com/kb/HT1633.
|
||||||
|
s, err := syscall.Sysctl("kern.osrelease")
|
||||||
|
if err != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
ss := strings.Split(s, ".")
|
||||||
|
if len(ss) == 0 {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
darwinVersion, _ = strconv.Atoi(ss[0])
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func supportsIPv6MulticastDeliveryOnLoopback() bool {
|
||||||
|
switch runtime.GOOS {
|
||||||
|
case "freebsd":
|
||||||
|
// See http://www.freebsd.org/cgi/query-pr.cgi?pr=180065.
|
||||||
|
// Even after the fix, it looks like the latest
|
||||||
|
// kernels don't deliver link-local scoped multicast
|
||||||
|
// packets correctly.
|
||||||
|
return false
|
||||||
|
case "darwin":
|
||||||
|
return !causesIPv6Crash()
|
||||||
|
default:
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func causesIPv6Crash() bool {
|
||||||
|
// We see some kernel crash when running IPv6 with IP-level
|
||||||
|
// options on Darwin kernel version 12 or below.
|
||||||
|
// See golang.org/issues/17015.
|
||||||
|
return darwinVersion < 13
|
||||||
|
}
|
15
vendor/golang.org/x/net/internal/nettest/helper_nobsd.go
generated
vendored
Normal file
15
vendor/golang.org/x/net/internal/nettest/helper_nobsd.go
generated
vendored
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
// Copyright 2016 The Go Authors. All rights reserved.
|
||||||
|
// Use of this source code is governed by a BSD-style
|
||||||
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
|
// +build linux solaris
|
||||||
|
|
||||||
|
package nettest
|
||||||
|
|
||||||
|
func supportsIPv6MulticastDeliveryOnLoopback() bool {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
|
func causesIPv6Crash() bool {
|
||||||
|
return false
|
||||||
|
}
|
31
vendor/golang.org/x/net/internal/nettest/helper_posix.go
generated
vendored
Normal file
31
vendor/golang.org/x/net/internal/nettest/helper_posix.go
generated
vendored
Normal file
@ -0,0 +1,31 @@
|
|||||||
|
// Copyright 2014 The Go Authors. All rights reserved.
|
||||||
|
// Use of this source code is governed by a BSD-style
|
||||||
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
|
// +build darwin dragonfly freebsd linux netbsd openbsd solaris windows
|
||||||
|
|
||||||
|
package nettest
|
||||||
|
|
||||||
|
import (
|
||||||
|
"os"
|
||||||
|
"syscall"
|
||||||
|
)
|
||||||
|
|
||||||
|
func protocolNotSupported(err error) bool {
|
||||||
|
switch err := err.(type) {
|
||||||
|
case syscall.Errno:
|
||||||
|
switch err {
|
||||||
|
case syscall.EPROTONOSUPPORT, syscall.ENOPROTOOPT:
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
case *os.SyscallError:
|
||||||
|
switch err := err.Err.(type) {
|
||||||
|
case syscall.Errno:
|
||||||
|
switch err {
|
||||||
|
case syscall.EPROTONOSUPPORT, syscall.ENOPROTOOPT:
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false
|
||||||
|
}
|
32
vendor/golang.org/x/net/internal/nettest/helper_stub.go
generated
vendored
Normal file
32
vendor/golang.org/x/net/internal/nettest/helper_stub.go
generated
vendored
Normal file
@ -0,0 +1,32 @@
|
|||||||
|
// Copyright 2014 The Go Authors. All rights reserved.
|
||||||
|
// Use of this source code is governed by a BSD-style
|
||||||
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
|
// +build js nacl plan9
|
||||||
|
|
||||||
|
package nettest
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
"runtime"
|
||||||
|
)
|
||||||
|
|
||||||
|
func maxOpenFiles() int {
|
||||||
|
return defaultMaxOpenFiles
|
||||||
|
}
|
||||||
|
|
||||||
|
func supportsRawIPSocket() (string, bool) {
|
||||||
|
return fmt.Sprintf("not supported on %s", runtime.GOOS), false
|
||||||
|
}
|
||||||
|
|
||||||
|
func supportsIPv6MulticastDeliveryOnLoopback() bool {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
func causesIPv6Crash() bool {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
func protocolNotSupported(err error) bool {
|
||||||
|
return false
|
||||||
|
}
|
29
vendor/golang.org/x/net/internal/nettest/helper_unix.go
generated
vendored
Normal file
29
vendor/golang.org/x/net/internal/nettest/helper_unix.go
generated
vendored
Normal file
@ -0,0 +1,29 @@
|
|||||||
|
// Copyright 2015 The Go Authors. All rights reserved.
|
||||||
|
// Use of this source code is governed by a BSD-style
|
||||||
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
|
// +build darwin dragonfly freebsd linux netbsd openbsd solaris
|
||||||
|
|
||||||
|
package nettest
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
"os"
|
||||||
|
"runtime"
|
||||||
|
"syscall"
|
||||||
|
)
|
||||||
|
|
||||||
|
func maxOpenFiles() int {
|
||||||
|
var rlim syscall.Rlimit
|
||||||
|
if err := syscall.Getrlimit(syscall.RLIMIT_NOFILE, &rlim); err != nil {
|
||||||
|
return defaultMaxOpenFiles
|
||||||
|
}
|
||||||
|
return int(rlim.Cur)
|
||||||
|
}
|
||||||
|
|
||||||
|
func supportsRawIPSocket() (string, bool) {
|
||||||
|
if os.Getuid() != 0 {
|
||||||
|
return fmt.Sprintf("must be root on %s", runtime.GOOS), false
|
||||||
|
}
|
||||||
|
return "", true
|
||||||
|
}
|
42
vendor/golang.org/x/net/internal/nettest/helper_windows.go
generated
vendored
Normal file
42
vendor/golang.org/x/net/internal/nettest/helper_windows.go
generated
vendored
Normal file
@ -0,0 +1,42 @@
|
|||||||
|
// Copyright 2015 The Go Authors. All rights reserved.
|
||||||
|
// Use of this source code is governed by a BSD-style
|
||||||
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
|
package nettest
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
"runtime"
|
||||||
|
"syscall"
|
||||||
|
)
|
||||||
|
|
||||||
|
func maxOpenFiles() int {
|
||||||
|
return 4 * defaultMaxOpenFiles /* actually it's 16581375 */
|
||||||
|
}
|
||||||
|
|
||||||
|
func supportsRawIPSocket() (string, bool) {
|
||||||
|
// From http://msdn.microsoft.com/en-us/library/windows/desktop/ms740548.aspx:
|
||||||
|
// Note: To use a socket of type SOCK_RAW requires administrative privileges.
|
||||||
|
// Users running Winsock applications that use raw sockets must be a member of
|
||||||
|
// the Administrators group on the local computer, otherwise raw socket calls
|
||||||
|
// will fail with an error code of WSAEACCES. On Windows Vista and later, access
|
||||||
|
// for raw sockets is enforced at socket creation. In earlier versions of Windows,
|
||||||
|
// access for raw sockets is enforced during other socket operations.
|
||||||
|
s, err := syscall.Socket(syscall.AF_INET, syscall.SOCK_RAW, 0)
|
||||||
|
if err == syscall.WSAEACCES {
|
||||||
|
return fmt.Sprintf("no access to raw socket allowed on %s", runtime.GOOS), false
|
||||||
|
}
|
||||||
|
if err != nil {
|
||||||
|
return err.Error(), false
|
||||||
|
}
|
||||||
|
syscall.Closesocket(s)
|
||||||
|
return "", true
|
||||||
|
}
|
||||||
|
|
||||||
|
func supportsIPv6MulticastDeliveryOnLoopback() bool {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
|
func causesIPv6Crash() bool {
|
||||||
|
return false
|
||||||
|
}
|
94
vendor/golang.org/x/net/internal/nettest/interface.go
generated
vendored
Normal file
94
vendor/golang.org/x/net/internal/nettest/interface.go
generated
vendored
Normal file
@ -0,0 +1,94 @@
|
|||||||
|
// Copyright 2012 The Go Authors. All rights reserved.
|
||||||
|
// Use of this source code is governed by a BSD-style
|
||||||
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
|
package nettest
|
||||||
|
|
||||||
|
import "net"
|
||||||
|
|
||||||
|
// IsMulticastCapable reports whether ifi is an IP multicast-capable
|
||||||
|
// network interface. Network must be "ip", "ip4" or "ip6".
|
||||||
|
func IsMulticastCapable(network string, ifi *net.Interface) (net.IP, bool) {
|
||||||
|
switch network {
|
||||||
|
case "ip", "ip4", "ip6":
|
||||||
|
default:
|
||||||
|
return nil, false
|
||||||
|
}
|
||||||
|
if ifi == nil || ifi.Flags&net.FlagUp == 0 || ifi.Flags&net.FlagMulticast == 0 {
|
||||||
|
return nil, false
|
||||||
|
}
|
||||||
|
return hasRoutableIP(network, ifi)
|
||||||
|
}
|
||||||
|
|
||||||
|
// RoutedInterface returns a network interface that can route IP
|
||||||
|
// traffic and satisfies flags. It returns nil when an appropriate
|
||||||
|
// network interface is not found. Network must be "ip", "ip4" or
|
||||||
|
// "ip6".
|
||||||
|
func RoutedInterface(network string, flags net.Flags) *net.Interface {
|
||||||
|
switch network {
|
||||||
|
case "ip", "ip4", "ip6":
|
||||||
|
default:
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
ift, err := net.Interfaces()
|
||||||
|
if err != nil {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
for _, ifi := range ift {
|
||||||
|
if ifi.Flags&flags != flags {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
if _, ok := hasRoutableIP(network, &ifi); !ok {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
return &ifi
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func hasRoutableIP(network string, ifi *net.Interface) (net.IP, bool) {
|
||||||
|
ifat, err := ifi.Addrs()
|
||||||
|
if err != nil {
|
||||||
|
return nil, false
|
||||||
|
}
|
||||||
|
for _, ifa := range ifat {
|
||||||
|
switch ifa := ifa.(type) {
|
||||||
|
case *net.IPAddr:
|
||||||
|
if ip := routableIP(network, ifa.IP); ip != nil {
|
||||||
|
return ip, true
|
||||||
|
}
|
||||||
|
case *net.IPNet:
|
||||||
|
if ip := routableIP(network, ifa.IP); ip != nil {
|
||||||
|
return ip, true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return nil, false
|
||||||
|
}
|
||||||
|
|
||||||
|
func routableIP(network string, ip net.IP) net.IP {
|
||||||
|
if !ip.IsLoopback() && !ip.IsLinkLocalUnicast() && !ip.IsGlobalUnicast() {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
switch network {
|
||||||
|
case "ip4":
|
||||||
|
if ip := ip.To4(); ip != nil {
|
||||||
|
return ip
|
||||||
|
}
|
||||||
|
case "ip6":
|
||||||
|
if ip.IsLoopback() { // addressing scope of the loopback address depends on each implementation
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
if ip := ip.To16(); ip != nil && ip.To4() == nil {
|
||||||
|
return ip
|
||||||
|
}
|
||||||
|
default:
|
||||||
|
if ip := ip.To4(); ip != nil {
|
||||||
|
return ip
|
||||||
|
}
|
||||||
|
if ip := ip.To16(); ip != nil {
|
||||||
|
return ip
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
11
vendor/golang.org/x/net/internal/nettest/rlimit.go
generated
vendored
Normal file
11
vendor/golang.org/x/net/internal/nettest/rlimit.go
generated
vendored
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
// Copyright 2015 The Go Authors. All rights reserved.
|
||||||
|
// Use of this source code is governed by a BSD-style
|
||||||
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
|
package nettest
|
||||||
|
|
||||||
|
const defaultMaxOpenFiles = 256
|
||||||
|
|
||||||
|
// MaxOpenFiles returns the maximum number of open files for the
|
||||||
|
// caller's process.
|
||||||
|
func MaxOpenFiles() int { return maxOpenFiles() }
|
152
vendor/golang.org/x/net/internal/nettest/stack.go
generated
vendored
Normal file
152
vendor/golang.org/x/net/internal/nettest/stack.go
generated
vendored
Normal file
@ -0,0 +1,152 @@
|
|||||||
|
// Copyright 2014 The Go Authors. All rights reserved.
|
||||||
|
// Use of this source code is governed by a BSD-style
|
||||||
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
|
// Package nettest provides utilities for network testing.
|
||||||
|
package nettest // import "golang.org/x/net/internal/nettest"
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
"io/ioutil"
|
||||||
|
"net"
|
||||||
|
"os"
|
||||||
|
"runtime"
|
||||||
|
)
|
||||||
|
|
||||||
|
var (
|
||||||
|
supportsIPv4 bool
|
||||||
|
supportsIPv6 bool
|
||||||
|
)
|
||||||
|
|
||||||
|
func init() {
|
||||||
|
if ln, err := net.Listen("tcp4", "127.0.0.1:0"); err == nil {
|
||||||
|
ln.Close()
|
||||||
|
supportsIPv4 = true
|
||||||
|
}
|
||||||
|
if ln, err := net.Listen("tcp6", "[::1]:0"); err == nil {
|
||||||
|
ln.Close()
|
||||||
|
supportsIPv6 = true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// SupportsIPv4 reports whether the platform supports IPv4 networking
|
||||||
|
// functionality.
|
||||||
|
func SupportsIPv4() bool { return supportsIPv4 }
|
||||||
|
|
||||||
|
// SupportsIPv6 reports whether the platform supports IPv6 networking
|
||||||
|
// functionality.
|
||||||
|
func SupportsIPv6() bool { return supportsIPv6 }
|
||||||
|
|
||||||
|
// SupportsRawIPSocket reports whether the platform supports raw IP
|
||||||
|
// sockets.
|
||||||
|
func SupportsRawIPSocket() (string, bool) {
|
||||||
|
return supportsRawIPSocket()
|
||||||
|
}
|
||||||
|
|
||||||
|
// SupportsIPv6MulticastDeliveryOnLoopback reports whether the
|
||||||
|
// platform supports IPv6 multicast packet delivery on software
|
||||||
|
// loopback interface.
|
||||||
|
func SupportsIPv6MulticastDeliveryOnLoopback() bool {
|
||||||
|
return supportsIPv6MulticastDeliveryOnLoopback()
|
||||||
|
}
|
||||||
|
|
||||||
|
// ProtocolNotSupported reports whether err is a protocol not
|
||||||
|
// supported error.
|
||||||
|
func ProtocolNotSupported(err error) bool {
|
||||||
|
return protocolNotSupported(err)
|
||||||
|
}
|
||||||
|
|
||||||
|
// TestableNetwork reports whether network is testable on the current
|
||||||
|
// platform configuration.
|
||||||
|
func TestableNetwork(network string) bool {
|
||||||
|
// This is based on logic from standard library's
|
||||||
|
// net/platform_test.go.
|
||||||
|
switch network {
|
||||||
|
case "unix", "unixgram":
|
||||||
|
switch runtime.GOOS {
|
||||||
|
case "android", "js", "nacl", "plan9", "windows":
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
if runtime.GOOS == "darwin" && (runtime.GOARCH == "arm" || runtime.GOARCH == "arm64") {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
case "unixpacket":
|
||||||
|
switch runtime.GOOS {
|
||||||
|
case "android", "darwin", "freebsd", "js", "nacl", "plan9", "windows":
|
||||||
|
return false
|
||||||
|
case "netbsd":
|
||||||
|
// It passes on amd64 at least. 386 fails (Issue 22927). arm is unknown.
|
||||||
|
if runtime.GOARCH == "386" {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
|
// NewLocalListener returns a listener which listens to a loopback IP
|
||||||
|
// address or local file system path.
|
||||||
|
// Network must be "tcp", "tcp4", "tcp6", "unix" or "unixpacket".
|
||||||
|
func NewLocalListener(network string) (net.Listener, error) {
|
||||||
|
switch network {
|
||||||
|
case "tcp":
|
||||||
|
if supportsIPv4 {
|
||||||
|
if ln, err := net.Listen("tcp4", "127.0.0.1:0"); err == nil {
|
||||||
|
return ln, nil
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if supportsIPv6 {
|
||||||
|
return net.Listen("tcp6", "[::1]:0")
|
||||||
|
}
|
||||||
|
case "tcp4":
|
||||||
|
if supportsIPv4 {
|
||||||
|
return net.Listen("tcp4", "127.0.0.1:0")
|
||||||
|
}
|
||||||
|
case "tcp6":
|
||||||
|
if supportsIPv6 {
|
||||||
|
return net.Listen("tcp6", "[::1]:0")
|
||||||
|
}
|
||||||
|
case "unix", "unixpacket":
|
||||||
|
return net.Listen(network, localPath())
|
||||||
|
}
|
||||||
|
return nil, fmt.Errorf("%s is not supported", network)
|
||||||
|
}
|
||||||
|
|
||||||
|
// NewLocalPacketListener returns a packet listener which listens to a
|
||||||
|
// loopback IP address or local file system path.
|
||||||
|
// Network must be "udp", "udp4", "udp6" or "unixgram".
|
||||||
|
func NewLocalPacketListener(network string) (net.PacketConn, error) {
|
||||||
|
switch network {
|
||||||
|
case "udp":
|
||||||
|
if supportsIPv4 {
|
||||||
|
if c, err := net.ListenPacket("udp4", "127.0.0.1:0"); err == nil {
|
||||||
|
return c, nil
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if supportsIPv6 {
|
||||||
|
return net.ListenPacket("udp6", "[::1]:0")
|
||||||
|
}
|
||||||
|
case "udp4":
|
||||||
|
if supportsIPv4 {
|
||||||
|
return net.ListenPacket("udp4", "127.0.0.1:0")
|
||||||
|
}
|
||||||
|
case "udp6":
|
||||||
|
if supportsIPv6 {
|
||||||
|
return net.ListenPacket("udp6", "[::1]:0")
|
||||||
|
}
|
||||||
|
case "unixgram":
|
||||||
|
return net.ListenPacket(network, localPath())
|
||||||
|
}
|
||||||
|
return nil, fmt.Errorf("%s is not supported", network)
|
||||||
|
}
|
||||||
|
|
||||||
|
func localPath() string {
|
||||||
|
f, err := ioutil.TempFile("", "nettest")
|
||||||
|
if err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
path := f.Name()
|
||||||
|
f.Close()
|
||||||
|
os.Remove(path)
|
||||||
|
return path
|
||||||
|
}
|
11
vendor/golang.org/x/net/internal/socket/cmsghdr.go
generated
vendored
Normal file
11
vendor/golang.org/x/net/internal/socket/cmsghdr.go
generated
vendored
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
// Copyright 2017 The Go Authors. All rights reserved.
|
||||||
|
// Use of this source code is governed by a BSD-style
|
||||||
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
|
// +build darwin dragonfly freebsd linux netbsd openbsd solaris
|
||||||
|
|
||||||
|
package socket
|
||||||
|
|
||||||
|
func (h *cmsghdr) len() int { return int(h.Len) }
|
||||||
|
func (h *cmsghdr) lvl() int { return int(h.Level) }
|
||||||
|
func (h *cmsghdr) typ() int { return int(h.Type) }
|
13
vendor/golang.org/x/net/internal/socket/cmsghdr_bsd.go
generated
vendored
Normal file
13
vendor/golang.org/x/net/internal/socket/cmsghdr_bsd.go
generated
vendored
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
// Copyright 2017 The Go Authors. All rights reserved.
|
||||||
|
// Use of this source code is governed by a BSD-style
|
||||||
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
|
// +build darwin dragonfly freebsd netbsd openbsd
|
||||||
|
|
||||||
|
package socket
|
||||||
|
|
||||||
|
func (h *cmsghdr) set(l, lvl, typ int) {
|
||||||
|
h.Len = uint32(l)
|
||||||
|
h.Level = int32(lvl)
|
||||||
|
h.Type = int32(typ)
|
||||||
|
}
|
14
vendor/golang.org/x/net/internal/socket/cmsghdr_linux_32bit.go
generated
vendored
Normal file
14
vendor/golang.org/x/net/internal/socket/cmsghdr_linux_32bit.go
generated
vendored
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
// Copyright 2017 The Go Authors. All rights reserved.
|
||||||
|
// Use of this source code is governed by a BSD-style
|
||||||
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
|
// +build arm mips mipsle 386
|
||||||
|
// +build linux
|
||||||
|
|
||||||
|
package socket
|
||||||
|
|
||||||
|
func (h *cmsghdr) set(l, lvl, typ int) {
|
||||||
|
h.Len = uint32(l)
|
||||||
|
h.Level = int32(lvl)
|
||||||
|
h.Type = int32(typ)
|
||||||
|
}
|
14
vendor/golang.org/x/net/internal/socket/cmsghdr_linux_64bit.go
generated
vendored
Normal file
14
vendor/golang.org/x/net/internal/socket/cmsghdr_linux_64bit.go
generated
vendored
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
// Copyright 2017 The Go Authors. All rights reserved.
|
||||||
|
// Use of this source code is governed by a BSD-style
|
||||||
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
|
// +build arm64 amd64 ppc64 ppc64le mips64 mips64le s390x
|
||||||
|
// +build linux
|
||||||
|
|
||||||
|
package socket
|
||||||
|
|
||||||
|
func (h *cmsghdr) set(l, lvl, typ int) {
|
||||||
|
h.Len = uint64(l)
|
||||||
|
h.Level = int32(lvl)
|
||||||
|
h.Type = int32(typ)
|
||||||
|
}
|
14
vendor/golang.org/x/net/internal/socket/cmsghdr_solaris_64bit.go
generated
vendored
Normal file
14
vendor/golang.org/x/net/internal/socket/cmsghdr_solaris_64bit.go
generated
vendored
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
// Copyright 2017 The Go Authors. All rights reserved.
|
||||||
|
// Use of this source code is governed by a BSD-style
|
||||||
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
|
// +build amd64
|
||||||
|
// +build solaris
|
||||||
|
|
||||||
|
package socket
|
||||||
|
|
||||||
|
func (h *cmsghdr) set(l, lvl, typ int) {
|
||||||
|
h.Len = uint32(l)
|
||||||
|
h.Level = int32(lvl)
|
||||||
|
h.Type = int32(typ)
|
||||||
|
}
|
17
vendor/golang.org/x/net/internal/socket/cmsghdr_stub.go
generated
vendored
Normal file
17
vendor/golang.org/x/net/internal/socket/cmsghdr_stub.go
generated
vendored
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
// Copyright 2017 The Go Authors. All rights reserved.
|
||||||
|
// Use of this source code is governed by a BSD-style
|
||||||
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
|
// +build !darwin,!dragonfly,!freebsd,!linux,!netbsd,!openbsd,!solaris
|
||||||
|
|
||||||
|
package socket
|
||||||
|
|
||||||
|
type cmsghdr struct{}
|
||||||
|
|
||||||
|
const sizeofCmsghdr = 0
|
||||||
|
|
||||||
|
func (h *cmsghdr) len() int { return 0 }
|
||||||
|
func (h *cmsghdr) lvl() int { return 0 }
|
||||||
|
func (h *cmsghdr) typ() int { return 0 }
|
||||||
|
|
||||||
|
func (h *cmsghdr) set(l, lvl, typ int) {}
|
44
vendor/golang.org/x/net/internal/socket/defs_darwin.go
generated
vendored
Normal file
44
vendor/golang.org/x/net/internal/socket/defs_darwin.go
generated
vendored
Normal file
@ -0,0 +1,44 @@
|
|||||||
|
// Copyright 2017 The Go Authors. All rights reserved.
|
||||||
|
// Use of this source code is governed by a BSD-style
|
||||||
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
|
// +build ignore
|
||||||
|
|
||||||
|
// +godefs map struct_in_addr [4]byte /* in_addr */
|
||||||
|
// +godefs map struct_in6_addr [16]byte /* in6_addr */
|
||||||
|
|
||||||
|
package socket
|
||||||
|
|
||||||
|
/*
|
||||||
|
#include <sys/socket.h>
|
||||||
|
|
||||||
|
#include <netinet/in.h>
|
||||||
|
*/
|
||||||
|
import "C"
|
||||||
|
|
||||||
|
const (
|
||||||
|
sysAF_UNSPEC = C.AF_UNSPEC
|
||||||
|
sysAF_INET = C.AF_INET
|
||||||
|
sysAF_INET6 = C.AF_INET6
|
||||||
|
|
||||||
|
sysSOCK_RAW = C.SOCK_RAW
|
||||||
|
)
|
||||||
|
|
||||||
|
type iovec C.struct_iovec
|
||||||
|
|
||||||
|
type msghdr C.struct_msghdr
|
||||||
|
|
||||||
|
type cmsghdr C.struct_cmsghdr
|
||||||
|
|
||||||
|
type sockaddrInet C.struct_sockaddr_in
|
||||||
|
|
||||||
|
type sockaddrInet6 C.struct_sockaddr_in6
|
||||||
|
|
||||||
|
const (
|
||||||
|
sizeofIovec = C.sizeof_struct_iovec
|
||||||
|
sizeofMsghdr = C.sizeof_struct_msghdr
|
||||||
|
sizeofCmsghdr = C.sizeof_struct_cmsghdr
|
||||||
|
|
||||||
|
sizeofSockaddrInet = C.sizeof_struct_sockaddr_in
|
||||||
|
sizeofSockaddrInet6 = C.sizeof_struct_sockaddr_in6
|
||||||
|
)
|
44
vendor/golang.org/x/net/internal/socket/defs_dragonfly.go
generated
vendored
Normal file
44
vendor/golang.org/x/net/internal/socket/defs_dragonfly.go
generated
vendored
Normal file
@ -0,0 +1,44 @@
|
|||||||
|
// Copyright 2017 The Go Authors. All rights reserved.
|
||||||
|
// Use of this source code is governed by a BSD-style
|
||||||
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
|
// +build ignore
|
||||||
|
|
||||||
|
// +godefs map struct_in_addr [4]byte /* in_addr */
|
||||||
|
// +godefs map struct_in6_addr [16]byte /* in6_addr */
|
||||||
|
|
||||||
|
package socket
|
||||||
|
|
||||||
|
/*
|
||||||
|
#include <sys/socket.h>
|
||||||
|
|
||||||
|
#include <netinet/in.h>
|
||||||
|
*/
|
||||||
|
import "C"
|
||||||
|
|
||||||
|
const (
|
||||||
|
sysAF_UNSPEC = C.AF_UNSPEC
|
||||||
|
sysAF_INET = C.AF_INET
|
||||||
|
sysAF_INET6 = C.AF_INET6
|
||||||
|
|
||||||
|
sysSOCK_RAW = C.SOCK_RAW
|
||||||
|
)
|
||||||
|
|
||||||
|
type iovec C.struct_iovec
|
||||||
|
|
||||||
|
type msghdr C.struct_msghdr
|
||||||
|
|
||||||
|
type cmsghdr C.struct_cmsghdr
|
||||||
|
|
||||||
|
type sockaddrInet C.struct_sockaddr_in
|
||||||
|
|
||||||
|
type sockaddrInet6 C.struct_sockaddr_in6
|
||||||
|
|
||||||
|
const (
|
||||||
|
sizeofIovec = C.sizeof_struct_iovec
|
||||||
|
sizeofMsghdr = C.sizeof_struct_msghdr
|
||||||
|
sizeofCmsghdr = C.sizeof_struct_cmsghdr
|
||||||
|
|
||||||
|
sizeofSockaddrInet = C.sizeof_struct_sockaddr_in
|
||||||
|
sizeofSockaddrInet6 = C.sizeof_struct_sockaddr_in6
|
||||||
|
)
|
44
vendor/golang.org/x/net/internal/socket/defs_freebsd.go
generated
vendored
Normal file
44
vendor/golang.org/x/net/internal/socket/defs_freebsd.go
generated
vendored
Normal file
@ -0,0 +1,44 @@
|
|||||||
|
// Copyright 2017 The Go Authors. All rights reserved.
|
||||||
|
// Use of this source code is governed by a BSD-style
|
||||||
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
|
// +build ignore
|
||||||
|
|
||||||
|
// +godefs map struct_in_addr [4]byte /* in_addr */
|
||||||
|
// +godefs map struct_in6_addr [16]byte /* in6_addr */
|
||||||
|
|
||||||
|
package socket
|
||||||
|
|
||||||
|
/*
|
||||||
|
#include <sys/socket.h>
|
||||||
|
|
||||||
|
#include <netinet/in.h>
|
||||||
|
*/
|
||||||
|
import "C"
|
||||||
|
|
||||||
|
const (
|
||||||
|
sysAF_UNSPEC = C.AF_UNSPEC
|
||||||
|
sysAF_INET = C.AF_INET
|
||||||
|
sysAF_INET6 = C.AF_INET6
|
||||||
|
|
||||||
|
sysSOCK_RAW = C.SOCK_RAW
|
||||||
|
)
|
||||||
|
|
||||||
|
type iovec C.struct_iovec
|
||||||
|
|
||||||
|
type msghdr C.struct_msghdr
|
||||||
|
|
||||||
|
type cmsghdr C.struct_cmsghdr
|
||||||
|
|
||||||
|
type sockaddrInet C.struct_sockaddr_in
|
||||||
|
|
||||||
|
type sockaddrInet6 C.struct_sockaddr_in6
|
||||||
|
|
||||||
|
const (
|
||||||
|
sizeofIovec = C.sizeof_struct_iovec
|
||||||
|
sizeofMsghdr = C.sizeof_struct_msghdr
|
||||||
|
sizeofCmsghdr = C.sizeof_struct_cmsghdr
|
||||||
|
|
||||||
|
sizeofSockaddrInet = C.sizeof_struct_sockaddr_in
|
||||||
|
sizeofSockaddrInet6 = C.sizeof_struct_sockaddr_in6
|
||||||
|
)
|
49
vendor/golang.org/x/net/internal/socket/defs_linux.go
generated
vendored
Normal file
49
vendor/golang.org/x/net/internal/socket/defs_linux.go
generated
vendored
Normal file
@ -0,0 +1,49 @@
|
|||||||
|
// Copyright 2017 The Go Authors. All rights reserved.
|
||||||
|
// Use of this source code is governed by a BSD-style
|
||||||
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
|
// +build ignore
|
||||||
|
|
||||||
|
// +godefs map struct_in_addr [4]byte /* in_addr */
|
||||||
|
// +godefs map struct_in6_addr [16]byte /* in6_addr */
|
||||||
|
|
||||||
|
package socket
|
||||||
|
|
||||||
|
/*
|
||||||
|
#include <linux/in.h>
|
||||||
|
#include <linux/in6.h>
|
||||||
|
|
||||||
|
#define _GNU_SOURCE
|
||||||
|
#include <sys/socket.h>
|
||||||
|
*/
|
||||||
|
import "C"
|
||||||
|
|
||||||
|
const (
|
||||||
|
sysAF_UNSPEC = C.AF_UNSPEC
|
||||||
|
sysAF_INET = C.AF_INET
|
||||||
|
sysAF_INET6 = C.AF_INET6
|
||||||
|
|
||||||
|
sysSOCK_RAW = C.SOCK_RAW
|
||||||
|
)
|
||||||
|
|
||||||
|
type iovec C.struct_iovec
|
||||||
|
|
||||||
|
type msghdr C.struct_msghdr
|
||||||
|
|
||||||
|
type mmsghdr C.struct_mmsghdr
|
||||||
|
|
||||||
|
type cmsghdr C.struct_cmsghdr
|
||||||
|
|
||||||
|
type sockaddrInet C.struct_sockaddr_in
|
||||||
|
|
||||||
|
type sockaddrInet6 C.struct_sockaddr_in6
|
||||||
|
|
||||||
|
const (
|
||||||
|
sizeofIovec = C.sizeof_struct_iovec
|
||||||
|
sizeofMsghdr = C.sizeof_struct_msghdr
|
||||||
|
sizeofMmsghdr = C.sizeof_struct_mmsghdr
|
||||||
|
sizeofCmsghdr = C.sizeof_struct_cmsghdr
|
||||||
|
|
||||||
|
sizeofSockaddrInet = C.sizeof_struct_sockaddr_in
|
||||||
|
sizeofSockaddrInet6 = C.sizeof_struct_sockaddr_in6
|
||||||
|
)
|
47
vendor/golang.org/x/net/internal/socket/defs_netbsd.go
generated
vendored
Normal file
47
vendor/golang.org/x/net/internal/socket/defs_netbsd.go
generated
vendored
Normal file
@ -0,0 +1,47 @@
|
|||||||
|
// Copyright 2017 The Go Authors. All rights reserved.
|
||||||
|
// Use of this source code is governed by a BSD-style
|
||||||
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
|
// +build ignore
|
||||||
|
|
||||||
|
// +godefs map struct_in_addr [4]byte /* in_addr */
|
||||||
|
// +godefs map struct_in6_addr [16]byte /* in6_addr */
|
||||||
|
|
||||||
|
package socket
|
||||||
|
|
||||||
|
/*
|
||||||
|
#include <sys/socket.h>
|
||||||
|
|
||||||
|
#include <netinet/in.h>
|
||||||
|
*/
|
||||||
|
import "C"
|
||||||
|
|
||||||
|
const (
|
||||||
|
sysAF_UNSPEC = C.AF_UNSPEC
|
||||||
|
sysAF_INET = C.AF_INET
|
||||||
|
sysAF_INET6 = C.AF_INET6
|
||||||
|
|
||||||
|
sysSOCK_RAW = C.SOCK_RAW
|
||||||
|
)
|
||||||
|
|
||||||
|
type iovec C.struct_iovec
|
||||||
|
|
||||||
|
type msghdr C.struct_msghdr
|
||||||
|
|
||||||
|
type mmsghdr C.struct_mmsghdr
|
||||||
|
|
||||||
|
type cmsghdr C.struct_cmsghdr
|
||||||
|
|
||||||
|
type sockaddrInet C.struct_sockaddr_in
|
||||||
|
|
||||||
|
type sockaddrInet6 C.struct_sockaddr_in6
|
||||||
|
|
||||||
|
const (
|
||||||
|
sizeofIovec = C.sizeof_struct_iovec
|
||||||
|
sizeofMsghdr = C.sizeof_struct_msghdr
|
||||||
|
sizeofMmsghdr = C.sizeof_struct_mmsghdr
|
||||||
|
sizeofCmsghdr = C.sizeof_struct_cmsghdr
|
||||||
|
|
||||||
|
sizeofSockaddrInet = C.sizeof_struct_sockaddr_in
|
||||||
|
sizeofSockaddrInet6 = C.sizeof_struct_sockaddr_in6
|
||||||
|
)
|
44
vendor/golang.org/x/net/internal/socket/defs_openbsd.go
generated
vendored
Normal file
44
vendor/golang.org/x/net/internal/socket/defs_openbsd.go
generated
vendored
Normal file
@ -0,0 +1,44 @@
|
|||||||
|
// Copyright 2017 The Go Authors. All rights reserved.
|
||||||
|
// Use of this source code is governed by a BSD-style
|
||||||
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
|
// +build ignore
|
||||||
|
|
||||||
|
// +godefs map struct_in_addr [4]byte /* in_addr */
|
||||||
|
// +godefs map struct_in6_addr [16]byte /* in6_addr */
|
||||||
|
|
||||||
|
package socket
|
||||||
|
|
||||||
|
/*
|
||||||
|
#include <sys/socket.h>
|
||||||
|
|
||||||
|
#include <netinet/in.h>
|
||||||
|
*/
|
||||||
|
import "C"
|
||||||
|
|
||||||
|
const (
|
||||||
|
sysAF_UNSPEC = C.AF_UNSPEC
|
||||||
|
sysAF_INET = C.AF_INET
|
||||||
|
sysAF_INET6 = C.AF_INET6
|
||||||
|
|
||||||
|
sysSOCK_RAW = C.SOCK_RAW
|
||||||
|
)
|
||||||
|
|
||||||
|
type iovec C.struct_iovec
|
||||||
|
|
||||||
|
type msghdr C.struct_msghdr
|
||||||
|
|
||||||
|
type cmsghdr C.struct_cmsghdr
|
||||||
|
|
||||||
|
type sockaddrInet C.struct_sockaddr_in
|
||||||
|
|
||||||
|
type sockaddrInet6 C.struct_sockaddr_in6
|
||||||
|
|
||||||
|
const (
|
||||||
|
sizeofIovec = C.sizeof_struct_iovec
|
||||||
|
sizeofMsghdr = C.sizeof_struct_msghdr
|
||||||
|
sizeofCmsghdr = C.sizeof_struct_cmsghdr
|
||||||
|
|
||||||
|
sizeofSockaddrInet = C.sizeof_struct_sockaddr_in
|
||||||
|
sizeofSockaddrInet6 = C.sizeof_struct_sockaddr_in6
|
||||||
|
)
|
44
vendor/golang.org/x/net/internal/socket/defs_solaris.go
generated
vendored
Normal file
44
vendor/golang.org/x/net/internal/socket/defs_solaris.go
generated
vendored
Normal file
@ -0,0 +1,44 @@
|
|||||||
|
// Copyright 2017 The Go Authors. All rights reserved.
|
||||||
|
// Use of this source code is governed by a BSD-style
|
||||||
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
|
// +build ignore
|
||||||
|
|
||||||
|
// +godefs map struct_in_addr [4]byte /* in_addr */
|
||||||
|
// +godefs map struct_in6_addr [16]byte /* in6_addr */
|
||||||
|
|
||||||
|
package socket
|
||||||
|
|
||||||
|
/*
|
||||||
|
#include <sys/socket.h>
|
||||||
|
|
||||||
|
#include <netinet/in.h>
|
||||||
|
*/
|
||||||
|
import "C"
|
||||||
|
|
||||||
|
const (
|
||||||
|
sysAF_UNSPEC = C.AF_UNSPEC
|
||||||
|
sysAF_INET = C.AF_INET
|
||||||
|
sysAF_INET6 = C.AF_INET6
|
||||||
|
|
||||||
|
sysSOCK_RAW = C.SOCK_RAW
|
||||||
|
)
|
||||||
|
|
||||||
|
type iovec C.struct_iovec
|
||||||
|
|
||||||
|
type msghdr C.struct_msghdr
|
||||||
|
|
||||||
|
type cmsghdr C.struct_cmsghdr
|
||||||
|
|
||||||
|
type sockaddrInet C.struct_sockaddr_in
|
||||||
|
|
||||||
|
type sockaddrInet6 C.struct_sockaddr_in6
|
||||||
|
|
||||||
|
const (
|
||||||
|
sizeofIovec = C.sizeof_struct_iovec
|
||||||
|
sizeofMsghdr = C.sizeof_struct_msghdr
|
||||||
|
sizeofCmsghdr = C.sizeof_struct_cmsghdr
|
||||||
|
|
||||||
|
sizeofSockaddrInet = C.sizeof_struct_sockaddr_in
|
||||||
|
sizeofSockaddrInet6 = C.sizeof_struct_sockaddr_in6
|
||||||
|
)
|
31
vendor/golang.org/x/net/internal/socket/error_unix.go
generated
vendored
Normal file
31
vendor/golang.org/x/net/internal/socket/error_unix.go
generated
vendored
Normal file
@ -0,0 +1,31 @@
|
|||||||
|
// Copyright 2017 The Go Authors. All rights reserved.
|
||||||
|
// Use of this source code is governed by a BSD-style
|
||||||
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
|
// +build darwin dragonfly freebsd linux netbsd openbsd solaris
|
||||||
|
|
||||||
|
package socket
|
||||||
|
|
||||||
|
import "syscall"
|
||||||
|
|
||||||
|
var (
|
||||||
|
errEAGAIN error = syscall.EAGAIN
|
||||||
|
errEINVAL error = syscall.EINVAL
|
||||||
|
errENOENT error = syscall.ENOENT
|
||||||
|
)
|
||||||
|
|
||||||
|
// errnoErr returns common boxed Errno values, to prevent allocations
|
||||||
|
// at runtime.
|
||||||
|
func errnoErr(errno syscall.Errno) error {
|
||||||
|
switch errno {
|
||||||
|
case 0:
|
||||||
|
return nil
|
||||||
|
case syscall.EAGAIN:
|
||||||
|
return errEAGAIN
|
||||||
|
case syscall.EINVAL:
|
||||||
|
return errEINVAL
|
||||||
|
case syscall.ENOENT:
|
||||||
|
return errENOENT
|
||||||
|
}
|
||||||
|
return errno
|
||||||
|
}
|
26
vendor/golang.org/x/net/internal/socket/error_windows.go
generated
vendored
Normal file
26
vendor/golang.org/x/net/internal/socket/error_windows.go
generated
vendored
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
// Copyright 2017 The Go Authors. All rights reserved.
|
||||||
|
// Use of this source code is governed by a BSD-style
|
||||||
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
|
package socket
|
||||||
|
|
||||||
|
import "syscall"
|
||||||
|
|
||||||
|
var (
|
||||||
|
errERROR_IO_PENDING error = syscall.ERROR_IO_PENDING
|
||||||
|
errEINVAL error = syscall.EINVAL
|
||||||
|
)
|
||||||
|
|
||||||
|
// errnoErr returns common boxed Errno values, to prevent allocations
|
||||||
|
// at runtime.
|
||||||
|
func errnoErr(errno syscall.Errno) error {
|
||||||
|
switch errno {
|
||||||
|
case 0:
|
||||||
|
return nil
|
||||||
|
case syscall.ERROR_IO_PENDING:
|
||||||
|
return errERROR_IO_PENDING
|
||||||
|
case syscall.EINVAL:
|
||||||
|
return errEINVAL
|
||||||
|
}
|
||||||
|
return errno
|
||||||
|
}
|
19
vendor/golang.org/x/net/internal/socket/iovec_32bit.go
generated
vendored
Normal file
19
vendor/golang.org/x/net/internal/socket/iovec_32bit.go
generated
vendored
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
// Copyright 2017 The Go Authors. All rights reserved.
|
||||||
|
// Use of this source code is governed by a BSD-style
|
||||||
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
|
// +build arm mips mipsle 386
|
||||||
|
// +build darwin dragonfly freebsd linux netbsd openbsd
|
||||||
|
|
||||||
|
package socket
|
||||||
|
|
||||||
|
import "unsafe"
|
||||||
|
|
||||||
|
func (v *iovec) set(b []byte) {
|
||||||
|
l := len(b)
|
||||||
|
if l == 0 {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
v.Base = (*byte)(unsafe.Pointer(&b[0]))
|
||||||
|
v.Len = uint32(l)
|
||||||
|
}
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user