Update golang.org/x/net dependency
This commit is contained in:
parent
d5436fb28b
commit
ba8c9295ac
23 changed files with 934 additions and 422 deletions
8
Gopkg.lock
generated
8
Gopkg.lock
generated
|
@ -758,7 +758,6 @@
|
||||||
version = "v1.3.7"
|
version = "v1.3.7"
|
||||||
|
|
||||||
[[projects]]
|
[[projects]]
|
||||||
branch = "master"
|
|
||||||
name = "github.com/jjcollinge/servicefabric"
|
name = "github.com/jjcollinge/servicefabric"
|
||||||
packages = ["."]
|
packages = ["."]
|
||||||
revision = "8eebe170fa1ba25d3dfb928b3f86a7313b13b9fe"
|
revision = "8eebe170fa1ba25d3dfb928b3f86a7313b13b9fe"
|
||||||
|
@ -1303,20 +1302,21 @@
|
||||||
"bpf",
|
"bpf",
|
||||||
"context",
|
"context",
|
||||||
"context/ctxhttp",
|
"context/ctxhttp",
|
||||||
|
"http/httpguts",
|
||||||
"http2",
|
"http2",
|
||||||
"http2/hpack",
|
"http2/hpack",
|
||||||
"idna",
|
"idna",
|
||||||
"internal/iana",
|
"internal/iana",
|
||||||
"internal/socket",
|
"internal/socket",
|
||||||
|
"internal/socks",
|
||||||
"internal/timeseries",
|
"internal/timeseries",
|
||||||
"ipv4",
|
"ipv4",
|
||||||
"ipv6",
|
"ipv6",
|
||||||
"lex/httplex",
|
|
||||||
"proxy",
|
"proxy",
|
||||||
"trace",
|
"trace",
|
||||||
"websocket"
|
"websocket"
|
||||||
]
|
]
|
||||||
revision = "22ae77b79946ea320088417e4d50825671d82d57"
|
revision = "e514e69ffb8bc3c76a71ae40de0118d794855992"
|
||||||
|
|
||||||
[[projects]]
|
[[projects]]
|
||||||
branch = "master"
|
branch = "master"
|
||||||
|
@ -1687,6 +1687,6 @@
|
||||||
[solve-meta]
|
[solve-meta]
|
||||||
analyzer-name = "dep"
|
analyzer-name = "dep"
|
||||||
analyzer-version = 1
|
analyzer-version = 1
|
||||||
inputs-digest = "f9bdfe14aca106f6bfc75da6f7282791c12c503b65581797bbb484566858a2f3"
|
inputs-digest = "6090df9fbed29043b8602fafc92694ee7f3783d1c97a2cb080dc44913f928d1e"
|
||||||
solver-name = "gps-cdcl"
|
solver-name = "gps-cdcl"
|
||||||
solver-version = 1
|
solver-version = 1
|
||||||
|
|
|
@ -24,9 +24,9 @@ import (
|
||||||
|
|
||||||
"github.com/containous/traefik/log"
|
"github.com/containous/traefik/log"
|
||||||
|
|
||||||
|
"golang.org/x/net/http/httpguts"
|
||||||
"golang.org/x/net/http2"
|
"golang.org/x/net/http2"
|
||||||
"golang.org/x/net/http2/hpack"
|
"golang.org/x/net/http2/hpack"
|
||||||
"golang.org/x/net/lex/httplex"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
|
@ -347,8 +347,8 @@ func (w *settingsAckSwallowWriter) Flush() error {
|
||||||
// isH2CUpgrade returns true if the header properly request an upgrade to h2c
|
// isH2CUpgrade returns true if the header properly request an upgrade to h2c
|
||||||
// as specified by Section 3.2.
|
// as specified by Section 3.2.
|
||||||
func isH2CUpgrade(h http.Header) bool {
|
func isH2CUpgrade(h http.Header) bool {
|
||||||
return httplex.HeaderValuesContainsToken(h[textproto.CanonicalMIMEHeaderKey("Upgrade")], "h2c") &&
|
return httpguts.HeaderValuesContainsToken(h[textproto.CanonicalMIMEHeaderKey("Upgrade")], "h2c") &&
|
||||||
httplex.HeaderValuesContainsToken(h[textproto.CanonicalMIMEHeaderKey("Connection")], "HTTP2-Settings")
|
httpguts.HeaderValuesContainsToken(h[textproto.CanonicalMIMEHeaderKey("Connection")], "HTTP2-Settings")
|
||||||
}
|
}
|
||||||
|
|
||||||
// getH2Settings returns the []http2.Setting that are encoded in the
|
// getH2Settings returns the []http2.Setting that are encoded in the
|
||||||
|
|
50
vendor/golang.org/x/net/http/httpguts/guts.go
generated
vendored
Normal file
50
vendor/golang.org/x/net/http/httpguts/guts.go
generated
vendored
Normal file
|
@ -0,0 +1,50 @@
|
||||||
|
// 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.
|
||||||
|
|
||||||
|
// Package httpguts provides functions implementing various details
|
||||||
|
// of the HTTP specification.
|
||||||
|
//
|
||||||
|
// This package is shared by the standard library (which vendors it)
|
||||||
|
// and x/net/http2. It comes with no API stability promise.
|
||||||
|
package httpguts
|
||||||
|
|
||||||
|
import (
|
||||||
|
"net/textproto"
|
||||||
|
"strings"
|
||||||
|
)
|
||||||
|
|
||||||
|
// ValidTrailerHeader reports whether name is a valid header field name to appear
|
||||||
|
// in trailers.
|
||||||
|
// See RFC 7230, Section 4.1.2
|
||||||
|
func ValidTrailerHeader(name string) bool {
|
||||||
|
name = textproto.CanonicalMIMEHeaderKey(name)
|
||||||
|
if strings.HasPrefix(name, "If-") || badTrailer[name] {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
|
var badTrailer = map[string]bool{
|
||||||
|
"Authorization": true,
|
||||||
|
"Cache-Control": true,
|
||||||
|
"Connection": true,
|
||||||
|
"Content-Encoding": true,
|
||||||
|
"Content-Length": true,
|
||||||
|
"Content-Range": true,
|
||||||
|
"Content-Type": true,
|
||||||
|
"Expect": true,
|
||||||
|
"Host": true,
|
||||||
|
"Keep-Alive": true,
|
||||||
|
"Max-Forwards": true,
|
||||||
|
"Pragma": true,
|
||||||
|
"Proxy-Authenticate": true,
|
||||||
|
"Proxy-Authorization": true,
|
||||||
|
"Proxy-Connection": true,
|
||||||
|
"Range": true,
|
||||||
|
"Realm": true,
|
||||||
|
"Te": true,
|
||||||
|
"Trailer": true,
|
||||||
|
"Transfer-Encoding": true,
|
||||||
|
"Www-Authenticate": true,
|
||||||
|
}
|
|
@ -2,12 +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.
|
||||||
|
|
||||||
// Package httplex contains rules around lexical matters of various
|
package httpguts
|
||||||
// HTTP-related specifications.
|
|
||||||
//
|
|
||||||
// This package is shared by the standard library (which vendors it)
|
|
||||||
// and x/net/http2. It comes with no API stability promise.
|
|
||||||
package httplex
|
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"net"
|
"net"
|
4
vendor/golang.org/x/net/http2/frame.go
generated
vendored
4
vendor/golang.org/x/net/http2/frame.go
generated
vendored
|
@ -14,8 +14,8 @@ import (
|
||||||
"strings"
|
"strings"
|
||||||
"sync"
|
"sync"
|
||||||
|
|
||||||
|
"golang.org/x/net/http/httpguts"
|
||||||
"golang.org/x/net/http2/hpack"
|
"golang.org/x/net/http2/hpack"
|
||||||
"golang.org/x/net/lex/httplex"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
const frameHeaderLen = 9
|
const frameHeaderLen = 9
|
||||||
|
@ -1462,7 +1462,7 @@ func (fr *Framer) readMetaFrame(hf *HeadersFrame) (*MetaHeadersFrame, error) {
|
||||||
if VerboseLogs && fr.logReads {
|
if VerboseLogs && fr.logReads {
|
||||||
fr.debugReadLoggerf("http2: decoded hpack field %+v", hf)
|
fr.debugReadLoggerf("http2: decoded hpack field %+v", hf)
|
||||||
}
|
}
|
||||||
if !httplex.ValidHeaderFieldValue(hf.Value) {
|
if !httpguts.ValidHeaderFieldValue(hf.Value) {
|
||||||
invalid = headerFieldValueError(hf.Value)
|
invalid = headerFieldValueError(hf.Value)
|
||||||
}
|
}
|
||||||
isPseudo := strings.HasPrefix(hf.Name, ":")
|
isPseudo := strings.HasPrefix(hf.Name, ":")
|
||||||
|
|
6
vendor/golang.org/x/net/http2/hpack/hpack.go
generated
vendored
6
vendor/golang.org/x/net/http2/hpack/hpack.go
generated
vendored
|
@ -389,6 +389,12 @@ func (d *Decoder) callEmit(hf HeaderField) error {
|
||||||
|
|
||||||
// (same invariants and behavior as parseHeaderFieldRepr)
|
// (same invariants and behavior as parseHeaderFieldRepr)
|
||||||
func (d *Decoder) parseDynamicTableSizeUpdate() error {
|
func (d *Decoder) parseDynamicTableSizeUpdate() error {
|
||||||
|
// RFC 7541, sec 4.2: This dynamic table size update MUST occur at the
|
||||||
|
// beginning of the first header block following the change to the dynamic table size.
|
||||||
|
if d.dynTab.size > 0 {
|
||||||
|
return DecodingError{errors.New("dynamic table size update MUST occur at the beginning of a header block")}
|
||||||
|
}
|
||||||
|
|
||||||
buf := d.buf
|
buf := d.buf
|
||||||
size, buf, err := readVarInt(5, buf)
|
size, buf, err := readVarInt(5, buf)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
6
vendor/golang.org/x/net/http2/http2.go
generated
vendored
6
vendor/golang.org/x/net/http2/http2.go
generated
vendored
|
@ -29,7 +29,7 @@ import (
|
||||||
"strings"
|
"strings"
|
||||||
"sync"
|
"sync"
|
||||||
|
|
||||||
"golang.org/x/net/lex/httplex"
|
"golang.org/x/net/http/httpguts"
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
|
@ -179,7 +179,7 @@ var (
|
||||||
)
|
)
|
||||||
|
|
||||||
// validWireHeaderFieldName reports whether v is a valid header field
|
// validWireHeaderFieldName reports whether v is a valid header field
|
||||||
// name (key). See httplex.ValidHeaderName for the base rules.
|
// name (key). See httpguts.ValidHeaderName for the base rules.
|
||||||
//
|
//
|
||||||
// Further, http2 says:
|
// Further, http2 says:
|
||||||
// "Just as in HTTP/1.x, header field names are strings of ASCII
|
// "Just as in HTTP/1.x, header field names are strings of ASCII
|
||||||
|
@ -191,7 +191,7 @@ func validWireHeaderFieldName(v string) bool {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
for _, r := range v {
|
for _, r := range v {
|
||||||
if !httplex.IsTokenRune(r) {
|
if !httpguts.IsTokenRune(r) {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
if 'A' <= r && r <= 'Z' {
|
if 'A' <= r && r <= 'Z' {
|
||||||
|
|
55
vendor/golang.org/x/net/http2/server.go
generated
vendored
55
vendor/golang.org/x/net/http2/server.go
generated
vendored
|
@ -46,6 +46,7 @@ import (
|
||||||
"sync"
|
"sync"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
"golang.org/x/net/http/httpguts"
|
||||||
"golang.org/x/net/http2/hpack"
|
"golang.org/x/net/http2/hpack"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -1607,7 +1608,10 @@ func (sc *serverConn) processData(f *DataFrame) error {
|
||||||
// Sender sending more than they'd declared?
|
// Sender sending more than they'd declared?
|
||||||
if st.declBodyBytes != -1 && st.bodyBytes+int64(len(data)) > st.declBodyBytes {
|
if st.declBodyBytes != -1 && st.bodyBytes+int64(len(data)) > st.declBodyBytes {
|
||||||
st.body.CloseWithError(fmt.Errorf("sender tried to send more than declared Content-Length of %d bytes", st.declBodyBytes))
|
st.body.CloseWithError(fmt.Errorf("sender tried to send more than declared Content-Length of %d bytes", st.declBodyBytes))
|
||||||
return streamError(id, ErrCodeStreamClosed)
|
// RFC 7540, sec 8.1.2.6: A request or response is also malformed if the
|
||||||
|
// value of a content-length header field does not equal the sum of the
|
||||||
|
// DATA frame payload lengths that form the body.
|
||||||
|
return streamError(id, ErrCodeProtocol)
|
||||||
}
|
}
|
||||||
if f.Length > 0 {
|
if f.Length > 0 {
|
||||||
// Check whether the client has flow control quota.
|
// Check whether the client has flow control quota.
|
||||||
|
@ -1817,7 +1821,7 @@ func (st *stream) processTrailerHeaders(f *MetaHeadersFrame) error {
|
||||||
if st.trailer != nil {
|
if st.trailer != nil {
|
||||||
for _, hf := range f.RegularFields() {
|
for _, hf := range f.RegularFields() {
|
||||||
key := sc.canonicalHeader(hf.Name)
|
key := sc.canonicalHeader(hf.Name)
|
||||||
if !ValidTrailerHeader(key) {
|
if !httpguts.ValidTrailerHeader(key) {
|
||||||
// TODO: send more details to the peer somehow. But http2 has
|
// TODO: send more details to the peer somehow. But http2 has
|
||||||
// no way to send debug data at a stream level. Discuss with
|
// no way to send debug data at a stream level. Discuss with
|
||||||
// HTTP folk.
|
// HTTP folk.
|
||||||
|
@ -2284,7 +2288,7 @@ func (rws *responseWriterState) hasTrailers() bool { return len(rws.trailers) !=
|
||||||
// written in the trailers at the end of the response.
|
// written in the trailers at the end of the response.
|
||||||
func (rws *responseWriterState) declareTrailer(k string) {
|
func (rws *responseWriterState) declareTrailer(k string) {
|
||||||
k = http.CanonicalHeaderKey(k)
|
k = http.CanonicalHeaderKey(k)
|
||||||
if !ValidTrailerHeader(k) {
|
if !httpguts.ValidTrailerHeader(k) {
|
||||||
// Forbidden by RFC 7230, section 4.1.2.
|
// Forbidden by RFC 7230, section 4.1.2.
|
||||||
rws.conn.logf("ignoring invalid trailer %q", k)
|
rws.conn.logf("ignoring invalid trailer %q", k)
|
||||||
return
|
return
|
||||||
|
@ -2323,7 +2327,15 @@ func (rws *responseWriterState) writeChunk(p []byte) (n int, err error) {
|
||||||
}
|
}
|
||||||
_, hasContentType := rws.snapHeader["Content-Type"]
|
_, hasContentType := rws.snapHeader["Content-Type"]
|
||||||
if !hasContentType && bodyAllowedForStatus(rws.status) && len(p) > 0 {
|
if !hasContentType && bodyAllowedForStatus(rws.status) && len(p) > 0 {
|
||||||
ctype = http.DetectContentType(p)
|
if cto := rws.snapHeader.Get("X-Content-Type-Options"); strings.EqualFold("nosniff", cto) {
|
||||||
|
// nosniff is an explicit directive not to guess a content-type.
|
||||||
|
// Content-sniffing is no less susceptible to polyglot attacks via
|
||||||
|
// hosted content when done on the server.
|
||||||
|
ctype = "application/octet-stream"
|
||||||
|
rws.conn.logf("http2: WriteHeader called with X-Content-Type-Options:nosniff but no Content-Type")
|
||||||
|
} else {
|
||||||
|
ctype = http.DetectContentType(p)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
var date string
|
var date string
|
||||||
if _, ok := rws.snapHeader["Date"]; !ok {
|
if _, ok := rws.snapHeader["Date"]; !ok {
|
||||||
|
@ -2838,41 +2850,6 @@ func new400Handler(err error) http.HandlerFunc {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// ValidTrailerHeader reports whether name is a valid header field name to appear
|
|
||||||
// in trailers.
|
|
||||||
// See: http://tools.ietf.org/html/rfc7230#section-4.1.2
|
|
||||||
func ValidTrailerHeader(name string) bool {
|
|
||||||
name = http.CanonicalHeaderKey(name)
|
|
||||||
if strings.HasPrefix(name, "If-") || badTrailer[name] {
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
|
|
||||||
var badTrailer = map[string]bool{
|
|
||||||
"Authorization": true,
|
|
||||||
"Cache-Control": true,
|
|
||||||
"Connection": true,
|
|
||||||
"Content-Encoding": true,
|
|
||||||
"Content-Length": true,
|
|
||||||
"Content-Range": true,
|
|
||||||
"Content-Type": true,
|
|
||||||
"Expect": true,
|
|
||||||
"Host": true,
|
|
||||||
"Keep-Alive": true,
|
|
||||||
"Max-Forwards": true,
|
|
||||||
"Pragma": true,
|
|
||||||
"Proxy-Authenticate": true,
|
|
||||||
"Proxy-Authorization": true,
|
|
||||||
"Proxy-Connection": true,
|
|
||||||
"Range": true,
|
|
||||||
"Realm": true,
|
|
||||||
"Te": true,
|
|
||||||
"Trailer": true,
|
|
||||||
"Transfer-Encoding": true,
|
|
||||||
"Www-Authenticate": true,
|
|
||||||
}
|
|
||||||
|
|
||||||
// h1ServerKeepAlivesDisabled reports whether hs has its keep-alives
|
// h1ServerKeepAlivesDisabled reports whether hs has its keep-alives
|
||||||
// disabled. See comments on h1ServerShutdownChan above for why
|
// disabled. See comments on h1ServerShutdownChan above for why
|
||||||
// the code is written this way.
|
// the code is written this way.
|
||||||
|
|
19
vendor/golang.org/x/net/http2/transport.go
generated
vendored
19
vendor/golang.org/x/net/http2/transport.go
generated
vendored
|
@ -27,9 +27,9 @@ import (
|
||||||
"sync"
|
"sync"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
"golang.org/x/net/http/httpguts"
|
||||||
"golang.org/x/net/http2/hpack"
|
"golang.org/x/net/http2/hpack"
|
||||||
"golang.org/x/net/idna"
|
"golang.org/x/net/idna"
|
||||||
"golang.org/x/net/lex/httplex"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
|
@ -567,6 +567,10 @@ func (t *Transport) newClientConn(c net.Conn, singleUse bool) (*ClientConn, erro
|
||||||
// henc in response to SETTINGS frames?
|
// henc in response to SETTINGS frames?
|
||||||
cc.henc = hpack.NewEncoder(&cc.hbuf)
|
cc.henc = hpack.NewEncoder(&cc.hbuf)
|
||||||
|
|
||||||
|
if t.AllowHTTP {
|
||||||
|
cc.nextStreamID = 3
|
||||||
|
}
|
||||||
|
|
||||||
if cs, ok := c.(connectionStater); ok {
|
if cs, ok := c.(connectionStater); ok {
|
||||||
state := cs.ConnectionState()
|
state := cs.ConnectionState()
|
||||||
cc.tlsState = &state
|
cc.tlsState = &state
|
||||||
|
@ -951,6 +955,9 @@ func (cc *ClientConn) awaitOpenSlotForRequest(req *http.Request) error {
|
||||||
for {
|
for {
|
||||||
cc.lastActive = time.Now()
|
cc.lastActive = time.Now()
|
||||||
if cc.closed || !cc.canTakeNewRequestLocked() {
|
if cc.closed || !cc.canTakeNewRequestLocked() {
|
||||||
|
if waitingForConn != nil {
|
||||||
|
close(waitingForConn)
|
||||||
|
}
|
||||||
return errClientConnUnusable
|
return errClientConnUnusable
|
||||||
}
|
}
|
||||||
if int64(len(cc.streams))+1 <= int64(cc.maxConcurrentStreams) {
|
if int64(len(cc.streams))+1 <= int64(cc.maxConcurrentStreams) {
|
||||||
|
@ -1174,7 +1181,7 @@ func (cc *ClientConn) encodeHeaders(req *http.Request, addGzipHeader bool, trail
|
||||||
if host == "" {
|
if host == "" {
|
||||||
host = req.URL.Host
|
host = req.URL.Host
|
||||||
}
|
}
|
||||||
host, err := httplex.PunycodeHostPort(host)
|
host, err := httpguts.PunycodeHostPort(host)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
@ -1199,11 +1206,11 @@ func (cc *ClientConn) encodeHeaders(req *http.Request, addGzipHeader bool, trail
|
||||||
// potentially pollute our hpack state. (We want to be able to
|
// potentially pollute our hpack state. (We want to be able to
|
||||||
// continue to reuse the hpack encoder for future requests)
|
// continue to reuse the hpack encoder for future requests)
|
||||||
for k, vv := range req.Header {
|
for k, vv := range req.Header {
|
||||||
if !httplex.ValidHeaderFieldName(k) {
|
if !httpguts.ValidHeaderFieldName(k) {
|
||||||
return nil, fmt.Errorf("invalid HTTP header name %q", k)
|
return nil, fmt.Errorf("invalid HTTP header name %q", k)
|
||||||
}
|
}
|
||||||
for _, v := range vv {
|
for _, v := range vv {
|
||||||
if !httplex.ValidHeaderFieldValue(v) {
|
if !httpguts.ValidHeaderFieldValue(v) {
|
||||||
return nil, fmt.Errorf("invalid HTTP header value %q for header %q", v, k)
|
return nil, fmt.Errorf("invalid HTTP header value %q for header %q", v, k)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2244,7 +2251,7 @@ func (t *Transport) getBodyWriterState(cs *clientStream, body io.Reader) (s body
|
||||||
}
|
}
|
||||||
s.delay = t.expectContinueTimeout()
|
s.delay = t.expectContinueTimeout()
|
||||||
if s.delay == 0 ||
|
if s.delay == 0 ||
|
||||||
!httplex.HeaderValuesContainsToken(
|
!httpguts.HeaderValuesContainsToken(
|
||||||
cs.req.Header["Expect"],
|
cs.req.Header["Expect"],
|
||||||
"100-continue") {
|
"100-continue") {
|
||||||
return
|
return
|
||||||
|
@ -2299,5 +2306,5 @@ func (s bodyWriterState) scheduleBodyWrite() {
|
||||||
// isConnectionCloseRequest reports whether req should use its own
|
// isConnectionCloseRequest reports whether req should use its own
|
||||||
// connection for a single request and then close the connection.
|
// connection for a single request and then close the connection.
|
||||||
func isConnectionCloseRequest(req *http.Request) bool {
|
func isConnectionCloseRequest(req *http.Request) bool {
|
||||||
return req.Close || httplex.HeaderValuesContainsToken(req.Header["Connection"], "close")
|
return req.Close || httpguts.HeaderValuesContainsToken(req.Header["Connection"], "close")
|
||||||
}
|
}
|
||||||
|
|
4
vendor/golang.org/x/net/http2/write.go
generated
vendored
4
vendor/golang.org/x/net/http2/write.go
generated
vendored
|
@ -11,8 +11,8 @@ import (
|
||||||
"net/http"
|
"net/http"
|
||||||
"net/url"
|
"net/url"
|
||||||
|
|
||||||
|
"golang.org/x/net/http/httpguts"
|
||||||
"golang.org/x/net/http2/hpack"
|
"golang.org/x/net/http2/hpack"
|
||||||
"golang.org/x/net/lex/httplex"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// writeFramer is implemented by any type that is used to write frames.
|
// writeFramer is implemented by any type that is used to write frames.
|
||||||
|
@ -350,7 +350,7 @@ func encodeHeaders(enc *hpack.Encoder, h http.Header, keys []string) {
|
||||||
}
|
}
|
||||||
isTE := k == "transfer-encoding"
|
isTE := k == "transfer-encoding"
|
||||||
for _, v := range vv {
|
for _, v := range vv {
|
||||||
if !httplex.ValidHeaderFieldValue(v) {
|
if !httpguts.ValidHeaderFieldValue(v) {
|
||||||
// TODO: return an error? golang.org/issue/14048
|
// TODO: return an error? golang.org/issue/14048
|
||||||
// For now just omit it.
|
// For now just omit it.
|
||||||
continue
|
continue
|
||||||
|
|
109
vendor/golang.org/x/net/internal/iana/const.go
generated
vendored
109
vendor/golang.org/x/net/internal/iana/const.go
generated
vendored
|
@ -1,44 +1,40 @@
|
||||||
// go generate gen.go
|
// go generate gen.go
|
||||||
// GENERATED BY THE COMMAND ABOVE; DO NOT EDIT
|
// 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 provides protocol number resources managed by the Internet Assigned Numbers Authority (IANA).
|
||||||
package iana // import "golang.org/x/net/internal/iana"
|
package iana // import "golang.org/x/net/internal/iana"
|
||||||
|
|
||||||
// Differentiated Services Field Codepoints (DSCP), Updated: 2017-05-12
|
// Differentiated Services Field Codepoints (DSCP), Updated: 2018-05-04
|
||||||
const (
|
const (
|
||||||
DiffServCS0 = 0x0 // CS0
|
DiffServCS0 = 0x00 // CS0
|
||||||
DiffServCS1 = 0x20 // CS1
|
DiffServCS1 = 0x20 // CS1
|
||||||
DiffServCS2 = 0x40 // CS2
|
DiffServCS2 = 0x40 // CS2
|
||||||
DiffServCS3 = 0x60 // CS3
|
DiffServCS3 = 0x60 // CS3
|
||||||
DiffServCS4 = 0x80 // CS4
|
DiffServCS4 = 0x80 // CS4
|
||||||
DiffServCS5 = 0xa0 // CS5
|
DiffServCS5 = 0xa0 // CS5
|
||||||
DiffServCS6 = 0xc0 // CS6
|
DiffServCS6 = 0xc0 // CS6
|
||||||
DiffServCS7 = 0xe0 // CS7
|
DiffServCS7 = 0xe0 // CS7
|
||||||
DiffServAF11 = 0x28 // AF11
|
DiffServAF11 = 0x28 // AF11
|
||||||
DiffServAF12 = 0x30 // AF12
|
DiffServAF12 = 0x30 // AF12
|
||||||
DiffServAF13 = 0x38 // AF13
|
DiffServAF13 = 0x38 // AF13
|
||||||
DiffServAF21 = 0x48 // AF21
|
DiffServAF21 = 0x48 // AF21
|
||||||
DiffServAF22 = 0x50 // AF22
|
DiffServAF22 = 0x50 // AF22
|
||||||
DiffServAF23 = 0x58 // AF23
|
DiffServAF23 = 0x58 // AF23
|
||||||
DiffServAF31 = 0x68 // AF31
|
DiffServAF31 = 0x68 // AF31
|
||||||
DiffServAF32 = 0x70 // AF32
|
DiffServAF32 = 0x70 // AF32
|
||||||
DiffServAF33 = 0x78 // AF33
|
DiffServAF33 = 0x78 // AF33
|
||||||
DiffServAF41 = 0x88 // AF41
|
DiffServAF41 = 0x88 // AF41
|
||||||
DiffServAF42 = 0x90 // AF42
|
DiffServAF42 = 0x90 // AF42
|
||||||
DiffServAF43 = 0x98 // AF43
|
DiffServAF43 = 0x98 // AF43
|
||||||
DiffServEF = 0xb8 // EF
|
DiffServEF = 0xb8 // EF
|
||||||
DiffServVOICEADMIT = 0xb0 // VOICE-ADMIT
|
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)
|
||||||
)
|
)
|
||||||
|
|
||||||
// IPv4 TOS Byte and IPv6 Traffic Class Octet, Updated: 2001-09-06
|
// Protocol Numbers, Updated: 2017-10-13
|
||||||
const (
|
|
||||||
NotECNTransport = 0x0 // Not-ECT (Not ECN-Capable Transport)
|
|
||||||
ECNTransport1 = 0x1 // ECT(1) (ECN-Capable Transport(1))
|
|
||||||
ECNTransport0 = 0x2 // ECT(0) (ECN-Capable Transport(0))
|
|
||||||
CongestionExperienced = 0x3 // CE (Congestion Experienced)
|
|
||||||
)
|
|
||||||
|
|
||||||
// Protocol Numbers, Updated: 2016-06-22
|
|
||||||
const (
|
const (
|
||||||
ProtocolIP = 0 // IPv4 encapsulation, pseudo protocol number
|
ProtocolIP = 0 // IPv4 encapsulation, pseudo protocol number
|
||||||
ProtocolHOPOPT = 0 // IPv6 Hop-by-Hop Option
|
ProtocolHOPOPT = 0 // IPv6 Hop-by-Hop Option
|
||||||
|
@ -178,3 +174,50 @@ const (
|
||||||
ProtocolROHC = 142 // Robust Header Compression
|
ProtocolROHC = 142 // Robust Header Compression
|
||||||
ProtocolReserved = 255 // Reserved
|
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
|
||||||
|
)
|
||||||
|
|
282
vendor/golang.org/x/net/internal/iana/gen.go
generated
vendored
282
vendor/golang.org/x/net/internal/iana/gen.go
generated
vendored
|
@ -31,20 +31,20 @@ var registries = []struct {
|
||||||
"https://www.iana.org/assignments/dscp-registry/dscp-registry.xml",
|
"https://www.iana.org/assignments/dscp-registry/dscp-registry.xml",
|
||||||
parseDSCPRegistry,
|
parseDSCPRegistry,
|
||||||
},
|
},
|
||||||
{
|
|
||||||
"https://www.iana.org/assignments/ipv4-tos-byte/ipv4-tos-byte.xml",
|
|
||||||
parseTOSTCByte,
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
"https://www.iana.org/assignments/protocol-numbers/protocol-numbers.xml",
|
"https://www.iana.org/assignments/protocol-numbers/protocol-numbers.xml",
|
||||||
parseProtocolNumbers,
|
parseProtocolNumbers,
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"https://www.iana.org/assignments/address-family-numbers/address-family-numbers.xml",
|
||||||
|
parseAddrFamilyNumbers,
|
||||||
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
var bb bytes.Buffer
|
var bb bytes.Buffer
|
||||||
fmt.Fprintf(&bb, "// go generate gen.go\n")
|
fmt.Fprintf(&bb, "// go generate gen.go\n")
|
||||||
fmt.Fprintf(&bb, "// GENERATED BY THE COMMAND ABOVE; DO NOT EDIT\n\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 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")
|
fmt.Fprintf(&bb, `package iana // import "golang.org/x/net/internal/iana"`+"\n\n")
|
||||||
for _, r := range registries {
|
for _, r := range registries {
|
||||||
|
@ -81,31 +81,39 @@ func parseDSCPRegistry(w io.Writer, r io.Reader) error {
|
||||||
if err := dec.Decode(&dr); err != nil {
|
if err := dec.Decode(&dr); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
drs := dr.escape()
|
|
||||||
fmt.Fprintf(w, "// %s, Updated: %s\n", dr.Title, dr.Updated)
|
fmt.Fprintf(w, "// %s, Updated: %s\n", dr.Title, dr.Updated)
|
||||||
fmt.Fprintf(w, "const (\n")
|
fmt.Fprintf(w, "const (\n")
|
||||||
for _, dr := range drs {
|
for _, dr := range dr.escapeDSCP() {
|
||||||
fmt.Fprintf(w, "DiffServ%s = %#x", dr.Name, dr.Value)
|
fmt.Fprintf(w, "DiffServ%s = %#02x", dr.Name, dr.Value)
|
||||||
fmt.Fprintf(w, "// %s\n", dr.OrigName)
|
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")
|
fmt.Fprintf(w, ")\n")
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
type dscpRegistry struct {
|
type dscpRegistry struct {
|
||||||
XMLName xml.Name `xml:"registry"`
|
XMLName xml.Name `xml:"registry"`
|
||||||
Title string `xml:"title"`
|
Title string `xml:"title"`
|
||||||
Updated string `xml:"updated"`
|
Updated string `xml:"updated"`
|
||||||
Note string `xml:"note"`
|
Note string `xml:"note"`
|
||||||
RegTitle string `xml:"registry>title"`
|
Registries []struct {
|
||||||
PoolRecords []struct {
|
Title string `xml:"title"`
|
||||||
Name string `xml:"name"`
|
Registries []struct {
|
||||||
Space string `xml:"space"`
|
Title string `xml:"title"`
|
||||||
} `xml:"registry>record"`
|
Records []struct {
|
||||||
Records []struct {
|
Name string `xml:"name"`
|
||||||
Name string `xml:"name"`
|
Space string `xml:"space"`
|
||||||
Space string `xml:"space"`
|
} `xml:"record"`
|
||||||
} `xml:"registry>registry>record"`
|
} `xml:"registry"`
|
||||||
|
Records []struct {
|
||||||
|
Value string `xml:"value"`
|
||||||
|
Descr string `xml:"description"`
|
||||||
|
} `xml:"record"`
|
||||||
|
} `xml:"registry"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type canonDSCPRecord struct {
|
type canonDSCPRecord struct {
|
||||||
|
@ -114,92 +122,84 @@ type canonDSCPRecord struct {
|
||||||
Value int
|
Value int
|
||||||
}
|
}
|
||||||
|
|
||||||
func (drr *dscpRegistry) escape() []canonDSCPRecord {
|
func (drr *dscpRegistry) escapeDSCP() []canonDSCPRecord {
|
||||||
drs := make([]canonDSCPRecord, len(drr.Records))
|
var drs []canonDSCPRecord
|
||||||
sr := strings.NewReplacer(
|
for _, preg := range drr.Registries {
|
||||||
"+", "",
|
if !strings.Contains(preg.Title, "Differentiated Services Field Codepoints") {
|
||||||
"-", "",
|
|
||||||
"/", "",
|
|
||||||
".", "",
|
|
||||||
" ", "",
|
|
||||||
)
|
|
||||||
for i, dr := range drr.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
|
continue
|
||||||
}
|
}
|
||||||
drs[i].Value = int(n) << 2
|
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
|
return drs
|
||||||
}
|
}
|
||||||
|
|
||||||
func parseTOSTCByte(w io.Writer, r io.Reader) error {
|
type canonECNRecord struct {
|
||||||
dec := xml.NewDecoder(r)
|
OrigDescr string
|
||||||
var ttb tosTCByte
|
Descr string
|
||||||
if err := dec.Decode(&ttb); err != nil {
|
Value int
|
||||||
return err
|
|
||||||
}
|
|
||||||
trs := ttb.escape()
|
|
||||||
fmt.Fprintf(w, "// %s, Updated: %s\n", ttb.Title, ttb.Updated)
|
|
||||||
fmt.Fprintf(w, "const (\n")
|
|
||||||
for _, tr := range trs {
|
|
||||||
fmt.Fprintf(w, "%s = %#x", tr.Keyword, tr.Value)
|
|
||||||
fmt.Fprintf(w, "// %s\n", tr.OrigKeyword)
|
|
||||||
}
|
|
||||||
fmt.Fprintf(w, ")\n")
|
|
||||||
return nil
|
|
||||||
}
|
}
|
||||||
|
|
||||||
type tosTCByte struct {
|
func (drr *dscpRegistry) escapeECN() []canonECNRecord {
|
||||||
XMLName xml.Name `xml:"registry"`
|
var ers []canonECNRecord
|
||||||
Title string `xml:"title"`
|
for _, reg := range drr.Registries {
|
||||||
Updated string `xml:"updated"`
|
if !strings.Contains(reg.Title, "ECN Field") {
|
||||||
Note string `xml:"note"`
|
|
||||||
RegTitle string `xml:"registry>title"`
|
|
||||||
Records []struct {
|
|
||||||
Binary string `xml:"binary"`
|
|
||||||
Keyword string `xml:"keyword"`
|
|
||||||
} `xml:"registry>record"`
|
|
||||||
}
|
|
||||||
|
|
||||||
type canonTOSTCByteRecord struct {
|
|
||||||
OrigKeyword string
|
|
||||||
Keyword string
|
|
||||||
Value int
|
|
||||||
}
|
|
||||||
|
|
||||||
func (ttb *tosTCByte) escape() []canonTOSTCByteRecord {
|
|
||||||
trs := make([]canonTOSTCByteRecord, len(ttb.Records))
|
|
||||||
sr := strings.NewReplacer(
|
|
||||||
"Capable", "",
|
|
||||||
"(", "",
|
|
||||||
")", "",
|
|
||||||
"+", "",
|
|
||||||
"-", "",
|
|
||||||
"/", "",
|
|
||||||
".", "",
|
|
||||||
" ", "",
|
|
||||||
)
|
|
||||||
for i, tr := range ttb.Records {
|
|
||||||
s := strings.TrimSpace(tr.Keyword)
|
|
||||||
trs[i].OrigKeyword = s
|
|
||||||
ss := strings.Split(s, " ")
|
|
||||||
if len(ss) > 1 {
|
|
||||||
trs[i].Keyword = strings.Join(ss[1:], " ")
|
|
||||||
} else {
|
|
||||||
trs[i].Keyword = ss[0]
|
|
||||||
}
|
|
||||||
trs[i].Keyword = sr.Replace(trs[i].Keyword)
|
|
||||||
n, err := strconv.ParseUint(tr.Binary, 2, 8)
|
|
||||||
if err != nil {
|
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
trs[i].Value = int(n)
|
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 trs
|
return ers
|
||||||
}
|
}
|
||||||
|
|
||||||
func parseProtocolNumbers(w io.Writer, r io.Reader) error {
|
func parseProtocolNumbers(w io.Writer, r io.Reader) error {
|
||||||
|
@ -291,3 +291,93 @@ func (pn *protocolNumbers) escape() []canonProtocolRecord {
|
||||||
}
|
}
|
||||||
return prs
|
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
|
||||||
|
}
|
||||||
|
|
6
vendor/golang.org/x/net/internal/socket/zsys_netbsd_arm.go
generated
vendored
6
vendor/golang.org/x/net/internal/socket/zsys_netbsd_arm.go
generated
vendored
|
@ -26,6 +26,11 @@ type msghdr struct {
|
||||||
Flags int32
|
Flags int32
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type mmsghdr struct {
|
||||||
|
Hdr msghdr
|
||||||
|
Len uint32
|
||||||
|
}
|
||||||
|
|
||||||
type cmsghdr struct {
|
type cmsghdr struct {
|
||||||
Len uint32
|
Len uint32
|
||||||
Level int32
|
Level int32
|
||||||
|
@ -52,6 +57,7 @@ type sockaddrInet6 struct {
|
||||||
const (
|
const (
|
||||||
sizeofIovec = 0x8
|
sizeofIovec = 0x8
|
||||||
sizeofMsghdr = 0x1c
|
sizeofMsghdr = 0x1c
|
||||||
|
sizeofMmsghdr = 0x20
|
||||||
sizeofCmsghdr = 0xc
|
sizeofCmsghdr = 0xc
|
||||||
|
|
||||||
sizeofSockaddrInet = 0x10
|
sizeofSockaddrInet = 0x10
|
||||||
|
|
168
vendor/golang.org/x/net/internal/socks/client.go
generated
vendored
Normal file
168
vendor/golang.org/x/net/internal/socks/client.go
generated
vendored
Normal file
|
@ -0,0 +1,168 @@
|
||||||
|
// 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.
|
||||||
|
|
||||||
|
package socks
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"errors"
|
||||||
|
"io"
|
||||||
|
"net"
|
||||||
|
"strconv"
|
||||||
|
"time"
|
||||||
|
)
|
||||||
|
|
||||||
|
var (
|
||||||
|
noDeadline = time.Time{}
|
||||||
|
aLongTimeAgo = time.Unix(1, 0)
|
||||||
|
)
|
||||||
|
|
||||||
|
func (d *Dialer) connect(ctx context.Context, c net.Conn, address string) (_ net.Addr, ctxErr error) {
|
||||||
|
host, port, err := splitHostPort(address)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
if deadline, ok := ctx.Deadline(); ok && !deadline.IsZero() {
|
||||||
|
c.SetDeadline(deadline)
|
||||||
|
defer c.SetDeadline(noDeadline)
|
||||||
|
}
|
||||||
|
if ctx != context.Background() {
|
||||||
|
errCh := make(chan error, 1)
|
||||||
|
done := make(chan struct{})
|
||||||
|
defer func() {
|
||||||
|
close(done)
|
||||||
|
if ctxErr == nil {
|
||||||
|
ctxErr = <-errCh
|
||||||
|
}
|
||||||
|
}()
|
||||||
|
go func() {
|
||||||
|
select {
|
||||||
|
case <-ctx.Done():
|
||||||
|
c.SetDeadline(aLongTimeAgo)
|
||||||
|
errCh <- ctx.Err()
|
||||||
|
case <-done:
|
||||||
|
errCh <- nil
|
||||||
|
}
|
||||||
|
}()
|
||||||
|
}
|
||||||
|
|
||||||
|
b := make([]byte, 0, 6+len(host)) // the size here is just an estimate
|
||||||
|
b = append(b, Version5)
|
||||||
|
if len(d.AuthMethods) == 0 || d.Authenticate == nil {
|
||||||
|
b = append(b, 1, byte(AuthMethodNotRequired))
|
||||||
|
} else {
|
||||||
|
ams := d.AuthMethods
|
||||||
|
if len(ams) > 255 {
|
||||||
|
return nil, errors.New("too many authentication methods")
|
||||||
|
}
|
||||||
|
b = append(b, byte(len(ams)))
|
||||||
|
for _, am := range ams {
|
||||||
|
b = append(b, byte(am))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if _, ctxErr = c.Write(b); ctxErr != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
if _, ctxErr = io.ReadFull(c, b[:2]); ctxErr != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if b[0] != Version5 {
|
||||||
|
return nil, errors.New("unexpected protocol version " + strconv.Itoa(int(b[0])))
|
||||||
|
}
|
||||||
|
am := AuthMethod(b[1])
|
||||||
|
if am == AuthMethodNoAcceptableMethods {
|
||||||
|
return nil, errors.New("no acceptable authentication methods")
|
||||||
|
}
|
||||||
|
if d.Authenticate != nil {
|
||||||
|
if ctxErr = d.Authenticate(ctx, c, am); ctxErr != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
b = b[:0]
|
||||||
|
b = append(b, Version5, byte(d.cmd), 0)
|
||||||
|
if ip := net.ParseIP(host); ip != nil {
|
||||||
|
if ip4 := ip.To4(); ip4 != nil {
|
||||||
|
b = append(b, AddrTypeIPv4)
|
||||||
|
b = append(b, ip4...)
|
||||||
|
} else if ip6 := ip.To16(); ip6 != nil {
|
||||||
|
b = append(b, AddrTypeIPv6)
|
||||||
|
b = append(b, ip6...)
|
||||||
|
} else {
|
||||||
|
return nil, errors.New("unknown address type")
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if len(host) > 255 {
|
||||||
|
return nil, errors.New("FQDN too long")
|
||||||
|
}
|
||||||
|
b = append(b, AddrTypeFQDN)
|
||||||
|
b = append(b, byte(len(host)))
|
||||||
|
b = append(b, host...)
|
||||||
|
}
|
||||||
|
b = append(b, byte(port>>8), byte(port))
|
||||||
|
if _, ctxErr = c.Write(b); ctxErr != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
if _, ctxErr = io.ReadFull(c, b[:4]); ctxErr != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if b[0] != Version5 {
|
||||||
|
return nil, errors.New("unexpected protocol version " + strconv.Itoa(int(b[0])))
|
||||||
|
}
|
||||||
|
if cmdErr := Reply(b[1]); cmdErr != StatusSucceeded {
|
||||||
|
return nil, errors.New("unknown error " + cmdErr.String())
|
||||||
|
}
|
||||||
|
if b[2] != 0 {
|
||||||
|
return nil, errors.New("non-zero reserved field")
|
||||||
|
}
|
||||||
|
l := 2
|
||||||
|
var a Addr
|
||||||
|
switch b[3] {
|
||||||
|
case AddrTypeIPv4:
|
||||||
|
l += net.IPv4len
|
||||||
|
a.IP = make(net.IP, net.IPv4len)
|
||||||
|
case AddrTypeIPv6:
|
||||||
|
l += net.IPv6len
|
||||||
|
a.IP = make(net.IP, net.IPv6len)
|
||||||
|
case AddrTypeFQDN:
|
||||||
|
if _, err := io.ReadFull(c, b[:1]); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
l += int(b[0])
|
||||||
|
default:
|
||||||
|
return nil, errors.New("unknown address type " + strconv.Itoa(int(b[3])))
|
||||||
|
}
|
||||||
|
if cap(b) < l {
|
||||||
|
b = make([]byte, l)
|
||||||
|
} else {
|
||||||
|
b = b[:l]
|
||||||
|
}
|
||||||
|
if _, ctxErr = io.ReadFull(c, b); ctxErr != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if a.IP != nil {
|
||||||
|
copy(a.IP, b)
|
||||||
|
} else {
|
||||||
|
a.Name = string(b[:len(b)-2])
|
||||||
|
}
|
||||||
|
a.Port = int(b[len(b)-2])<<8 | int(b[len(b)-1])
|
||||||
|
return &a, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func splitHostPort(address string) (string, int, error) {
|
||||||
|
host, port, err := net.SplitHostPort(address)
|
||||||
|
if err != nil {
|
||||||
|
return "", 0, err
|
||||||
|
}
|
||||||
|
portnum, err := strconv.Atoi(port)
|
||||||
|
if err != nil {
|
||||||
|
return "", 0, err
|
||||||
|
}
|
||||||
|
if 1 > portnum || portnum > 0xffff {
|
||||||
|
return "", 0, errors.New("port number out of range " + port)
|
||||||
|
}
|
||||||
|
return host, portnum, nil
|
||||||
|
}
|
316
vendor/golang.org/x/net/internal/socks/socks.go
generated
vendored
Normal file
316
vendor/golang.org/x/net/internal/socks/socks.go
generated
vendored
Normal file
|
@ -0,0 +1,316 @@
|
||||||
|
// 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.
|
||||||
|
|
||||||
|
// Package socks provides a SOCKS version 5 client implementation.
|
||||||
|
//
|
||||||
|
// SOCKS protocol version 5 is defined in RFC 1928.
|
||||||
|
// Username/Password authentication for SOCKS version 5 is defined in
|
||||||
|
// RFC 1929.
|
||||||
|
package socks
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"errors"
|
||||||
|
"io"
|
||||||
|
"net"
|
||||||
|
"strconv"
|
||||||
|
)
|
||||||
|
|
||||||
|
// A Command represents a SOCKS command.
|
||||||
|
type Command int
|
||||||
|
|
||||||
|
func (cmd Command) String() string {
|
||||||
|
switch cmd {
|
||||||
|
case CmdConnect:
|
||||||
|
return "socks connect"
|
||||||
|
case cmdBind:
|
||||||
|
return "socks bind"
|
||||||
|
default:
|
||||||
|
return "socks " + strconv.Itoa(int(cmd))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// An AuthMethod represents a SOCKS authentication method.
|
||||||
|
type AuthMethod int
|
||||||
|
|
||||||
|
// A Reply represents a SOCKS command reply code.
|
||||||
|
type Reply int
|
||||||
|
|
||||||
|
func (code Reply) String() string {
|
||||||
|
switch code {
|
||||||
|
case StatusSucceeded:
|
||||||
|
return "succeeded"
|
||||||
|
case 0x01:
|
||||||
|
return "general SOCKS server failure"
|
||||||
|
case 0x02:
|
||||||
|
return "connection not allowed by ruleset"
|
||||||
|
case 0x03:
|
||||||
|
return "network unreachable"
|
||||||
|
case 0x04:
|
||||||
|
return "host unreachable"
|
||||||
|
case 0x05:
|
||||||
|
return "connection refused"
|
||||||
|
case 0x06:
|
||||||
|
return "TTL expired"
|
||||||
|
case 0x07:
|
||||||
|
return "command not supported"
|
||||||
|
case 0x08:
|
||||||
|
return "address type not supported"
|
||||||
|
default:
|
||||||
|
return "unknown code: " + strconv.Itoa(int(code))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Wire protocol constants.
|
||||||
|
const (
|
||||||
|
Version5 = 0x05
|
||||||
|
|
||||||
|
AddrTypeIPv4 = 0x01
|
||||||
|
AddrTypeFQDN = 0x03
|
||||||
|
AddrTypeIPv6 = 0x04
|
||||||
|
|
||||||
|
CmdConnect Command = 0x01 // establishes an active-open forward proxy connection
|
||||||
|
cmdBind Command = 0x02 // establishes a passive-open forward proxy connection
|
||||||
|
|
||||||
|
AuthMethodNotRequired AuthMethod = 0x00 // no authentication required
|
||||||
|
AuthMethodUsernamePassword AuthMethod = 0x02 // use username/password
|
||||||
|
AuthMethodNoAcceptableMethods AuthMethod = 0xff // no acceptable authentication methods
|
||||||
|
|
||||||
|
StatusSucceeded Reply = 0x00
|
||||||
|
)
|
||||||
|
|
||||||
|
// An Addr represents a SOCKS-specific address.
|
||||||
|
// Either Name or IP is used exclusively.
|
||||||
|
type Addr struct {
|
||||||
|
Name string // fully-qualified domain name
|
||||||
|
IP net.IP
|
||||||
|
Port int
|
||||||
|
}
|
||||||
|
|
||||||
|
func (a *Addr) Network() string { return "socks" }
|
||||||
|
|
||||||
|
func (a *Addr) String() string {
|
||||||
|
if a == nil {
|
||||||
|
return "<nil>"
|
||||||
|
}
|
||||||
|
port := strconv.Itoa(a.Port)
|
||||||
|
if a.IP == nil {
|
||||||
|
return net.JoinHostPort(a.Name, port)
|
||||||
|
}
|
||||||
|
return net.JoinHostPort(a.IP.String(), port)
|
||||||
|
}
|
||||||
|
|
||||||
|
// A Conn represents a forward proxy connection.
|
||||||
|
type Conn struct {
|
||||||
|
net.Conn
|
||||||
|
|
||||||
|
boundAddr net.Addr
|
||||||
|
}
|
||||||
|
|
||||||
|
// BoundAddr returns the address assigned by the proxy server for
|
||||||
|
// connecting to the command target address from the proxy server.
|
||||||
|
func (c *Conn) BoundAddr() net.Addr {
|
||||||
|
if c == nil {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
return c.boundAddr
|
||||||
|
}
|
||||||
|
|
||||||
|
// A Dialer holds SOCKS-specific options.
|
||||||
|
type Dialer struct {
|
||||||
|
cmd Command // either CmdConnect or cmdBind
|
||||||
|
proxyNetwork string // network between a proxy server and a client
|
||||||
|
proxyAddress string // proxy server address
|
||||||
|
|
||||||
|
// ProxyDial specifies the optional dial function for
|
||||||
|
// establishing the transport connection.
|
||||||
|
ProxyDial func(context.Context, string, string) (net.Conn, error)
|
||||||
|
|
||||||
|
// AuthMethods specifies the list of request authention
|
||||||
|
// methods.
|
||||||
|
// If empty, SOCKS client requests only AuthMethodNotRequired.
|
||||||
|
AuthMethods []AuthMethod
|
||||||
|
|
||||||
|
// Authenticate specifies the optional authentication
|
||||||
|
// function. It must be non-nil when AuthMethods is not empty.
|
||||||
|
// It must return an error when the authentication is failed.
|
||||||
|
Authenticate func(context.Context, io.ReadWriter, AuthMethod) error
|
||||||
|
}
|
||||||
|
|
||||||
|
// DialContext connects to the provided address on the provided
|
||||||
|
// network.
|
||||||
|
//
|
||||||
|
// The returned error value may be a net.OpError. When the Op field of
|
||||||
|
// net.OpError contains "socks", the Source field contains a proxy
|
||||||
|
// server address and the Addr field contains a command target
|
||||||
|
// address.
|
||||||
|
//
|
||||||
|
// See func Dial of the net package of standard library for a
|
||||||
|
// description of the network and address parameters.
|
||||||
|
func (d *Dialer) DialContext(ctx context.Context, network, address string) (net.Conn, error) {
|
||||||
|
if err := d.validateTarget(network, address); err != nil {
|
||||||
|
proxy, dst, _ := d.pathAddrs(address)
|
||||||
|
return nil, &net.OpError{Op: d.cmd.String(), Net: network, Source: proxy, Addr: dst, Err: err}
|
||||||
|
}
|
||||||
|
if ctx == nil {
|
||||||
|
proxy, dst, _ := d.pathAddrs(address)
|
||||||
|
return nil, &net.OpError{Op: d.cmd.String(), Net: network, Source: proxy, Addr: dst, Err: errors.New("nil context")}
|
||||||
|
}
|
||||||
|
var err error
|
||||||
|
var c net.Conn
|
||||||
|
if d.ProxyDial != nil {
|
||||||
|
c, err = d.ProxyDial(ctx, d.proxyNetwork, d.proxyAddress)
|
||||||
|
} else {
|
||||||
|
var dd net.Dialer
|
||||||
|
c, err = dd.DialContext(ctx, d.proxyNetwork, d.proxyAddress)
|
||||||
|
}
|
||||||
|
if err != nil {
|
||||||
|
proxy, dst, _ := d.pathAddrs(address)
|
||||||
|
return nil, &net.OpError{Op: d.cmd.String(), Net: network, Source: proxy, Addr: dst, Err: err}
|
||||||
|
}
|
||||||
|
a, err := d.connect(ctx, c, address)
|
||||||
|
if err != nil {
|
||||||
|
c.Close()
|
||||||
|
proxy, dst, _ := d.pathAddrs(address)
|
||||||
|
return nil, &net.OpError{Op: d.cmd.String(), Net: network, Source: proxy, Addr: dst, Err: err}
|
||||||
|
}
|
||||||
|
return &Conn{Conn: c, boundAddr: a}, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// DialWithConn initiates a connection from SOCKS server to the target
|
||||||
|
// network and address using the connection c that is already
|
||||||
|
// connected to the SOCKS server.
|
||||||
|
//
|
||||||
|
// It returns the connection's local address assigned by the SOCKS
|
||||||
|
// server.
|
||||||
|
func (d *Dialer) DialWithConn(ctx context.Context, c net.Conn, network, address string) (net.Addr, error) {
|
||||||
|
if err := d.validateTarget(network, address); err != nil {
|
||||||
|
proxy, dst, _ := d.pathAddrs(address)
|
||||||
|
return nil, &net.OpError{Op: d.cmd.String(), Net: network, Source: proxy, Addr: dst, Err: err}
|
||||||
|
}
|
||||||
|
if ctx == nil {
|
||||||
|
proxy, dst, _ := d.pathAddrs(address)
|
||||||
|
return nil, &net.OpError{Op: d.cmd.String(), Net: network, Source: proxy, Addr: dst, Err: errors.New("nil context")}
|
||||||
|
}
|
||||||
|
a, err := d.connect(ctx, c, address)
|
||||||
|
if err != nil {
|
||||||
|
proxy, dst, _ := d.pathAddrs(address)
|
||||||
|
return nil, &net.OpError{Op: d.cmd.String(), Net: network, Source: proxy, Addr: dst, Err: err}
|
||||||
|
}
|
||||||
|
return a, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// Dial connects to the provided address on the provided network.
|
||||||
|
//
|
||||||
|
// Unlike DialContext, it returns a raw transport connection instead
|
||||||
|
// of a forward proxy connection.
|
||||||
|
//
|
||||||
|
// Deprecated: Use DialContext or DialWithConn instead.
|
||||||
|
func (d *Dialer) Dial(network, address string) (net.Conn, error) {
|
||||||
|
if err := d.validateTarget(network, address); err != nil {
|
||||||
|
proxy, dst, _ := d.pathAddrs(address)
|
||||||
|
return nil, &net.OpError{Op: d.cmd.String(), Net: network, Source: proxy, Addr: dst, Err: err}
|
||||||
|
}
|
||||||
|
var err error
|
||||||
|
var c net.Conn
|
||||||
|
if d.ProxyDial != nil {
|
||||||
|
c, err = d.ProxyDial(context.Background(), d.proxyNetwork, d.proxyAddress)
|
||||||
|
} else {
|
||||||
|
c, err = net.Dial(d.proxyNetwork, d.proxyAddress)
|
||||||
|
}
|
||||||
|
if err != nil {
|
||||||
|
proxy, dst, _ := d.pathAddrs(address)
|
||||||
|
return nil, &net.OpError{Op: d.cmd.String(), Net: network, Source: proxy, Addr: dst, Err: err}
|
||||||
|
}
|
||||||
|
if _, err := d.DialWithConn(context.Background(), c, network, address); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return c, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (d *Dialer) validateTarget(network, address string) error {
|
||||||
|
switch network {
|
||||||
|
case "tcp", "tcp6", "tcp4":
|
||||||
|
default:
|
||||||
|
return errors.New("network not implemented")
|
||||||
|
}
|
||||||
|
switch d.cmd {
|
||||||
|
case CmdConnect, cmdBind:
|
||||||
|
default:
|
||||||
|
return errors.New("command not implemented")
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (d *Dialer) pathAddrs(address string) (proxy, dst net.Addr, err error) {
|
||||||
|
for i, s := range []string{d.proxyAddress, address} {
|
||||||
|
host, port, err := splitHostPort(s)
|
||||||
|
if err != nil {
|
||||||
|
return nil, nil, err
|
||||||
|
}
|
||||||
|
a := &Addr{Port: port}
|
||||||
|
a.IP = net.ParseIP(host)
|
||||||
|
if a.IP == nil {
|
||||||
|
a.Name = host
|
||||||
|
}
|
||||||
|
if i == 0 {
|
||||||
|
proxy = a
|
||||||
|
} else {
|
||||||
|
dst = a
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// NewDialer returns a new Dialer that dials through the provided
|
||||||
|
// proxy server's network and address.
|
||||||
|
func NewDialer(network, address string) *Dialer {
|
||||||
|
return &Dialer{proxyNetwork: network, proxyAddress: address, cmd: CmdConnect}
|
||||||
|
}
|
||||||
|
|
||||||
|
const (
|
||||||
|
authUsernamePasswordVersion = 0x01
|
||||||
|
authStatusSucceeded = 0x00
|
||||||
|
)
|
||||||
|
|
||||||
|
// UsernamePassword are the credentials for the username/password
|
||||||
|
// authentication method.
|
||||||
|
type UsernamePassword struct {
|
||||||
|
Username string
|
||||||
|
Password string
|
||||||
|
}
|
||||||
|
|
||||||
|
// Authenticate authenticates a pair of username and password with the
|
||||||
|
// proxy server.
|
||||||
|
func (up *UsernamePassword) Authenticate(ctx context.Context, rw io.ReadWriter, auth AuthMethod) error {
|
||||||
|
switch auth {
|
||||||
|
case AuthMethodNotRequired:
|
||||||
|
return nil
|
||||||
|
case AuthMethodUsernamePassword:
|
||||||
|
if len(up.Username) == 0 || len(up.Username) > 255 || len(up.Password) == 0 || len(up.Password) > 255 {
|
||||||
|
return errors.New("invalid username/password")
|
||||||
|
}
|
||||||
|
b := []byte{authUsernamePasswordVersion}
|
||||||
|
b = append(b, byte(len(up.Username)))
|
||||||
|
b = append(b, up.Username...)
|
||||||
|
b = append(b, byte(len(up.Password)))
|
||||||
|
b = append(b, up.Password...)
|
||||||
|
// TODO(mikio): handle IO deadlines and cancelation if
|
||||||
|
// necessary
|
||||||
|
if _, err := rw.Write(b); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
if _, err := io.ReadFull(rw, b[:2]); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
if b[0] != authUsernamePasswordVersion {
|
||||||
|
return errors.New("invalid username/password version")
|
||||||
|
}
|
||||||
|
if b[1] != authStatusSucceeded {
|
||||||
|
return errors.New("username/password authentication failed")
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
return errors.New("unsupported authentication method " + strconv.Itoa(int(auth)))
|
||||||
|
}
|
2
vendor/golang.org/x/net/ipv4/gen.go
generated
vendored
2
vendor/golang.org/x/net/ipv4/gen.go
generated
vendored
|
@ -80,7 +80,7 @@ var registries = []struct {
|
||||||
func geniana() error {
|
func geniana() error {
|
||||||
var bb bytes.Buffer
|
var bb bytes.Buffer
|
||||||
fmt.Fprintf(&bb, "// go generate gen.go\n")
|
fmt.Fprintf(&bb, "// go generate gen.go\n")
|
||||||
fmt.Fprintf(&bb, "// GENERATED BY THE COMMAND ABOVE; DO NOT EDIT\n\n")
|
fmt.Fprintf(&bb, "// Code generated by the command above; DO NOT EDIT.\n\n")
|
||||||
fmt.Fprintf(&bb, "package ipv4\n\n")
|
fmt.Fprintf(&bb, "package ipv4\n\n")
|
||||||
for _, r := range registries {
|
for _, r := range registries {
|
||||||
resp, err := http.Get(r.url)
|
resp, err := http.Get(r.url)
|
||||||
|
|
2
vendor/golang.org/x/net/ipv4/header.go
generated
vendored
2
vendor/golang.org/x/net/ipv4/header.go
generated
vendored
|
@ -98,7 +98,7 @@ func (h *Header) Marshal() ([]byte, error) {
|
||||||
return b, nil
|
return b, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// Parse parses b as an IPv4 header and sotres the result in h.
|
// Parse parses b as an IPv4 header and stores the result in h.
|
||||||
func (h *Header) Parse(b []byte) error {
|
func (h *Header) Parse(b []byte) error {
|
||||||
if h == nil || len(b) < HeaderLen {
|
if h == nil || len(b) < HeaderLen {
|
||||||
return errHeaderTooShort
|
return errHeaderTooShort
|
||||||
|
|
10
vendor/golang.org/x/net/ipv4/iana.go
generated
vendored
10
vendor/golang.org/x/net/ipv4/iana.go
generated
vendored
|
@ -1,9 +1,9 @@
|
||||||
// go generate gen.go
|
// go generate gen.go
|
||||||
// GENERATED BY THE COMMAND ABOVE; DO NOT EDIT
|
// Code generated by the command above; DO NOT EDIT.
|
||||||
|
|
||||||
package ipv4
|
package ipv4
|
||||||
|
|
||||||
// Internet Control Message Protocol (ICMP) Parameters, Updated: 2013-04-19
|
// Internet Control Message Protocol (ICMP) Parameters, Updated: 2018-02-26
|
||||||
const (
|
const (
|
||||||
ICMPTypeEchoReply ICMPType = 0 // Echo Reply
|
ICMPTypeEchoReply ICMPType = 0 // Echo Reply
|
||||||
ICMPTypeDestinationUnreachable ICMPType = 3 // Destination Unreachable
|
ICMPTypeDestinationUnreachable ICMPType = 3 // Destination Unreachable
|
||||||
|
@ -16,9 +16,11 @@ const (
|
||||||
ICMPTypeTimestamp ICMPType = 13 // Timestamp
|
ICMPTypeTimestamp ICMPType = 13 // Timestamp
|
||||||
ICMPTypeTimestampReply ICMPType = 14 // Timestamp Reply
|
ICMPTypeTimestampReply ICMPType = 14 // Timestamp Reply
|
||||||
ICMPTypePhoturis ICMPType = 40 // Photuris
|
ICMPTypePhoturis ICMPType = 40 // Photuris
|
||||||
|
ICMPTypeExtendedEchoRequest ICMPType = 42 // Extended Echo Request
|
||||||
|
ICMPTypeExtendedEchoReply ICMPType = 43 // Extended Echo Reply
|
||||||
)
|
)
|
||||||
|
|
||||||
// Internet Control Message Protocol (ICMP) Parameters, Updated: 2013-04-19
|
// Internet Control Message Protocol (ICMP) Parameters, Updated: 2018-02-26
|
||||||
var icmpTypes = map[ICMPType]string{
|
var icmpTypes = map[ICMPType]string{
|
||||||
0: "echo reply",
|
0: "echo reply",
|
||||||
3: "destination unreachable",
|
3: "destination unreachable",
|
||||||
|
@ -31,4 +33,6 @@ var icmpTypes = map[ICMPType]string{
|
||||||
13: "timestamp",
|
13: "timestamp",
|
||||||
14: "timestamp reply",
|
14: "timestamp reply",
|
||||||
40: "photuris",
|
40: "photuris",
|
||||||
|
42: "extended echo request",
|
||||||
|
43: "extended echo reply",
|
||||||
}
|
}
|
||||||
|
|
2
vendor/golang.org/x/net/ipv6/gen.go
generated
vendored
2
vendor/golang.org/x/net/ipv6/gen.go
generated
vendored
|
@ -80,7 +80,7 @@ var registries = []struct {
|
||||||
func geniana() error {
|
func geniana() error {
|
||||||
var bb bytes.Buffer
|
var bb bytes.Buffer
|
||||||
fmt.Fprintf(&bb, "// go generate gen.go\n")
|
fmt.Fprintf(&bb, "// go generate gen.go\n")
|
||||||
fmt.Fprintf(&bb, "// GENERATED BY THE COMMAND ABOVE; DO NOT EDIT\n\n")
|
fmt.Fprintf(&bb, "// Code generated by the command above; DO NOT EDIT.\n\n")
|
||||||
fmt.Fprintf(&bb, "package ipv6\n\n")
|
fmt.Fprintf(&bb, "package ipv6\n\n")
|
||||||
for _, r := range registries {
|
for _, r := range registries {
|
||||||
resp, err := http.Get(r.url)
|
resp, err := http.Get(r.url)
|
||||||
|
|
10
vendor/golang.org/x/net/ipv6/iana.go
generated
vendored
10
vendor/golang.org/x/net/ipv6/iana.go
generated
vendored
|
@ -1,9 +1,9 @@
|
||||||
// go generate gen.go
|
// go generate gen.go
|
||||||
// GENERATED BY THE COMMAND ABOVE; DO NOT EDIT
|
// Code generated by the command above; DO NOT EDIT.
|
||||||
|
|
||||||
package ipv6
|
package ipv6
|
||||||
|
|
||||||
// Internet Control Message Protocol version 6 (ICMPv6) Parameters, Updated: 2015-07-07
|
// Internet Control Message Protocol version 6 (ICMPv6) Parameters, Updated: 2018-03-09
|
||||||
const (
|
const (
|
||||||
ICMPTypeDestinationUnreachable ICMPType = 1 // Destination Unreachable
|
ICMPTypeDestinationUnreachable ICMPType = 1 // Destination Unreachable
|
||||||
ICMPTypePacketTooBig ICMPType = 2 // Packet Too Big
|
ICMPTypePacketTooBig ICMPType = 2 // Packet Too Big
|
||||||
|
@ -40,9 +40,11 @@ const (
|
||||||
ICMPTypeDuplicateAddressRequest ICMPType = 157 // Duplicate Address Request
|
ICMPTypeDuplicateAddressRequest ICMPType = 157 // Duplicate Address Request
|
||||||
ICMPTypeDuplicateAddressConfirmation ICMPType = 158 // Duplicate Address Confirmation
|
ICMPTypeDuplicateAddressConfirmation ICMPType = 158 // Duplicate Address Confirmation
|
||||||
ICMPTypeMPLControl ICMPType = 159 // MPL Control Message
|
ICMPTypeMPLControl ICMPType = 159 // MPL Control Message
|
||||||
|
ICMPTypeExtendedEchoRequest ICMPType = 160 // Extended Echo Request
|
||||||
|
ICMPTypeExtendedEchoReply ICMPType = 161 // Extended Echo Reply
|
||||||
)
|
)
|
||||||
|
|
||||||
// Internet Control Message Protocol version 6 (ICMPv6) Parameters, Updated: 2015-07-07
|
// Internet Control Message Protocol version 6 (ICMPv6) Parameters, Updated: 2018-03-09
|
||||||
var icmpTypes = map[ICMPType]string{
|
var icmpTypes = map[ICMPType]string{
|
||||||
1: "destination unreachable",
|
1: "destination unreachable",
|
||||||
2: "packet too big",
|
2: "packet too big",
|
||||||
|
@ -79,4 +81,6 @@ var icmpTypes = map[ICMPType]string{
|
||||||
157: "duplicate address request",
|
157: "duplicate address request",
|
||||||
158: "duplicate address confirmation",
|
158: "duplicate address confirmation",
|
||||||
159: "mpl control message",
|
159: "mpl control message",
|
||||||
|
160: "extended echo request",
|
||||||
|
161: "extended echo reply",
|
||||||
}
|
}
|
||||||
|
|
222
vendor/golang.org/x/net/proxy/socks5.go
generated
vendored
222
vendor/golang.org/x/net/proxy/socks5.go
generated
vendored
|
@ -5,210 +5,32 @@
|
||||||
package proxy
|
package proxy
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"errors"
|
"context"
|
||||||
"io"
|
|
||||||
"net"
|
"net"
|
||||||
"strconv"
|
|
||||||
|
"golang.org/x/net/internal/socks"
|
||||||
)
|
)
|
||||||
|
|
||||||
// SOCKS5 returns a Dialer that makes SOCKSv5 connections to the given address
|
// SOCKS5 returns a Dialer that makes SOCKSv5 connections to the given
|
||||||
// with an optional username and password. See RFC 1928 and RFC 1929.
|
// address with an optional username and password.
|
||||||
func SOCKS5(network, addr string, auth *Auth, forward Dialer) (Dialer, error) {
|
// See RFC 1928 and RFC 1929.
|
||||||
s := &socks5{
|
func SOCKS5(network, address string, auth *Auth, forward Dialer) (Dialer, error) {
|
||||||
network: network,
|
d := socks.NewDialer(network, address)
|
||||||
addr: addr,
|
if forward != nil {
|
||||||
forward: forward,
|
d.ProxyDial = func(_ context.Context, network string, address string) (net.Conn, error) {
|
||||||
|
return forward.Dial(network, address)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if auth != nil {
|
if auth != nil {
|
||||||
s.user = auth.User
|
up := socks.UsernamePassword{
|
||||||
s.password = auth.Password
|
Username: auth.User,
|
||||||
|
Password: auth.Password,
|
||||||
|
}
|
||||||
|
d.AuthMethods = []socks.AuthMethod{
|
||||||
|
socks.AuthMethodNotRequired,
|
||||||
|
socks.AuthMethodUsernamePassword,
|
||||||
|
}
|
||||||
|
d.Authenticate = up.Authenticate
|
||||||
}
|
}
|
||||||
|
return d, nil
|
||||||
return s, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
type socks5 struct {
|
|
||||||
user, password string
|
|
||||||
network, addr string
|
|
||||||
forward Dialer
|
|
||||||
}
|
|
||||||
|
|
||||||
const socks5Version = 5
|
|
||||||
|
|
||||||
const (
|
|
||||||
socks5AuthNone = 0
|
|
||||||
socks5AuthPassword = 2
|
|
||||||
)
|
|
||||||
|
|
||||||
const socks5Connect = 1
|
|
||||||
|
|
||||||
const (
|
|
||||||
socks5IP4 = 1
|
|
||||||
socks5Domain = 3
|
|
||||||
socks5IP6 = 4
|
|
||||||
)
|
|
||||||
|
|
||||||
var socks5Errors = []string{
|
|
||||||
"",
|
|
||||||
"general failure",
|
|
||||||
"connection forbidden",
|
|
||||||
"network unreachable",
|
|
||||||
"host unreachable",
|
|
||||||
"connection refused",
|
|
||||||
"TTL expired",
|
|
||||||
"command not supported",
|
|
||||||
"address type not supported",
|
|
||||||
}
|
|
||||||
|
|
||||||
// Dial connects to the address addr on the given network via the SOCKS5 proxy.
|
|
||||||
func (s *socks5) Dial(network, addr string) (net.Conn, error) {
|
|
||||||
switch network {
|
|
||||||
case "tcp", "tcp6", "tcp4":
|
|
||||||
default:
|
|
||||||
return nil, errors.New("proxy: no support for SOCKS5 proxy connections of type " + network)
|
|
||||||
}
|
|
||||||
|
|
||||||
conn, err := s.forward.Dial(s.network, s.addr)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
if err := s.connect(conn, addr); err != nil {
|
|
||||||
conn.Close()
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
return conn, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// connect takes an existing connection to a socks5 proxy server,
|
|
||||||
// and commands the server to extend that connection to target,
|
|
||||||
// which must be a canonical address with a host and port.
|
|
||||||
func (s *socks5) connect(conn net.Conn, target string) error {
|
|
||||||
host, portStr, err := net.SplitHostPort(target)
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
port, err := strconv.Atoi(portStr)
|
|
||||||
if err != nil {
|
|
||||||
return errors.New("proxy: failed to parse port number: " + portStr)
|
|
||||||
}
|
|
||||||
if port < 1 || port > 0xffff {
|
|
||||||
return errors.New("proxy: port number out of range: " + portStr)
|
|
||||||
}
|
|
||||||
|
|
||||||
// the size here is just an estimate
|
|
||||||
buf := make([]byte, 0, 6+len(host))
|
|
||||||
|
|
||||||
buf = append(buf, socks5Version)
|
|
||||||
if len(s.user) > 0 && len(s.user) < 256 && len(s.password) < 256 {
|
|
||||||
buf = append(buf, 2 /* num auth methods */, socks5AuthNone, socks5AuthPassword)
|
|
||||||
} else {
|
|
||||||
buf = append(buf, 1 /* num auth methods */, socks5AuthNone)
|
|
||||||
}
|
|
||||||
|
|
||||||
if _, err := conn.Write(buf); err != nil {
|
|
||||||
return errors.New("proxy: failed to write greeting to SOCKS5 proxy at " + s.addr + ": " + err.Error())
|
|
||||||
}
|
|
||||||
|
|
||||||
if _, err := io.ReadFull(conn, buf[:2]); err != nil {
|
|
||||||
return errors.New("proxy: failed to read greeting from SOCKS5 proxy at " + s.addr + ": " + err.Error())
|
|
||||||
}
|
|
||||||
if buf[0] != 5 {
|
|
||||||
return errors.New("proxy: SOCKS5 proxy at " + s.addr + " has unexpected version " + strconv.Itoa(int(buf[0])))
|
|
||||||
}
|
|
||||||
if buf[1] == 0xff {
|
|
||||||
return errors.New("proxy: SOCKS5 proxy at " + s.addr + " requires authentication")
|
|
||||||
}
|
|
||||||
|
|
||||||
// See RFC 1929
|
|
||||||
if buf[1] == socks5AuthPassword {
|
|
||||||
buf = buf[:0]
|
|
||||||
buf = append(buf, 1 /* password protocol version */)
|
|
||||||
buf = append(buf, uint8(len(s.user)))
|
|
||||||
buf = append(buf, s.user...)
|
|
||||||
buf = append(buf, uint8(len(s.password)))
|
|
||||||
buf = append(buf, s.password...)
|
|
||||||
|
|
||||||
if _, err := conn.Write(buf); err != nil {
|
|
||||||
return errors.New("proxy: failed to write authentication request to SOCKS5 proxy at " + s.addr + ": " + err.Error())
|
|
||||||
}
|
|
||||||
|
|
||||||
if _, err := io.ReadFull(conn, buf[:2]); err != nil {
|
|
||||||
return errors.New("proxy: failed to read authentication reply from SOCKS5 proxy at " + s.addr + ": " + err.Error())
|
|
||||||
}
|
|
||||||
|
|
||||||
if buf[1] != 0 {
|
|
||||||
return errors.New("proxy: SOCKS5 proxy at " + s.addr + " rejected username/password")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
buf = buf[:0]
|
|
||||||
buf = append(buf, socks5Version, socks5Connect, 0 /* reserved */)
|
|
||||||
|
|
||||||
if ip := net.ParseIP(host); ip != nil {
|
|
||||||
if ip4 := ip.To4(); ip4 != nil {
|
|
||||||
buf = append(buf, socks5IP4)
|
|
||||||
ip = ip4
|
|
||||||
} else {
|
|
||||||
buf = append(buf, socks5IP6)
|
|
||||||
}
|
|
||||||
buf = append(buf, ip...)
|
|
||||||
} else {
|
|
||||||
if len(host) > 255 {
|
|
||||||
return errors.New("proxy: destination host name too long: " + host)
|
|
||||||
}
|
|
||||||
buf = append(buf, socks5Domain)
|
|
||||||
buf = append(buf, byte(len(host)))
|
|
||||||
buf = append(buf, host...)
|
|
||||||
}
|
|
||||||
buf = append(buf, byte(port>>8), byte(port))
|
|
||||||
|
|
||||||
if _, err := conn.Write(buf); err != nil {
|
|
||||||
return errors.New("proxy: failed to write connect request to SOCKS5 proxy at " + s.addr + ": " + err.Error())
|
|
||||||
}
|
|
||||||
|
|
||||||
if _, err := io.ReadFull(conn, buf[:4]); err != nil {
|
|
||||||
return errors.New("proxy: failed to read connect reply from SOCKS5 proxy at " + s.addr + ": " + err.Error())
|
|
||||||
}
|
|
||||||
|
|
||||||
failure := "unknown error"
|
|
||||||
if int(buf[1]) < len(socks5Errors) {
|
|
||||||
failure = socks5Errors[buf[1]]
|
|
||||||
}
|
|
||||||
|
|
||||||
if len(failure) > 0 {
|
|
||||||
return errors.New("proxy: SOCKS5 proxy at " + s.addr + " failed to connect: " + failure)
|
|
||||||
}
|
|
||||||
|
|
||||||
bytesToDiscard := 0
|
|
||||||
switch buf[3] {
|
|
||||||
case socks5IP4:
|
|
||||||
bytesToDiscard = net.IPv4len
|
|
||||||
case socks5IP6:
|
|
||||||
bytesToDiscard = net.IPv6len
|
|
||||||
case socks5Domain:
|
|
||||||
_, err := io.ReadFull(conn, buf[:1])
|
|
||||||
if err != nil {
|
|
||||||
return errors.New("proxy: failed to read domain length from SOCKS5 proxy at " + s.addr + ": " + err.Error())
|
|
||||||
}
|
|
||||||
bytesToDiscard = int(buf[0])
|
|
||||||
default:
|
|
||||||
return errors.New("proxy: got unknown address type " + strconv.Itoa(int(buf[3])) + " from SOCKS5 proxy at " + s.addr)
|
|
||||||
}
|
|
||||||
|
|
||||||
if cap(buf) < bytesToDiscard {
|
|
||||||
buf = make([]byte, bytesToDiscard)
|
|
||||||
} else {
|
|
||||||
buf = buf[:bytesToDiscard]
|
|
||||||
}
|
|
||||||
if _, err := io.ReadFull(conn, buf); err != nil {
|
|
||||||
return errors.New("proxy: failed to read address from SOCKS5 proxy at " + s.addr + ": " + err.Error())
|
|
||||||
}
|
|
||||||
|
|
||||||
// Also need to discard the port number
|
|
||||||
if _, err := io.ReadFull(conn, buf[:2]); err != nil {
|
|
||||||
return errors.New("proxy: failed to read port from SOCKS5 proxy at " + s.addr + ": " + err.Error())
|
|
||||||
}
|
|
||||||
|
|
||||||
return nil
|
|
||||||
}
|
}
|
||||||
|
|
59
vendor/golang.org/x/net/trace/trace.go
generated
vendored
59
vendor/golang.org/x/net/trace/trace.go
generated
vendored
|
@ -368,7 +368,11 @@ func New(family, title string) Trace {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (tr *trace) Finish() {
|
func (tr *trace) Finish() {
|
||||||
tr.Elapsed = time.Now().Sub(tr.Start)
|
elapsed := time.Now().Sub(tr.Start)
|
||||||
|
tr.mu.Lock()
|
||||||
|
tr.Elapsed = elapsed
|
||||||
|
tr.mu.Unlock()
|
||||||
|
|
||||||
if DebugUseAfterFinish {
|
if DebugUseAfterFinish {
|
||||||
buf := make([]byte, 4<<10) // 4 KB should be enough
|
buf := make([]byte, 4<<10) // 4 KB should be enough
|
||||||
n := runtime.Stack(buf, false)
|
n := runtime.Stack(buf, false)
|
||||||
|
@ -381,14 +385,17 @@ func (tr *trace) Finish() {
|
||||||
m.Remove(tr)
|
m.Remove(tr)
|
||||||
|
|
||||||
f := getFamily(tr.Family, true)
|
f := getFamily(tr.Family, true)
|
||||||
|
tr.mu.RLock() // protects tr fields in Cond.match calls
|
||||||
for _, b := range f.Buckets {
|
for _, b := range f.Buckets {
|
||||||
if b.Cond.match(tr) {
|
if b.Cond.match(tr) {
|
||||||
b.Add(tr)
|
b.Add(tr)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
tr.mu.RUnlock()
|
||||||
|
|
||||||
// Add a sample of elapsed time as microseconds to the family's timeseries
|
// Add a sample of elapsed time as microseconds to the family's timeseries
|
||||||
h := new(histogram)
|
h := new(histogram)
|
||||||
h.addMeasurement(tr.Elapsed.Nanoseconds() / 1e3)
|
h.addMeasurement(elapsed.Nanoseconds() / 1e3)
|
||||||
f.LatencyMu.Lock()
|
f.LatencyMu.Lock()
|
||||||
f.Latency.Add(h)
|
f.Latency.Add(h)
|
||||||
f.LatencyMu.Unlock()
|
f.LatencyMu.Unlock()
|
||||||
|
@ -684,25 +691,20 @@ type trace struct {
|
||||||
// Title is the title of this trace.
|
// Title is the title of this trace.
|
||||||
Title string
|
Title string
|
||||||
|
|
||||||
// Timing information.
|
// Start time of the this trace.
|
||||||
Start time.Time
|
Start time.Time
|
||||||
Elapsed time.Duration // zero while active
|
|
||||||
|
|
||||||
// Trace information if non-zero.
|
|
||||||
traceID uint64
|
|
||||||
spanID uint64
|
|
||||||
|
|
||||||
// Whether this trace resulted in an error.
|
|
||||||
IsError bool
|
|
||||||
|
|
||||||
// Append-only sequence of events (modulo discards).
|
|
||||||
mu sync.RWMutex
|
mu sync.RWMutex
|
||||||
events []event
|
events []event // Append-only sequence of events (modulo discards).
|
||||||
maxEvents int
|
maxEvents int
|
||||||
|
recycler func(interface{})
|
||||||
|
IsError bool // Whether this trace resulted in an error.
|
||||||
|
Elapsed time.Duration // Elapsed time for this trace, zero while active.
|
||||||
|
traceID uint64 // Trace information if non-zero.
|
||||||
|
spanID uint64
|
||||||
|
|
||||||
refs int32 // how many buckets this is in
|
refs int32 // how many buckets this is in
|
||||||
recycler func(interface{})
|
disc discarded // scratch space to avoid allocation
|
||||||
disc discarded // scratch space to avoid allocation
|
|
||||||
|
|
||||||
finishStack []byte // where finish was called, if DebugUseAfterFinish is set
|
finishStack []byte // where finish was called, if DebugUseAfterFinish is set
|
||||||
|
|
||||||
|
@ -714,14 +716,18 @@ func (tr *trace) reset() {
|
||||||
tr.Family = ""
|
tr.Family = ""
|
||||||
tr.Title = ""
|
tr.Title = ""
|
||||||
tr.Start = time.Time{}
|
tr.Start = time.Time{}
|
||||||
|
|
||||||
|
tr.mu.Lock()
|
||||||
tr.Elapsed = 0
|
tr.Elapsed = 0
|
||||||
tr.traceID = 0
|
tr.traceID = 0
|
||||||
tr.spanID = 0
|
tr.spanID = 0
|
||||||
tr.IsError = false
|
tr.IsError = false
|
||||||
tr.maxEvents = 0
|
tr.maxEvents = 0
|
||||||
tr.events = nil
|
tr.events = nil
|
||||||
tr.refs = 0
|
|
||||||
tr.recycler = nil
|
tr.recycler = nil
|
||||||
|
tr.mu.Unlock()
|
||||||
|
|
||||||
|
tr.refs = 0
|
||||||
tr.disc = 0
|
tr.disc = 0
|
||||||
tr.finishStack = nil
|
tr.finishStack = nil
|
||||||
for i := range tr.eventsBuf {
|
for i := range tr.eventsBuf {
|
||||||
|
@ -801,21 +807,31 @@ func (tr *trace) LazyPrintf(format string, a ...interface{}) {
|
||||||
tr.addEvent(&lazySprintf{format, a}, false, false)
|
tr.addEvent(&lazySprintf{format, a}, false, false)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (tr *trace) SetError() { tr.IsError = true }
|
func (tr *trace) SetError() {
|
||||||
|
tr.mu.Lock()
|
||||||
|
tr.IsError = true
|
||||||
|
tr.mu.Unlock()
|
||||||
|
}
|
||||||
|
|
||||||
func (tr *trace) SetRecycler(f func(interface{})) {
|
func (tr *trace) SetRecycler(f func(interface{})) {
|
||||||
|
tr.mu.Lock()
|
||||||
tr.recycler = f
|
tr.recycler = f
|
||||||
|
tr.mu.Unlock()
|
||||||
}
|
}
|
||||||
|
|
||||||
func (tr *trace) SetTraceInfo(traceID, spanID uint64) {
|
func (tr *trace) SetTraceInfo(traceID, spanID uint64) {
|
||||||
|
tr.mu.Lock()
|
||||||
tr.traceID, tr.spanID = traceID, spanID
|
tr.traceID, tr.spanID = traceID, spanID
|
||||||
|
tr.mu.Unlock()
|
||||||
}
|
}
|
||||||
|
|
||||||
func (tr *trace) SetMaxEvents(m int) {
|
func (tr *trace) SetMaxEvents(m int) {
|
||||||
|
tr.mu.Lock()
|
||||||
// Always keep at least three events: first, discarded count, last.
|
// Always keep at least three events: first, discarded count, last.
|
||||||
if len(tr.events) == 0 && m > 3 {
|
if len(tr.events) == 0 && m > 3 {
|
||||||
tr.maxEvents = m
|
tr.maxEvents = m
|
||||||
}
|
}
|
||||||
|
tr.mu.Unlock()
|
||||||
}
|
}
|
||||||
|
|
||||||
func (tr *trace) ref() {
|
func (tr *trace) ref() {
|
||||||
|
@ -824,6 +840,7 @@ func (tr *trace) ref() {
|
||||||
|
|
||||||
func (tr *trace) unref() {
|
func (tr *trace) unref() {
|
||||||
if atomic.AddInt32(&tr.refs, -1) == 0 {
|
if atomic.AddInt32(&tr.refs, -1) == 0 {
|
||||||
|
tr.mu.RLock()
|
||||||
if tr.recycler != nil {
|
if tr.recycler != nil {
|
||||||
// freeTrace clears tr, so we hold tr.recycler and tr.events here.
|
// freeTrace clears tr, so we hold tr.recycler and tr.events here.
|
||||||
go func(f func(interface{}), es []event) {
|
go func(f func(interface{}), es []event) {
|
||||||
|
@ -834,6 +851,7 @@ func (tr *trace) unref() {
|
||||||
}
|
}
|
||||||
}(tr.recycler, tr.events)
|
}(tr.recycler, tr.events)
|
||||||
}
|
}
|
||||||
|
tr.mu.RUnlock()
|
||||||
|
|
||||||
freeTrace(tr)
|
freeTrace(tr)
|
||||||
}
|
}
|
||||||
|
@ -844,7 +862,10 @@ func (tr *trace) When() string {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (tr *trace) ElapsedTime() string {
|
func (tr *trace) ElapsedTime() string {
|
||||||
|
tr.mu.RLock()
|
||||||
t := tr.Elapsed
|
t := tr.Elapsed
|
||||||
|
tr.mu.RUnlock()
|
||||||
|
|
||||||
if t == 0 {
|
if t == 0 {
|
||||||
// Active trace.
|
// Active trace.
|
||||||
t = time.Since(tr.Start)
|
t = time.Since(tr.Start)
|
||||||
|
|
3
vendor/golang.org/x/net/websocket/websocket.go
generated
vendored
3
vendor/golang.org/x/net/websocket/websocket.go
generated
vendored
|
@ -241,7 +241,10 @@ func (ws *Conn) Close() error {
|
||||||
return err1
|
return err1
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// IsClientConn reports whether ws is a client-side connection.
|
||||||
func (ws *Conn) IsClientConn() bool { return ws.request == nil }
|
func (ws *Conn) IsClientConn() bool { return ws.request == nil }
|
||||||
|
|
||||||
|
// IsServerConn reports whether ws is a server-side connection.
|
||||||
func (ws *Conn) IsServerConn() bool { return ws.request != nil }
|
func (ws *Conn) IsServerConn() bool { return ws.request != nil }
|
||||||
|
|
||||||
// LocalAddr returns the WebSocket Origin for the connection for client, or
|
// LocalAddr returns the WebSocket Origin for the connection for client, or
|
||||||
|
|
Loading…
Reference in a new issue