mirror of
https://github.com/fatedier/frp.git
synced 2025-02-02 07:54:23 +00:00
vendor update github.com/gorilla/websocket
This commit is contained in:
parent
80154639e3
commit
abc6d720d0
2
go.mod
2
go.mod
@ -9,7 +9,7 @@ require (
|
|||||||
github.com/fatedier/kcp-go v2.0.4-0.20190803094908-fe8645b0a904+incompatible
|
github.com/fatedier/kcp-go v2.0.4-0.20190803094908-fe8645b0a904+incompatible
|
||||||
github.com/golang/snappy v0.0.0-20170215233205-553a64147049 // indirect
|
github.com/golang/snappy v0.0.0-20170215233205-553a64147049 // indirect
|
||||||
github.com/gorilla/mux v1.7.3
|
github.com/gorilla/mux v1.7.3
|
||||||
github.com/gorilla/websocket v1.2.0
|
github.com/gorilla/websocket v1.4.0
|
||||||
github.com/hashicorp/yamux v0.0.0-20181012175058-2f1d1f20f75d
|
github.com/hashicorp/yamux v0.0.0-20181012175058-2f1d1f20f75d
|
||||||
github.com/inconshreveable/mousetrap v1.0.0 // indirect
|
github.com/inconshreveable/mousetrap v1.0.0 // indirect
|
||||||
github.com/klauspost/cpuid v1.2.0 // indirect
|
github.com/klauspost/cpuid v1.2.0 // indirect
|
||||||
|
3
go.sum
3
go.sum
@ -11,7 +11,8 @@ github.com/golang/snappy v0.0.0-20170215233205-553a64147049 h1:K9KHZbXKpGydfDN0a
|
|||||||
github.com/golang/snappy v0.0.0-20170215233205-553a64147049/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q=
|
github.com/golang/snappy v0.0.0-20170215233205-553a64147049/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q=
|
||||||
github.com/gorilla/mux v1.7.3 h1:gnP5JzjVOuiZD07fKKToCAOjS0yOpj/qPETTXCCS6hw=
|
github.com/gorilla/mux v1.7.3 h1:gnP5JzjVOuiZD07fKKToCAOjS0yOpj/qPETTXCCS6hw=
|
||||||
github.com/gorilla/mux v1.7.3/go.mod h1:1lud6UwP+6orDFRuTfBEV8e9/aOM/c4fVVCaMa2zaAs=
|
github.com/gorilla/mux v1.7.3/go.mod h1:1lud6UwP+6orDFRuTfBEV8e9/aOM/c4fVVCaMa2zaAs=
|
||||||
github.com/gorilla/websocket v1.2.0/go.mod h1:E7qHFY5m1UJ88s3WnNqhKjPHQ0heANvMoAMk2YaljkQ=
|
github.com/gorilla/websocket v1.4.0 h1:WDFjx/TMzVgy9VdMMQi2K2Emtwi2QcUQsztZ/zLaH/Q=
|
||||||
|
github.com/gorilla/websocket v1.4.0/go.mod h1:E7qHFY5m1UJ88s3WnNqhKjPHQ0heANvMoAMk2YaljkQ=
|
||||||
github.com/hashicorp/yamux v0.0.0-20181012175058-2f1d1f20f75d h1:kJCB4vdITiW1eC1vq2e6IsrXKrZit1bv/TDYFGMp4BQ=
|
github.com/hashicorp/yamux v0.0.0-20181012175058-2f1d1f20f75d h1:kJCB4vdITiW1eC1vq2e6IsrXKrZit1bv/TDYFGMp4BQ=
|
||||||
github.com/hashicorp/yamux v0.0.0-20181012175058-2f1d1f20f75d/go.mod h1:+NfK9FKeTrX5uv1uIXGdwYDTeHna2qgaIlx54MXqjAM=
|
github.com/hashicorp/yamux v0.0.0-20181012175058-2f1d1f20f75d/go.mod h1:+NfK9FKeTrX5uv1uIXGdwYDTeHna2qgaIlx54MXqjAM=
|
||||||
github.com/inconshreveable/mousetrap v1.0.0 h1:Z8tu5sraLXCXIcARxBp/8cbvlwVa7Z1NHg9XEKhtSvM=
|
github.com/inconshreveable/mousetrap v1.0.0 h1:Z8tu5sraLXCXIcARxBp/8cbvlwVa7Z1NHg9XEKhtSvM=
|
||||||
|
@ -89,15 +89,10 @@ func NewHttpReverseProxy(option HttpReverseProxyOptions, vhostRouter *VhostRoute
|
|||||||
return rp.CreateConnection(host, url, remote)
|
return rp.CreateConnection(host, url, remote)
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
//WebSocketDialContext: func(ctx context.Context, network, addr string) (net.Conn, error) {
|
|
||||||
//url := ctx.Value("url").(string)
|
|
||||||
//host := getHostFromAddr(ctx.Value("host").(string))
|
|
||||||
//remote := ctx.Value("remote").(string)
|
|
||||||
//return rp.CreateConnection(host, url, remote)
|
|
||||||
//},
|
|
||||||
BufferPool: newWrapPool(),
|
BufferPool: newWrapPool(),
|
||||||
ErrorLog: log.New(newWrapLogger(), "", 0),
|
ErrorLog: log.New(newWrapLogger(), "", 0),
|
||||||
ErrorHandler: func(rw http.ResponseWriter, req *http.Request, err error) {
|
ErrorHandler: func(rw http.ResponseWriter, req *http.Request, err error) {
|
||||||
|
frpLog.Warn("do http proxy request error: %v", err)
|
||||||
rw.WriteHeader(http.StatusNotFound)
|
rw.WriteHeader(http.StatusNotFound)
|
||||||
rw.Write(getNotFoundPageContent())
|
rw.Write(getNotFoundPageContent())
|
||||||
},
|
},
|
||||||
|
2
vendor/github.com/gorilla/websocket/.gitignore
generated
vendored
2
vendor/github.com/gorilla/websocket/.gitignore
generated
vendored
@ -22,4 +22,4 @@ _testmain.go
|
|||||||
*.exe
|
*.exe
|
||||||
|
|
||||||
.idea/
|
.idea/
|
||||||
*.iml
|
*.iml
|
||||||
|
10
vendor/github.com/gorilla/websocket/.travis.yml
generated
vendored
10
vendor/github.com/gorilla/websocket/.travis.yml
generated
vendored
@ -3,11 +3,11 @@ sudo: false
|
|||||||
|
|
||||||
matrix:
|
matrix:
|
||||||
include:
|
include:
|
||||||
- go: 1.4
|
- go: 1.7.x
|
||||||
- go: 1.5
|
- go: 1.8.x
|
||||||
- go: 1.6
|
- go: 1.9.x
|
||||||
- go: 1.7
|
- go: 1.10.x
|
||||||
- go: 1.8
|
- go: 1.11.x
|
||||||
- go: tip
|
- go: tip
|
||||||
allow_failures:
|
allow_failures:
|
||||||
- go: tip
|
- go: tip
|
||||||
|
1
vendor/github.com/gorilla/websocket/AUTHORS
generated
vendored
1
vendor/github.com/gorilla/websocket/AUTHORS
generated
vendored
@ -4,5 +4,6 @@
|
|||||||
# Please keep the list sorted.
|
# Please keep the list sorted.
|
||||||
|
|
||||||
Gary Burd <gary@beagledreams.com>
|
Gary Burd <gary@beagledreams.com>
|
||||||
|
Google LLC (https://opensource.google.com/)
|
||||||
Joachim Bauch <mail@joachim-bauch.de>
|
Joachim Bauch <mail@joachim-bauch.de>
|
||||||
|
|
||||||
|
2
vendor/github.com/gorilla/websocket/README.md
generated
vendored
2
vendor/github.com/gorilla/websocket/README.md
generated
vendored
@ -51,7 +51,7 @@ subdirectory](https://github.com/gorilla/websocket/tree/master/examples/autobahn
|
|||||||
<tr><td>Write message using io.WriteCloser</td><td><a href="http://godoc.org/github.com/gorilla/websocket#Conn.NextWriter">Yes</a></td><td>No, see note 3</td></tr>
|
<tr><td>Write message using io.WriteCloser</td><td><a href="http://godoc.org/github.com/gorilla/websocket#Conn.NextWriter">Yes</a></td><td>No, see note 3</td></tr>
|
||||||
</table>
|
</table>
|
||||||
|
|
||||||
Notes:
|
Notes:
|
||||||
|
|
||||||
1. Large messages are fragmented in [Chrome's new WebSocket implementation](http://www.ietf.org/mail-archive/web/hybi/current/msg10503.html).
|
1. Large messages are fragmented in [Chrome's new WebSocket implementation](http://www.ietf.org/mail-archive/web/hybi/current/msg10503.html).
|
||||||
2. The application can get the type of a received data message by implementing
|
2. The application can get the type of a received data message by implementing
|
||||||
|
253
vendor/github.com/gorilla/websocket/client.go
generated
vendored
253
vendor/github.com/gorilla/websocket/client.go
generated
vendored
@ -5,15 +5,15 @@
|
|||||||
package websocket
|
package websocket
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"bufio"
|
|
||||||
"bytes"
|
"bytes"
|
||||||
|
"context"
|
||||||
"crypto/tls"
|
"crypto/tls"
|
||||||
"encoding/base64"
|
|
||||||
"errors"
|
"errors"
|
||||||
"io"
|
"io"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"net"
|
"net"
|
||||||
"net/http"
|
"net/http"
|
||||||
|
"net/http/httptrace"
|
||||||
"net/url"
|
"net/url"
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
@ -53,6 +53,10 @@ type Dialer struct {
|
|||||||
// NetDial is nil, net.Dial is used.
|
// NetDial is nil, net.Dial is used.
|
||||||
NetDial func(network, addr string) (net.Conn, error)
|
NetDial func(network, addr string) (net.Conn, error)
|
||||||
|
|
||||||
|
// NetDialContext specifies the dial function for creating TCP connections. If
|
||||||
|
// NetDialContext is nil, net.DialContext is used.
|
||||||
|
NetDialContext func(ctx context.Context, network, addr string) (net.Conn, error)
|
||||||
|
|
||||||
// Proxy specifies a function to return a proxy for a given
|
// Proxy specifies a function to return a proxy for a given
|
||||||
// Request. If the function returns a non-nil error, the
|
// Request. If the function returns a non-nil error, the
|
||||||
// request is aborted with the provided error.
|
// request is aborted with the provided error.
|
||||||
@ -71,6 +75,17 @@ type Dialer struct {
|
|||||||
// do not limit the size of the messages that can be sent or received.
|
// do not limit the size of the messages that can be sent or received.
|
||||||
ReadBufferSize, WriteBufferSize int
|
ReadBufferSize, WriteBufferSize int
|
||||||
|
|
||||||
|
// WriteBufferPool is a pool of buffers for write operations. If the value
|
||||||
|
// is not set, then write buffers are allocated to the connection for the
|
||||||
|
// lifetime of the connection.
|
||||||
|
//
|
||||||
|
// A pool is most useful when the application has a modest volume of writes
|
||||||
|
// across a large number of connections.
|
||||||
|
//
|
||||||
|
// Applications should use a single pool for each unique value of
|
||||||
|
// WriteBufferSize.
|
||||||
|
WriteBufferPool BufferPool
|
||||||
|
|
||||||
// Subprotocols specifies the client's requested subprotocols.
|
// Subprotocols specifies the client's requested subprotocols.
|
||||||
Subprotocols []string
|
Subprotocols []string
|
||||||
|
|
||||||
@ -86,52 +101,13 @@ type Dialer struct {
|
|||||||
Jar http.CookieJar
|
Jar http.CookieJar
|
||||||
}
|
}
|
||||||
|
|
||||||
var errMalformedURL = errors.New("malformed ws or wss URL")
|
// Dial creates a new client connection by calling DialContext with a background context.
|
||||||
|
func (d *Dialer) Dial(urlStr string, requestHeader http.Header) (*Conn, *http.Response, error) {
|
||||||
// parseURL parses the URL.
|
return d.DialContext(context.Background(), urlStr, requestHeader)
|
||||||
//
|
|
||||||
// This function is a replacement for the standard library url.Parse function.
|
|
||||||
// In Go 1.4 and earlier, url.Parse loses information from the path.
|
|
||||||
func parseURL(s string) (*url.URL, error) {
|
|
||||||
// From the RFC:
|
|
||||||
//
|
|
||||||
// ws-URI = "ws:" "//" host [ ":" port ] path [ "?" query ]
|
|
||||||
// wss-URI = "wss:" "//" host [ ":" port ] path [ "?" query ]
|
|
||||||
var u url.URL
|
|
||||||
switch {
|
|
||||||
case strings.HasPrefix(s, "ws://"):
|
|
||||||
u.Scheme = "ws"
|
|
||||||
s = s[len("ws://"):]
|
|
||||||
case strings.HasPrefix(s, "wss://"):
|
|
||||||
u.Scheme = "wss"
|
|
||||||
s = s[len("wss://"):]
|
|
||||||
default:
|
|
||||||
return nil, errMalformedURL
|
|
||||||
}
|
|
||||||
|
|
||||||
if i := strings.Index(s, "?"); i >= 0 {
|
|
||||||
u.RawQuery = s[i+1:]
|
|
||||||
s = s[:i]
|
|
||||||
}
|
|
||||||
|
|
||||||
if i := strings.Index(s, "/"); i >= 0 {
|
|
||||||
u.Opaque = s[i:]
|
|
||||||
s = s[:i]
|
|
||||||
} else {
|
|
||||||
u.Opaque = "/"
|
|
||||||
}
|
|
||||||
|
|
||||||
u.Host = s
|
|
||||||
|
|
||||||
if strings.Contains(u.Host, "@") {
|
|
||||||
// Don't bother parsing user information because user information is
|
|
||||||
// not allowed in websocket URIs.
|
|
||||||
return nil, errMalformedURL
|
|
||||||
}
|
|
||||||
|
|
||||||
return &u, nil
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var errMalformedURL = errors.New("malformed ws or wss URL")
|
||||||
|
|
||||||
func hostPortNoPort(u *url.URL) (hostPort, hostNoPort string) {
|
func hostPortNoPort(u *url.URL) (hostPort, hostNoPort string) {
|
||||||
hostPort = u.Host
|
hostPort = u.Host
|
||||||
hostNoPort = u.Host
|
hostNoPort = u.Host
|
||||||
@ -150,26 +126,29 @@ func hostPortNoPort(u *url.URL) (hostPort, hostNoPort string) {
|
|||||||
return hostPort, hostNoPort
|
return hostPort, hostNoPort
|
||||||
}
|
}
|
||||||
|
|
||||||
// DefaultDialer is a dialer with all fields set to the default zero values.
|
// DefaultDialer is a dialer with all fields set to the default values.
|
||||||
var DefaultDialer = &Dialer{
|
var DefaultDialer = &Dialer{
|
||||||
Proxy: http.ProxyFromEnvironment,
|
Proxy: http.ProxyFromEnvironment,
|
||||||
|
HandshakeTimeout: 45 * time.Second,
|
||||||
}
|
}
|
||||||
|
|
||||||
// Dial creates a new client connection. Use requestHeader to specify the
|
// nilDialer is dialer to use when receiver is nil.
|
||||||
|
var nilDialer = *DefaultDialer
|
||||||
|
|
||||||
|
// DialContext creates a new client connection. Use requestHeader to specify the
|
||||||
// origin (Origin), subprotocols (Sec-WebSocket-Protocol) and cookies (Cookie).
|
// origin (Origin), subprotocols (Sec-WebSocket-Protocol) and cookies (Cookie).
|
||||||
// Use the response.Header to get the selected subprotocol
|
// Use the response.Header to get the selected subprotocol
|
||||||
// (Sec-WebSocket-Protocol) and cookies (Set-Cookie).
|
// (Sec-WebSocket-Protocol) and cookies (Set-Cookie).
|
||||||
//
|
//
|
||||||
|
// The context will be used in the request and in the Dialer
|
||||||
|
//
|
||||||
// If the WebSocket handshake fails, ErrBadHandshake is returned along with a
|
// If the WebSocket handshake fails, ErrBadHandshake is returned along with a
|
||||||
// non-nil *http.Response so that callers can handle redirects, authentication,
|
// non-nil *http.Response so that callers can handle redirects, authentication,
|
||||||
// etcetera. The response body may not contain the entire response and does not
|
// etcetera. The response body may not contain the entire response and does not
|
||||||
// need to be closed by the application.
|
// need to be closed by the application.
|
||||||
func (d *Dialer) Dial(urlStr string, requestHeader http.Header) (*Conn, *http.Response, error) {
|
func (d *Dialer) DialContext(ctx context.Context, urlStr string, requestHeader http.Header) (*Conn, *http.Response, error) {
|
||||||
|
|
||||||
if d == nil {
|
if d == nil {
|
||||||
d = &Dialer{
|
d = &nilDialer
|
||||||
Proxy: http.ProxyFromEnvironment,
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
challengeKey, err := generateChallengeKey()
|
challengeKey, err := generateChallengeKey()
|
||||||
@ -177,7 +156,7 @@ func (d *Dialer) Dial(urlStr string, requestHeader http.Header) (*Conn, *http.Re
|
|||||||
return nil, nil, err
|
return nil, nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
u, err := parseURL(urlStr)
|
u, err := url.Parse(urlStr)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, nil, err
|
return nil, nil, err
|
||||||
}
|
}
|
||||||
@ -205,6 +184,7 @@ func (d *Dialer) Dial(urlStr string, requestHeader http.Header) (*Conn, *http.Re
|
|||||||
Header: make(http.Header),
|
Header: make(http.Header),
|
||||||
Host: u.Host,
|
Host: u.Host,
|
||||||
}
|
}
|
||||||
|
req = req.WithContext(ctx)
|
||||||
|
|
||||||
// Set the cookies present in the cookie jar of the dialer
|
// Set the cookies present in the cookie jar of the dialer
|
||||||
if d.Jar != nil {
|
if d.Jar != nil {
|
||||||
@ -237,45 +217,83 @@ func (d *Dialer) Dial(urlStr string, requestHeader http.Header) (*Conn, *http.Re
|
|||||||
k == "Sec-Websocket-Extensions" ||
|
k == "Sec-Websocket-Extensions" ||
|
||||||
(k == "Sec-Websocket-Protocol" && len(d.Subprotocols) > 0):
|
(k == "Sec-Websocket-Protocol" && len(d.Subprotocols) > 0):
|
||||||
return nil, nil, errors.New("websocket: duplicate header not allowed: " + k)
|
return nil, nil, errors.New("websocket: duplicate header not allowed: " + k)
|
||||||
|
case k == "Sec-Websocket-Protocol":
|
||||||
|
req.Header["Sec-WebSocket-Protocol"] = vs
|
||||||
default:
|
default:
|
||||||
req.Header[k] = vs
|
req.Header[k] = vs
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if d.EnableCompression {
|
if d.EnableCompression {
|
||||||
req.Header.Set("Sec-Websocket-Extensions", "permessage-deflate; server_no_context_takeover; client_no_context_takeover")
|
req.Header["Sec-WebSocket-Extensions"] = []string{"permessage-deflate; server_no_context_takeover; client_no_context_takeover"}
|
||||||
|
}
|
||||||
|
|
||||||
|
if d.HandshakeTimeout != 0 {
|
||||||
|
var cancel func()
|
||||||
|
ctx, cancel = context.WithTimeout(ctx, d.HandshakeTimeout)
|
||||||
|
defer cancel()
|
||||||
|
}
|
||||||
|
|
||||||
|
// Get network dial function.
|
||||||
|
var netDial func(network, add string) (net.Conn, error)
|
||||||
|
|
||||||
|
if d.NetDialContext != nil {
|
||||||
|
netDial = func(network, addr string) (net.Conn, error) {
|
||||||
|
return d.NetDialContext(ctx, network, addr)
|
||||||
|
}
|
||||||
|
} else if d.NetDial != nil {
|
||||||
|
netDial = d.NetDial
|
||||||
|
} else {
|
||||||
|
netDialer := &net.Dialer{}
|
||||||
|
netDial = func(network, addr string) (net.Conn, error) {
|
||||||
|
return netDialer.DialContext(ctx, network, addr)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// If needed, wrap the dial function to set the connection deadline.
|
||||||
|
if deadline, ok := ctx.Deadline(); ok {
|
||||||
|
forwardDial := netDial
|
||||||
|
netDial = func(network, addr string) (net.Conn, error) {
|
||||||
|
c, err := forwardDial(network, addr)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
err = c.SetDeadline(deadline)
|
||||||
|
if err != nil {
|
||||||
|
c.Close()
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return c, nil
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// If needed, wrap the dial function to connect through a proxy.
|
||||||
|
if d.Proxy != nil {
|
||||||
|
proxyURL, err := d.Proxy(req)
|
||||||
|
if err != nil {
|
||||||
|
return nil, nil, err
|
||||||
|
}
|
||||||
|
if proxyURL != nil {
|
||||||
|
dialer, err := proxy_FromURL(proxyURL, netDialerFunc(netDial))
|
||||||
|
if err != nil {
|
||||||
|
return nil, nil, err
|
||||||
|
}
|
||||||
|
netDial = dialer.Dial
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
hostPort, hostNoPort := hostPortNoPort(u)
|
hostPort, hostNoPort := hostPortNoPort(u)
|
||||||
|
trace := httptrace.ContextClientTrace(ctx)
|
||||||
var proxyURL *url.URL
|
if trace != nil && trace.GetConn != nil {
|
||||||
// Check wether the proxy method has been configured
|
trace.GetConn(hostPort)
|
||||||
if d.Proxy != nil {
|
|
||||||
proxyURL, err = d.Proxy(req)
|
|
||||||
}
|
|
||||||
if err != nil {
|
|
||||||
return nil, nil, err
|
|
||||||
}
|
}
|
||||||
|
|
||||||
var targetHostPort string
|
netConn, err := netDial("tcp", hostPort)
|
||||||
if proxyURL != nil {
|
if trace != nil && trace.GotConn != nil {
|
||||||
targetHostPort, _ = hostPortNoPort(proxyURL)
|
trace.GotConn(httptrace.GotConnInfo{
|
||||||
} else {
|
Conn: netConn,
|
||||||
targetHostPort = hostPort
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
var deadline time.Time
|
|
||||||
if d.HandshakeTimeout != 0 {
|
|
||||||
deadline = time.Now().Add(d.HandshakeTimeout)
|
|
||||||
}
|
|
||||||
|
|
||||||
netDial := d.NetDial
|
|
||||||
if netDial == nil {
|
|
||||||
netDialer := &net.Dialer{Deadline: deadline}
|
|
||||||
netDial = netDialer.Dial
|
|
||||||
}
|
|
||||||
|
|
||||||
netConn, err := netDial("tcp", targetHostPort)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, nil, err
|
return nil, nil, err
|
||||||
}
|
}
|
||||||
@ -286,42 +304,6 @@ func (d *Dialer) Dial(urlStr string, requestHeader http.Header) (*Conn, *http.Re
|
|||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
|
|
||||||
if err := netConn.SetDeadline(deadline); err != nil {
|
|
||||||
return nil, nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
if proxyURL != nil {
|
|
||||||
connectHeader := make(http.Header)
|
|
||||||
if user := proxyURL.User; user != nil {
|
|
||||||
proxyUser := user.Username()
|
|
||||||
if proxyPassword, passwordSet := user.Password(); passwordSet {
|
|
||||||
credential := base64.StdEncoding.EncodeToString([]byte(proxyUser + ":" + proxyPassword))
|
|
||||||
connectHeader.Set("Proxy-Authorization", "Basic "+credential)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
connectReq := &http.Request{
|
|
||||||
Method: "CONNECT",
|
|
||||||
URL: &url.URL{Opaque: hostPort},
|
|
||||||
Host: hostPort,
|
|
||||||
Header: connectHeader,
|
|
||||||
}
|
|
||||||
|
|
||||||
connectReq.Write(netConn)
|
|
||||||
|
|
||||||
// Read response.
|
|
||||||
// Okay to use and discard buffered reader here, because
|
|
||||||
// TLS server will not speak until spoken to.
|
|
||||||
br := bufio.NewReader(netConn)
|
|
||||||
resp, err := http.ReadResponse(br, connectReq)
|
|
||||||
if err != nil {
|
|
||||||
return nil, nil, err
|
|
||||||
}
|
|
||||||
if resp.StatusCode != 200 {
|
|
||||||
f := strings.SplitN(resp.Status, " ", 2)
|
|
||||||
return nil, nil, errors.New(f[1])
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if u.Scheme == "https" {
|
if u.Scheme == "https" {
|
||||||
cfg := cloneTLSConfig(d.TLSClientConfig)
|
cfg := cloneTLSConfig(d.TLSClientConfig)
|
||||||
if cfg.ServerName == "" {
|
if cfg.ServerName == "" {
|
||||||
@ -329,22 +311,31 @@ func (d *Dialer) Dial(urlStr string, requestHeader http.Header) (*Conn, *http.Re
|
|||||||
}
|
}
|
||||||
tlsConn := tls.Client(netConn, cfg)
|
tlsConn := tls.Client(netConn, cfg)
|
||||||
netConn = tlsConn
|
netConn = tlsConn
|
||||||
if err := tlsConn.Handshake(); err != nil {
|
|
||||||
return nil, nil, err
|
var err error
|
||||||
|
if trace != nil {
|
||||||
|
err = doHandshakeWithTrace(trace, tlsConn, cfg)
|
||||||
|
} else {
|
||||||
|
err = doHandshake(tlsConn, cfg)
|
||||||
}
|
}
|
||||||
if !cfg.InsecureSkipVerify {
|
|
||||||
if err := tlsConn.VerifyHostname(cfg.ServerName); err != nil {
|
if err != nil {
|
||||||
return nil, nil, err
|
return nil, nil, err
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
conn := newConn(netConn, false, d.ReadBufferSize, d.WriteBufferSize)
|
conn := newConn(netConn, false, d.ReadBufferSize, d.WriteBufferSize, d.WriteBufferPool, nil, nil)
|
||||||
|
|
||||||
if err := req.Write(netConn); err != nil {
|
if err := req.Write(netConn); err != nil {
|
||||||
return nil, nil, err
|
return nil, nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if trace != nil && trace.GotFirstResponseByte != nil {
|
||||||
|
if peek, err := conn.br.Peek(1); err == nil && len(peek) == 1 {
|
||||||
|
trace.GotFirstResponseByte()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
resp, err := http.ReadResponse(conn.br, req)
|
resp, err := http.ReadResponse(conn.br, req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, nil, err
|
return nil, nil, err
|
||||||
@ -390,3 +381,15 @@ func (d *Dialer) Dial(urlStr string, requestHeader http.Header) (*Conn, *http.Re
|
|||||||
netConn = nil // to avoid close in defer.
|
netConn = nil // to avoid close in defer.
|
||||||
return conn, resp, nil
|
return conn, resp, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func doHandshake(tlsConn *tls.Conn, cfg *tls.Config) error {
|
||||||
|
if err := tlsConn.Handshake(); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
if !cfg.InsecureSkipVerify {
|
||||||
|
if err := tlsConn.VerifyHostname(cfg.ServerName); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
174
vendor/github.com/gorilla/websocket/conn.go
generated
vendored
174
vendor/github.com/gorilla/websocket/conn.go
generated
vendored
@ -76,7 +76,7 @@ const (
|
|||||||
// is UTF-8 encoded text.
|
// is UTF-8 encoded text.
|
||||||
PingMessage = 9
|
PingMessage = 9
|
||||||
|
|
||||||
// PongMessage denotes a ping control message. The optional message payload
|
// PongMessage denotes a pong control message. The optional message payload
|
||||||
// is UTF-8 encoded text.
|
// is UTF-8 encoded text.
|
||||||
PongMessage = 10
|
PongMessage = 10
|
||||||
)
|
)
|
||||||
@ -100,9 +100,8 @@ func (e *netError) Error() string { return e.msg }
|
|||||||
func (e *netError) Temporary() bool { return e.temporary }
|
func (e *netError) Temporary() bool { return e.temporary }
|
||||||
func (e *netError) Timeout() bool { return e.timeout }
|
func (e *netError) Timeout() bool { return e.timeout }
|
||||||
|
|
||||||
// CloseError represents close frame.
|
// CloseError represents a close message.
|
||||||
type CloseError struct {
|
type CloseError struct {
|
||||||
|
|
||||||
// Code is defined in RFC 6455, section 11.7.
|
// Code is defined in RFC 6455, section 11.7.
|
||||||
Code int
|
Code int
|
||||||
|
|
||||||
@ -224,6 +223,20 @@ func isValidReceivedCloseCode(code int) bool {
|
|||||||
return validReceivedCloseCodes[code] || (code >= 3000 && code <= 4999)
|
return validReceivedCloseCodes[code] || (code >= 3000 && code <= 4999)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// BufferPool represents a pool of buffers. The *sync.Pool type satisfies this
|
||||||
|
// interface. The type of the value stored in a pool is not specified.
|
||||||
|
type BufferPool interface {
|
||||||
|
// Get gets a value from the pool or returns nil if the pool is empty.
|
||||||
|
Get() interface{}
|
||||||
|
// Put adds a value to the pool.
|
||||||
|
Put(interface{})
|
||||||
|
}
|
||||||
|
|
||||||
|
// writePoolData is the type added to the write buffer pool. This wrapper is
|
||||||
|
// used to prevent applications from peeking at and depending on the values
|
||||||
|
// added to the pool.
|
||||||
|
type writePoolData struct{ buf []byte }
|
||||||
|
|
||||||
// The Conn type represents a WebSocket connection.
|
// The Conn type represents a WebSocket connection.
|
||||||
type Conn struct {
|
type Conn struct {
|
||||||
conn net.Conn
|
conn net.Conn
|
||||||
@ -233,6 +246,8 @@ type Conn struct {
|
|||||||
// Write fields
|
// Write fields
|
||||||
mu chan bool // used as mutex to protect write to conn
|
mu chan bool // used as mutex to protect write to conn
|
||||||
writeBuf []byte // frame is constructed in this buffer.
|
writeBuf []byte // frame is constructed in this buffer.
|
||||||
|
writePool BufferPool
|
||||||
|
writeBufSize int
|
||||||
writeDeadline time.Time
|
writeDeadline time.Time
|
||||||
writer io.WriteCloser // the current writer returned to the application
|
writer io.WriteCloser // the current writer returned to the application
|
||||||
isWriting bool // for best-effort concurrent write detection
|
isWriting bool // for best-effort concurrent write detection
|
||||||
@ -264,64 +279,29 @@ type Conn struct {
|
|||||||
newDecompressionReader func(io.Reader) io.ReadCloser
|
newDecompressionReader func(io.Reader) io.ReadCloser
|
||||||
}
|
}
|
||||||
|
|
||||||
func newConn(conn net.Conn, isServer bool, readBufferSize, writeBufferSize int) *Conn {
|
func newConn(conn net.Conn, isServer bool, readBufferSize, writeBufferSize int, writeBufferPool BufferPool, br *bufio.Reader, writeBuf []byte) *Conn {
|
||||||
return newConnBRW(conn, isServer, readBufferSize, writeBufferSize, nil)
|
|
||||||
}
|
|
||||||
|
|
||||||
type writeHook struct {
|
|
||||||
p []byte
|
|
||||||
}
|
|
||||||
|
|
||||||
func (wh *writeHook) Write(p []byte) (int, error) {
|
|
||||||
wh.p = p
|
|
||||||
return len(p), nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func newConnBRW(conn net.Conn, isServer bool, readBufferSize, writeBufferSize int, brw *bufio.ReadWriter) *Conn {
|
|
||||||
mu := make(chan bool, 1)
|
|
||||||
mu <- true
|
|
||||||
|
|
||||||
var br *bufio.Reader
|
|
||||||
if readBufferSize == 0 && brw != nil && brw.Reader != nil {
|
|
||||||
// Reuse the supplied bufio.Reader if the buffer has a useful size.
|
|
||||||
// This code assumes that peek on a reader returns
|
|
||||||
// bufio.Reader.buf[:0].
|
|
||||||
brw.Reader.Reset(conn)
|
|
||||||
if p, err := brw.Reader.Peek(0); err == nil && cap(p) >= 256 {
|
|
||||||
br = brw.Reader
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if br == nil {
|
if br == nil {
|
||||||
if readBufferSize == 0 {
|
if readBufferSize == 0 {
|
||||||
readBufferSize = defaultReadBufferSize
|
readBufferSize = defaultReadBufferSize
|
||||||
}
|
} else if readBufferSize < maxControlFramePayloadSize {
|
||||||
if readBufferSize < maxControlFramePayloadSize {
|
// must be large enough for control frame
|
||||||
readBufferSize = maxControlFramePayloadSize
|
readBufferSize = maxControlFramePayloadSize
|
||||||
}
|
}
|
||||||
br = bufio.NewReaderSize(conn, readBufferSize)
|
br = bufio.NewReaderSize(conn, readBufferSize)
|
||||||
}
|
}
|
||||||
|
|
||||||
var writeBuf []byte
|
if writeBufferSize <= 0 {
|
||||||
if writeBufferSize == 0 && brw != nil && brw.Writer != nil {
|
writeBufferSize = defaultWriteBufferSize
|
||||||
// Use the bufio.Writer's buffer if the buffer has a useful size. This
|
}
|
||||||
// code assumes that bufio.Writer.buf[:1] is passed to the
|
writeBufferSize += maxFrameHeaderSize
|
||||||
// bufio.Writer's underlying writer.
|
|
||||||
var wh writeHook
|
if writeBuf == nil && writeBufferPool == nil {
|
||||||
brw.Writer.Reset(&wh)
|
writeBuf = make([]byte, writeBufferSize)
|
||||||
brw.Writer.WriteByte(0)
|
|
||||||
brw.Flush()
|
|
||||||
if cap(wh.p) >= maxFrameHeaderSize+256 {
|
|
||||||
writeBuf = wh.p[:cap(wh.p)]
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if writeBuf == nil {
|
|
||||||
if writeBufferSize == 0 {
|
|
||||||
writeBufferSize = defaultWriteBufferSize
|
|
||||||
}
|
|
||||||
writeBuf = make([]byte, writeBufferSize+maxFrameHeaderSize)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
mu := make(chan bool, 1)
|
||||||
|
mu <- true
|
||||||
c := &Conn{
|
c := &Conn{
|
||||||
isServer: isServer,
|
isServer: isServer,
|
||||||
br: br,
|
br: br,
|
||||||
@ -329,6 +309,8 @@ func newConnBRW(conn net.Conn, isServer bool, readBufferSize, writeBufferSize in
|
|||||||
mu: mu,
|
mu: mu,
|
||||||
readFinal: true,
|
readFinal: true,
|
||||||
writeBuf: writeBuf,
|
writeBuf: writeBuf,
|
||||||
|
writePool: writeBufferPool,
|
||||||
|
writeBufSize: writeBufferSize,
|
||||||
enableWriteCompression: true,
|
enableWriteCompression: true,
|
||||||
compressionLevel: defaultCompressionLevel,
|
compressionLevel: defaultCompressionLevel,
|
||||||
}
|
}
|
||||||
@ -343,7 +325,8 @@ func (c *Conn) Subprotocol() string {
|
|||||||
return c.subprotocol
|
return c.subprotocol
|
||||||
}
|
}
|
||||||
|
|
||||||
// Close closes the underlying network connection without sending or waiting for a close frame.
|
// Close closes the underlying network connection without sending or waiting
|
||||||
|
// for a close message.
|
||||||
func (c *Conn) Close() error {
|
func (c *Conn) Close() error {
|
||||||
return c.conn.Close()
|
return c.conn.Close()
|
||||||
}
|
}
|
||||||
@ -370,7 +353,16 @@ func (c *Conn) writeFatal(err error) error {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *Conn) write(frameType int, deadline time.Time, bufs ...[]byte) error {
|
func (c *Conn) read(n int) ([]byte, error) {
|
||||||
|
p, err := c.br.Peek(n)
|
||||||
|
if err == io.EOF {
|
||||||
|
err = errUnexpectedEOF
|
||||||
|
}
|
||||||
|
c.br.Discard(len(p))
|
||||||
|
return p, err
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *Conn) write(frameType int, deadline time.Time, buf0, buf1 []byte) error {
|
||||||
<-c.mu
|
<-c.mu
|
||||||
defer func() { c.mu <- true }()
|
defer func() { c.mu <- true }()
|
||||||
|
|
||||||
@ -382,15 +374,14 @@ func (c *Conn) write(frameType int, deadline time.Time, bufs ...[]byte) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
c.conn.SetWriteDeadline(deadline)
|
c.conn.SetWriteDeadline(deadline)
|
||||||
for _, buf := range bufs {
|
if len(buf1) == 0 {
|
||||||
if len(buf) > 0 {
|
_, err = c.conn.Write(buf0)
|
||||||
_, err := c.conn.Write(buf)
|
} else {
|
||||||
if err != nil {
|
err = c.writeBufs(buf0, buf1)
|
||||||
return c.writeFatal(err)
|
}
|
||||||
}
|
if err != nil {
|
||||||
}
|
return c.writeFatal(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
if frameType == CloseMessage {
|
if frameType == CloseMessage {
|
||||||
c.writeFatal(ErrCloseSent)
|
c.writeFatal(ErrCloseSent)
|
||||||
}
|
}
|
||||||
@ -476,7 +467,19 @@ func (c *Conn) prepWrite(messageType int) error {
|
|||||||
c.writeErrMu.Lock()
|
c.writeErrMu.Lock()
|
||||||
err := c.writeErr
|
err := c.writeErr
|
||||||
c.writeErrMu.Unlock()
|
c.writeErrMu.Unlock()
|
||||||
return err
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
if c.writeBuf == nil {
|
||||||
|
wpd, ok := c.writePool.Get().(writePoolData)
|
||||||
|
if ok {
|
||||||
|
c.writeBuf = wpd.buf
|
||||||
|
} else {
|
||||||
|
c.writeBuf = make([]byte, c.writeBufSize)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// NextWriter returns a writer for the next message to send. The writer's Close
|
// NextWriter returns a writer for the next message to send. The writer's Close
|
||||||
@ -484,6 +487,9 @@ func (c *Conn) prepWrite(messageType int) error {
|
|||||||
//
|
//
|
||||||
// There can be at most one open writer on a connection. NextWriter closes the
|
// There can be at most one open writer on a connection. NextWriter closes the
|
||||||
// previous writer if the application has not already done so.
|
// previous writer if the application has not already done so.
|
||||||
|
//
|
||||||
|
// All message types (TextMessage, BinaryMessage, CloseMessage, PingMessage and
|
||||||
|
// PongMessage) are supported.
|
||||||
func (c *Conn) NextWriter(messageType int) (io.WriteCloser, error) {
|
func (c *Conn) NextWriter(messageType int) (io.WriteCloser, error) {
|
||||||
if err := c.prepWrite(messageType); err != nil {
|
if err := c.prepWrite(messageType); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
@ -599,6 +605,10 @@ func (w *messageWriter) flushFrame(final bool, extra []byte) error {
|
|||||||
|
|
||||||
if final {
|
if final {
|
||||||
c.writer = nil
|
c.writer = nil
|
||||||
|
if c.writePool != nil {
|
||||||
|
c.writePool.Put(writePoolData{buf: c.writeBuf})
|
||||||
|
c.writeBuf = nil
|
||||||
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -764,7 +774,6 @@ func (c *Conn) SetWriteDeadline(t time.Time) error {
|
|||||||
// Read methods
|
// Read methods
|
||||||
|
|
||||||
func (c *Conn) advanceFrame() (int, error) {
|
func (c *Conn) advanceFrame() (int, error) {
|
||||||
|
|
||||||
// 1. Skip remainder of previous frame.
|
// 1. Skip remainder of previous frame.
|
||||||
|
|
||||||
if c.readRemaining > 0 {
|
if c.readRemaining > 0 {
|
||||||
@ -1033,7 +1042,7 @@ func (c *Conn) SetReadDeadline(t time.Time) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// SetReadLimit sets the maximum size for a message read from the peer. If a
|
// SetReadLimit sets the maximum size for a message read from the peer. If a
|
||||||
// message exceeds the limit, the connection sends a close frame to the peer
|
// message exceeds the limit, the connection sends a close message to the peer
|
||||||
// and returns ErrReadLimit to the application.
|
// and returns ErrReadLimit to the application.
|
||||||
func (c *Conn) SetReadLimit(limit int64) {
|
func (c *Conn) SetReadLimit(limit int64) {
|
||||||
c.readLimit = limit
|
c.readLimit = limit
|
||||||
@ -1046,24 +1055,22 @@ func (c *Conn) CloseHandler() func(code int, text string) error {
|
|||||||
|
|
||||||
// SetCloseHandler sets the handler for close messages received from the peer.
|
// SetCloseHandler sets the handler for close messages received from the peer.
|
||||||
// The code argument to h is the received close code or CloseNoStatusReceived
|
// The code argument to h is the received close code or CloseNoStatusReceived
|
||||||
// if the close message is empty. The default close handler sends a close frame
|
// if the close message is empty. The default close handler sends a close
|
||||||
// back to the peer.
|
// message back to the peer.
|
||||||
//
|
//
|
||||||
// The application must read the connection to process close messages as
|
// The handler function is called from the NextReader, ReadMessage and message
|
||||||
// described in the section on Control Frames above.
|
// reader Read methods. The application must read the connection to process
|
||||||
|
// close messages as described in the section on Control Messages above.
|
||||||
//
|
//
|
||||||
// The connection read methods return a CloseError when a close frame is
|
// The connection read methods return a CloseError when a close message is
|
||||||
// received. Most applications should handle close messages as part of their
|
// received. Most applications should handle close messages as part of their
|
||||||
// normal error handling. Applications should only set a close handler when the
|
// normal error handling. Applications should only set a close handler when the
|
||||||
// application must perform some action before sending a close frame back to
|
// application must perform some action before sending a close message back to
|
||||||
// the peer.
|
// the peer.
|
||||||
func (c *Conn) SetCloseHandler(h func(code int, text string) error) {
|
func (c *Conn) SetCloseHandler(h func(code int, text string) error) {
|
||||||
if h == nil {
|
if h == nil {
|
||||||
h = func(code int, text string) error {
|
h = func(code int, text string) error {
|
||||||
message := []byte{}
|
message := FormatCloseMessage(code, "")
|
||||||
if code != CloseNoStatusReceived {
|
|
||||||
message = FormatCloseMessage(code, "")
|
|
||||||
}
|
|
||||||
c.WriteControl(CloseMessage, message, time.Now().Add(writeWait))
|
c.WriteControl(CloseMessage, message, time.Now().Add(writeWait))
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
@ -1077,11 +1084,12 @@ func (c *Conn) PingHandler() func(appData string) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// SetPingHandler sets the handler for ping messages received from the peer.
|
// SetPingHandler sets the handler for ping messages received from the peer.
|
||||||
// The appData argument to h is the PING frame application data. The default
|
// The appData argument to h is the PING message application data. The default
|
||||||
// ping handler sends a pong to the peer.
|
// ping handler sends a pong to the peer.
|
||||||
//
|
//
|
||||||
// The application must read the connection to process ping messages as
|
// The handler function is called from the NextReader, ReadMessage and message
|
||||||
// described in the section on Control Frames above.
|
// reader Read methods. The application must read the connection to process
|
||||||
|
// ping messages as described in the section on Control Messages above.
|
||||||
func (c *Conn) SetPingHandler(h func(appData string) error) {
|
func (c *Conn) SetPingHandler(h func(appData string) error) {
|
||||||
if h == nil {
|
if h == nil {
|
||||||
h = func(message string) error {
|
h = func(message string) error {
|
||||||
@ -1103,11 +1111,12 @@ func (c *Conn) PongHandler() func(appData string) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// SetPongHandler sets the handler for pong messages received from the peer.
|
// SetPongHandler sets the handler for pong messages received from the peer.
|
||||||
// The appData argument to h is the PONG frame application data. The default
|
// The appData argument to h is the PONG message application data. The default
|
||||||
// pong handler does nothing.
|
// pong handler does nothing.
|
||||||
//
|
//
|
||||||
// The application must read the connection to process ping messages as
|
// The handler function is called from the NextReader, ReadMessage and message
|
||||||
// described in the section on Control Frames above.
|
// reader Read methods. The application must read the connection to process
|
||||||
|
// pong messages as described in the section on Control Messages above.
|
||||||
func (c *Conn) SetPongHandler(h func(appData string) error) {
|
func (c *Conn) SetPongHandler(h func(appData string) error) {
|
||||||
if h == nil {
|
if h == nil {
|
||||||
h = func(string) error { return nil }
|
h = func(string) error { return nil }
|
||||||
@ -1141,7 +1150,14 @@ func (c *Conn) SetCompressionLevel(level int) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// FormatCloseMessage formats closeCode and text as a WebSocket close message.
|
// FormatCloseMessage formats closeCode and text as a WebSocket close message.
|
||||||
|
// An empty message is returned for code CloseNoStatusReceived.
|
||||||
func FormatCloseMessage(closeCode int, text string) []byte {
|
func FormatCloseMessage(closeCode int, text string) []byte {
|
||||||
|
if closeCode == CloseNoStatusReceived {
|
||||||
|
// Return empty message because it's illegal to send
|
||||||
|
// CloseNoStatusReceived. Return non-nil value in case application
|
||||||
|
// checks for nil.
|
||||||
|
return []byte{}
|
||||||
|
}
|
||||||
buf := make([]byte, 2+len(text))
|
buf := make([]byte, 2+len(text))
|
||||||
binary.BigEndian.PutUint16(buf, uint16(closeCode))
|
binary.BigEndian.PutUint16(buf, uint16(closeCode))
|
||||||
copy(buf[2:], text)
|
copy(buf[2:], text)
|
||||||
|
21
vendor/github.com/gorilla/websocket/conn_read_legacy.go
generated
vendored
21
vendor/github.com/gorilla/websocket/conn_read_legacy.go
generated
vendored
@ -1,21 +0,0 @@
|
|||||||
// Copyright 2016 The Gorilla WebSocket 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.5
|
|
||||||
|
|
||||||
package websocket
|
|
||||||
|
|
||||||
import "io"
|
|
||||||
|
|
||||||
func (c *Conn) read(n int) ([]byte, error) {
|
|
||||||
p, err := c.br.Peek(n)
|
|
||||||
if err == io.EOF {
|
|
||||||
err = errUnexpectedEOF
|
|
||||||
}
|
|
||||||
if len(p) > 0 {
|
|
||||||
// advance over the bytes just read
|
|
||||||
io.ReadFull(c.br, p)
|
|
||||||
}
|
|
||||||
return p, err
|
|
||||||
}
|
|
@ -2,17 +2,14 @@
|
|||||||
// 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 go1.5
|
// +build go1.8
|
||||||
|
|
||||||
package websocket
|
package websocket
|
||||||
|
|
||||||
import "io"
|
import "net"
|
||||||
|
|
||||||
func (c *Conn) read(n int) ([]byte, error) {
|
func (c *Conn) writeBufs(bufs ...[]byte) error {
|
||||||
p, err := c.br.Peek(n)
|
b := net.Buffers(bufs)
|
||||||
if err == io.EOF {
|
_, err := b.WriteTo(c.conn)
|
||||||
err = errUnexpectedEOF
|
return err
|
||||||
}
|
|
||||||
c.br.Discard(len(p))
|
|
||||||
return p, err
|
|
||||||
}
|
}
|
18
vendor/github.com/gorilla/websocket/conn_write_legacy.go
generated
vendored
Normal file
18
vendor/github.com/gorilla/websocket/conn_write_legacy.go
generated
vendored
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
// Copyright 2016 The Gorilla WebSocket 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.8
|
||||||
|
|
||||||
|
package websocket
|
||||||
|
|
||||||
|
func (c *Conn) writeBufs(bufs ...[]byte) error {
|
||||||
|
for _, buf := range bufs {
|
||||||
|
if len(buf) > 0 {
|
||||||
|
if _, err := c.conn.Write(buf); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
56
vendor/github.com/gorilla/websocket/doc.go
generated
vendored
56
vendor/github.com/gorilla/websocket/doc.go
generated
vendored
@ -6,9 +6,8 @@
|
|||||||
//
|
//
|
||||||
// Overview
|
// Overview
|
||||||
//
|
//
|
||||||
// The Conn type represents a WebSocket connection. A server application uses
|
// The Conn type represents a WebSocket connection. A server application calls
|
||||||
// the Upgrade function from an Upgrader object with a HTTP request handler
|
// the Upgrader.Upgrade method from an HTTP request handler to get a *Conn:
|
||||||
// to get a pointer to a Conn:
|
|
||||||
//
|
//
|
||||||
// var upgrader = websocket.Upgrader{
|
// var upgrader = websocket.Upgrader{
|
||||||
// ReadBufferSize: 1024,
|
// ReadBufferSize: 1024,
|
||||||
@ -31,10 +30,12 @@
|
|||||||
// for {
|
// for {
|
||||||
// messageType, p, err := conn.ReadMessage()
|
// messageType, p, err := conn.ReadMessage()
|
||||||
// if err != nil {
|
// if err != nil {
|
||||||
|
// log.Println(err)
|
||||||
// return
|
// return
|
||||||
// }
|
// }
|
||||||
// if err = conn.WriteMessage(messageType, p); err != nil {
|
// if err := conn.WriteMessage(messageType, p); err != nil {
|
||||||
// return err
|
// log.Println(err)
|
||||||
|
// return
|
||||||
// }
|
// }
|
||||||
// }
|
// }
|
||||||
//
|
//
|
||||||
@ -85,20 +86,26 @@
|
|||||||
// and pong. Call the connection WriteControl, WriteMessage or NextWriter
|
// and pong. Call the connection WriteControl, WriteMessage or NextWriter
|
||||||
// methods to send a control message to the peer.
|
// methods to send a control message to the peer.
|
||||||
//
|
//
|
||||||
// Connections handle received close messages by sending a close message to the
|
// Connections handle received close messages by calling the handler function
|
||||||
// peer and returning a *CloseError from the the NextReader, ReadMessage or the
|
// set with the SetCloseHandler method and by returning a *CloseError from the
|
||||||
// message Read method.
|
// NextReader, ReadMessage or the message Read method. The default close
|
||||||
|
// handler sends a close message to the peer.
|
||||||
//
|
//
|
||||||
// Connections handle received ping and pong messages by invoking callback
|
// Connections handle received ping messages by calling the handler function
|
||||||
// functions set with SetPingHandler and SetPongHandler methods. The callback
|
// set with the SetPingHandler method. The default ping handler sends a pong
|
||||||
// functions are called from the NextReader, ReadMessage and the message Read
|
// message to the peer.
|
||||||
// methods.
|
|
||||||
//
|
//
|
||||||
// The default ping handler sends a pong to the peer. The application's reading
|
// Connections handle received pong messages by calling the handler function
|
||||||
// goroutine can block for a short time while the handler writes the pong data
|
// set with the SetPongHandler method. The default pong handler does nothing.
|
||||||
// to the connection.
|
// If an application sends ping messages, then the application should set a
|
||||||
|
// pong handler to receive the corresponding pong.
|
||||||
//
|
//
|
||||||
// The application must read the connection to process ping, pong and close
|
// The control message handler functions are called from the NextReader,
|
||||||
|
// ReadMessage and message reader Read methods. The default close and ping
|
||||||
|
// handlers can block these methods for a short time when the handler writes to
|
||||||
|
// the connection.
|
||||||
|
//
|
||||||
|
// The application must read the connection to process close, ping and pong
|
||||||
// messages sent from the peer. If the application is not otherwise interested
|
// messages sent from the peer. If the application is not otherwise interested
|
||||||
// in messages from the peer, then the application should start a goroutine to
|
// in messages from the peer, then the application should start a goroutine to
|
||||||
// read and discard messages from the peer. A simple example is:
|
// read and discard messages from the peer. A simple example is:
|
||||||
@ -137,19 +144,12 @@
|
|||||||
// method fails the WebSocket handshake with HTTP status 403.
|
// method fails the WebSocket handshake with HTTP status 403.
|
||||||
//
|
//
|
||||||
// If the CheckOrigin field is nil, then the Upgrader uses a safe default: fail
|
// If the CheckOrigin field is nil, then the Upgrader uses a safe default: fail
|
||||||
// the handshake if the Origin request header is present and not equal to the
|
// the handshake if the Origin request header is present and the Origin host is
|
||||||
// Host request header.
|
// not equal to the Host request header.
|
||||||
//
|
//
|
||||||
// An application can allow connections from any origin by specifying a
|
// The deprecated package-level Upgrade function does not perform origin
|
||||||
// function that always returns true:
|
// checking. The application is responsible for checking the Origin header
|
||||||
//
|
// before calling the Upgrade function.
|
||||||
// var upgrader = websocket.Upgrader{
|
|
||||||
// CheckOrigin: func(r *http.Request) bool { return true },
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// The deprecated Upgrade function does not enforce an origin policy. It's the
|
|
||||||
// application's responsibility to check the Origin header before calling
|
|
||||||
// Upgrade.
|
|
||||||
//
|
//
|
||||||
// Compression EXPERIMENTAL
|
// Compression EXPERIMENTAL
|
||||||
//
|
//
|
||||||
|
11
vendor/github.com/gorilla/websocket/json.go
generated
vendored
11
vendor/github.com/gorilla/websocket/json.go
generated
vendored
@ -9,12 +9,14 @@ import (
|
|||||||
"io"
|
"io"
|
||||||
)
|
)
|
||||||
|
|
||||||
// WriteJSON is deprecated, use c.WriteJSON instead.
|
// WriteJSON writes the JSON encoding of v as a message.
|
||||||
|
//
|
||||||
|
// Deprecated: Use c.WriteJSON instead.
|
||||||
func WriteJSON(c *Conn, v interface{}) error {
|
func WriteJSON(c *Conn, v interface{}) error {
|
||||||
return c.WriteJSON(v)
|
return c.WriteJSON(v)
|
||||||
}
|
}
|
||||||
|
|
||||||
// WriteJSON writes the JSON encoding of v to the connection.
|
// WriteJSON writes the JSON encoding of v as a message.
|
||||||
//
|
//
|
||||||
// See the documentation for encoding/json Marshal for details about the
|
// See the documentation for encoding/json Marshal for details about the
|
||||||
// conversion of Go values to JSON.
|
// conversion of Go values to JSON.
|
||||||
@ -31,7 +33,10 @@ func (c *Conn) WriteJSON(v interface{}) error {
|
|||||||
return err2
|
return err2
|
||||||
}
|
}
|
||||||
|
|
||||||
// ReadJSON is deprecated, use c.ReadJSON instead.
|
// ReadJSON reads the next JSON-encoded message from the connection and stores
|
||||||
|
// it in the value pointed to by v.
|
||||||
|
//
|
||||||
|
// Deprecated: Use c.ReadJSON instead.
|
||||||
func ReadJSON(c *Conn, v interface{}) error {
|
func ReadJSON(c *Conn, v interface{}) error {
|
||||||
return c.ReadJSON(v)
|
return c.ReadJSON(v)
|
||||||
}
|
}
|
||||||
|
1
vendor/github.com/gorilla/websocket/mask.go
generated
vendored
1
vendor/github.com/gorilla/websocket/mask.go
generated
vendored
@ -11,7 +11,6 @@ import "unsafe"
|
|||||||
const wordSize = int(unsafe.Sizeof(uintptr(0)))
|
const wordSize = int(unsafe.Sizeof(uintptr(0)))
|
||||||
|
|
||||||
func maskBytes(key [4]byte, pos int, b []byte) int {
|
func maskBytes(key [4]byte, pos int, b []byte) int {
|
||||||
|
|
||||||
// Mask one byte at a time for small buffers.
|
// Mask one byte at a time for small buffers.
|
||||||
if len(b) < 2*wordSize {
|
if len(b) < 2*wordSize {
|
||||||
for i := range b {
|
for i := range b {
|
||||||
|
1
vendor/github.com/gorilla/websocket/prepared.go
generated
vendored
1
vendor/github.com/gorilla/websocket/prepared.go
generated
vendored
@ -19,7 +19,6 @@ import (
|
|||||||
type PreparedMessage struct {
|
type PreparedMessage struct {
|
||||||
messageType int
|
messageType int
|
||||||
data []byte
|
data []byte
|
||||||
err error
|
|
||||||
mu sync.Mutex
|
mu sync.Mutex
|
||||||
frames map[prepareKey]*preparedFrame
|
frames map[prepareKey]*preparedFrame
|
||||||
}
|
}
|
||||||
|
77
vendor/github.com/gorilla/websocket/proxy.go
generated
vendored
Normal file
77
vendor/github.com/gorilla/websocket/proxy.go
generated
vendored
Normal file
@ -0,0 +1,77 @@
|
|||||||
|
// Copyright 2017 The Gorilla WebSocket 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 websocket
|
||||||
|
|
||||||
|
import (
|
||||||
|
"bufio"
|
||||||
|
"encoding/base64"
|
||||||
|
"errors"
|
||||||
|
"net"
|
||||||
|
"net/http"
|
||||||
|
"net/url"
|
||||||
|
"strings"
|
||||||
|
)
|
||||||
|
|
||||||
|
type netDialerFunc func(network, addr string) (net.Conn, error)
|
||||||
|
|
||||||
|
func (fn netDialerFunc) Dial(network, addr string) (net.Conn, error) {
|
||||||
|
return fn(network, addr)
|
||||||
|
}
|
||||||
|
|
||||||
|
func init() {
|
||||||
|
proxy_RegisterDialerType("http", func(proxyURL *url.URL, forwardDialer proxy_Dialer) (proxy_Dialer, error) {
|
||||||
|
return &httpProxyDialer{proxyURL: proxyURL, fowardDial: forwardDialer.Dial}, nil
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
type httpProxyDialer struct {
|
||||||
|
proxyURL *url.URL
|
||||||
|
fowardDial func(network, addr string) (net.Conn, error)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (hpd *httpProxyDialer) Dial(network string, addr string) (net.Conn, error) {
|
||||||
|
hostPort, _ := hostPortNoPort(hpd.proxyURL)
|
||||||
|
conn, err := hpd.fowardDial(network, hostPort)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
connectHeader := make(http.Header)
|
||||||
|
if user := hpd.proxyURL.User; user != nil {
|
||||||
|
proxyUser := user.Username()
|
||||||
|
if proxyPassword, passwordSet := user.Password(); passwordSet {
|
||||||
|
credential := base64.StdEncoding.EncodeToString([]byte(proxyUser + ":" + proxyPassword))
|
||||||
|
connectHeader.Set("Proxy-Authorization", "Basic "+credential)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
connectReq := &http.Request{
|
||||||
|
Method: "CONNECT",
|
||||||
|
URL: &url.URL{Opaque: addr},
|
||||||
|
Host: addr,
|
||||||
|
Header: connectHeader,
|
||||||
|
}
|
||||||
|
|
||||||
|
if err := connectReq.Write(conn); err != nil {
|
||||||
|
conn.Close()
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
// Read response. It's OK to use and discard buffered reader here becaue
|
||||||
|
// the remote server does not speak until spoken to.
|
||||||
|
br := bufio.NewReader(conn)
|
||||||
|
resp, err := http.ReadResponse(br, connectReq)
|
||||||
|
if err != nil {
|
||||||
|
conn.Close()
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
if resp.StatusCode != 200 {
|
||||||
|
conn.Close()
|
||||||
|
f := strings.SplitN(resp.Status, " ", 2)
|
||||||
|
return nil, errors.New(f[1])
|
||||||
|
}
|
||||||
|
return conn, nil
|
||||||
|
}
|
136
vendor/github.com/gorilla/websocket/server.go
generated
vendored
136
vendor/github.com/gorilla/websocket/server.go
generated
vendored
@ -7,7 +7,7 @@ package websocket
|
|||||||
import (
|
import (
|
||||||
"bufio"
|
"bufio"
|
||||||
"errors"
|
"errors"
|
||||||
"net"
|
"io"
|
||||||
"net/http"
|
"net/http"
|
||||||
"net/url"
|
"net/url"
|
||||||
"strings"
|
"strings"
|
||||||
@ -33,10 +33,23 @@ type Upgrader struct {
|
|||||||
// or received.
|
// or received.
|
||||||
ReadBufferSize, WriteBufferSize int
|
ReadBufferSize, WriteBufferSize int
|
||||||
|
|
||||||
|
// WriteBufferPool is a pool of buffers for write operations. If the value
|
||||||
|
// is not set, then write buffers are allocated to the connection for the
|
||||||
|
// lifetime of the connection.
|
||||||
|
//
|
||||||
|
// A pool is most useful when the application has a modest volume of writes
|
||||||
|
// across a large number of connections.
|
||||||
|
//
|
||||||
|
// Applications should use a single pool for each unique value of
|
||||||
|
// WriteBufferSize.
|
||||||
|
WriteBufferPool BufferPool
|
||||||
|
|
||||||
// Subprotocols specifies the server's supported protocols in order of
|
// Subprotocols specifies the server's supported protocols in order of
|
||||||
// preference. If this field is set, then the Upgrade method negotiates a
|
// preference. If this field is not nil, then the Upgrade method negotiates a
|
||||||
// subprotocol by selecting the first match in this list with a protocol
|
// subprotocol by selecting the first match in this list with a protocol
|
||||||
// requested by the client.
|
// requested by the client. If there's no match, then no protocol is
|
||||||
|
// negotiated (the Sec-Websocket-Protocol header is not included in the
|
||||||
|
// handshake response).
|
||||||
Subprotocols []string
|
Subprotocols []string
|
||||||
|
|
||||||
// Error specifies the function for generating HTTP error responses. If Error
|
// Error specifies the function for generating HTTP error responses. If Error
|
||||||
@ -44,8 +57,12 @@ type Upgrader struct {
|
|||||||
Error func(w http.ResponseWriter, r *http.Request, status int, reason error)
|
Error func(w http.ResponseWriter, r *http.Request, status int, reason error)
|
||||||
|
|
||||||
// CheckOrigin returns true if the request Origin header is acceptable. If
|
// CheckOrigin returns true if the request Origin header is acceptable. If
|
||||||
// CheckOrigin is nil, the host in the Origin header must not be set or
|
// CheckOrigin is nil, then a safe default is used: return false if the
|
||||||
// must match the host of the request.
|
// Origin request header is present and the origin host is not equal to
|
||||||
|
// request Host header.
|
||||||
|
//
|
||||||
|
// A CheckOrigin function should carefully validate the request origin to
|
||||||
|
// prevent cross-site request forgery.
|
||||||
CheckOrigin func(r *http.Request) bool
|
CheckOrigin func(r *http.Request) bool
|
||||||
|
|
||||||
// EnableCompression specify if the server should attempt to negotiate per
|
// EnableCompression specify if the server should attempt to negotiate per
|
||||||
@ -76,7 +93,7 @@ func checkSameOrigin(r *http.Request) bool {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
return u.Host == r.Host
|
return equalASCIIFold(u.Host, r.Host)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (u *Upgrader) selectSubprotocol(r *http.Request, responseHeader http.Header) string {
|
func (u *Upgrader) selectSubprotocol(r *http.Request, responseHeader http.Header) string {
|
||||||
@ -99,42 +116,44 @@ func (u *Upgrader) selectSubprotocol(r *http.Request, responseHeader http.Header
|
|||||||
//
|
//
|
||||||
// The responseHeader is included in the response to the client's upgrade
|
// The responseHeader is included in the response to the client's upgrade
|
||||||
// request. Use the responseHeader to specify cookies (Set-Cookie) and the
|
// request. Use the responseHeader to specify cookies (Set-Cookie) and the
|
||||||
// application negotiated subprotocol (Sec-Websocket-Protocol).
|
// application negotiated subprotocol (Sec-WebSocket-Protocol).
|
||||||
//
|
//
|
||||||
// If the upgrade fails, then Upgrade replies to the client with an HTTP error
|
// If the upgrade fails, then Upgrade replies to the client with an HTTP error
|
||||||
// response.
|
// response.
|
||||||
func (u *Upgrader) Upgrade(w http.ResponseWriter, r *http.Request, responseHeader http.Header) (*Conn, error) {
|
func (u *Upgrader) Upgrade(w http.ResponseWriter, r *http.Request, responseHeader http.Header) (*Conn, error) {
|
||||||
if r.Method != "GET" {
|
const badHandshake = "websocket: the client is not using the websocket protocol: "
|
||||||
return u.returnError(w, r, http.StatusMethodNotAllowed, "websocket: not a websocket handshake: request method is not GET")
|
|
||||||
}
|
|
||||||
|
|
||||||
if _, ok := responseHeader["Sec-Websocket-Extensions"]; ok {
|
|
||||||
return u.returnError(w, r, http.StatusInternalServerError, "websocket: application specific 'Sec-Websocket-Extensions' headers are unsupported")
|
|
||||||
}
|
|
||||||
|
|
||||||
if !tokenListContainsValue(r.Header, "Connection", "upgrade") {
|
if !tokenListContainsValue(r.Header, "Connection", "upgrade") {
|
||||||
return u.returnError(w, r, http.StatusBadRequest, "websocket: not a websocket handshake: 'upgrade' token not found in 'Connection' header")
|
return u.returnError(w, r, http.StatusBadRequest, badHandshake+"'upgrade' token not found in 'Connection' header")
|
||||||
}
|
}
|
||||||
|
|
||||||
if !tokenListContainsValue(r.Header, "Upgrade", "websocket") {
|
if !tokenListContainsValue(r.Header, "Upgrade", "websocket") {
|
||||||
return u.returnError(w, r, http.StatusBadRequest, "websocket: not a websocket handshake: 'websocket' token not found in 'Upgrade' header")
|
return u.returnError(w, r, http.StatusBadRequest, badHandshake+"'websocket' token not found in 'Upgrade' header")
|
||||||
|
}
|
||||||
|
|
||||||
|
if r.Method != "GET" {
|
||||||
|
return u.returnError(w, r, http.StatusMethodNotAllowed, badHandshake+"request method is not GET")
|
||||||
}
|
}
|
||||||
|
|
||||||
if !tokenListContainsValue(r.Header, "Sec-Websocket-Version", "13") {
|
if !tokenListContainsValue(r.Header, "Sec-Websocket-Version", "13") {
|
||||||
return u.returnError(w, r, http.StatusBadRequest, "websocket: unsupported version: 13 not found in 'Sec-Websocket-Version' header")
|
return u.returnError(w, r, http.StatusBadRequest, "websocket: unsupported version: 13 not found in 'Sec-Websocket-Version' header")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if _, ok := responseHeader["Sec-Websocket-Extensions"]; ok {
|
||||||
|
return u.returnError(w, r, http.StatusInternalServerError, "websocket: application specific 'Sec-WebSocket-Extensions' headers are unsupported")
|
||||||
|
}
|
||||||
|
|
||||||
checkOrigin := u.CheckOrigin
|
checkOrigin := u.CheckOrigin
|
||||||
if checkOrigin == nil {
|
if checkOrigin == nil {
|
||||||
checkOrigin = checkSameOrigin
|
checkOrigin = checkSameOrigin
|
||||||
}
|
}
|
||||||
if !checkOrigin(r) {
|
if !checkOrigin(r) {
|
||||||
return u.returnError(w, r, http.StatusForbidden, "websocket: 'Origin' header value not allowed")
|
return u.returnError(w, r, http.StatusForbidden, "websocket: request origin not allowed by Upgrader.CheckOrigin")
|
||||||
}
|
}
|
||||||
|
|
||||||
challengeKey := r.Header.Get("Sec-Websocket-Key")
|
challengeKey := r.Header.Get("Sec-Websocket-Key")
|
||||||
if challengeKey == "" {
|
if challengeKey == "" {
|
||||||
return u.returnError(w, r, http.StatusBadRequest, "websocket: not a websocket handshake: `Sec-Websocket-Key' header is missing or blank")
|
return u.returnError(w, r, http.StatusBadRequest, "websocket: not a websocket handshake: `Sec-WebSocket-Key' header is missing or blank")
|
||||||
}
|
}
|
||||||
|
|
||||||
subprotocol := u.selectSubprotocol(r, responseHeader)
|
subprotocol := u.selectSubprotocol(r, responseHeader)
|
||||||
@ -151,17 +170,12 @@ func (u *Upgrader) Upgrade(w http.ResponseWriter, r *http.Request, responseHeade
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
var (
|
|
||||||
netConn net.Conn
|
|
||||||
err error
|
|
||||||
)
|
|
||||||
|
|
||||||
h, ok := w.(http.Hijacker)
|
h, ok := w.(http.Hijacker)
|
||||||
if !ok {
|
if !ok {
|
||||||
return u.returnError(w, r, http.StatusInternalServerError, "websocket: response does not implement http.Hijacker")
|
return u.returnError(w, r, http.StatusInternalServerError, "websocket: response does not implement http.Hijacker")
|
||||||
}
|
}
|
||||||
var brw *bufio.ReadWriter
|
var brw *bufio.ReadWriter
|
||||||
netConn, brw, err = h.Hijack()
|
netConn, brw, err := h.Hijack()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return u.returnError(w, r, http.StatusInternalServerError, err.Error())
|
return u.returnError(w, r, http.StatusInternalServerError, err.Error())
|
||||||
}
|
}
|
||||||
@ -171,7 +185,21 @@ func (u *Upgrader) Upgrade(w http.ResponseWriter, r *http.Request, responseHeade
|
|||||||
return nil, errors.New("websocket: client sent data before handshake is complete")
|
return nil, errors.New("websocket: client sent data before handshake is complete")
|
||||||
}
|
}
|
||||||
|
|
||||||
c := newConnBRW(netConn, true, u.ReadBufferSize, u.WriteBufferSize, brw)
|
var br *bufio.Reader
|
||||||
|
if u.ReadBufferSize == 0 && bufioReaderSize(netConn, brw.Reader) > 256 {
|
||||||
|
// Reuse hijacked buffered reader as connection reader.
|
||||||
|
br = brw.Reader
|
||||||
|
}
|
||||||
|
|
||||||
|
buf := bufioWriterBuffer(netConn, brw.Writer)
|
||||||
|
|
||||||
|
var writeBuf []byte
|
||||||
|
if u.WriteBufferPool == nil && u.WriteBufferSize == 0 && len(buf) >= maxFrameHeaderSize+256 {
|
||||||
|
// Reuse hijacked write buffer as connection buffer.
|
||||||
|
writeBuf = buf
|
||||||
|
}
|
||||||
|
|
||||||
|
c := newConn(netConn, true, u.ReadBufferSize, u.WriteBufferSize, u.WriteBufferPool, br, writeBuf)
|
||||||
c.subprotocol = subprotocol
|
c.subprotocol = subprotocol
|
||||||
|
|
||||||
if compress {
|
if compress {
|
||||||
@ -179,17 +207,23 @@ func (u *Upgrader) Upgrade(w http.ResponseWriter, r *http.Request, responseHeade
|
|||||||
c.newDecompressionReader = decompressNoContextTakeover
|
c.newDecompressionReader = decompressNoContextTakeover
|
||||||
}
|
}
|
||||||
|
|
||||||
p := c.writeBuf[:0]
|
// Use larger of hijacked buffer and connection write buffer for header.
|
||||||
|
p := buf
|
||||||
|
if len(c.writeBuf) > len(p) {
|
||||||
|
p = c.writeBuf
|
||||||
|
}
|
||||||
|
p = p[:0]
|
||||||
|
|
||||||
p = append(p, "HTTP/1.1 101 Switching Protocols\r\nUpgrade: websocket\r\nConnection: Upgrade\r\nSec-WebSocket-Accept: "...)
|
p = append(p, "HTTP/1.1 101 Switching Protocols\r\nUpgrade: websocket\r\nConnection: Upgrade\r\nSec-WebSocket-Accept: "...)
|
||||||
p = append(p, computeAcceptKey(challengeKey)...)
|
p = append(p, computeAcceptKey(challengeKey)...)
|
||||||
p = append(p, "\r\n"...)
|
p = append(p, "\r\n"...)
|
||||||
if c.subprotocol != "" {
|
if c.subprotocol != "" {
|
||||||
p = append(p, "Sec-Websocket-Protocol: "...)
|
p = append(p, "Sec-WebSocket-Protocol: "...)
|
||||||
p = append(p, c.subprotocol...)
|
p = append(p, c.subprotocol...)
|
||||||
p = append(p, "\r\n"...)
|
p = append(p, "\r\n"...)
|
||||||
}
|
}
|
||||||
if compress {
|
if compress {
|
||||||
p = append(p, "Sec-Websocket-Extensions: permessage-deflate; server_no_context_takeover; client_no_context_takeover\r\n"...)
|
p = append(p, "Sec-WebSocket-Extensions: permessage-deflate; server_no_context_takeover; client_no_context_takeover\r\n"...)
|
||||||
}
|
}
|
||||||
for k, vs := range responseHeader {
|
for k, vs := range responseHeader {
|
||||||
if k == "Sec-Websocket-Protocol" {
|
if k == "Sec-Websocket-Protocol" {
|
||||||
@ -230,13 +264,14 @@ func (u *Upgrader) Upgrade(w http.ResponseWriter, r *http.Request, responseHeade
|
|||||||
|
|
||||||
// Upgrade upgrades the HTTP server connection to the WebSocket protocol.
|
// Upgrade upgrades the HTTP server connection to the WebSocket protocol.
|
||||||
//
|
//
|
||||||
// This function is deprecated, use websocket.Upgrader instead.
|
// Deprecated: Use websocket.Upgrader instead.
|
||||||
//
|
//
|
||||||
// The application is responsible for checking the request origin before
|
// Upgrade does not perform origin checking. The application is responsible for
|
||||||
// calling Upgrade. An example implementation of the same origin policy is:
|
// checking the Origin header before calling Upgrade. An example implementation
|
||||||
|
// of the same origin policy check is:
|
||||||
//
|
//
|
||||||
// if req.Header.Get("Origin") != "http://"+req.Host {
|
// if req.Header.Get("Origin") != "http://"+req.Host {
|
||||||
// http.Error(w, "Origin not allowed", 403)
|
// http.Error(w, "Origin not allowed", http.StatusForbidden)
|
||||||
// return
|
// return
|
||||||
// }
|
// }
|
||||||
//
|
//
|
||||||
@ -289,3 +324,40 @@ func IsWebSocketUpgrade(r *http.Request) bool {
|
|||||||
return tokenListContainsValue(r.Header, "Connection", "upgrade") &&
|
return tokenListContainsValue(r.Header, "Connection", "upgrade") &&
|
||||||
tokenListContainsValue(r.Header, "Upgrade", "websocket")
|
tokenListContainsValue(r.Header, "Upgrade", "websocket")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// bufioReaderSize size returns the size of a bufio.Reader.
|
||||||
|
func bufioReaderSize(originalReader io.Reader, br *bufio.Reader) int {
|
||||||
|
// This code assumes that peek on a reset reader returns
|
||||||
|
// bufio.Reader.buf[:0].
|
||||||
|
// TODO: Use bufio.Reader.Size() after Go 1.10
|
||||||
|
br.Reset(originalReader)
|
||||||
|
if p, err := br.Peek(0); err == nil {
|
||||||
|
return cap(p)
|
||||||
|
}
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
|
||||||
|
// writeHook is an io.Writer that records the last slice passed to it vio
|
||||||
|
// io.Writer.Write.
|
||||||
|
type writeHook struct {
|
||||||
|
p []byte
|
||||||
|
}
|
||||||
|
|
||||||
|
func (wh *writeHook) Write(p []byte) (int, error) {
|
||||||
|
wh.p = p
|
||||||
|
return len(p), nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// bufioWriterBuffer grabs the buffer from a bufio.Writer.
|
||||||
|
func bufioWriterBuffer(originalWriter io.Writer, bw *bufio.Writer) []byte {
|
||||||
|
// This code assumes that bufio.Writer.buf[:1] is passed to the
|
||||||
|
// bufio.Writer's underlying writer.
|
||||||
|
var wh writeHook
|
||||||
|
bw.Reset(&wh)
|
||||||
|
bw.WriteByte(0)
|
||||||
|
bw.Flush()
|
||||||
|
|
||||||
|
bw.Reset(originalWriter)
|
||||||
|
|
||||||
|
return wh.p[:cap(wh.p)]
|
||||||
|
}
|
||||||
|
19
vendor/github.com/gorilla/websocket/trace.go
generated
vendored
Normal file
19
vendor/github.com/gorilla/websocket/trace.go
generated
vendored
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
// +build go1.8
|
||||||
|
|
||||||
|
package websocket
|
||||||
|
|
||||||
|
import (
|
||||||
|
"crypto/tls"
|
||||||
|
"net/http/httptrace"
|
||||||
|
)
|
||||||
|
|
||||||
|
func doHandshakeWithTrace(trace *httptrace.ClientTrace, tlsConn *tls.Conn, cfg *tls.Config) error {
|
||||||
|
if trace.TLSHandshakeStart != nil {
|
||||||
|
trace.TLSHandshakeStart()
|
||||||
|
}
|
||||||
|
err := doHandshake(tlsConn, cfg)
|
||||||
|
if trace.TLSHandshakeDone != nil {
|
||||||
|
trace.TLSHandshakeDone(tlsConn.ConnectionState(), err)
|
||||||
|
}
|
||||||
|
return err
|
||||||
|
}
|
12
vendor/github.com/gorilla/websocket/trace_17.go
generated
vendored
Normal file
12
vendor/github.com/gorilla/websocket/trace_17.go
generated
vendored
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
// +build !go1.8
|
||||||
|
|
||||||
|
package websocket
|
||||||
|
|
||||||
|
import (
|
||||||
|
"crypto/tls"
|
||||||
|
"net/http/httptrace"
|
||||||
|
)
|
||||||
|
|
||||||
|
func doHandshakeWithTrace(trace *httptrace.ClientTrace, tlsConn *tls.Conn, cfg *tls.Config) error {
|
||||||
|
return doHandshake(tlsConn, cfg)
|
||||||
|
}
|
35
vendor/github.com/gorilla/websocket/util.go
generated
vendored
35
vendor/github.com/gorilla/websocket/util.go
generated
vendored
@ -11,6 +11,7 @@ import (
|
|||||||
"io"
|
"io"
|
||||||
"net/http"
|
"net/http"
|
||||||
"strings"
|
"strings"
|
||||||
|
"unicode/utf8"
|
||||||
)
|
)
|
||||||
|
|
||||||
var keyGUID = []byte("258EAFA5-E914-47DA-95CA-C5AB0DC85B11")
|
var keyGUID = []byte("258EAFA5-E914-47DA-95CA-C5AB0DC85B11")
|
||||||
@ -111,14 +112,14 @@ func nextTokenOrQuoted(s string) (value string, rest string) {
|
|||||||
case escape:
|
case escape:
|
||||||
escape = false
|
escape = false
|
||||||
p[j] = b
|
p[j] = b
|
||||||
j += 1
|
j++
|
||||||
case b == '\\':
|
case b == '\\':
|
||||||
escape = true
|
escape = true
|
||||||
case b == '"':
|
case b == '"':
|
||||||
return string(p[:j]), s[i+1:]
|
return string(p[:j]), s[i+1:]
|
||||||
default:
|
default:
|
||||||
p[j] = b
|
p[j] = b
|
||||||
j += 1
|
j++
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return "", ""
|
return "", ""
|
||||||
@ -127,8 +128,31 @@ func nextTokenOrQuoted(s string) (value string, rest string) {
|
|||||||
return "", ""
|
return "", ""
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// equalASCIIFold returns true if s is equal to t with ASCII case folding.
|
||||||
|
func equalASCIIFold(s, t string) bool {
|
||||||
|
for s != "" && t != "" {
|
||||||
|
sr, size := utf8.DecodeRuneInString(s)
|
||||||
|
s = s[size:]
|
||||||
|
tr, size := utf8.DecodeRuneInString(t)
|
||||||
|
t = t[size:]
|
||||||
|
if sr == tr {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
if 'A' <= sr && sr <= 'Z' {
|
||||||
|
sr = sr + 'a' - 'A'
|
||||||
|
}
|
||||||
|
if 'A' <= tr && tr <= 'Z' {
|
||||||
|
tr = tr + 'a' - 'A'
|
||||||
|
}
|
||||||
|
if sr != tr {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return s == t
|
||||||
|
}
|
||||||
|
|
||||||
// tokenListContainsValue returns true if the 1#token header with the given
|
// tokenListContainsValue returns true if the 1#token header with the given
|
||||||
// name contains token.
|
// name contains a token equal to value with ASCII case folding.
|
||||||
func tokenListContainsValue(header http.Header, name string, value string) bool {
|
func tokenListContainsValue(header http.Header, name string, value string) bool {
|
||||||
headers:
|
headers:
|
||||||
for _, s := range header[name] {
|
for _, s := range header[name] {
|
||||||
@ -142,7 +166,7 @@ headers:
|
|||||||
if s != "" && s[0] != ',' {
|
if s != "" && s[0] != ',' {
|
||||||
continue headers
|
continue headers
|
||||||
}
|
}
|
||||||
if strings.EqualFold(t, value) {
|
if equalASCIIFold(t, value) {
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
if s == "" {
|
if s == "" {
|
||||||
@ -154,9 +178,8 @@ headers:
|
|||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
// parseExtensiosn parses WebSocket extensions from a header.
|
// parseExtensions parses WebSocket extensions from a header.
|
||||||
func parseExtensions(header http.Header) []map[string]string {
|
func parseExtensions(header http.Header) []map[string]string {
|
||||||
|
|
||||||
// From RFC 6455:
|
// From RFC 6455:
|
||||||
//
|
//
|
||||||
// Sec-WebSocket-Extensions = extension-list
|
// Sec-WebSocket-Extensions = extension-list
|
||||||
|
473
vendor/github.com/gorilla/websocket/x_net_proxy.go
generated
vendored
Normal file
473
vendor/github.com/gorilla/websocket/x_net_proxy.go
generated
vendored
Normal file
@ -0,0 +1,473 @@
|
|||||||
|
// Code generated by golang.org/x/tools/cmd/bundle. DO NOT EDIT.
|
||||||
|
//go:generate bundle -o x_net_proxy.go golang.org/x/net/proxy
|
||||||
|
|
||||||
|
// Package proxy provides support for a variety of protocols to proxy network
|
||||||
|
// data.
|
||||||
|
//
|
||||||
|
|
||||||
|
package websocket
|
||||||
|
|
||||||
|
import (
|
||||||
|
"errors"
|
||||||
|
"io"
|
||||||
|
"net"
|
||||||
|
"net/url"
|
||||||
|
"os"
|
||||||
|
"strconv"
|
||||||
|
"strings"
|
||||||
|
"sync"
|
||||||
|
)
|
||||||
|
|
||||||
|
type proxy_direct struct{}
|
||||||
|
|
||||||
|
// Direct is a direct proxy: one that makes network connections directly.
|
||||||
|
var proxy_Direct = proxy_direct{}
|
||||||
|
|
||||||
|
func (proxy_direct) Dial(network, addr string) (net.Conn, error) {
|
||||||
|
return net.Dial(network, addr)
|
||||||
|
}
|
||||||
|
|
||||||
|
// A PerHost directs connections to a default Dialer unless the host name
|
||||||
|
// requested matches one of a number of exceptions.
|
||||||
|
type proxy_PerHost struct {
|
||||||
|
def, bypass proxy_Dialer
|
||||||
|
|
||||||
|
bypassNetworks []*net.IPNet
|
||||||
|
bypassIPs []net.IP
|
||||||
|
bypassZones []string
|
||||||
|
bypassHosts []string
|
||||||
|
}
|
||||||
|
|
||||||
|
// NewPerHost returns a PerHost Dialer that directs connections to either
|
||||||
|
// defaultDialer or bypass, depending on whether the connection matches one of
|
||||||
|
// the configured rules.
|
||||||
|
func proxy_NewPerHost(defaultDialer, bypass proxy_Dialer) *proxy_PerHost {
|
||||||
|
return &proxy_PerHost{
|
||||||
|
def: defaultDialer,
|
||||||
|
bypass: bypass,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Dial connects to the address addr on the given network through either
|
||||||
|
// defaultDialer or bypass.
|
||||||
|
func (p *proxy_PerHost) Dial(network, addr string) (c net.Conn, err error) {
|
||||||
|
host, _, err := net.SplitHostPort(addr)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return p.dialerForRequest(host).Dial(network, addr)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (p *proxy_PerHost) dialerForRequest(host string) proxy_Dialer {
|
||||||
|
if ip := net.ParseIP(host); ip != nil {
|
||||||
|
for _, net := range p.bypassNetworks {
|
||||||
|
if net.Contains(ip) {
|
||||||
|
return p.bypass
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for _, bypassIP := range p.bypassIPs {
|
||||||
|
if bypassIP.Equal(ip) {
|
||||||
|
return p.bypass
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return p.def
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, zone := range p.bypassZones {
|
||||||
|
if strings.HasSuffix(host, zone) {
|
||||||
|
return p.bypass
|
||||||
|
}
|
||||||
|
if host == zone[1:] {
|
||||||
|
// For a zone ".example.com", we match "example.com"
|
||||||
|
// too.
|
||||||
|
return p.bypass
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for _, bypassHost := range p.bypassHosts {
|
||||||
|
if bypassHost == host {
|
||||||
|
return p.bypass
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return p.def
|
||||||
|
}
|
||||||
|
|
||||||
|
// AddFromString parses a string that contains comma-separated values
|
||||||
|
// specifying hosts that should use the bypass proxy. Each value is either an
|
||||||
|
// IP address, a CIDR range, a zone (*.example.com) or a host name
|
||||||
|
// (localhost). A best effort is made to parse the string and errors are
|
||||||
|
// ignored.
|
||||||
|
func (p *proxy_PerHost) AddFromString(s string) {
|
||||||
|
hosts := strings.Split(s, ",")
|
||||||
|
for _, host := range hosts {
|
||||||
|
host = strings.TrimSpace(host)
|
||||||
|
if len(host) == 0 {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
if strings.Contains(host, "/") {
|
||||||
|
// We assume that it's a CIDR address like 127.0.0.0/8
|
||||||
|
if _, net, err := net.ParseCIDR(host); err == nil {
|
||||||
|
p.AddNetwork(net)
|
||||||
|
}
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
if ip := net.ParseIP(host); ip != nil {
|
||||||
|
p.AddIP(ip)
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
if strings.HasPrefix(host, "*.") {
|
||||||
|
p.AddZone(host[1:])
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
p.AddHost(host)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// AddIP specifies an IP address that will use the bypass proxy. Note that
|
||||||
|
// this will only take effect if a literal IP address is dialed. A connection
|
||||||
|
// to a named host will never match an IP.
|
||||||
|
func (p *proxy_PerHost) AddIP(ip net.IP) {
|
||||||
|
p.bypassIPs = append(p.bypassIPs, ip)
|
||||||
|
}
|
||||||
|
|
||||||
|
// AddNetwork specifies an IP range that will use the bypass proxy. Note that
|
||||||
|
// this will only take effect if a literal IP address is dialed. A connection
|
||||||
|
// to a named host will never match.
|
||||||
|
func (p *proxy_PerHost) AddNetwork(net *net.IPNet) {
|
||||||
|
p.bypassNetworks = append(p.bypassNetworks, net)
|
||||||
|
}
|
||||||
|
|
||||||
|
// AddZone specifies a DNS suffix that will use the bypass proxy. A zone of
|
||||||
|
// "example.com" matches "example.com" and all of its subdomains.
|
||||||
|
func (p *proxy_PerHost) AddZone(zone string) {
|
||||||
|
if strings.HasSuffix(zone, ".") {
|
||||||
|
zone = zone[:len(zone)-1]
|
||||||
|
}
|
||||||
|
if !strings.HasPrefix(zone, ".") {
|
||||||
|
zone = "." + zone
|
||||||
|
}
|
||||||
|
p.bypassZones = append(p.bypassZones, zone)
|
||||||
|
}
|
||||||
|
|
||||||
|
// AddHost specifies a host name that will use the bypass proxy.
|
||||||
|
func (p *proxy_PerHost) AddHost(host string) {
|
||||||
|
if strings.HasSuffix(host, ".") {
|
||||||
|
host = host[:len(host)-1]
|
||||||
|
}
|
||||||
|
p.bypassHosts = append(p.bypassHosts, host)
|
||||||
|
}
|
||||||
|
|
||||||
|
// A Dialer is a means to establish a connection.
|
||||||
|
type proxy_Dialer interface {
|
||||||
|
// Dial connects to the given address via the proxy.
|
||||||
|
Dial(network, addr string) (c net.Conn, err error)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Auth contains authentication parameters that specific Dialers may require.
|
||||||
|
type proxy_Auth struct {
|
||||||
|
User, Password string
|
||||||
|
}
|
||||||
|
|
||||||
|
// FromEnvironment returns the dialer specified by the proxy related variables in
|
||||||
|
// the environment.
|
||||||
|
func proxy_FromEnvironment() proxy_Dialer {
|
||||||
|
allProxy := proxy_allProxyEnv.Get()
|
||||||
|
if len(allProxy) == 0 {
|
||||||
|
return proxy_Direct
|
||||||
|
}
|
||||||
|
|
||||||
|
proxyURL, err := url.Parse(allProxy)
|
||||||
|
if err != nil {
|
||||||
|
return proxy_Direct
|
||||||
|
}
|
||||||
|
proxy, err := proxy_FromURL(proxyURL, proxy_Direct)
|
||||||
|
if err != nil {
|
||||||
|
return proxy_Direct
|
||||||
|
}
|
||||||
|
|
||||||
|
noProxy := proxy_noProxyEnv.Get()
|
||||||
|
if len(noProxy) == 0 {
|
||||||
|
return proxy
|
||||||
|
}
|
||||||
|
|
||||||
|
perHost := proxy_NewPerHost(proxy, proxy_Direct)
|
||||||
|
perHost.AddFromString(noProxy)
|
||||||
|
return perHost
|
||||||
|
}
|
||||||
|
|
||||||
|
// proxySchemes is a map from URL schemes to a function that creates a Dialer
|
||||||
|
// from a URL with such a scheme.
|
||||||
|
var proxy_proxySchemes map[string]func(*url.URL, proxy_Dialer) (proxy_Dialer, error)
|
||||||
|
|
||||||
|
// RegisterDialerType takes a URL scheme and a function to generate Dialers from
|
||||||
|
// a URL with that scheme and a forwarding Dialer. Registered schemes are used
|
||||||
|
// by FromURL.
|
||||||
|
func proxy_RegisterDialerType(scheme string, f func(*url.URL, proxy_Dialer) (proxy_Dialer, error)) {
|
||||||
|
if proxy_proxySchemes == nil {
|
||||||
|
proxy_proxySchemes = make(map[string]func(*url.URL, proxy_Dialer) (proxy_Dialer, error))
|
||||||
|
}
|
||||||
|
proxy_proxySchemes[scheme] = f
|
||||||
|
}
|
||||||
|
|
||||||
|
// FromURL returns a Dialer given a URL specification and an underlying
|
||||||
|
// Dialer for it to make network requests.
|
||||||
|
func proxy_FromURL(u *url.URL, forward proxy_Dialer) (proxy_Dialer, error) {
|
||||||
|
var auth *proxy_Auth
|
||||||
|
if u.User != nil {
|
||||||
|
auth = new(proxy_Auth)
|
||||||
|
auth.User = u.User.Username()
|
||||||
|
if p, ok := u.User.Password(); ok {
|
||||||
|
auth.Password = p
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
switch u.Scheme {
|
||||||
|
case "socks5":
|
||||||
|
return proxy_SOCKS5("tcp", u.Host, auth, forward)
|
||||||
|
}
|
||||||
|
|
||||||
|
// If the scheme doesn't match any of the built-in schemes, see if it
|
||||||
|
// was registered by another package.
|
||||||
|
if proxy_proxySchemes != nil {
|
||||||
|
if f, ok := proxy_proxySchemes[u.Scheme]; ok {
|
||||||
|
return f(u, forward)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil, errors.New("proxy: unknown scheme: " + u.Scheme)
|
||||||
|
}
|
||||||
|
|
||||||
|
var (
|
||||||
|
proxy_allProxyEnv = &proxy_envOnce{
|
||||||
|
names: []string{"ALL_PROXY", "all_proxy"},
|
||||||
|
}
|
||||||
|
proxy_noProxyEnv = &proxy_envOnce{
|
||||||
|
names: []string{"NO_PROXY", "no_proxy"},
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
|
// envOnce looks up an environment variable (optionally by multiple
|
||||||
|
// names) once. It mitigates expensive lookups on some platforms
|
||||||
|
// (e.g. Windows).
|
||||||
|
// (Borrowed from net/http/transport.go)
|
||||||
|
type proxy_envOnce struct {
|
||||||
|
names []string
|
||||||
|
once sync.Once
|
||||||
|
val string
|
||||||
|
}
|
||||||
|
|
||||||
|
func (e *proxy_envOnce) Get() string {
|
||||||
|
e.once.Do(e.init)
|
||||||
|
return e.val
|
||||||
|
}
|
||||||
|
|
||||||
|
func (e *proxy_envOnce) init() {
|
||||||
|
for _, n := range e.names {
|
||||||
|
e.val = os.Getenv(n)
|
||||||
|
if e.val != "" {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// SOCKS5 returns a Dialer that makes SOCKSv5 connections to the given address
|
||||||
|
// with an optional username and password. See RFC 1928 and RFC 1929.
|
||||||
|
func proxy_SOCKS5(network, addr string, auth *proxy_Auth, forward proxy_Dialer) (proxy_Dialer, error) {
|
||||||
|
s := &proxy_socks5{
|
||||||
|
network: network,
|
||||||
|
addr: addr,
|
||||||
|
forward: forward,
|
||||||
|
}
|
||||||
|
if auth != nil {
|
||||||
|
s.user = auth.User
|
||||||
|
s.password = auth.Password
|
||||||
|
}
|
||||||
|
|
||||||
|
return s, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
type proxy_socks5 struct {
|
||||||
|
user, password string
|
||||||
|
network, addr string
|
||||||
|
forward proxy_Dialer
|
||||||
|
}
|
||||||
|
|
||||||
|
const proxy_socks5Version = 5
|
||||||
|
|
||||||
|
const (
|
||||||
|
proxy_socks5AuthNone = 0
|
||||||
|
proxy_socks5AuthPassword = 2
|
||||||
|
)
|
||||||
|
|
||||||
|
const proxy_socks5Connect = 1
|
||||||
|
|
||||||
|
const (
|
||||||
|
proxy_socks5IP4 = 1
|
||||||
|
proxy_socks5Domain = 3
|
||||||
|
proxy_socks5IP6 = 4
|
||||||
|
)
|
||||||
|
|
||||||
|
var proxy_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 *proxy_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 *proxy_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, proxy_socks5Version)
|
||||||
|
if len(s.user) > 0 && len(s.user) < 256 && len(s.password) < 256 {
|
||||||
|
buf = append(buf, 2 /* num auth methods */, proxy_socks5AuthNone, proxy_socks5AuthPassword)
|
||||||
|
} else {
|
||||||
|
buf = append(buf, 1 /* num auth methods */, proxy_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] == proxy_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, proxy_socks5Version, proxy_socks5Connect, 0 /* reserved */)
|
||||||
|
|
||||||
|
if ip := net.ParseIP(host); ip != nil {
|
||||||
|
if ip4 := ip.To4(); ip4 != nil {
|
||||||
|
buf = append(buf, proxy_socks5IP4)
|
||||||
|
ip = ip4
|
||||||
|
} else {
|
||||||
|
buf = append(buf, proxy_socks5IP6)
|
||||||
|
}
|
||||||
|
buf = append(buf, ip...)
|
||||||
|
} else {
|
||||||
|
if len(host) > 255 {
|
||||||
|
return errors.New("proxy: destination host name too long: " + host)
|
||||||
|
}
|
||||||
|
buf = append(buf, proxy_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(proxy_socks5Errors) {
|
||||||
|
failure = proxy_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 proxy_socks5IP4:
|
||||||
|
bytesToDiscard = net.IPv4len
|
||||||
|
case proxy_socks5IP6:
|
||||||
|
bytesToDiscard = net.IPv6len
|
||||||
|
case proxy_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
|
||||||
|
}
|
8
vendor/golang.org/x/crypto/blowfish/cipher.go
generated
vendored
8
vendor/golang.org/x/crypto/blowfish/cipher.go
generated
vendored
@ -3,6 +3,14 @@
|
|||||||
// license that can be found in the LICENSE file.
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
// Package blowfish implements Bruce Schneier's Blowfish encryption algorithm.
|
// Package blowfish implements Bruce Schneier's Blowfish encryption algorithm.
|
||||||
|
//
|
||||||
|
// Blowfish is a legacy cipher and its short block size makes it vulnerable to
|
||||||
|
// birthday bound attacks (see https://sweet32.info). It should only be used
|
||||||
|
// where compatibility with legacy systems, not security, is the goal.
|
||||||
|
//
|
||||||
|
// Deprecated: any new system should use AES (from crypto/aes, if necessary in
|
||||||
|
// an AEAD mode like crypto/cipher.NewGCM) or XChaCha20-Poly1305 (from
|
||||||
|
// golang.org/x/crypto/chacha20poly1305).
|
||||||
package blowfish // import "golang.org/x/crypto/blowfish"
|
package blowfish // import "golang.org/x/crypto/blowfish"
|
||||||
|
|
||||||
// The code is a port of Bruce Schneier's C implementation.
|
// The code is a port of Bruce Schneier's C implementation.
|
||||||
|
11
vendor/golang.org/x/crypto/cast5/cast5.go
generated
vendored
11
vendor/golang.org/x/crypto/cast5/cast5.go
generated
vendored
@ -2,8 +2,15 @@
|
|||||||
// 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 cast5 implements CAST5, as defined in RFC 2144. CAST5 is a common
|
// Package cast5 implements CAST5, as defined in RFC 2144.
|
||||||
// OpenPGP cipher.
|
//
|
||||||
|
// CAST5 is a legacy cipher and its short block size makes it vulnerable to
|
||||||
|
// birthday bound attacks (see https://sweet32.info). It should only be used
|
||||||
|
// where compatibility with legacy systems, not security, is the goal.
|
||||||
|
//
|
||||||
|
// Deprecated: any new system should use AES (from crypto/aes, if necessary in
|
||||||
|
// an AEAD mode like crypto/cipher.NewGCM) or XChaCha20-Poly1305 (from
|
||||||
|
// golang.org/x/crypto/chacha20poly1305).
|
||||||
package cast5 // import "golang.org/x/crypto/cast5"
|
package cast5 // import "golang.org/x/crypto/cast5"
|
||||||
|
|
||||||
import "errors"
|
import "errors"
|
||||||
|
32
vendor/golang.org/x/crypto/internal/subtle/aliasing.go
generated
vendored
Normal file
32
vendor/golang.org/x/crypto/internal/subtle/aliasing.go
generated
vendored
Normal file
@ -0,0 +1,32 @@
|
|||||||
|
// 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 !appengine
|
||||||
|
|
||||||
|
// Package subtle implements functions that are often useful in cryptographic
|
||||||
|
// code but require careful thought to use correctly.
|
||||||
|
package subtle // import "golang.org/x/crypto/internal/subtle"
|
||||||
|
|
||||||
|
import "unsafe"
|
||||||
|
|
||||||
|
// AnyOverlap reports whether x and y share memory at any (not necessarily
|
||||||
|
// corresponding) index. The memory beyond the slice length is ignored.
|
||||||
|
func AnyOverlap(x, y []byte) bool {
|
||||||
|
return len(x) > 0 && len(y) > 0 &&
|
||||||
|
uintptr(unsafe.Pointer(&x[0])) <= uintptr(unsafe.Pointer(&y[len(y)-1])) &&
|
||||||
|
uintptr(unsafe.Pointer(&y[0])) <= uintptr(unsafe.Pointer(&x[len(x)-1]))
|
||||||
|
}
|
||||||
|
|
||||||
|
// InexactOverlap reports whether x and y share memory at any non-corresponding
|
||||||
|
// index. The memory beyond the slice length is ignored. Note that x and y can
|
||||||
|
// have different lengths and still not have any inexact overlap.
|
||||||
|
//
|
||||||
|
// InexactOverlap can be used to implement the requirements of the crypto/cipher
|
||||||
|
// AEAD, Block, BlockMode and Stream interfaces.
|
||||||
|
func InexactOverlap(x, y []byte) bool {
|
||||||
|
if len(x) == 0 || len(y) == 0 || &x[0] == &y[0] {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
return AnyOverlap(x, y)
|
||||||
|
}
|
35
vendor/golang.org/x/crypto/internal/subtle/aliasing_appengine.go
generated
vendored
Normal file
35
vendor/golang.org/x/crypto/internal/subtle/aliasing_appengine.go
generated
vendored
Normal file
@ -0,0 +1,35 @@
|
|||||||
|
// 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 appengine
|
||||||
|
|
||||||
|
// Package subtle implements functions that are often useful in cryptographic
|
||||||
|
// code but require careful thought to use correctly.
|
||||||
|
package subtle // import "golang.org/x/crypto/internal/subtle"
|
||||||
|
|
||||||
|
// This is the Google App Engine standard variant based on reflect
|
||||||
|
// because the unsafe package and cgo are disallowed.
|
||||||
|
|
||||||
|
import "reflect"
|
||||||
|
|
||||||
|
// AnyOverlap reports whether x and y share memory at any (not necessarily
|
||||||
|
// corresponding) index. The memory beyond the slice length is ignored.
|
||||||
|
func AnyOverlap(x, y []byte) bool {
|
||||||
|
return len(x) > 0 && len(y) > 0 &&
|
||||||
|
reflect.ValueOf(&x[0]).Pointer() <= reflect.ValueOf(&y[len(y)-1]).Pointer() &&
|
||||||
|
reflect.ValueOf(&y[0]).Pointer() <= reflect.ValueOf(&x[len(x)-1]).Pointer()
|
||||||
|
}
|
||||||
|
|
||||||
|
// InexactOverlap reports whether x and y share memory at any non-corresponding
|
||||||
|
// index. The memory beyond the slice length is ignored. Note that x and y can
|
||||||
|
// have different lengths and still not have any inexact overlap.
|
||||||
|
//
|
||||||
|
// InexactOverlap can be used to implement the requirements of the crypto/cipher
|
||||||
|
// AEAD, Block, BlockMode and Stream interfaces.
|
||||||
|
func InexactOverlap(x, y []byte) bool {
|
||||||
|
if len(x) == 0 || len(y) == 0 || &x[0] == &y[0] {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
return AnyOverlap(x, y)
|
||||||
|
}
|
6
vendor/golang.org/x/crypto/salsa20/salsa20.go
generated
vendored
6
vendor/golang.org/x/crypto/salsa20/salsa20.go
generated
vendored
@ -24,6 +24,7 @@ package salsa20 // import "golang.org/x/crypto/salsa20"
|
|||||||
// TODO(agl): implement XORKeyStream12 and XORKeyStream8 - the reduced round variants of Salsa20.
|
// TODO(agl): implement XORKeyStream12 and XORKeyStream8 - the reduced round variants of Salsa20.
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"golang.org/x/crypto/internal/subtle"
|
||||||
"golang.org/x/crypto/salsa20/salsa"
|
"golang.org/x/crypto/salsa20/salsa"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -32,7 +33,10 @@ import (
|
|||||||
// be either 8 or 24 bytes long.
|
// be either 8 or 24 bytes long.
|
||||||
func XORKeyStream(out, in []byte, nonce []byte, key *[32]byte) {
|
func XORKeyStream(out, in []byte, nonce []byte, key *[32]byte) {
|
||||||
if len(out) < len(in) {
|
if len(out) < len(in) {
|
||||||
in = in[:len(out)]
|
panic("salsa20: output smaller than input")
|
||||||
|
}
|
||||||
|
if subtle.InexactOverlap(out[:len(in)], in) {
|
||||||
|
panic("salsa20: invalid buffer overlap")
|
||||||
}
|
}
|
||||||
|
|
||||||
var subNonce [16]byte
|
var subNonce [16]byte
|
||||||
|
8
vendor/golang.org/x/crypto/tea/cipher.go
generated
vendored
8
vendor/golang.org/x/crypto/tea/cipher.go
generated
vendored
@ -5,6 +5,14 @@
|
|||||||
// Package tea implements the TEA algorithm, as defined in Needham and
|
// Package tea implements the TEA algorithm, as defined in Needham and
|
||||||
// Wheeler's 1994 technical report, “TEA, a Tiny Encryption Algorithm”. See
|
// Wheeler's 1994 technical report, “TEA, a Tiny Encryption Algorithm”. See
|
||||||
// http://www.cix.co.uk/~klockstone/tea.pdf for details.
|
// http://www.cix.co.uk/~klockstone/tea.pdf for details.
|
||||||
|
//
|
||||||
|
// TEA is a legacy cipher and its short block size makes it vulnerable to
|
||||||
|
// birthday bound attacks (see https://sweet32.info). It should only be used
|
||||||
|
// where compatibility with legacy systems, not security, is the goal.
|
||||||
|
//
|
||||||
|
// Deprecated: any new system should use AES (from crypto/aes, if necessary in
|
||||||
|
// an AEAD mode like crypto/cipher.NewGCM) or XChaCha20-Poly1305 (from
|
||||||
|
// golang.org/x/crypto/chacha20poly1305).
|
||||||
package tea
|
package tea
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
6
vendor/golang.org/x/crypto/twofish/twofish.go
generated
vendored
6
vendor/golang.org/x/crypto/twofish/twofish.go
generated
vendored
@ -3,6 +3,12 @@
|
|||||||
// license that can be found in the LICENSE file.
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
// Package twofish implements Bruce Schneier's Twofish encryption algorithm.
|
// Package twofish implements Bruce Schneier's Twofish encryption algorithm.
|
||||||
|
//
|
||||||
|
// Deprecated: Twofish is a legacy cipher and should not be used for new
|
||||||
|
// applications. Also, this package does not and will not provide an optimized
|
||||||
|
// implementation. Instead, use AES (from crypto/aes, if necessary in an AEAD
|
||||||
|
// mode like crypto/cipher.NewGCM) or XChaCha20-Poly1305 (from
|
||||||
|
// golang.org/x/crypto/chacha20poly1305).
|
||||||
package twofish // import "golang.org/x/crypto/twofish"
|
package twofish // import "golang.org/x/crypto/twofish"
|
||||||
|
|
||||||
// Twofish is defined in https://www.schneier.com/paper-twofish-paper.pdf [TWOFISH]
|
// Twofish is defined in https://www.schneier.com/paper-twofish-paper.pdf [TWOFISH]
|
||||||
|
8
vendor/golang.org/x/crypto/xtea/cipher.go
generated
vendored
8
vendor/golang.org/x/crypto/xtea/cipher.go
generated
vendored
@ -4,6 +4,14 @@
|
|||||||
|
|
||||||
// Package xtea implements XTEA encryption, as defined in Needham and Wheeler's
|
// Package xtea implements XTEA encryption, as defined in Needham and Wheeler's
|
||||||
// 1997 technical report, "Tea extensions."
|
// 1997 technical report, "Tea extensions."
|
||||||
|
//
|
||||||
|
// XTEA is a legacy cipher and its short block size makes it vulnerable to
|
||||||
|
// birthday bound attacks (see https://sweet32.info). It should only be used
|
||||||
|
// where compatibility with legacy systems, not security, is the goal.
|
||||||
|
//
|
||||||
|
// Deprecated: any new system should use AES (from crypto/aes, if necessary in
|
||||||
|
// an AEAD mode like crypto/cipher.NewGCM) or XChaCha20-Poly1305 (from
|
||||||
|
// golang.org/x/crypto/chacha20poly1305).
|
||||||
package xtea // import "golang.org/x/crypto/xtea"
|
package xtea // import "golang.org/x/crypto/xtea"
|
||||||
|
|
||||||
// For details, see http://www.cix.co.uk/~klockstone/xtea.pdf
|
// For details, see http://www.cix.co.uk/~klockstone/xtea.pdf
|
||||||
|
24
vendor/golang.org/x/net/bpf/constants.go
generated
vendored
24
vendor/golang.org/x/net/bpf/constants.go
generated
vendored
@ -38,6 +38,7 @@ const (
|
|||||||
type JumpTest uint16
|
type JumpTest uint16
|
||||||
|
|
||||||
// Supported operators for conditional jumps.
|
// Supported operators for conditional jumps.
|
||||||
|
// K can be RegX for JumpIfX
|
||||||
const (
|
const (
|
||||||
// K == A
|
// K == A
|
||||||
JumpEqual JumpTest = iota
|
JumpEqual JumpTest = iota
|
||||||
@ -134,12 +135,9 @@ const (
|
|||||||
opMaskLoadDest = 0x01
|
opMaskLoadDest = 0x01
|
||||||
opMaskLoadWidth = 0x18
|
opMaskLoadWidth = 0x18
|
||||||
opMaskLoadMode = 0xe0
|
opMaskLoadMode = 0xe0
|
||||||
// opClsALU
|
// opClsALU & opClsJump
|
||||||
opMaskOperandSrc = 0x08
|
opMaskOperand = 0x08
|
||||||
opMaskOperator = 0xf0
|
opMaskOperator = 0xf0
|
||||||
// opClsJump
|
|
||||||
opMaskJumpConst = 0x0f
|
|
||||||
opMaskJumpCond = 0xf0
|
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
@ -192,15 +190,21 @@ const (
|
|||||||
opLoadWidth1
|
opLoadWidth1
|
||||||
)
|
)
|
||||||
|
|
||||||
// Operator defined by ALUOp*
|
// Operand for ALU and Jump instructions
|
||||||
|
type opOperand uint16
|
||||||
|
|
||||||
|
// Supported operand sources.
|
||||||
const (
|
const (
|
||||||
opALUSrcConstant uint16 = iota << 3
|
opOperandConstant opOperand = iota << 3
|
||||||
opALUSrcX
|
opOperandX
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// An jumpOp is a conditional jump condition.
|
||||||
|
type jumpOp uint16
|
||||||
|
|
||||||
|
// Supported jump conditions.
|
||||||
const (
|
const (
|
||||||
opJumpAlways = iota << 4
|
opJumpAlways jumpOp = iota << 4
|
||||||
opJumpEqual
|
opJumpEqual
|
||||||
opJumpGT
|
opJumpGT
|
||||||
opJumpGE
|
opJumpGE
|
||||||
|
194
vendor/golang.org/x/net/bpf/instructions.go
generated
vendored
194
vendor/golang.org/x/net/bpf/instructions.go
generated
vendored
@ -89,10 +89,14 @@ func (ri RawInstruction) Disassemble() Instruction {
|
|||||||
case opClsALU:
|
case opClsALU:
|
||||||
switch op := ALUOp(ri.Op & opMaskOperator); op {
|
switch op := ALUOp(ri.Op & opMaskOperator); op {
|
||||||
case ALUOpAdd, ALUOpSub, ALUOpMul, ALUOpDiv, ALUOpOr, ALUOpAnd, ALUOpShiftLeft, ALUOpShiftRight, ALUOpMod, ALUOpXor:
|
case ALUOpAdd, ALUOpSub, ALUOpMul, ALUOpDiv, ALUOpOr, ALUOpAnd, ALUOpShiftLeft, ALUOpShiftRight, ALUOpMod, ALUOpXor:
|
||||||
if ri.Op&opMaskOperandSrc != 0 {
|
switch operand := opOperand(ri.Op & opMaskOperand); operand {
|
||||||
|
case opOperandX:
|
||||||
return ALUOpX{Op: op}
|
return ALUOpX{Op: op}
|
||||||
|
case opOperandConstant:
|
||||||
|
return ALUOpConstant{Op: op, Val: ri.K}
|
||||||
|
default:
|
||||||
|
return ri
|
||||||
}
|
}
|
||||||
return ALUOpConstant{Op: op, Val: ri.K}
|
|
||||||
case aluOpNeg:
|
case aluOpNeg:
|
||||||
return NegateA{}
|
return NegateA{}
|
||||||
default:
|
default:
|
||||||
@ -100,63 +104,18 @@ func (ri RawInstruction) Disassemble() Instruction {
|
|||||||
}
|
}
|
||||||
|
|
||||||
case opClsJump:
|
case opClsJump:
|
||||||
if ri.Op&opMaskJumpConst != opClsJump {
|
switch op := jumpOp(ri.Op & opMaskOperator); op {
|
||||||
return ri
|
|
||||||
}
|
|
||||||
switch ri.Op & opMaskJumpCond {
|
|
||||||
case opJumpAlways:
|
case opJumpAlways:
|
||||||
return Jump{Skip: ri.K}
|
return Jump{Skip: ri.K}
|
||||||
case opJumpEqual:
|
case opJumpEqual, opJumpGT, opJumpGE, opJumpSet:
|
||||||
if ri.Jt == 0 {
|
cond, skipTrue, skipFalse := jumpOpToTest(op, ri.Jt, ri.Jf)
|
||||||
return JumpIf{
|
switch operand := opOperand(ri.Op & opMaskOperand); operand {
|
||||||
Cond: JumpNotEqual,
|
case opOperandX:
|
||||||
Val: ri.K,
|
return JumpIfX{Cond: cond, SkipTrue: skipTrue, SkipFalse: skipFalse}
|
||||||
SkipTrue: ri.Jf,
|
case opOperandConstant:
|
||||||
SkipFalse: 0,
|
return JumpIf{Cond: cond, Val: ri.K, SkipTrue: skipTrue, SkipFalse: skipFalse}
|
||||||
}
|
default:
|
||||||
}
|
return ri
|
||||||
return JumpIf{
|
|
||||||
Cond: JumpEqual,
|
|
||||||
Val: ri.K,
|
|
||||||
SkipTrue: ri.Jt,
|
|
||||||
SkipFalse: ri.Jf,
|
|
||||||
}
|
|
||||||
case opJumpGT:
|
|
||||||
if ri.Jt == 0 {
|
|
||||||
return JumpIf{
|
|
||||||
Cond: JumpLessOrEqual,
|
|
||||||
Val: ri.K,
|
|
||||||
SkipTrue: ri.Jf,
|
|
||||||
SkipFalse: 0,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return JumpIf{
|
|
||||||
Cond: JumpGreaterThan,
|
|
||||||
Val: ri.K,
|
|
||||||
SkipTrue: ri.Jt,
|
|
||||||
SkipFalse: ri.Jf,
|
|
||||||
}
|
|
||||||
case opJumpGE:
|
|
||||||
if ri.Jt == 0 {
|
|
||||||
return JumpIf{
|
|
||||||
Cond: JumpLessThan,
|
|
||||||
Val: ri.K,
|
|
||||||
SkipTrue: ri.Jf,
|
|
||||||
SkipFalse: 0,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return JumpIf{
|
|
||||||
Cond: JumpGreaterOrEqual,
|
|
||||||
Val: ri.K,
|
|
||||||
SkipTrue: ri.Jt,
|
|
||||||
SkipFalse: ri.Jf,
|
|
||||||
}
|
|
||||||
case opJumpSet:
|
|
||||||
return JumpIf{
|
|
||||||
Cond: JumpBitsSet,
|
|
||||||
Val: ri.K,
|
|
||||||
SkipTrue: ri.Jt,
|
|
||||||
SkipFalse: ri.Jf,
|
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
return ri
|
return ri
|
||||||
@ -187,6 +146,41 @@ func (ri RawInstruction) Disassemble() Instruction {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func jumpOpToTest(op jumpOp, skipTrue uint8, skipFalse uint8) (JumpTest, uint8, uint8) {
|
||||||
|
var test JumpTest
|
||||||
|
|
||||||
|
// Decode "fake" jump conditions that don't appear in machine code
|
||||||
|
// Ensures the Assemble -> Disassemble stage recreates the same instructions
|
||||||
|
// See https://github.com/golang/go/issues/18470
|
||||||
|
if skipTrue == 0 {
|
||||||
|
switch op {
|
||||||
|
case opJumpEqual:
|
||||||
|
test = JumpNotEqual
|
||||||
|
case opJumpGT:
|
||||||
|
test = JumpLessOrEqual
|
||||||
|
case opJumpGE:
|
||||||
|
test = JumpLessThan
|
||||||
|
case opJumpSet:
|
||||||
|
test = JumpBitsNotSet
|
||||||
|
}
|
||||||
|
|
||||||
|
return test, skipFalse, 0
|
||||||
|
}
|
||||||
|
|
||||||
|
switch op {
|
||||||
|
case opJumpEqual:
|
||||||
|
test = JumpEqual
|
||||||
|
case opJumpGT:
|
||||||
|
test = JumpGreaterThan
|
||||||
|
case opJumpGE:
|
||||||
|
test = JumpGreaterOrEqual
|
||||||
|
case opJumpSet:
|
||||||
|
test = JumpBitsSet
|
||||||
|
}
|
||||||
|
|
||||||
|
return test, skipTrue, skipFalse
|
||||||
|
}
|
||||||
|
|
||||||
// LoadConstant loads Val into register Dst.
|
// LoadConstant loads Val into register Dst.
|
||||||
type LoadConstant struct {
|
type LoadConstant struct {
|
||||||
Dst Register
|
Dst Register
|
||||||
@ -413,7 +407,7 @@ type ALUOpConstant struct {
|
|||||||
// Assemble implements the Instruction Assemble method.
|
// Assemble implements the Instruction Assemble method.
|
||||||
func (a ALUOpConstant) Assemble() (RawInstruction, error) {
|
func (a ALUOpConstant) Assemble() (RawInstruction, error) {
|
||||||
return RawInstruction{
|
return RawInstruction{
|
||||||
Op: opClsALU | opALUSrcConstant | uint16(a.Op),
|
Op: opClsALU | uint16(opOperandConstant) | uint16(a.Op),
|
||||||
K: a.Val,
|
K: a.Val,
|
||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
@ -454,7 +448,7 @@ type ALUOpX struct {
|
|||||||
// Assemble implements the Instruction Assemble method.
|
// Assemble implements the Instruction Assemble method.
|
||||||
func (a ALUOpX) Assemble() (RawInstruction, error) {
|
func (a ALUOpX) Assemble() (RawInstruction, error) {
|
||||||
return RawInstruction{
|
return RawInstruction{
|
||||||
Op: opClsALU | opALUSrcX | uint16(a.Op),
|
Op: opClsALU | uint16(opOperandX) | uint16(a.Op),
|
||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -509,7 +503,7 @@ type Jump struct {
|
|||||||
// Assemble implements the Instruction Assemble method.
|
// Assemble implements the Instruction Assemble method.
|
||||||
func (a Jump) Assemble() (RawInstruction, error) {
|
func (a Jump) Assemble() (RawInstruction, error) {
|
||||||
return RawInstruction{
|
return RawInstruction{
|
||||||
Op: opClsJump | opJumpAlways,
|
Op: opClsJump | uint16(opJumpAlways),
|
||||||
K: a.Skip,
|
K: a.Skip,
|
||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
@ -530,11 +524,39 @@ type JumpIf struct {
|
|||||||
|
|
||||||
// Assemble implements the Instruction Assemble method.
|
// Assemble implements the Instruction Assemble method.
|
||||||
func (a JumpIf) Assemble() (RawInstruction, error) {
|
func (a JumpIf) Assemble() (RawInstruction, error) {
|
||||||
|
return jumpToRaw(a.Cond, opOperandConstant, a.Val, a.SkipTrue, a.SkipFalse)
|
||||||
|
}
|
||||||
|
|
||||||
|
// String returns the instruction in assembler notation.
|
||||||
|
func (a JumpIf) String() string {
|
||||||
|
return jumpToString(a.Cond, fmt.Sprintf("#%d", a.Val), a.SkipTrue, a.SkipFalse)
|
||||||
|
}
|
||||||
|
|
||||||
|
// JumpIfX skips the following Skip instructions in the program if A
|
||||||
|
// <Cond> X is true.
|
||||||
|
type JumpIfX struct {
|
||||||
|
Cond JumpTest
|
||||||
|
SkipTrue uint8
|
||||||
|
SkipFalse uint8
|
||||||
|
}
|
||||||
|
|
||||||
|
// Assemble implements the Instruction Assemble method.
|
||||||
|
func (a JumpIfX) Assemble() (RawInstruction, error) {
|
||||||
|
return jumpToRaw(a.Cond, opOperandX, 0, a.SkipTrue, a.SkipFalse)
|
||||||
|
}
|
||||||
|
|
||||||
|
// String returns the instruction in assembler notation.
|
||||||
|
func (a JumpIfX) String() string {
|
||||||
|
return jumpToString(a.Cond, "x", a.SkipTrue, a.SkipFalse)
|
||||||
|
}
|
||||||
|
|
||||||
|
// jumpToRaw assembles a jump instruction into a RawInstruction
|
||||||
|
func jumpToRaw(test JumpTest, operand opOperand, k uint32, skipTrue, skipFalse uint8) (RawInstruction, error) {
|
||||||
var (
|
var (
|
||||||
cond uint16
|
cond jumpOp
|
||||||
flip bool
|
flip bool
|
||||||
)
|
)
|
||||||
switch a.Cond {
|
switch test {
|
||||||
case JumpEqual:
|
case JumpEqual:
|
||||||
cond = opJumpEqual
|
cond = opJumpEqual
|
||||||
case JumpNotEqual:
|
case JumpNotEqual:
|
||||||
@ -552,63 +574,63 @@ func (a JumpIf) Assemble() (RawInstruction, error) {
|
|||||||
case JumpBitsNotSet:
|
case JumpBitsNotSet:
|
||||||
cond, flip = opJumpSet, true
|
cond, flip = opJumpSet, true
|
||||||
default:
|
default:
|
||||||
return RawInstruction{}, fmt.Errorf("unknown JumpTest %v", a.Cond)
|
return RawInstruction{}, fmt.Errorf("unknown JumpTest %v", test)
|
||||||
}
|
}
|
||||||
jt, jf := a.SkipTrue, a.SkipFalse
|
jt, jf := skipTrue, skipFalse
|
||||||
if flip {
|
if flip {
|
||||||
jt, jf = jf, jt
|
jt, jf = jf, jt
|
||||||
}
|
}
|
||||||
return RawInstruction{
|
return RawInstruction{
|
||||||
Op: opClsJump | cond,
|
Op: opClsJump | uint16(cond) | uint16(operand),
|
||||||
Jt: jt,
|
Jt: jt,
|
||||||
Jf: jf,
|
Jf: jf,
|
||||||
K: a.Val,
|
K: k,
|
||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// String returns the instruction in assembler notation.
|
// jumpToString converts a jump instruction to assembler notation
|
||||||
func (a JumpIf) String() string {
|
func jumpToString(cond JumpTest, operand string, skipTrue, skipFalse uint8) string {
|
||||||
switch a.Cond {
|
switch cond {
|
||||||
// K == A
|
// K == A
|
||||||
case JumpEqual:
|
case JumpEqual:
|
||||||
return conditionalJump(a, "jeq", "jneq")
|
return conditionalJump(operand, skipTrue, skipFalse, "jeq", "jneq")
|
||||||
// K != A
|
// K != A
|
||||||
case JumpNotEqual:
|
case JumpNotEqual:
|
||||||
return fmt.Sprintf("jneq #%d,%d", a.Val, a.SkipTrue)
|
return fmt.Sprintf("jneq %s,%d", operand, skipTrue)
|
||||||
// K > A
|
// K > A
|
||||||
case JumpGreaterThan:
|
case JumpGreaterThan:
|
||||||
return conditionalJump(a, "jgt", "jle")
|
return conditionalJump(operand, skipTrue, skipFalse, "jgt", "jle")
|
||||||
// K < A
|
// K < A
|
||||||
case JumpLessThan:
|
case JumpLessThan:
|
||||||
return fmt.Sprintf("jlt #%d,%d", a.Val, a.SkipTrue)
|
return fmt.Sprintf("jlt %s,%d", operand, skipTrue)
|
||||||
// K >= A
|
// K >= A
|
||||||
case JumpGreaterOrEqual:
|
case JumpGreaterOrEqual:
|
||||||
return conditionalJump(a, "jge", "jlt")
|
return conditionalJump(operand, skipTrue, skipFalse, "jge", "jlt")
|
||||||
// K <= A
|
// K <= A
|
||||||
case JumpLessOrEqual:
|
case JumpLessOrEqual:
|
||||||
return fmt.Sprintf("jle #%d,%d", a.Val, a.SkipTrue)
|
return fmt.Sprintf("jle %s,%d", operand, skipTrue)
|
||||||
// K & A != 0
|
// K & A != 0
|
||||||
case JumpBitsSet:
|
case JumpBitsSet:
|
||||||
if a.SkipFalse > 0 {
|
if skipFalse > 0 {
|
||||||
return fmt.Sprintf("jset #%d,%d,%d", a.Val, a.SkipTrue, a.SkipFalse)
|
return fmt.Sprintf("jset %s,%d,%d", operand, skipTrue, skipFalse)
|
||||||
}
|
}
|
||||||
return fmt.Sprintf("jset #%d,%d", a.Val, a.SkipTrue)
|
return fmt.Sprintf("jset %s,%d", operand, skipTrue)
|
||||||
// K & A == 0, there is no assembler instruction for JumpBitNotSet, use JumpBitSet and invert skips
|
// K & A == 0, there is no assembler instruction for JumpBitNotSet, use JumpBitSet and invert skips
|
||||||
case JumpBitsNotSet:
|
case JumpBitsNotSet:
|
||||||
return JumpIf{Cond: JumpBitsSet, SkipTrue: a.SkipFalse, SkipFalse: a.SkipTrue, Val: a.Val}.String()
|
return jumpToString(JumpBitsSet, operand, skipFalse, skipTrue)
|
||||||
default:
|
default:
|
||||||
return fmt.Sprintf("unknown instruction: %#v", a)
|
return fmt.Sprintf("unknown JumpTest %#v", cond)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func conditionalJump(inst JumpIf, positiveJump, negativeJump string) string {
|
func conditionalJump(operand string, skipTrue, skipFalse uint8, positiveJump, negativeJump string) string {
|
||||||
if inst.SkipTrue > 0 {
|
if skipTrue > 0 {
|
||||||
if inst.SkipFalse > 0 {
|
if skipFalse > 0 {
|
||||||
return fmt.Sprintf("%s #%d,%d,%d", positiveJump, inst.Val, inst.SkipTrue, inst.SkipFalse)
|
return fmt.Sprintf("%s %s,%d,%d", positiveJump, operand, skipTrue, skipFalse)
|
||||||
}
|
}
|
||||||
return fmt.Sprintf("%s #%d,%d", positiveJump, inst.Val, inst.SkipTrue)
|
return fmt.Sprintf("%s %s,%d", positiveJump, operand, skipTrue)
|
||||||
}
|
}
|
||||||
return fmt.Sprintf("%s #%d,%d", negativeJump, inst.Val, inst.SkipFalse)
|
return fmt.Sprintf("%s %s,%d", negativeJump, operand, skipFalse)
|
||||||
}
|
}
|
||||||
|
|
||||||
// RetA exits the BPF program, returning the value of register A.
|
// RetA exits the BPF program, returning the value of register A.
|
||||||
|
10
vendor/golang.org/x/net/bpf/vm.go
generated
vendored
10
vendor/golang.org/x/net/bpf/vm.go
generated
vendored
@ -35,6 +35,13 @@ func NewVM(filter []Instruction) (*VM, error) {
|
|||||||
if check <= int(ins.SkipFalse) {
|
if check <= int(ins.SkipFalse) {
|
||||||
return nil, fmt.Errorf("cannot jump %d instructions in false case; jumping past program bounds", ins.SkipFalse)
|
return nil, fmt.Errorf("cannot jump %d instructions in false case; jumping past program bounds", ins.SkipFalse)
|
||||||
}
|
}
|
||||||
|
case JumpIfX:
|
||||||
|
if check <= int(ins.SkipTrue) {
|
||||||
|
return nil, fmt.Errorf("cannot jump %d instructions in true case; jumping past program bounds", ins.SkipTrue)
|
||||||
|
}
|
||||||
|
if check <= int(ins.SkipFalse) {
|
||||||
|
return nil, fmt.Errorf("cannot jump %d instructions in false case; jumping past program bounds", ins.SkipFalse)
|
||||||
|
}
|
||||||
// Check for division or modulus by zero
|
// Check for division or modulus by zero
|
||||||
case ALUOpConstant:
|
case ALUOpConstant:
|
||||||
if ins.Val != 0 {
|
if ins.Val != 0 {
|
||||||
@ -109,6 +116,9 @@ func (v *VM) Run(in []byte) (int, error) {
|
|||||||
case JumpIf:
|
case JumpIf:
|
||||||
jump := jumpIf(ins, regA)
|
jump := jumpIf(ins, regA)
|
||||||
i += jump
|
i += jump
|
||||||
|
case JumpIfX:
|
||||||
|
jump := jumpIfX(ins, regA, regX)
|
||||||
|
i += jump
|
||||||
case LoadAbsolute:
|
case LoadAbsolute:
|
||||||
regA, ok = loadAbsolute(ins, in)
|
regA, ok = loadAbsolute(ins, in)
|
||||||
case LoadConstant:
|
case LoadConstant:
|
||||||
|
38
vendor/golang.org/x/net/bpf/vm_instructions.go
generated
vendored
38
vendor/golang.org/x/net/bpf/vm_instructions.go
generated
vendored
@ -55,34 +55,41 @@ func aluOpCommon(op ALUOp, regA uint32, value uint32) uint32 {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func jumpIf(ins JumpIf, value uint32) int {
|
func jumpIf(ins JumpIf, regA uint32) int {
|
||||||
var ok bool
|
return jumpIfCommon(ins.Cond, ins.SkipTrue, ins.SkipFalse, regA, ins.Val)
|
||||||
inV := uint32(ins.Val)
|
}
|
||||||
|
|
||||||
switch ins.Cond {
|
func jumpIfX(ins JumpIfX, regA uint32, regX uint32) int {
|
||||||
|
return jumpIfCommon(ins.Cond, ins.SkipTrue, ins.SkipFalse, regA, regX)
|
||||||
|
}
|
||||||
|
|
||||||
|
func jumpIfCommon(cond JumpTest, skipTrue, skipFalse uint8, regA uint32, value uint32) int {
|
||||||
|
var ok bool
|
||||||
|
|
||||||
|
switch cond {
|
||||||
case JumpEqual:
|
case JumpEqual:
|
||||||
ok = value == inV
|
ok = regA == value
|
||||||
case JumpNotEqual:
|
case JumpNotEqual:
|
||||||
ok = value != inV
|
ok = regA != value
|
||||||
case JumpGreaterThan:
|
case JumpGreaterThan:
|
||||||
ok = value > inV
|
ok = regA > value
|
||||||
case JumpLessThan:
|
case JumpLessThan:
|
||||||
ok = value < inV
|
ok = regA < value
|
||||||
case JumpGreaterOrEqual:
|
case JumpGreaterOrEqual:
|
||||||
ok = value >= inV
|
ok = regA >= value
|
||||||
case JumpLessOrEqual:
|
case JumpLessOrEqual:
|
||||||
ok = value <= inV
|
ok = regA <= value
|
||||||
case JumpBitsSet:
|
case JumpBitsSet:
|
||||||
ok = (value & inV) != 0
|
ok = (regA & value) != 0
|
||||||
case JumpBitsNotSet:
|
case JumpBitsNotSet:
|
||||||
ok = (value & inV) == 0
|
ok = (regA & value) == 0
|
||||||
}
|
}
|
||||||
|
|
||||||
if ok {
|
if ok {
|
||||||
return int(ins.SkipTrue)
|
return int(skipTrue)
|
||||||
}
|
}
|
||||||
|
|
||||||
return int(ins.SkipFalse)
|
return int(skipFalse)
|
||||||
}
|
}
|
||||||
|
|
||||||
func loadAbsolute(ins LoadAbsolute, in []byte) (uint32, bool) {
|
func loadAbsolute(ins LoadAbsolute, in []byte) (uint32, bool) {
|
||||||
@ -122,7 +129,8 @@ func loadIndirect(ins LoadIndirect, in []byte, regX uint32) (uint32, bool) {
|
|||||||
func loadMemShift(ins LoadMemShift, in []byte) (uint32, bool) {
|
func loadMemShift(ins LoadMemShift, in []byte) (uint32, bool) {
|
||||||
offset := int(ins.Off)
|
offset := int(ins.Off)
|
||||||
|
|
||||||
if !inBounds(len(in), offset, 0) {
|
// Size of LoadMemShift is always 1 byte
|
||||||
|
if !inBounds(len(in), offset, 1) {
|
||||||
return 0, false
|
return 0, false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
15
vendor/golang.org/x/net/http/httpguts/guts.go
generated
vendored
15
vendor/golang.org/x/net/http/httpguts/guts.go
generated
vendored
@ -14,21 +14,6 @@ import (
|
|||||||
"strings"
|
"strings"
|
||||||
)
|
)
|
||||||
|
|
||||||
// SniffedContentType reports whether ct is a Content-Type that is known
|
|
||||||
// to cause client-side content sniffing.
|
|
||||||
//
|
|
||||||
// This provides just a partial implementation of mime.ParseMediaType
|
|
||||||
// with the assumption that the Content-Type is not attacker controlled.
|
|
||||||
func SniffedContentType(ct string) bool {
|
|
||||||
if i := strings.Index(ct, ";"); i != -1 {
|
|
||||||
ct = ct[:i]
|
|
||||||
}
|
|
||||||
ct = strings.ToLower(strings.TrimSpace(ct))
|
|
||||||
return ct == "text/plain" || ct == "application/octet-stream" ||
|
|
||||||
ct == "application/unknown" || ct == "unknown/unknown" || ct == "*/*" ||
|
|
||||||
!strings.Contains(ct, "/")
|
|
||||||
}
|
|
||||||
|
|
||||||
// ValidTrailerHeader reports whether name is a valid header field name to appear
|
// ValidTrailerHeader reports whether name is a valid header field name to appear
|
||||||
// in trailers.
|
// in trailers.
|
||||||
// See RFC 7230, Section 4.1.2
|
// See RFC 7230, Section 4.1.2
|
||||||
|
8
vendor/golang.org/x/net/idna/idna.go → vendor/golang.org/x/net/idna/idna10.0.0.go
generated
vendored
8
vendor/golang.org/x/net/idna/idna.go → vendor/golang.org/x/net/idna/idna10.0.0.go
generated
vendored
@ -4,14 +4,16 @@
|
|||||||
// 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 go1.10
|
||||||
|
|
||||||
// Package idna implements IDNA2008 using the compatibility processing
|
// Package idna implements IDNA2008 using the compatibility processing
|
||||||
// defined by UTS (Unicode Technical Standard) #46, which defines a standard to
|
// defined by UTS (Unicode Technical Standard) #46, which defines a standard to
|
||||||
// deal with the transition from IDNA2003.
|
// deal with the transition from IDNA2003.
|
||||||
//
|
//
|
||||||
// IDNA2008 (Internationalized Domain Names for Applications), is defined in RFC
|
// IDNA2008 (Internationalized Domain Names for Applications), is defined in RFC
|
||||||
// 5890, RFC 5891, RFC 5892, RFC 5893 and RFC 5894.
|
// 5890, RFC 5891, RFC 5892, RFC 5893 and RFC 5894.
|
||||||
// UTS #46 is defined in http://www.unicode.org/reports/tr46.
|
// UTS #46 is defined in https://www.unicode.org/reports/tr46.
|
||||||
// See http://unicode.org/cldr/utility/idna.jsp for a visualization of the
|
// See https://unicode.org/cldr/utility/idna.jsp for a visualization of the
|
||||||
// differences between these two standards.
|
// differences between these two standards.
|
||||||
package idna // import "golang.org/x/net/idna"
|
package idna // import "golang.org/x/net/idna"
|
||||||
|
|
||||||
@ -297,7 +299,7 @@ func (e runeError) Error() string {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// process implements the algorithm described in section 4 of UTS #46,
|
// process implements the algorithm described in section 4 of UTS #46,
|
||||||
// see http://www.unicode.org/reports/tr46.
|
// see https://www.unicode.org/reports/tr46.
|
||||||
func (p *Profile) process(s string, toASCII bool) (string, error) {
|
func (p *Profile) process(s string, toASCII bool) (string, error) {
|
||||||
var err error
|
var err error
|
||||||
var isBidi bool
|
var isBidi bool
|
682
vendor/golang.org/x/net/idna/idna9.0.0.go
generated
vendored
Normal file
682
vendor/golang.org/x/net/idna/idna9.0.0.go
generated
vendored
Normal file
@ -0,0 +1,682 @@
|
|||||||
|
// Code generated by running "go generate" in golang.org/x/text. DO NOT EDIT.
|
||||||
|
|
||||||
|
// 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 !go1.10
|
||||||
|
|
||||||
|
// Package idna implements IDNA2008 using the compatibility processing
|
||||||
|
// defined by UTS (Unicode Technical Standard) #46, which defines a standard to
|
||||||
|
// deal with the transition from IDNA2003.
|
||||||
|
//
|
||||||
|
// IDNA2008 (Internationalized Domain Names for Applications), is defined in RFC
|
||||||
|
// 5890, RFC 5891, RFC 5892, RFC 5893 and RFC 5894.
|
||||||
|
// UTS #46 is defined in https://www.unicode.org/reports/tr46.
|
||||||
|
// See https://unicode.org/cldr/utility/idna.jsp for a visualization of the
|
||||||
|
// differences between these two standards.
|
||||||
|
package idna // import "golang.org/x/net/idna"
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
"strings"
|
||||||
|
"unicode/utf8"
|
||||||
|
|
||||||
|
"golang.org/x/text/secure/bidirule"
|
||||||
|
"golang.org/x/text/unicode/norm"
|
||||||
|
)
|
||||||
|
|
||||||
|
// NOTE: Unlike common practice in Go APIs, the functions will return a
|
||||||
|
// sanitized domain name in case of errors. Browsers sometimes use a partially
|
||||||
|
// evaluated string as lookup.
|
||||||
|
// TODO: the current error handling is, in my opinion, the least opinionated.
|
||||||
|
// Other strategies are also viable, though:
|
||||||
|
// Option 1) Return an empty string in case of error, but allow the user to
|
||||||
|
// specify explicitly which errors to ignore.
|
||||||
|
// Option 2) Return the partially evaluated string if it is itself a valid
|
||||||
|
// string, otherwise return the empty string in case of error.
|
||||||
|
// Option 3) Option 1 and 2.
|
||||||
|
// Option 4) Always return an empty string for now and implement Option 1 as
|
||||||
|
// needed, and document that the return string may not be empty in case of
|
||||||
|
// error in the future.
|
||||||
|
// I think Option 1 is best, but it is quite opinionated.
|
||||||
|
|
||||||
|
// ToASCII is a wrapper for Punycode.ToASCII.
|
||||||
|
func ToASCII(s string) (string, error) {
|
||||||
|
return Punycode.process(s, true)
|
||||||
|
}
|
||||||
|
|
||||||
|
// ToUnicode is a wrapper for Punycode.ToUnicode.
|
||||||
|
func ToUnicode(s string) (string, error) {
|
||||||
|
return Punycode.process(s, false)
|
||||||
|
}
|
||||||
|
|
||||||
|
// An Option configures a Profile at creation time.
|
||||||
|
type Option func(*options)
|
||||||
|
|
||||||
|
// Transitional sets a Profile to use the Transitional mapping as defined in UTS
|
||||||
|
// #46. This will cause, for example, "ß" to be mapped to "ss". Using the
|
||||||
|
// transitional mapping provides a compromise between IDNA2003 and IDNA2008
|
||||||
|
// compatibility. It is used by most browsers when resolving domain names. This
|
||||||
|
// option is only meaningful if combined with MapForLookup.
|
||||||
|
func Transitional(transitional bool) Option {
|
||||||
|
return func(o *options) { o.transitional = true }
|
||||||
|
}
|
||||||
|
|
||||||
|
// VerifyDNSLength sets whether a Profile should fail if any of the IDN parts
|
||||||
|
// are longer than allowed by the RFC.
|
||||||
|
func VerifyDNSLength(verify bool) Option {
|
||||||
|
return func(o *options) { o.verifyDNSLength = verify }
|
||||||
|
}
|
||||||
|
|
||||||
|
// RemoveLeadingDots removes leading label separators. Leading runes that map to
|
||||||
|
// dots, such as U+3002 IDEOGRAPHIC FULL STOP, are removed as well.
|
||||||
|
//
|
||||||
|
// This is the behavior suggested by the UTS #46 and is adopted by some
|
||||||
|
// browsers.
|
||||||
|
func RemoveLeadingDots(remove bool) Option {
|
||||||
|
return func(o *options) { o.removeLeadingDots = remove }
|
||||||
|
}
|
||||||
|
|
||||||
|
// ValidateLabels sets whether to check the mandatory label validation criteria
|
||||||
|
// as defined in Section 5.4 of RFC 5891. This includes testing for correct use
|
||||||
|
// of hyphens ('-'), normalization, validity of runes, and the context rules.
|
||||||
|
func ValidateLabels(enable bool) Option {
|
||||||
|
return func(o *options) {
|
||||||
|
// Don't override existing mappings, but set one that at least checks
|
||||||
|
// normalization if it is not set.
|
||||||
|
if o.mapping == nil && enable {
|
||||||
|
o.mapping = normalize
|
||||||
|
}
|
||||||
|
o.trie = trie
|
||||||
|
o.validateLabels = enable
|
||||||
|
o.fromPuny = validateFromPunycode
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// StrictDomainName limits the set of permissable ASCII characters to those
|
||||||
|
// allowed in domain names as defined in RFC 1034 (A-Z, a-z, 0-9 and the
|
||||||
|
// hyphen). This is set by default for MapForLookup and ValidateForRegistration.
|
||||||
|
//
|
||||||
|
// This option is useful, for instance, for browsers that allow characters
|
||||||
|
// outside this range, for example a '_' (U+005F LOW LINE). See
|
||||||
|
// http://www.rfc-editor.org/std/std3.txt for more details This option
|
||||||
|
// corresponds to the UseSTD3ASCIIRules option in UTS #46.
|
||||||
|
func StrictDomainName(use bool) Option {
|
||||||
|
return func(o *options) {
|
||||||
|
o.trie = trie
|
||||||
|
o.useSTD3Rules = use
|
||||||
|
o.fromPuny = validateFromPunycode
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// NOTE: the following options pull in tables. The tables should not be linked
|
||||||
|
// in as long as the options are not used.
|
||||||
|
|
||||||
|
// BidiRule enables the Bidi rule as defined in RFC 5893. Any application
|
||||||
|
// that relies on proper validation of labels should include this rule.
|
||||||
|
func BidiRule() Option {
|
||||||
|
return func(o *options) { o.bidirule = bidirule.ValidString }
|
||||||
|
}
|
||||||
|
|
||||||
|
// ValidateForRegistration sets validation options to verify that a given IDN is
|
||||||
|
// properly formatted for registration as defined by Section 4 of RFC 5891.
|
||||||
|
func ValidateForRegistration() Option {
|
||||||
|
return func(o *options) {
|
||||||
|
o.mapping = validateRegistration
|
||||||
|
StrictDomainName(true)(o)
|
||||||
|
ValidateLabels(true)(o)
|
||||||
|
VerifyDNSLength(true)(o)
|
||||||
|
BidiRule()(o)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// MapForLookup sets validation and mapping options such that a given IDN is
|
||||||
|
// transformed for domain name lookup according to the requirements set out in
|
||||||
|
// Section 5 of RFC 5891. The mappings follow the recommendations of RFC 5894,
|
||||||
|
// RFC 5895 and UTS 46. It does not add the Bidi Rule. Use the BidiRule option
|
||||||
|
// to add this check.
|
||||||
|
//
|
||||||
|
// The mappings include normalization and mapping case, width and other
|
||||||
|
// compatibility mappings.
|
||||||
|
func MapForLookup() Option {
|
||||||
|
return func(o *options) {
|
||||||
|
o.mapping = validateAndMap
|
||||||
|
StrictDomainName(true)(o)
|
||||||
|
ValidateLabels(true)(o)
|
||||||
|
RemoveLeadingDots(true)(o)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
type options struct {
|
||||||
|
transitional bool
|
||||||
|
useSTD3Rules bool
|
||||||
|
validateLabels bool
|
||||||
|
verifyDNSLength bool
|
||||||
|
removeLeadingDots bool
|
||||||
|
|
||||||
|
trie *idnaTrie
|
||||||
|
|
||||||
|
// fromPuny calls validation rules when converting A-labels to U-labels.
|
||||||
|
fromPuny func(p *Profile, s string) error
|
||||||
|
|
||||||
|
// mapping implements a validation and mapping step as defined in RFC 5895
|
||||||
|
// or UTS 46, tailored to, for example, domain registration or lookup.
|
||||||
|
mapping func(p *Profile, s string) (string, error)
|
||||||
|
|
||||||
|
// bidirule, if specified, checks whether s conforms to the Bidi Rule
|
||||||
|
// defined in RFC 5893.
|
||||||
|
bidirule func(s string) bool
|
||||||
|
}
|
||||||
|
|
||||||
|
// A Profile defines the configuration of a IDNA mapper.
|
||||||
|
type Profile struct {
|
||||||
|
options
|
||||||
|
}
|
||||||
|
|
||||||
|
func apply(o *options, opts []Option) {
|
||||||
|
for _, f := range opts {
|
||||||
|
f(o)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// New creates a new Profile.
|
||||||
|
//
|
||||||
|
// With no options, the returned Profile is the most permissive and equals the
|
||||||
|
// Punycode Profile. Options can be passed to further restrict the Profile. The
|
||||||
|
// MapForLookup and ValidateForRegistration options set a collection of options,
|
||||||
|
// for lookup and registration purposes respectively, which can be tailored by
|
||||||
|
// adding more fine-grained options, where later options override earlier
|
||||||
|
// options.
|
||||||
|
func New(o ...Option) *Profile {
|
||||||
|
p := &Profile{}
|
||||||
|
apply(&p.options, o)
|
||||||
|
return p
|
||||||
|
}
|
||||||
|
|
||||||
|
// ToASCII converts a domain or domain label to its ASCII form. For example,
|
||||||
|
// ToASCII("bücher.example.com") is "xn--bcher-kva.example.com", and
|
||||||
|
// ToASCII("golang") is "golang". If an error is encountered it will return
|
||||||
|
// an error and a (partially) processed result.
|
||||||
|
func (p *Profile) ToASCII(s string) (string, error) {
|
||||||
|
return p.process(s, true)
|
||||||
|
}
|
||||||
|
|
||||||
|
// ToUnicode converts a domain or domain label to its Unicode form. For example,
|
||||||
|
// ToUnicode("xn--bcher-kva.example.com") is "bücher.example.com", and
|
||||||
|
// ToUnicode("golang") is "golang". If an error is encountered it will return
|
||||||
|
// an error and a (partially) processed result.
|
||||||
|
func (p *Profile) ToUnicode(s string) (string, error) {
|
||||||
|
pp := *p
|
||||||
|
pp.transitional = false
|
||||||
|
return pp.process(s, false)
|
||||||
|
}
|
||||||
|
|
||||||
|
// String reports a string with a description of the profile for debugging
|
||||||
|
// purposes. The string format may change with different versions.
|
||||||
|
func (p *Profile) String() string {
|
||||||
|
s := ""
|
||||||
|
if p.transitional {
|
||||||
|
s = "Transitional"
|
||||||
|
} else {
|
||||||
|
s = "NonTransitional"
|
||||||
|
}
|
||||||
|
if p.useSTD3Rules {
|
||||||
|
s += ":UseSTD3Rules"
|
||||||
|
}
|
||||||
|
if p.validateLabels {
|
||||||
|
s += ":ValidateLabels"
|
||||||
|
}
|
||||||
|
if p.verifyDNSLength {
|
||||||
|
s += ":VerifyDNSLength"
|
||||||
|
}
|
||||||
|
return s
|
||||||
|
}
|
||||||
|
|
||||||
|
var (
|
||||||
|
// Punycode is a Profile that does raw punycode processing with a minimum
|
||||||
|
// of validation.
|
||||||
|
Punycode *Profile = punycode
|
||||||
|
|
||||||
|
// Lookup is the recommended profile for looking up domain names, according
|
||||||
|
// to Section 5 of RFC 5891. The exact configuration of this profile may
|
||||||
|
// change over time.
|
||||||
|
Lookup *Profile = lookup
|
||||||
|
|
||||||
|
// Display is the recommended profile for displaying domain names.
|
||||||
|
// The configuration of this profile may change over time.
|
||||||
|
Display *Profile = display
|
||||||
|
|
||||||
|
// Registration is the recommended profile for checking whether a given
|
||||||
|
// IDN is valid for registration, according to Section 4 of RFC 5891.
|
||||||
|
Registration *Profile = registration
|
||||||
|
|
||||||
|
punycode = &Profile{}
|
||||||
|
lookup = &Profile{options{
|
||||||
|
transitional: true,
|
||||||
|
useSTD3Rules: true,
|
||||||
|
validateLabels: true,
|
||||||
|
removeLeadingDots: true,
|
||||||
|
trie: trie,
|
||||||
|
fromPuny: validateFromPunycode,
|
||||||
|
mapping: validateAndMap,
|
||||||
|
bidirule: bidirule.ValidString,
|
||||||
|
}}
|
||||||
|
display = &Profile{options{
|
||||||
|
useSTD3Rules: true,
|
||||||
|
validateLabels: true,
|
||||||
|
removeLeadingDots: true,
|
||||||
|
trie: trie,
|
||||||
|
fromPuny: validateFromPunycode,
|
||||||
|
mapping: validateAndMap,
|
||||||
|
bidirule: bidirule.ValidString,
|
||||||
|
}}
|
||||||
|
registration = &Profile{options{
|
||||||
|
useSTD3Rules: true,
|
||||||
|
validateLabels: true,
|
||||||
|
verifyDNSLength: true,
|
||||||
|
trie: trie,
|
||||||
|
fromPuny: validateFromPunycode,
|
||||||
|
mapping: validateRegistration,
|
||||||
|
bidirule: bidirule.ValidString,
|
||||||
|
}}
|
||||||
|
|
||||||
|
// TODO: profiles
|
||||||
|
// Register: recommended for approving domain names: don't do any mappings
|
||||||
|
// but rather reject on invalid input. Bundle or block deviation characters.
|
||||||
|
)
|
||||||
|
|
||||||
|
type labelError struct{ label, code_ string }
|
||||||
|
|
||||||
|
func (e labelError) code() string { return e.code_ }
|
||||||
|
func (e labelError) Error() string {
|
||||||
|
return fmt.Sprintf("idna: invalid label %q", e.label)
|
||||||
|
}
|
||||||
|
|
||||||
|
type runeError rune
|
||||||
|
|
||||||
|
func (e runeError) code() string { return "P1" }
|
||||||
|
func (e runeError) Error() string {
|
||||||
|
return fmt.Sprintf("idna: disallowed rune %U", e)
|
||||||
|
}
|
||||||
|
|
||||||
|
// process implements the algorithm described in section 4 of UTS #46,
|
||||||
|
// see https://www.unicode.org/reports/tr46.
|
||||||
|
func (p *Profile) process(s string, toASCII bool) (string, error) {
|
||||||
|
var err error
|
||||||
|
if p.mapping != nil {
|
||||||
|
s, err = p.mapping(p, s)
|
||||||
|
}
|
||||||
|
// Remove leading empty labels.
|
||||||
|
if p.removeLeadingDots {
|
||||||
|
for ; len(s) > 0 && s[0] == '.'; s = s[1:] {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// It seems like we should only create this error on ToASCII, but the
|
||||||
|
// UTS 46 conformance tests suggests we should always check this.
|
||||||
|
if err == nil && p.verifyDNSLength && s == "" {
|
||||||
|
err = &labelError{s, "A4"}
|
||||||
|
}
|
||||||
|
labels := labelIter{orig: s}
|
||||||
|
for ; !labels.done(); labels.next() {
|
||||||
|
label := labels.label()
|
||||||
|
if label == "" {
|
||||||
|
// Empty labels are not okay. The label iterator skips the last
|
||||||
|
// label if it is empty.
|
||||||
|
if err == nil && p.verifyDNSLength {
|
||||||
|
err = &labelError{s, "A4"}
|
||||||
|
}
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
if strings.HasPrefix(label, acePrefix) {
|
||||||
|
u, err2 := decode(label[len(acePrefix):])
|
||||||
|
if err2 != nil {
|
||||||
|
if err == nil {
|
||||||
|
err = err2
|
||||||
|
}
|
||||||
|
// Spec says keep the old label.
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
labels.set(u)
|
||||||
|
if err == nil && p.validateLabels {
|
||||||
|
err = p.fromPuny(p, u)
|
||||||
|
}
|
||||||
|
if err == nil {
|
||||||
|
// This should be called on NonTransitional, according to the
|
||||||
|
// spec, but that currently does not have any effect. Use the
|
||||||
|
// original profile to preserve options.
|
||||||
|
err = p.validateLabel(u)
|
||||||
|
}
|
||||||
|
} else if err == nil {
|
||||||
|
err = p.validateLabel(label)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if toASCII {
|
||||||
|
for labels.reset(); !labels.done(); labels.next() {
|
||||||
|
label := labels.label()
|
||||||
|
if !ascii(label) {
|
||||||
|
a, err2 := encode(acePrefix, label)
|
||||||
|
if err == nil {
|
||||||
|
err = err2
|
||||||
|
}
|
||||||
|
label = a
|
||||||
|
labels.set(a)
|
||||||
|
}
|
||||||
|
n := len(label)
|
||||||
|
if p.verifyDNSLength && err == nil && (n == 0 || n > 63) {
|
||||||
|
err = &labelError{label, "A4"}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
s = labels.result()
|
||||||
|
if toASCII && p.verifyDNSLength && err == nil {
|
||||||
|
// Compute the length of the domain name minus the root label and its dot.
|
||||||
|
n := len(s)
|
||||||
|
if n > 0 && s[n-1] == '.' {
|
||||||
|
n--
|
||||||
|
}
|
||||||
|
if len(s) < 1 || n > 253 {
|
||||||
|
err = &labelError{s, "A4"}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return s, err
|
||||||
|
}
|
||||||
|
|
||||||
|
func normalize(p *Profile, s string) (string, error) {
|
||||||
|
return norm.NFC.String(s), nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func validateRegistration(p *Profile, s string) (string, error) {
|
||||||
|
if !norm.NFC.IsNormalString(s) {
|
||||||
|
return s, &labelError{s, "V1"}
|
||||||
|
}
|
||||||
|
for i := 0; i < len(s); {
|
||||||
|
v, sz := trie.lookupString(s[i:])
|
||||||
|
// Copy bytes not copied so far.
|
||||||
|
switch p.simplify(info(v).category()) {
|
||||||
|
// TODO: handle the NV8 defined in the Unicode idna data set to allow
|
||||||
|
// for strict conformance to IDNA2008.
|
||||||
|
case valid, deviation:
|
||||||
|
case disallowed, mapped, unknown, ignored:
|
||||||
|
r, _ := utf8.DecodeRuneInString(s[i:])
|
||||||
|
return s, runeError(r)
|
||||||
|
}
|
||||||
|
i += sz
|
||||||
|
}
|
||||||
|
return s, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func validateAndMap(p *Profile, s string) (string, error) {
|
||||||
|
var (
|
||||||
|
err error
|
||||||
|
b []byte
|
||||||
|
k int
|
||||||
|
)
|
||||||
|
for i := 0; i < len(s); {
|
||||||
|
v, sz := trie.lookupString(s[i:])
|
||||||
|
start := i
|
||||||
|
i += sz
|
||||||
|
// Copy bytes not copied so far.
|
||||||
|
switch p.simplify(info(v).category()) {
|
||||||
|
case valid:
|
||||||
|
continue
|
||||||
|
case disallowed:
|
||||||
|
if err == nil {
|
||||||
|
r, _ := utf8.DecodeRuneInString(s[start:])
|
||||||
|
err = runeError(r)
|
||||||
|
}
|
||||||
|
continue
|
||||||
|
case mapped, deviation:
|
||||||
|
b = append(b, s[k:start]...)
|
||||||
|
b = info(v).appendMapping(b, s[start:i])
|
||||||
|
case ignored:
|
||||||
|
b = append(b, s[k:start]...)
|
||||||
|
// drop the rune
|
||||||
|
case unknown:
|
||||||
|
b = append(b, s[k:start]...)
|
||||||
|
b = append(b, "\ufffd"...)
|
||||||
|
}
|
||||||
|
k = i
|
||||||
|
}
|
||||||
|
if k == 0 {
|
||||||
|
// No changes so far.
|
||||||
|
s = norm.NFC.String(s)
|
||||||
|
} else {
|
||||||
|
b = append(b, s[k:]...)
|
||||||
|
if norm.NFC.QuickSpan(b) != len(b) {
|
||||||
|
b = norm.NFC.Bytes(b)
|
||||||
|
}
|
||||||
|
// TODO: the punycode converters require strings as input.
|
||||||
|
s = string(b)
|
||||||
|
}
|
||||||
|
return s, err
|
||||||
|
}
|
||||||
|
|
||||||
|
// A labelIter allows iterating over domain name labels.
|
||||||
|
type labelIter struct {
|
||||||
|
orig string
|
||||||
|
slice []string
|
||||||
|
curStart int
|
||||||
|
curEnd int
|
||||||
|
i int
|
||||||
|
}
|
||||||
|
|
||||||
|
func (l *labelIter) reset() {
|
||||||
|
l.curStart = 0
|
||||||
|
l.curEnd = 0
|
||||||
|
l.i = 0
|
||||||
|
}
|
||||||
|
|
||||||
|
func (l *labelIter) done() bool {
|
||||||
|
return l.curStart >= len(l.orig)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (l *labelIter) result() string {
|
||||||
|
if l.slice != nil {
|
||||||
|
return strings.Join(l.slice, ".")
|
||||||
|
}
|
||||||
|
return l.orig
|
||||||
|
}
|
||||||
|
|
||||||
|
func (l *labelIter) label() string {
|
||||||
|
if l.slice != nil {
|
||||||
|
return l.slice[l.i]
|
||||||
|
}
|
||||||
|
p := strings.IndexByte(l.orig[l.curStart:], '.')
|
||||||
|
l.curEnd = l.curStart + p
|
||||||
|
if p == -1 {
|
||||||
|
l.curEnd = len(l.orig)
|
||||||
|
}
|
||||||
|
return l.orig[l.curStart:l.curEnd]
|
||||||
|
}
|
||||||
|
|
||||||
|
// next sets the value to the next label. It skips the last label if it is empty.
|
||||||
|
func (l *labelIter) next() {
|
||||||
|
l.i++
|
||||||
|
if l.slice != nil {
|
||||||
|
if l.i >= len(l.slice) || l.i == len(l.slice)-1 && l.slice[l.i] == "" {
|
||||||
|
l.curStart = len(l.orig)
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
l.curStart = l.curEnd + 1
|
||||||
|
if l.curStart == len(l.orig)-1 && l.orig[l.curStart] == '.' {
|
||||||
|
l.curStart = len(l.orig)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (l *labelIter) set(s string) {
|
||||||
|
if l.slice == nil {
|
||||||
|
l.slice = strings.Split(l.orig, ".")
|
||||||
|
}
|
||||||
|
l.slice[l.i] = s
|
||||||
|
}
|
||||||
|
|
||||||
|
// acePrefix is the ASCII Compatible Encoding prefix.
|
||||||
|
const acePrefix = "xn--"
|
||||||
|
|
||||||
|
func (p *Profile) simplify(cat category) category {
|
||||||
|
switch cat {
|
||||||
|
case disallowedSTD3Mapped:
|
||||||
|
if p.useSTD3Rules {
|
||||||
|
cat = disallowed
|
||||||
|
} else {
|
||||||
|
cat = mapped
|
||||||
|
}
|
||||||
|
case disallowedSTD3Valid:
|
||||||
|
if p.useSTD3Rules {
|
||||||
|
cat = disallowed
|
||||||
|
} else {
|
||||||
|
cat = valid
|
||||||
|
}
|
||||||
|
case deviation:
|
||||||
|
if !p.transitional {
|
||||||
|
cat = valid
|
||||||
|
}
|
||||||
|
case validNV8, validXV8:
|
||||||
|
// TODO: handle V2008
|
||||||
|
cat = valid
|
||||||
|
}
|
||||||
|
return cat
|
||||||
|
}
|
||||||
|
|
||||||
|
func validateFromPunycode(p *Profile, s string) error {
|
||||||
|
if !norm.NFC.IsNormalString(s) {
|
||||||
|
return &labelError{s, "V1"}
|
||||||
|
}
|
||||||
|
for i := 0; i < len(s); {
|
||||||
|
v, sz := trie.lookupString(s[i:])
|
||||||
|
if c := p.simplify(info(v).category()); c != valid && c != deviation {
|
||||||
|
return &labelError{s, "V6"}
|
||||||
|
}
|
||||||
|
i += sz
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
const (
|
||||||
|
zwnj = "\u200c"
|
||||||
|
zwj = "\u200d"
|
||||||
|
)
|
||||||
|
|
||||||
|
type joinState int8
|
||||||
|
|
||||||
|
const (
|
||||||
|
stateStart joinState = iota
|
||||||
|
stateVirama
|
||||||
|
stateBefore
|
||||||
|
stateBeforeVirama
|
||||||
|
stateAfter
|
||||||
|
stateFAIL
|
||||||
|
)
|
||||||
|
|
||||||
|
var joinStates = [][numJoinTypes]joinState{
|
||||||
|
stateStart: {
|
||||||
|
joiningL: stateBefore,
|
||||||
|
joiningD: stateBefore,
|
||||||
|
joinZWNJ: stateFAIL,
|
||||||
|
joinZWJ: stateFAIL,
|
||||||
|
joinVirama: stateVirama,
|
||||||
|
},
|
||||||
|
stateVirama: {
|
||||||
|
joiningL: stateBefore,
|
||||||
|
joiningD: stateBefore,
|
||||||
|
},
|
||||||
|
stateBefore: {
|
||||||
|
joiningL: stateBefore,
|
||||||
|
joiningD: stateBefore,
|
||||||
|
joiningT: stateBefore,
|
||||||
|
joinZWNJ: stateAfter,
|
||||||
|
joinZWJ: stateFAIL,
|
||||||
|
joinVirama: stateBeforeVirama,
|
||||||
|
},
|
||||||
|
stateBeforeVirama: {
|
||||||
|
joiningL: stateBefore,
|
||||||
|
joiningD: stateBefore,
|
||||||
|
joiningT: stateBefore,
|
||||||
|
},
|
||||||
|
stateAfter: {
|
||||||
|
joiningL: stateFAIL,
|
||||||
|
joiningD: stateBefore,
|
||||||
|
joiningT: stateAfter,
|
||||||
|
joiningR: stateStart,
|
||||||
|
joinZWNJ: stateFAIL,
|
||||||
|
joinZWJ: stateFAIL,
|
||||||
|
joinVirama: stateAfter, // no-op as we can't accept joiners here
|
||||||
|
},
|
||||||
|
stateFAIL: {
|
||||||
|
0: stateFAIL,
|
||||||
|
joiningL: stateFAIL,
|
||||||
|
joiningD: stateFAIL,
|
||||||
|
joiningT: stateFAIL,
|
||||||
|
joiningR: stateFAIL,
|
||||||
|
joinZWNJ: stateFAIL,
|
||||||
|
joinZWJ: stateFAIL,
|
||||||
|
joinVirama: stateFAIL,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
// validateLabel validates the criteria from Section 4.1. Item 1, 4, and 6 are
|
||||||
|
// already implicitly satisfied by the overall implementation.
|
||||||
|
func (p *Profile) validateLabel(s string) error {
|
||||||
|
if s == "" {
|
||||||
|
if p.verifyDNSLength {
|
||||||
|
return &labelError{s, "A4"}
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
if p.bidirule != nil && !p.bidirule(s) {
|
||||||
|
return &labelError{s, "B"}
|
||||||
|
}
|
||||||
|
if !p.validateLabels {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
trie := p.trie // p.validateLabels is only set if trie is set.
|
||||||
|
if len(s) > 4 && s[2] == '-' && s[3] == '-' {
|
||||||
|
return &labelError{s, "V2"}
|
||||||
|
}
|
||||||
|
if s[0] == '-' || s[len(s)-1] == '-' {
|
||||||
|
return &labelError{s, "V3"}
|
||||||
|
}
|
||||||
|
// TODO: merge the use of this in the trie.
|
||||||
|
v, sz := trie.lookupString(s)
|
||||||
|
x := info(v)
|
||||||
|
if x.isModifier() {
|
||||||
|
return &labelError{s, "V5"}
|
||||||
|
}
|
||||||
|
// Quickly return in the absence of zero-width (non) joiners.
|
||||||
|
if strings.Index(s, zwj) == -1 && strings.Index(s, zwnj) == -1 {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
st := stateStart
|
||||||
|
for i := 0; ; {
|
||||||
|
jt := x.joinType()
|
||||||
|
if s[i:i+sz] == zwj {
|
||||||
|
jt = joinZWJ
|
||||||
|
} else if s[i:i+sz] == zwnj {
|
||||||
|
jt = joinZWNJ
|
||||||
|
}
|
||||||
|
st = joinStates[st][jt]
|
||||||
|
if x.isViramaModifier() {
|
||||||
|
st = joinStates[st][joinVirama]
|
||||||
|
}
|
||||||
|
if i += sz; i == len(s) {
|
||||||
|
break
|
||||||
|
}
|
||||||
|
v, sz = trie.lookupString(s[i:])
|
||||||
|
x = info(v)
|
||||||
|
}
|
||||||
|
if st == stateFAIL || st == stateAfter {
|
||||||
|
return &labelError{s, "C"}
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func ascii(s string) bool {
|
||||||
|
for i := 0; i < len(s); i++ {
|
||||||
|
if s[i] >= utf8.RuneSelf {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return true
|
||||||
|
}
|
@ -1,11 +1,13 @@
|
|||||||
// Code generated by running "go generate" in golang.org/x/text. DO NOT EDIT.
|
// Code generated by running "go generate" in golang.org/x/text. DO NOT EDIT.
|
||||||
|
|
||||||
|
// +build go1.10,!go1.13
|
||||||
|
|
||||||
package idna
|
package idna
|
||||||
|
|
||||||
// UnicodeVersion is the Unicode version from which the tables in this package are derived.
|
// UnicodeVersion is the Unicode version from which the tables in this package are derived.
|
||||||
const UnicodeVersion = "10.0.0"
|
const UnicodeVersion = "10.0.0"
|
||||||
|
|
||||||
var mappings string = "" + // Size: 8176 bytes
|
var mappings string = "" + // Size: 8175 bytes
|
||||||
"\x00\x01 \x03 ̈\x01a\x03 ̄\x012\x013\x03 ́\x03 ̧\x011\x01o\x051⁄4\x051⁄2" +
|
"\x00\x01 \x03 ̈\x01a\x03 ̄\x012\x013\x03 ́\x03 ̧\x011\x01o\x051⁄4\x051⁄2" +
|
||||||
"\x053⁄4\x03i̇\x03l·\x03ʼn\x01s\x03dž\x03ⱥ\x03ⱦ\x01h\x01j\x01r\x01w\x01y" +
|
"\x053⁄4\x03i̇\x03l·\x03ʼn\x01s\x03dž\x03ⱥ\x03ⱦ\x01h\x01j\x01r\x01w\x01y" +
|
||||||
"\x03 ̆\x03 ̇\x03 ̊\x03 ̨\x03 ̃\x03 ̋\x01l\x01x\x04̈́\x03 ι\x01;\x05 ̈́" +
|
"\x03 ̆\x03 ̇\x03 ̊\x03 ̨\x03 ̃\x03 ̋\x01l\x01x\x04̈́\x03 ι\x01;\x05 ̈́" +
|
||||||
@ -4554,4 +4556,4 @@ var idnaSparseValues = [1915]valueRange{
|
|||||||
{value: 0x0040, lo: 0xb0, hi: 0xbf},
|
{value: 0x0040, lo: 0xb0, hi: 0xbf},
|
||||||
}
|
}
|
||||||
|
|
||||||
// Total table size 42115 bytes (41KiB); checksum: F4A1FA4E
|
// Total table size 42114 bytes (41KiB); checksum: 355A58A4
|
4653
vendor/golang.org/x/net/idna/tables11.0.0.go
generated
vendored
Normal file
4653
vendor/golang.org/x/net/idna/tables11.0.0.go
generated
vendored
Normal file
File diff suppressed because it is too large
Load Diff
4486
vendor/golang.org/x/net/idna/tables9.0.0.go
generated
vendored
Normal file
4486
vendor/golang.org/x/net/idna/tables9.0.0.go
generated
vendored
Normal file
File diff suppressed because it is too large
Load Diff
60
vendor/golang.org/x/net/internal/iana/const.go
generated
vendored
60
vendor/golang.org/x/net/internal/iana/const.go
generated
vendored
@ -4,38 +4,34 @@
|
|||||||
// 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))
|
||||||
// IPv4 TOS Byte and IPv6 Traffic Class Octet, Updated: 2001-09-06
|
ECNTransport0 = 0x02 // ECT(0) (ECN-Capable Transport(0))
|
||||||
const (
|
CongestionExperienced = 0x03 // CE (Congestion Experienced)
|
||||||
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: 2017-10-13
|
// Protocol Numbers, Updated: 2017-10-13
|
||||||
@ -179,7 +175,7 @@ const (
|
|||||||
ProtocolReserved = 255 // Reserved
|
ProtocolReserved = 255 // Reserved
|
||||||
)
|
)
|
||||||
|
|
||||||
// Address Family Numbers, Updated: 2016-10-25
|
// Address Family Numbers, Updated: 2018-04-02
|
||||||
const (
|
const (
|
||||||
AddrFamilyIPv4 = 1 // IP (IP version 4)
|
AddrFamilyIPv4 = 1 // IP (IP version 4)
|
||||||
AddrFamilyIPv6 = 2 // IP6 (IP version 6)
|
AddrFamilyIPv6 = 2 // IP6 (IP version 6)
|
||||||
|
2
vendor/golang.org/x/net/internal/socket/cmsghdr.go
generated
vendored
2
vendor/golang.org/x/net/internal/socket/cmsghdr.go
generated
vendored
@ -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 darwin dragonfly freebsd linux netbsd openbsd solaris
|
// +build aix darwin dragonfly freebsd linux netbsd openbsd solaris
|
||||||
|
|
||||||
package socket
|
package socket
|
||||||
|
|
||||||
|
2
vendor/golang.org/x/net/internal/socket/cmsghdr_bsd.go
generated
vendored
2
vendor/golang.org/x/net/internal/socket/cmsghdr_bsd.go
generated
vendored
@ -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 darwin dragonfly freebsd netbsd openbsd
|
// +build aix darwin dragonfly freebsd netbsd openbsd
|
||||||
|
|
||||||
package socket
|
package socket
|
||||||
|
|
||||||
|
2
vendor/golang.org/x/net/internal/socket/cmsghdr_linux_64bit.go
generated
vendored
2
vendor/golang.org/x/net/internal/socket/cmsghdr_linux_64bit.go
generated
vendored
@ -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 arm64 amd64 ppc64 ppc64le mips64 mips64le s390x
|
// +build arm64 amd64 ppc64 ppc64le mips64 mips64le riscv64 s390x
|
||||||
// +build linux
|
// +build linux
|
||||||
|
|
||||||
package socket
|
package socket
|
||||||
|
2
vendor/golang.org/x/net/internal/socket/cmsghdr_stub.go
generated
vendored
2
vendor/golang.org/x/net/internal/socket/cmsghdr_stub.go
generated
vendored
@ -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 !darwin,!dragonfly,!freebsd,!linux,!netbsd,!openbsd,!solaris
|
// +build !aix,!darwin,!dragonfly,!freebsd,!linux,!netbsd,!openbsd,!solaris
|
||||||
|
|
||||||
package socket
|
package socket
|
||||||
|
|
||||||
|
7
vendor/golang.org/x/net/internal/socket/empty.s
generated
vendored
Normal file
7
vendor/golang.org/x/net/internal/socket/empty.s
generated
vendored
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
// 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 darwin,go1.12
|
||||||
|
|
||||||
|
// This exists solely so we can linkname in symbols from syscall.
|
2
vendor/golang.org/x/net/internal/socket/error_unix.go
generated
vendored
2
vendor/golang.org/x/net/internal/socket/error_unix.go
generated
vendored
@ -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 darwin dragonfly freebsd linux netbsd openbsd solaris
|
// +build aix darwin dragonfly freebsd linux netbsd openbsd solaris
|
||||||
|
|
||||||
package socket
|
package socket
|
||||||
|
|
||||||
|
4
vendor/golang.org/x/net/internal/socket/iovec_64bit.go
generated
vendored
4
vendor/golang.org/x/net/internal/socket/iovec_64bit.go
generated
vendored
@ -2,8 +2,8 @@
|
|||||||
// 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 arm64 amd64 ppc64 ppc64le mips64 mips64le s390x
|
// +build arm64 amd64 ppc64 ppc64le mips64 mips64le riscv64 s390x
|
||||||
// +build darwin dragonfly freebsd linux netbsd openbsd
|
// +build aix darwin dragonfly freebsd linux netbsd openbsd
|
||||||
|
|
||||||
package socket
|
package socket
|
||||||
|
|
||||||
|
2
vendor/golang.org/x/net/internal/socket/iovec_stub.go
generated
vendored
2
vendor/golang.org/x/net/internal/socket/iovec_stub.go
generated
vendored
@ -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 !darwin,!dragonfly,!freebsd,!linux,!netbsd,!openbsd,!solaris
|
// +build !aix,!darwin,!dragonfly,!freebsd,!linux,!netbsd,!openbsd,!solaris
|
||||||
|
|
||||||
package socket
|
package socket
|
||||||
|
|
||||||
|
2
vendor/golang.org/x/net/internal/socket/mmsghdr_stub.go
generated
vendored
2
vendor/golang.org/x/net/internal/socket/mmsghdr_stub.go
generated
vendored
@ -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 !linux,!netbsd
|
// +build !aix,!linux,!netbsd
|
||||||
|
|
||||||
package socket
|
package socket
|
||||||
|
|
||||||
|
2
vendor/golang.org/x/net/internal/socket/mmsghdr_unix.go
generated
vendored
2
vendor/golang.org/x/net/internal/socket/mmsghdr_unix.go
generated
vendored
@ -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 linux netbsd
|
// +build aix linux netbsd
|
||||||
|
|
||||||
package socket
|
package socket
|
||||||
|
|
||||||
|
2
vendor/golang.org/x/net/internal/socket/msghdr_bsd.go
generated
vendored
2
vendor/golang.org/x/net/internal/socket/msghdr_bsd.go
generated
vendored
@ -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 darwin dragonfly freebsd netbsd openbsd
|
// +build aix darwin dragonfly freebsd netbsd openbsd
|
||||||
|
|
||||||
package socket
|
package socket
|
||||||
|
|
||||||
|
2
vendor/golang.org/x/net/internal/socket/msghdr_bsdvar.go
generated
vendored
2
vendor/golang.org/x/net/internal/socket/msghdr_bsdvar.go
generated
vendored
@ -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 darwin dragonfly freebsd netbsd
|
// +build aix darwin dragonfly freebsd netbsd
|
||||||
|
|
||||||
package socket
|
package socket
|
||||||
|
|
||||||
|
2
vendor/golang.org/x/net/internal/socket/msghdr_linux_64bit.go
generated
vendored
2
vendor/golang.org/x/net/internal/socket/msghdr_linux_64bit.go
generated
vendored
@ -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 arm64 amd64 ppc64 ppc64le mips64 mips64le s390x
|
// +build arm64 amd64 ppc64 ppc64le mips64 mips64le riscv64 s390x
|
||||||
// +build linux
|
// +build linux
|
||||||
|
|
||||||
package socket
|
package socket
|
||||||
|
2
vendor/golang.org/x/net/internal/socket/msghdr_stub.go
generated
vendored
2
vendor/golang.org/x/net/internal/socket/msghdr_stub.go
generated
vendored
@ -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 !darwin,!dragonfly,!freebsd,!linux,!netbsd,!openbsd,!solaris
|
// +build !aix,!darwin,!dragonfly,!freebsd,!linux,!netbsd,!openbsd,!solaris
|
||||||
|
|
||||||
package socket
|
package socket
|
||||||
|
|
||||||
|
2
vendor/golang.org/x/net/internal/socket/rawconn.go
generated
vendored
2
vendor/golang.org/x/net/internal/socket/rawconn.go
generated
vendored
@ -2,8 +2,6 @@
|
|||||||
// 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 go1.9
|
|
||||||
|
|
||||||
package socket
|
package socket
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
1
vendor/golang.org/x/net/internal/socket/rawconn_mmsg.go
generated
vendored
1
vendor/golang.org/x/net/internal/socket/rawconn_mmsg.go
generated
vendored
@ -2,7 +2,6 @@
|
|||||||
// 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 go1.9
|
|
||||||
// +build linux
|
// +build linux
|
||||||
|
|
||||||
package socket
|
package socket
|
||||||
|
3
vendor/golang.org/x/net/internal/socket/rawconn_msg.go
generated
vendored
3
vendor/golang.org/x/net/internal/socket/rawconn_msg.go
generated
vendored
@ -2,8 +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 go1.9
|
// +build aix darwin dragonfly freebsd linux netbsd openbsd solaris windows
|
||||||
// +build darwin dragonfly freebsd linux netbsd openbsd solaris windows
|
|
||||||
|
|
||||||
package socket
|
package socket
|
||||||
|
|
||||||
|
7
vendor/golang.org/x/net/internal/socket/rawconn_nommsg.go
generated
vendored
7
vendor/golang.org/x/net/internal/socket/rawconn_nommsg.go
generated
vendored
@ -2,17 +2,14 @@
|
|||||||
// 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 go1.9
|
|
||||||
// +build !linux
|
// +build !linux
|
||||||
|
|
||||||
package socket
|
package socket
|
||||||
|
|
||||||
import "errors"
|
|
||||||
|
|
||||||
func (c *Conn) recvMsgs(ms []Message, flags int) (int, error) {
|
func (c *Conn) recvMsgs(ms []Message, flags int) (int, error) {
|
||||||
return 0, errors.New("not implemented")
|
return 0, errNotImplemented
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *Conn) sendMsgs(ms []Message, flags int) (int, error) {
|
func (c *Conn) sendMsgs(ms []Message, flags int) (int, error) {
|
||||||
return 0, errors.New("not implemented")
|
return 0, errNotImplemented
|
||||||
}
|
}
|
||||||
|
9
vendor/golang.org/x/net/internal/socket/rawconn_nomsg.go
generated
vendored
9
vendor/golang.org/x/net/internal/socket/rawconn_nomsg.go
generated
vendored
@ -2,17 +2,14 @@
|
|||||||
// 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 go1.9
|
// +build !aix,!darwin,!dragonfly,!freebsd,!linux,!netbsd,!openbsd,!solaris,!windows
|
||||||
// +build !darwin,!dragonfly,!freebsd,!linux,!netbsd,!openbsd,!solaris,!windows
|
|
||||||
|
|
||||||
package socket
|
package socket
|
||||||
|
|
||||||
import "errors"
|
|
||||||
|
|
||||||
func (c *Conn) recvMsg(m *Message, flags int) error {
|
func (c *Conn) recvMsg(m *Message, flags int) error {
|
||||||
return errors.New("not implemented")
|
return errNotImplemented
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *Conn) sendMsg(m *Message, flags int) error {
|
func (c *Conn) sendMsg(m *Message, flags int) error {
|
||||||
return errors.New("not implemented")
|
return errNotImplemented
|
||||||
}
|
}
|
||||||
|
25
vendor/golang.org/x/net/internal/socket/rawconn_stub.go
generated
vendored
25
vendor/golang.org/x/net/internal/socket/rawconn_stub.go
generated
vendored
@ -1,25 +0,0 @@
|
|||||||
// 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 !go1.9
|
|
||||||
|
|
||||||
package socket
|
|
||||||
|
|
||||||
import "errors"
|
|
||||||
|
|
||||||
func (c *Conn) recvMsg(m *Message, flags int) error {
|
|
||||||
return errors.New("not implemented")
|
|
||||||
}
|
|
||||||
|
|
||||||
func (c *Conn) sendMsg(m *Message, flags int) error {
|
|
||||||
return errors.New("not implemented")
|
|
||||||
}
|
|
||||||
|
|
||||||
func (c *Conn) recvMsgs(ms []Message, flags int) (int, error) {
|
|
||||||
return 0, errors.New("not implemented")
|
|
||||||
}
|
|
||||||
|
|
||||||
func (c *Conn) sendMsgs(ms []Message, flags int) (int, error) {
|
|
||||||
return 0, errors.New("not implemented")
|
|
||||||
}
|
|
62
vendor/golang.org/x/net/internal/socket/reflect.go
generated
vendored
62
vendor/golang.org/x/net/internal/socket/reflect.go
generated
vendored
@ -1,62 +0,0 @@
|
|||||||
// 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 !go1.9
|
|
||||||
|
|
||||||
package socket
|
|
||||||
|
|
||||||
import (
|
|
||||||
"errors"
|
|
||||||
"net"
|
|
||||||
"os"
|
|
||||||
"reflect"
|
|
||||||
"runtime"
|
|
||||||
)
|
|
||||||
|
|
||||||
// A Conn represents a raw connection.
|
|
||||||
type Conn struct {
|
|
||||||
c net.Conn
|
|
||||||
}
|
|
||||||
|
|
||||||
// NewConn returns a new raw connection.
|
|
||||||
func NewConn(c net.Conn) (*Conn, error) {
|
|
||||||
return &Conn{c: c}, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func (o *Option) get(c *Conn, b []byte) (int, error) {
|
|
||||||
s, err := socketOf(c.c)
|
|
||||||
if err != nil {
|
|
||||||
return 0, err
|
|
||||||
}
|
|
||||||
n, err := getsockopt(s, o.Level, o.Name, b)
|
|
||||||
return n, os.NewSyscallError("getsockopt", err)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (o *Option) set(c *Conn, b []byte) error {
|
|
||||||
s, err := socketOf(c.c)
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
return os.NewSyscallError("setsockopt", setsockopt(s, o.Level, o.Name, b))
|
|
||||||
}
|
|
||||||
|
|
||||||
func socketOf(c net.Conn) (uintptr, error) {
|
|
||||||
switch c.(type) {
|
|
||||||
case *net.TCPConn, *net.UDPConn, *net.IPConn:
|
|
||||||
v := reflect.ValueOf(c)
|
|
||||||
switch e := v.Elem(); e.Kind() {
|
|
||||||
case reflect.Struct:
|
|
||||||
fd := e.FieldByName("conn").FieldByName("fd")
|
|
||||||
switch e := fd.Elem(); e.Kind() {
|
|
||||||
case reflect.Struct:
|
|
||||||
sysfd := e.FieldByName("sysfd")
|
|
||||||
if runtime.GOOS == "windows" {
|
|
||||||
return uintptr(sysfd.Uint()), nil
|
|
||||||
}
|
|
||||||
return uintptr(sysfd.Int()), nil
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return 0, errors.New("invalid type")
|
|
||||||
}
|
|
3
vendor/golang.org/x/net/internal/socket/socket.go
generated
vendored
3
vendor/golang.org/x/net/internal/socket/socket.go
generated
vendored
@ -9,9 +9,12 @@ package socket // import "golang.org/x/net/internal/socket"
|
|||||||
import (
|
import (
|
||||||
"errors"
|
"errors"
|
||||||
"net"
|
"net"
|
||||||
|
"runtime"
|
||||||
"unsafe"
|
"unsafe"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
var errNotImplemented = errors.New("not implemented on " + runtime.GOOS + "/" + runtime.GOARCH)
|
||||||
|
|
||||||
// An Option represents a sticky socket option.
|
// An Option represents a sticky socket option.
|
||||||
type Option struct {
|
type Option struct {
|
||||||
Level int // level
|
Level int // level
|
||||||
|
2
vendor/golang.org/x/net/internal/socket/sys.go
generated
vendored
2
vendor/golang.org/x/net/internal/socket/sys.go
generated
vendored
@ -29,5 +29,5 @@ func init() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func roundup(l int) int {
|
func roundup(l int) int {
|
||||||
return (l + kernelAlign - 1) & ^(kernelAlign - 1)
|
return (l + kernelAlign - 1) &^ (kernelAlign - 1)
|
||||||
}
|
}
|
||||||
|
8
vendor/golang.org/x/net/internal/socket/sys_bsd.go
generated
vendored
8
vendor/golang.org/x/net/internal/socket/sys_bsd.go
generated
vendored
@ -2,16 +2,14 @@
|
|||||||
// 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 darwin dragonfly freebsd openbsd
|
// +build aix darwin dragonfly freebsd openbsd
|
||||||
|
|
||||||
package socket
|
package socket
|
||||||
|
|
||||||
import "errors"
|
|
||||||
|
|
||||||
func recvmmsg(s uintptr, hs []mmsghdr, flags int) (int, error) {
|
func recvmmsg(s uintptr, hs []mmsghdr, flags int) (int, error) {
|
||||||
return 0, errors.New("not implemented")
|
return 0, errNotImplemented
|
||||||
}
|
}
|
||||||
|
|
||||||
func sendmmsg(s uintptr, hs []mmsghdr, flags int) (int, error) {
|
func sendmmsg(s uintptr, hs []mmsghdr, flags int) (int, error) {
|
||||||
return 0, errors.New("not implemented")
|
return 0, errNotImplemented
|
||||||
}
|
}
|
||||||
|
13
vendor/golang.org/x/net/internal/socket/sys_bsdvar.go
generated
vendored
13
vendor/golang.org/x/net/internal/socket/sys_bsdvar.go
generated
vendored
@ -2,13 +2,22 @@
|
|||||||
// 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 freebsd netbsd openbsd
|
// +build aix freebsd netbsd openbsd
|
||||||
|
|
||||||
package socket
|
package socket
|
||||||
|
|
||||||
import "unsafe"
|
import (
|
||||||
|
"runtime"
|
||||||
|
"unsafe"
|
||||||
|
)
|
||||||
|
|
||||||
func probeProtocolStack() int {
|
func probeProtocolStack() int {
|
||||||
|
if (runtime.GOOS == "netbsd" || runtime.GOOS == "openbsd") && runtime.GOARCH == "arm" {
|
||||||
|
return 8
|
||||||
|
}
|
||||||
|
if runtime.GOOS == "aix" {
|
||||||
|
return 1
|
||||||
|
}
|
||||||
var p uintptr
|
var p uintptr
|
||||||
return int(unsafe.Sizeof(p))
|
return int(unsafe.Sizeof(p))
|
||||||
}
|
}
|
||||||
|
17
vendor/golang.org/x/net/internal/socket/sys_const_unix.go
generated
vendored
Normal file
17
vendor/golang.org/x/net/internal/socket/sys_const_unix.go
generated
vendored
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
// Copyright 2019 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 aix darwin dragonfly freebsd linux netbsd openbsd solaris
|
||||||
|
|
||||||
|
package socket
|
||||||
|
|
||||||
|
import "golang.org/x/sys/unix"
|
||||||
|
|
||||||
|
const (
|
||||||
|
sysAF_UNSPEC = unix.AF_UNSPEC
|
||||||
|
sysAF_INET = unix.AF_INET
|
||||||
|
sysAF_INET6 = unix.AF_INET6
|
||||||
|
|
||||||
|
sysSOCK_RAW = unix.SOCK_RAW
|
||||||
|
)
|
33
vendor/golang.org/x/net/internal/socket/sys_go1_11_darwin.go
generated
vendored
Normal file
33
vendor/golang.org/x/net/internal/socket/sys_go1_11_darwin.go
generated
vendored
Normal file
@ -0,0 +1,33 @@
|
|||||||
|
// 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.12
|
||||||
|
|
||||||
|
package socket
|
||||||
|
|
||||||
|
import (
|
||||||
|
"syscall"
|
||||||
|
"unsafe"
|
||||||
|
)
|
||||||
|
|
||||||
|
func getsockopt(s uintptr, level, name int, b []byte) (int, error) {
|
||||||
|
l := uint32(len(b))
|
||||||
|
_, _, errno := syscall.Syscall6(syscall.SYS_GETSOCKOPT, s, uintptr(level), uintptr(name), uintptr(unsafe.Pointer(&b[0])), uintptr(unsafe.Pointer(&l)), 0)
|
||||||
|
return int(l), errnoErr(errno)
|
||||||
|
}
|
||||||
|
|
||||||
|
func setsockopt(s uintptr, level, name int, b []byte) error {
|
||||||
|
_, _, errno := syscall.Syscall6(syscall.SYS_SETSOCKOPT, s, uintptr(level), uintptr(name), uintptr(unsafe.Pointer(&b[0])), uintptr(len(b)), 0)
|
||||||
|
return errnoErr(errno)
|
||||||
|
}
|
||||||
|
|
||||||
|
func recvmsg(s uintptr, h *msghdr, flags int) (int, error) {
|
||||||
|
n, _, errno := syscall.Syscall(syscall.SYS_RECVMSG, s, uintptr(unsafe.Pointer(h)), uintptr(flags))
|
||||||
|
return int(n), errnoErr(errno)
|
||||||
|
}
|
||||||
|
|
||||||
|
func sendmsg(s uintptr, h *msghdr, flags int) (int, error) {
|
||||||
|
n, _, errno := syscall.Syscall(syscall.SYS_SENDMSG, s, uintptr(unsafe.Pointer(h)), uintptr(flags))
|
||||||
|
return int(n), errnoErr(errno)
|
||||||
|
}
|
42
vendor/golang.org/x/net/internal/socket/sys_linkname.go
generated
vendored
Normal file
42
vendor/golang.org/x/net/internal/socket/sys_linkname.go
generated
vendored
Normal file
@ -0,0 +1,42 @@
|
|||||||
|
// 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 aix go1.12,darwin
|
||||||
|
|
||||||
|
package socket
|
||||||
|
|
||||||
|
import (
|
||||||
|
"syscall"
|
||||||
|
"unsafe"
|
||||||
|
)
|
||||||
|
|
||||||
|
//go:linkname syscall_getsockopt syscall.getsockopt
|
||||||
|
func syscall_getsockopt(s int, level int, name int, val unsafe.Pointer, vallen *uint32) error
|
||||||
|
|
||||||
|
func getsockopt(s uintptr, level, name int, b []byte) (int, error) {
|
||||||
|
l := uint32(len(b))
|
||||||
|
err := syscall_getsockopt(int(s), level, name, unsafe.Pointer(&b[0]), &l)
|
||||||
|
return int(l), err
|
||||||
|
}
|
||||||
|
|
||||||
|
//go:linkname syscall_setsockopt syscall.setsockopt
|
||||||
|
func syscall_setsockopt(s int, level int, name int, val unsafe.Pointer, vallen uintptr) error
|
||||||
|
|
||||||
|
func setsockopt(s uintptr, level, name int, b []byte) error {
|
||||||
|
return syscall_setsockopt(int(s), level, name, unsafe.Pointer(&b[0]), uintptr(len(b)))
|
||||||
|
}
|
||||||
|
|
||||||
|
//go:linkname syscall_recvmsg syscall.recvmsg
|
||||||
|
func syscall_recvmsg(s int, msg *syscall.Msghdr, flags int) (n int, err error)
|
||||||
|
|
||||||
|
func recvmsg(s uintptr, h *msghdr, flags int) (int, error) {
|
||||||
|
return syscall_recvmsg(int(s), (*syscall.Msghdr)(unsafe.Pointer(h)), flags)
|
||||||
|
}
|
||||||
|
|
||||||
|
//go:linkname syscall_sendmsg syscall.sendmsg
|
||||||
|
func syscall_sendmsg(s int, msg *syscall.Msghdr, flags int) (n int, err error)
|
||||||
|
|
||||||
|
func sendmsg(s uintptr, h *msghdr, flags int) (int, error) {
|
||||||
|
return syscall_sendmsg(int(s), (*syscall.Msghdr)(unsafe.Pointer(h)), flags)
|
||||||
|
}
|
12
vendor/golang.org/x/net/internal/socket/sys_linux_riscv64.go
generated
vendored
Normal file
12
vendor/golang.org/x/net/internal/socket/sys_linux_riscv64.go
generated
vendored
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
// Copyright 2019 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 riscv64
|
||||||
|
|
||||||
|
package socket
|
||||||
|
|
||||||
|
const (
|
||||||
|
sysRECVMMSG = 0xf3
|
||||||
|
sysSENDMMSG = 0x10d
|
||||||
|
)
|
45
vendor/golang.org/x/net/internal/socket/sys_posix.go
generated
vendored
45
vendor/golang.org/x/net/internal/socket/sys_posix.go
generated
vendored
@ -2,8 +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 go1.9
|
// +build aix darwin dragonfly freebsd linux netbsd openbsd solaris windows
|
||||||
// +build darwin dragonfly freebsd linux netbsd openbsd solaris windows
|
|
||||||
|
|
||||||
package socket
|
package socket
|
||||||
|
|
||||||
@ -34,7 +33,7 @@ func marshalSockaddr(ip net.IP, port int, zone string) []byte {
|
|||||||
if ip4 := ip.To4(); ip4 != nil {
|
if ip4 := ip.To4(); ip4 != nil {
|
||||||
b := make([]byte, sizeofSockaddrInet)
|
b := make([]byte, sizeofSockaddrInet)
|
||||||
switch runtime.GOOS {
|
switch runtime.GOOS {
|
||||||
case "android", "linux", "solaris", "windows":
|
case "android", "illumos", "linux", "solaris", "windows":
|
||||||
NativeEndian.PutUint16(b[:2], uint16(sysAF_INET))
|
NativeEndian.PutUint16(b[:2], uint16(sysAF_INET))
|
||||||
default:
|
default:
|
||||||
b[0] = sizeofSockaddrInet
|
b[0] = sizeofSockaddrInet
|
||||||
@ -47,7 +46,7 @@ func marshalSockaddr(ip net.IP, port int, zone string) []byte {
|
|||||||
if ip6 := ip.To16(); ip6 != nil && ip.To4() == nil {
|
if ip6 := ip.To16(); ip6 != nil && ip.To4() == nil {
|
||||||
b := make([]byte, sizeofSockaddrInet6)
|
b := make([]byte, sizeofSockaddrInet6)
|
||||||
switch runtime.GOOS {
|
switch runtime.GOOS {
|
||||||
case "android", "linux", "solaris", "windows":
|
case "android", "illumos", "linux", "solaris", "windows":
|
||||||
NativeEndian.PutUint16(b[:2], uint16(sysAF_INET6))
|
NativeEndian.PutUint16(b[:2], uint16(sysAF_INET6))
|
||||||
default:
|
default:
|
||||||
b[0] = sizeofSockaddrInet6
|
b[0] = sizeofSockaddrInet6
|
||||||
@ -69,7 +68,7 @@ func parseInetAddr(b []byte, network string) (net.Addr, error) {
|
|||||||
}
|
}
|
||||||
var af int
|
var af int
|
||||||
switch runtime.GOOS {
|
switch runtime.GOOS {
|
||||||
case "android", "linux", "solaris", "windows":
|
case "android", "illumos", "linux", "solaris", "windows":
|
||||||
af = int(NativeEndian.Uint16(b[:2]))
|
af = int(NativeEndian.Uint16(b[:2]))
|
||||||
default:
|
default:
|
||||||
af = int(b[1])
|
af = int(b[1])
|
||||||
@ -121,18 +120,21 @@ var zoneCache = ipv6ZoneCache{
|
|||||||
toName: make(map[int]string),
|
toName: make(map[int]string),
|
||||||
}
|
}
|
||||||
|
|
||||||
func (zc *ipv6ZoneCache) update(ift []net.Interface) {
|
// update refreshes the network interface information if the cache was last
|
||||||
|
// updated more than 1 minute ago, or if force is set. It returns whether the
|
||||||
|
// cache was updated.
|
||||||
|
func (zc *ipv6ZoneCache) update(ift []net.Interface, force bool) (updated bool) {
|
||||||
zc.Lock()
|
zc.Lock()
|
||||||
defer zc.Unlock()
|
defer zc.Unlock()
|
||||||
now := time.Now()
|
now := time.Now()
|
||||||
if zc.lastFetched.After(now.Add(-60 * time.Second)) {
|
if !force && zc.lastFetched.After(now.Add(-60*time.Second)) {
|
||||||
return
|
return false
|
||||||
}
|
}
|
||||||
zc.lastFetched = now
|
zc.lastFetched = now
|
||||||
if len(ift) == 0 {
|
if len(ift) == 0 {
|
||||||
var err error
|
var err error
|
||||||
if ift, err = net.Interfaces(); err != nil {
|
if ift, err = net.Interfaces(); err != nil {
|
||||||
return
|
return false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
zc.toIndex = make(map[string]int, len(ift))
|
zc.toIndex = make(map[string]int, len(ift))
|
||||||
@ -143,25 +145,38 @@ func (zc *ipv6ZoneCache) update(ift []net.Interface) {
|
|||||||
zc.toName[ifi.Index] = ifi.Name
|
zc.toName[ifi.Index] = ifi.Name
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
func (zc *ipv6ZoneCache) name(zone int) string {
|
func (zc *ipv6ZoneCache) name(zone int) string {
|
||||||
zoneCache.update(nil)
|
updated := zoneCache.update(nil, false)
|
||||||
zoneCache.RLock()
|
zoneCache.RLock()
|
||||||
defer zoneCache.RUnlock()
|
|
||||||
name, ok := zoneCache.toName[zone]
|
name, ok := zoneCache.toName[zone]
|
||||||
if !ok {
|
zoneCache.RUnlock()
|
||||||
|
if !ok && !updated {
|
||||||
|
zoneCache.update(nil, true)
|
||||||
|
zoneCache.RLock()
|
||||||
|
name, ok = zoneCache.toName[zone]
|
||||||
|
zoneCache.RUnlock()
|
||||||
|
}
|
||||||
|
if !ok { // last resort
|
||||||
name = strconv.Itoa(zone)
|
name = strconv.Itoa(zone)
|
||||||
}
|
}
|
||||||
return name
|
return name
|
||||||
}
|
}
|
||||||
|
|
||||||
func (zc *ipv6ZoneCache) index(zone string) int {
|
func (zc *ipv6ZoneCache) index(zone string) int {
|
||||||
zoneCache.update(nil)
|
updated := zoneCache.update(nil, false)
|
||||||
zoneCache.RLock()
|
zoneCache.RLock()
|
||||||
defer zoneCache.RUnlock()
|
|
||||||
index, ok := zoneCache.toIndex[zone]
|
index, ok := zoneCache.toIndex[zone]
|
||||||
if !ok {
|
zoneCache.RUnlock()
|
||||||
|
if !ok && !updated {
|
||||||
|
zoneCache.update(nil, true)
|
||||||
|
zoneCache.RLock()
|
||||||
|
index, ok = zoneCache.toIndex[zone]
|
||||||
|
zoneCache.RUnlock()
|
||||||
|
}
|
||||||
|
if !ok { // last resort
|
||||||
index, _ = strconv.Atoi(zone)
|
index, _ = strconv.Atoi(zone)
|
||||||
}
|
}
|
||||||
return index
|
return index
|
||||||
|
5
vendor/golang.org/x/net/internal/socket/sys_solaris.go
generated
vendored
5
vendor/golang.org/x/net/internal/socket/sys_solaris.go
generated
vendored
@ -5,7 +5,6 @@
|
|||||||
package socket
|
package socket
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"errors"
|
|
||||||
"runtime"
|
"runtime"
|
||||||
"syscall"
|
"syscall"
|
||||||
"unsafe"
|
"unsafe"
|
||||||
@ -63,9 +62,9 @@ func sendmsg(s uintptr, h *msghdr, flags int) (int, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func recvmmsg(s uintptr, hs []mmsghdr, flags int) (int, error) {
|
func recvmmsg(s uintptr, hs []mmsghdr, flags int) (int, error) {
|
||||||
return 0, errors.New("not implemented")
|
return 0, errNotImplemented
|
||||||
}
|
}
|
||||||
|
|
||||||
func sendmmsg(s uintptr, hs []mmsghdr, flags int) (int, error) {
|
func sendmmsg(s uintptr, hs []mmsghdr, flags int) (int, error) {
|
||||||
return 0, errors.New("not implemented")
|
return 0, errNotImplemented
|
||||||
}
|
}
|
||||||
|
17
vendor/golang.org/x/net/internal/socket/sys_stub.go
generated
vendored
17
vendor/golang.org/x/net/internal/socket/sys_stub.go
generated
vendored
@ -2,12 +2,11 @@
|
|||||||
// 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 !darwin,!dragonfly,!freebsd,!linux,!netbsd,!openbsd,!solaris,!windows
|
// +build !aix,!darwin,!dragonfly,!freebsd,!linux,!netbsd,!openbsd,!solaris,!windows
|
||||||
|
|
||||||
package socket
|
package socket
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"errors"
|
|
||||||
"net"
|
"net"
|
||||||
"runtime"
|
"runtime"
|
||||||
"unsafe"
|
"unsafe"
|
||||||
@ -36,29 +35,29 @@ func marshalInetAddr(ip net.IP, port int, zone string) []byte {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func parseInetAddr(b []byte, network string) (net.Addr, error) {
|
func parseInetAddr(b []byte, network string) (net.Addr, error) {
|
||||||
return nil, errors.New("not implemented")
|
return nil, errNotImplemented
|
||||||
}
|
}
|
||||||
|
|
||||||
func getsockopt(s uintptr, level, name int, b []byte) (int, error) {
|
func getsockopt(s uintptr, level, name int, b []byte) (int, error) {
|
||||||
return 0, errors.New("not implemented")
|
return 0, errNotImplemented
|
||||||
}
|
}
|
||||||
|
|
||||||
func setsockopt(s uintptr, level, name int, b []byte) error {
|
func setsockopt(s uintptr, level, name int, b []byte) error {
|
||||||
return errors.New("not implemented")
|
return errNotImplemented
|
||||||
}
|
}
|
||||||
|
|
||||||
func recvmsg(s uintptr, h *msghdr, flags int) (int, error) {
|
func recvmsg(s uintptr, h *msghdr, flags int) (int, error) {
|
||||||
return 0, errors.New("not implemented")
|
return 0, errNotImplemented
|
||||||
}
|
}
|
||||||
|
|
||||||
func sendmsg(s uintptr, h *msghdr, flags int) (int, error) {
|
func sendmsg(s uintptr, h *msghdr, flags int) (int, error) {
|
||||||
return 0, errors.New("not implemented")
|
return 0, errNotImplemented
|
||||||
}
|
}
|
||||||
|
|
||||||
func recvmmsg(s uintptr, hs []mmsghdr, flags int) (int, error) {
|
func recvmmsg(s uintptr, hs []mmsghdr, flags int) (int, error) {
|
||||||
return 0, errors.New("not implemented")
|
return 0, errNotImplemented
|
||||||
}
|
}
|
||||||
|
|
||||||
func sendmmsg(s uintptr, hs []mmsghdr, flags int) (int, error) {
|
func sendmmsg(s uintptr, hs []mmsghdr, flags int) (int, error) {
|
||||||
return 0, errors.New("not implemented")
|
return 0, errNotImplemented
|
||||||
}
|
}
|
||||||
|
2
vendor/golang.org/x/net/internal/socket/sys_unix.go
generated
vendored
2
vendor/golang.org/x/net/internal/socket/sys_unix.go
generated
vendored
@ -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 darwin dragonfly freebsd linux,!s390x,!386 netbsd openbsd
|
// +build dragonfly freebsd linux,!s390x,!386 netbsd openbsd
|
||||||
|
|
||||||
package socket
|
package socket
|
||||||
|
|
||||||
|
19
vendor/golang.org/x/net/internal/socket/sys_windows.go
generated
vendored
19
vendor/golang.org/x/net/internal/socket/sys_windows.go
generated
vendored
@ -5,9 +5,10 @@
|
|||||||
package socket
|
package socket
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"errors"
|
|
||||||
"syscall"
|
"syscall"
|
||||||
"unsafe"
|
"unsafe"
|
||||||
|
|
||||||
|
"golang.org/x/sys/windows"
|
||||||
)
|
)
|
||||||
|
|
||||||
func probeProtocolStack() int {
|
func probeProtocolStack() int {
|
||||||
@ -16,11 +17,11 @@ func probeProtocolStack() int {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const (
|
const (
|
||||||
sysAF_UNSPEC = 0x0
|
sysAF_UNSPEC = windows.AF_UNSPEC
|
||||||
sysAF_INET = 0x2
|
sysAF_INET = windows.AF_INET
|
||||||
sysAF_INET6 = 0x17
|
sysAF_INET6 = windows.AF_INET6
|
||||||
|
|
||||||
sysSOCK_RAW = 0x3
|
sysSOCK_RAW = windows.SOCK_RAW
|
||||||
)
|
)
|
||||||
|
|
||||||
type sockaddrInet struct {
|
type sockaddrInet struct {
|
||||||
@ -54,17 +55,17 @@ func setsockopt(s uintptr, level, name int, b []byte) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func recvmsg(s uintptr, h *msghdr, flags int) (int, error) {
|
func recvmsg(s uintptr, h *msghdr, flags int) (int, error) {
|
||||||
return 0, errors.New("not implemented")
|
return 0, errNotImplemented
|
||||||
}
|
}
|
||||||
|
|
||||||
func sendmsg(s uintptr, h *msghdr, flags int) (int, error) {
|
func sendmsg(s uintptr, h *msghdr, flags int) (int, error) {
|
||||||
return 0, errors.New("not implemented")
|
return 0, errNotImplemented
|
||||||
}
|
}
|
||||||
|
|
||||||
func recvmmsg(s uintptr, hs []mmsghdr, flags int) (int, error) {
|
func recvmmsg(s uintptr, hs []mmsghdr, flags int) (int, error) {
|
||||||
return 0, errors.New("not implemented")
|
return 0, errNotImplemented
|
||||||
}
|
}
|
||||||
|
|
||||||
func sendmmsg(s uintptr, hs []mmsghdr, flags int) (int, error) {
|
func sendmmsg(s uintptr, hs []mmsghdr, flags int) (int, error) {
|
||||||
return 0, errors.New("not implemented")
|
return 0, errNotImplemented
|
||||||
}
|
}
|
||||||
|
61
vendor/golang.org/x/net/internal/socket/zsys_aix_ppc64.go
generated
vendored
Normal file
61
vendor/golang.org/x/net/internal/socket/zsys_aix_ppc64.go
generated
vendored
Normal file
@ -0,0 +1,61 @@
|
|||||||
|
// Code generated by cmd/cgo -godefs; DO NOT EDIT.
|
||||||
|
// cgo -godefs defs_aix.go
|
||||||
|
|
||||||
|
// Added for go1.11 compatibility
|
||||||
|
// +build aix
|
||||||
|
|
||||||
|
package socket
|
||||||
|
|
||||||
|
type iovec struct {
|
||||||
|
Base *byte
|
||||||
|
Len uint64
|
||||||
|
}
|
||||||
|
|
||||||
|
type msghdr struct {
|
||||||
|
Name *byte
|
||||||
|
Namelen uint32
|
||||||
|
Iov *iovec
|
||||||
|
Iovlen int32
|
||||||
|
Control *byte
|
||||||
|
Controllen uint32
|
||||||
|
Flags int32
|
||||||
|
}
|
||||||
|
|
||||||
|
type mmsghdr struct {
|
||||||
|
Hdr msghdr
|
||||||
|
Len uint32
|
||||||
|
Pad_cgo_0 [4]byte
|
||||||
|
}
|
||||||
|
|
||||||
|
type cmsghdr struct {
|
||||||
|
Len uint32
|
||||||
|
Level int32
|
||||||
|
Type int32
|
||||||
|
}
|
||||||
|
|
||||||
|
type sockaddrInet struct {
|
||||||
|
Len uint8
|
||||||
|
Family uint8
|
||||||
|
Port uint16
|
||||||
|
Addr [4]byte /* in_addr */
|
||||||
|
Zero [8]uint8
|
||||||
|
}
|
||||||
|
|
||||||
|
type sockaddrInet6 struct {
|
||||||
|
Len uint8
|
||||||
|
Family uint8
|
||||||
|
Port uint16
|
||||||
|
Flowinfo uint32
|
||||||
|
Addr [16]byte /* in6_addr */
|
||||||
|
Scope_id uint32
|
||||||
|
}
|
||||||
|
|
||||||
|
const (
|
||||||
|
sizeofIovec = 0x10
|
||||||
|
sizeofMsghdr = 0x30
|
||||||
|
sizeofMmsghdr = 0x38
|
||||||
|
sizeofCmsghdr = 0xc
|
||||||
|
|
||||||
|
sizeofSockaddrInet = 0x10
|
||||||
|
sizeofSockaddrInet6 = 0x1c
|
||||||
|
)
|
10
vendor/golang.org/x/net/internal/socket/zsys_darwin_386.go
generated
vendored
10
vendor/golang.org/x/net/internal/socket/zsys_darwin_386.go
generated
vendored
@ -1,16 +1,8 @@
|
|||||||
// Created by cgo -godefs - DO NOT EDIT
|
// Code generated by cmd/cgo -godefs; DO NOT EDIT.
|
||||||
// cgo -godefs defs_darwin.go
|
// cgo -godefs defs_darwin.go
|
||||||
|
|
||||||
package socket
|
package socket
|
||||||
|
|
||||||
const (
|
|
||||||
sysAF_UNSPEC = 0x0
|
|
||||||
sysAF_INET = 0x2
|
|
||||||
sysAF_INET6 = 0x1e
|
|
||||||
|
|
||||||
sysSOCK_RAW = 0x3
|
|
||||||
)
|
|
||||||
|
|
||||||
type iovec struct {
|
type iovec struct {
|
||||||
Base *byte
|
Base *byte
|
||||||
Len uint32
|
Len uint32
|
||||||
|
10
vendor/golang.org/x/net/internal/socket/zsys_darwin_amd64.go
generated
vendored
10
vendor/golang.org/x/net/internal/socket/zsys_darwin_amd64.go
generated
vendored
@ -1,16 +1,8 @@
|
|||||||
// Created by cgo -godefs - DO NOT EDIT
|
// Code generated by cmd/cgo -godefs; DO NOT EDIT.
|
||||||
// cgo -godefs defs_darwin.go
|
// cgo -godefs defs_darwin.go
|
||||||
|
|
||||||
package socket
|
package socket
|
||||||
|
|
||||||
const (
|
|
||||||
sysAF_UNSPEC = 0x0
|
|
||||||
sysAF_INET = 0x2
|
|
||||||
sysAF_INET6 = 0x1e
|
|
||||||
|
|
||||||
sysSOCK_RAW = 0x3
|
|
||||||
)
|
|
||||||
|
|
||||||
type iovec struct {
|
type iovec struct {
|
||||||
Base *byte
|
Base *byte
|
||||||
Len uint64
|
Len uint64
|
||||||
|
10
vendor/golang.org/x/net/internal/socket/zsys_darwin_arm.go
generated
vendored
10
vendor/golang.org/x/net/internal/socket/zsys_darwin_arm.go
generated
vendored
@ -1,16 +1,8 @@
|
|||||||
// Created by cgo -godefs - DO NOT EDIT
|
// Code generated by cmd/cgo -godefs; DO NOT EDIT.
|
||||||
// cgo -godefs defs_darwin.go
|
// cgo -godefs defs_darwin.go
|
||||||
|
|
||||||
package socket
|
package socket
|
||||||
|
|
||||||
const (
|
|
||||||
sysAF_UNSPEC = 0x0
|
|
||||||
sysAF_INET = 0x2
|
|
||||||
sysAF_INET6 = 0x1e
|
|
||||||
|
|
||||||
sysSOCK_RAW = 0x3
|
|
||||||
)
|
|
||||||
|
|
||||||
type iovec struct {
|
type iovec struct {
|
||||||
Base *byte
|
Base *byte
|
||||||
Len uint32
|
Len uint32
|
||||||
|
10
vendor/golang.org/x/net/internal/socket/zsys_darwin_arm64.go
generated
vendored
10
vendor/golang.org/x/net/internal/socket/zsys_darwin_arm64.go
generated
vendored
@ -1,16 +1,8 @@
|
|||||||
// Created by cgo -godefs - DO NOT EDIT
|
// Code generated by cmd/cgo -godefs; DO NOT EDIT.
|
||||||
// cgo -godefs defs_darwin.go
|
// cgo -godefs defs_darwin.go
|
||||||
|
|
||||||
package socket
|
package socket
|
||||||
|
|
||||||
const (
|
|
||||||
sysAF_UNSPEC = 0x0
|
|
||||||
sysAF_INET = 0x2
|
|
||||||
sysAF_INET6 = 0x1e
|
|
||||||
|
|
||||||
sysSOCK_RAW = 0x3
|
|
||||||
)
|
|
||||||
|
|
||||||
type iovec struct {
|
type iovec struct {
|
||||||
Base *byte
|
Base *byte
|
||||||
Len uint64
|
Len uint64
|
||||||
|
10
vendor/golang.org/x/net/internal/socket/zsys_dragonfly_amd64.go
generated
vendored
10
vendor/golang.org/x/net/internal/socket/zsys_dragonfly_amd64.go
generated
vendored
@ -1,16 +1,8 @@
|
|||||||
// Created by cgo -godefs - DO NOT EDIT
|
// Code generated by cmd/cgo -godefs; DO NOT EDIT.
|
||||||
// cgo -godefs defs_dragonfly.go
|
// cgo -godefs defs_dragonfly.go
|
||||||
|
|
||||||
package socket
|
package socket
|
||||||
|
|
||||||
const (
|
|
||||||
sysAF_UNSPEC = 0x0
|
|
||||||
sysAF_INET = 0x2
|
|
||||||
sysAF_INET6 = 0x1c
|
|
||||||
|
|
||||||
sysSOCK_RAW = 0x3
|
|
||||||
)
|
|
||||||
|
|
||||||
type iovec struct {
|
type iovec struct {
|
||||||
Base *byte
|
Base *byte
|
||||||
Len uint64
|
Len uint64
|
||||||
|
10
vendor/golang.org/x/net/internal/socket/zsys_freebsd_386.go
generated
vendored
10
vendor/golang.org/x/net/internal/socket/zsys_freebsd_386.go
generated
vendored
@ -1,16 +1,8 @@
|
|||||||
// Created by cgo -godefs - DO NOT EDIT
|
// Code generated by cmd/cgo -godefs; DO NOT EDIT.
|
||||||
// cgo -godefs defs_freebsd.go
|
// cgo -godefs defs_freebsd.go
|
||||||
|
|
||||||
package socket
|
package socket
|
||||||
|
|
||||||
const (
|
|
||||||
sysAF_UNSPEC = 0x0
|
|
||||||
sysAF_INET = 0x2
|
|
||||||
sysAF_INET6 = 0x1c
|
|
||||||
|
|
||||||
sysSOCK_RAW = 0x3
|
|
||||||
)
|
|
||||||
|
|
||||||
type iovec struct {
|
type iovec struct {
|
||||||
Base *byte
|
Base *byte
|
||||||
Len uint32
|
Len uint32
|
||||||
|
10
vendor/golang.org/x/net/internal/socket/zsys_freebsd_amd64.go
generated
vendored
10
vendor/golang.org/x/net/internal/socket/zsys_freebsd_amd64.go
generated
vendored
@ -1,16 +1,8 @@
|
|||||||
// Created by cgo -godefs - DO NOT EDIT
|
// Code generated by cmd/cgo -godefs; DO NOT EDIT.
|
||||||
// cgo -godefs defs_freebsd.go
|
// cgo -godefs defs_freebsd.go
|
||||||
|
|
||||||
package socket
|
package socket
|
||||||
|
|
||||||
const (
|
|
||||||
sysAF_UNSPEC = 0x0
|
|
||||||
sysAF_INET = 0x2
|
|
||||||
sysAF_INET6 = 0x1c
|
|
||||||
|
|
||||||
sysSOCK_RAW = 0x3
|
|
||||||
)
|
|
||||||
|
|
||||||
type iovec struct {
|
type iovec struct {
|
||||||
Base *byte
|
Base *byte
|
||||||
Len uint64
|
Len uint64
|
||||||
|
10
vendor/golang.org/x/net/internal/socket/zsys_freebsd_arm.go
generated
vendored
10
vendor/golang.org/x/net/internal/socket/zsys_freebsd_arm.go
generated
vendored
@ -1,16 +1,8 @@
|
|||||||
// Created by cgo -godefs - DO NOT EDIT
|
// Code generated by cmd/cgo -godefs; DO NOT EDIT.
|
||||||
// cgo -godefs defs_freebsd.go
|
// cgo -godefs defs_freebsd.go
|
||||||
|
|
||||||
package socket
|
package socket
|
||||||
|
|
||||||
const (
|
|
||||||
sysAF_UNSPEC = 0x0
|
|
||||||
sysAF_INET = 0x2
|
|
||||||
sysAF_INET6 = 0x1c
|
|
||||||
|
|
||||||
sysSOCK_RAW = 0x3
|
|
||||||
)
|
|
||||||
|
|
||||||
type iovec struct {
|
type iovec struct {
|
||||||
Base *byte
|
Base *byte
|
||||||
Len uint32
|
Len uint32
|
||||||
|
53
vendor/golang.org/x/net/internal/socket/zsys_freebsd_arm64.go
generated
vendored
Normal file
53
vendor/golang.org/x/net/internal/socket/zsys_freebsd_arm64.go
generated
vendored
Normal file
@ -0,0 +1,53 @@
|
|||||||
|
// Code generated by cmd/cgo -godefs; DO NOT EDIT.
|
||||||
|
// cgo -godefs defs_freebsd.go
|
||||||
|
|
||||||
|
package socket
|
||||||
|
|
||||||
|
type iovec struct {
|
||||||
|
Base *byte
|
||||||
|
Len uint64
|
||||||
|
}
|
||||||
|
|
||||||
|
type msghdr struct {
|
||||||
|
Name *byte
|
||||||
|
Namelen uint32
|
||||||
|
Pad_cgo_0 [4]byte
|
||||||
|
Iov *iovec
|
||||||
|
Iovlen int32
|
||||||
|
Pad_cgo_1 [4]byte
|
||||||
|
Control *byte
|
||||||
|
Controllen uint32
|
||||||
|
Flags int32
|
||||||
|
}
|
||||||
|
|
||||||
|
type cmsghdr struct {
|
||||||
|
Len uint32
|
||||||
|
Level int32
|
||||||
|
Type int32
|
||||||
|
}
|
||||||
|
|
||||||
|
type sockaddrInet struct {
|
||||||
|
Len uint8
|
||||||
|
Family uint8
|
||||||
|
Port uint16
|
||||||
|
Addr [4]byte /* in_addr */
|
||||||
|
Zero [8]int8
|
||||||
|
}
|
||||||
|
|
||||||
|
type sockaddrInet6 struct {
|
||||||
|
Len uint8
|
||||||
|
Family uint8
|
||||||
|
Port uint16
|
||||||
|
Flowinfo uint32
|
||||||
|
Addr [16]byte /* in6_addr */
|
||||||
|
Scope_id uint32
|
||||||
|
}
|
||||||
|
|
||||||
|
const (
|
||||||
|
sizeofIovec = 0x10
|
||||||
|
sizeofMsghdr = 0x30
|
||||||
|
sizeofCmsghdr = 0xc
|
||||||
|
|
||||||
|
sizeofSockaddrInet = 0x10
|
||||||
|
sizeofSockaddrInet6 = 0x1c
|
||||||
|
)
|
10
vendor/golang.org/x/net/internal/socket/zsys_linux_386.go
generated
vendored
10
vendor/golang.org/x/net/internal/socket/zsys_linux_386.go
generated
vendored
@ -1,16 +1,8 @@
|
|||||||
// Created by cgo -godefs - DO NOT EDIT
|
// Code generated by cmd/cgo -godefs; DO NOT EDIT.
|
||||||
// cgo -godefs defs_linux.go
|
// cgo -godefs defs_linux.go
|
||||||
|
|
||||||
package socket
|
package socket
|
||||||
|
|
||||||
const (
|
|
||||||
sysAF_UNSPEC = 0x0
|
|
||||||
sysAF_INET = 0x2
|
|
||||||
sysAF_INET6 = 0xa
|
|
||||||
|
|
||||||
sysSOCK_RAW = 0x3
|
|
||||||
)
|
|
||||||
|
|
||||||
type iovec struct {
|
type iovec struct {
|
||||||
Base *byte
|
Base *byte
|
||||||
Len uint32
|
Len uint32
|
||||||
|
10
vendor/golang.org/x/net/internal/socket/zsys_linux_amd64.go
generated
vendored
10
vendor/golang.org/x/net/internal/socket/zsys_linux_amd64.go
generated
vendored
@ -1,16 +1,8 @@
|
|||||||
// Created by cgo -godefs - DO NOT EDIT
|
// Code generated by cmd/cgo -godefs; DO NOT EDIT.
|
||||||
// cgo -godefs defs_linux.go
|
// cgo -godefs defs_linux.go
|
||||||
|
|
||||||
package socket
|
package socket
|
||||||
|
|
||||||
const (
|
|
||||||
sysAF_UNSPEC = 0x0
|
|
||||||
sysAF_INET = 0x2
|
|
||||||
sysAF_INET6 = 0xa
|
|
||||||
|
|
||||||
sysSOCK_RAW = 0x3
|
|
||||||
)
|
|
||||||
|
|
||||||
type iovec struct {
|
type iovec struct {
|
||||||
Base *byte
|
Base *byte
|
||||||
Len uint64
|
Len uint64
|
||||||
|
10
vendor/golang.org/x/net/internal/socket/zsys_linux_arm.go
generated
vendored
10
vendor/golang.org/x/net/internal/socket/zsys_linux_arm.go
generated
vendored
@ -1,16 +1,8 @@
|
|||||||
// Created by cgo -godefs - DO NOT EDIT
|
// Code generated by cmd/cgo -godefs; DO NOT EDIT.
|
||||||
// cgo -godefs defs_linux.go
|
// cgo -godefs defs_linux.go
|
||||||
|
|
||||||
package socket
|
package socket
|
||||||
|
|
||||||
const (
|
|
||||||
sysAF_UNSPEC = 0x0
|
|
||||||
sysAF_INET = 0x2
|
|
||||||
sysAF_INET6 = 0xa
|
|
||||||
|
|
||||||
sysSOCK_RAW = 0x3
|
|
||||||
)
|
|
||||||
|
|
||||||
type iovec struct {
|
type iovec struct {
|
||||||
Base *byte
|
Base *byte
|
||||||
Len uint32
|
Len uint32
|
||||||
|
10
vendor/golang.org/x/net/internal/socket/zsys_linux_arm64.go
generated
vendored
10
vendor/golang.org/x/net/internal/socket/zsys_linux_arm64.go
generated
vendored
@ -1,16 +1,8 @@
|
|||||||
// Created by cgo -godefs - DO NOT EDIT
|
// Code generated by cmd/cgo -godefs; DO NOT EDIT.
|
||||||
// cgo -godefs defs_linux.go
|
// cgo -godefs defs_linux.go
|
||||||
|
|
||||||
package socket
|
package socket
|
||||||
|
|
||||||
const (
|
|
||||||
sysAF_UNSPEC = 0x0
|
|
||||||
sysAF_INET = 0x2
|
|
||||||
sysAF_INET6 = 0xa
|
|
||||||
|
|
||||||
sysSOCK_RAW = 0x3
|
|
||||||
)
|
|
||||||
|
|
||||||
type iovec struct {
|
type iovec struct {
|
||||||
Base *byte
|
Base *byte
|
||||||
Len uint64
|
Len uint64
|
||||||
|
10
vendor/golang.org/x/net/internal/socket/zsys_linux_mips.go
generated
vendored
10
vendor/golang.org/x/net/internal/socket/zsys_linux_mips.go
generated
vendored
@ -1,16 +1,8 @@
|
|||||||
// Created by cgo -godefs - DO NOT EDIT
|
// Code generated by cmd/cgo -godefs; DO NOT EDIT.
|
||||||
// cgo -godefs defs_linux.go
|
// cgo -godefs defs_linux.go
|
||||||
|
|
||||||
package socket
|
package socket
|
||||||
|
|
||||||
const (
|
|
||||||
sysAF_UNSPEC = 0x0
|
|
||||||
sysAF_INET = 0x2
|
|
||||||
sysAF_INET6 = 0xa
|
|
||||||
|
|
||||||
sysSOCK_RAW = 0x3
|
|
||||||
)
|
|
||||||
|
|
||||||
type iovec struct {
|
type iovec struct {
|
||||||
Base *byte
|
Base *byte
|
||||||
Len uint32
|
Len uint32
|
||||||
|
10
vendor/golang.org/x/net/internal/socket/zsys_linux_mips64.go
generated
vendored
10
vendor/golang.org/x/net/internal/socket/zsys_linux_mips64.go
generated
vendored
@ -1,16 +1,8 @@
|
|||||||
// Created by cgo -godefs - DO NOT EDIT
|
// Code generated by cmd/cgo -godefs; DO NOT EDIT.
|
||||||
// cgo -godefs defs_linux.go
|
// cgo -godefs defs_linux.go
|
||||||
|
|
||||||
package socket
|
package socket
|
||||||
|
|
||||||
const (
|
|
||||||
sysAF_UNSPEC = 0x0
|
|
||||||
sysAF_INET = 0x2
|
|
||||||
sysAF_INET6 = 0xa
|
|
||||||
|
|
||||||
sysSOCK_RAW = 0x3
|
|
||||||
)
|
|
||||||
|
|
||||||
type iovec struct {
|
type iovec struct {
|
||||||
Base *byte
|
Base *byte
|
||||||
Len uint64
|
Len uint64
|
||||||
|
10
vendor/golang.org/x/net/internal/socket/zsys_linux_mips64le.go
generated
vendored
10
vendor/golang.org/x/net/internal/socket/zsys_linux_mips64le.go
generated
vendored
@ -1,16 +1,8 @@
|
|||||||
// Created by cgo -godefs - DO NOT EDIT
|
// Code generated by cmd/cgo -godefs; DO NOT EDIT.
|
||||||
// cgo -godefs defs_linux.go
|
// cgo -godefs defs_linux.go
|
||||||
|
|
||||||
package socket
|
package socket
|
||||||
|
|
||||||
const (
|
|
||||||
sysAF_UNSPEC = 0x0
|
|
||||||
sysAF_INET = 0x2
|
|
||||||
sysAF_INET6 = 0xa
|
|
||||||
|
|
||||||
sysSOCK_RAW = 0x3
|
|
||||||
)
|
|
||||||
|
|
||||||
type iovec struct {
|
type iovec struct {
|
||||||
Base *byte
|
Base *byte
|
||||||
Len uint64
|
Len uint64
|
||||||
|
10
vendor/golang.org/x/net/internal/socket/zsys_linux_mipsle.go
generated
vendored
10
vendor/golang.org/x/net/internal/socket/zsys_linux_mipsle.go
generated
vendored
@ -1,16 +1,8 @@
|
|||||||
// Created by cgo -godefs - DO NOT EDIT
|
// Code generated by cmd/cgo -godefs; DO NOT EDIT.
|
||||||
// cgo -godefs defs_linux.go
|
// cgo -godefs defs_linux.go
|
||||||
|
|
||||||
package socket
|
package socket
|
||||||
|
|
||||||
const (
|
|
||||||
sysAF_UNSPEC = 0x0
|
|
||||||
sysAF_INET = 0x2
|
|
||||||
sysAF_INET6 = 0xa
|
|
||||||
|
|
||||||
sysSOCK_RAW = 0x3
|
|
||||||
)
|
|
||||||
|
|
||||||
type iovec struct {
|
type iovec struct {
|
||||||
Base *byte
|
Base *byte
|
||||||
Len uint32
|
Len uint32
|
||||||
|
10
vendor/golang.org/x/net/internal/socket/zsys_linux_ppc64.go
generated
vendored
10
vendor/golang.org/x/net/internal/socket/zsys_linux_ppc64.go
generated
vendored
@ -1,16 +1,8 @@
|
|||||||
// Created by cgo -godefs - DO NOT EDIT
|
// Code generated by cmd/cgo -godefs; DO NOT EDIT.
|
||||||
// cgo -godefs defs_linux.go
|
// cgo -godefs defs_linux.go
|
||||||
|
|
||||||
package socket
|
package socket
|
||||||
|
|
||||||
const (
|
|
||||||
sysAF_UNSPEC = 0x0
|
|
||||||
sysAF_INET = 0x2
|
|
||||||
sysAF_INET6 = 0xa
|
|
||||||
|
|
||||||
sysSOCK_RAW = 0x3
|
|
||||||
)
|
|
||||||
|
|
||||||
type iovec struct {
|
type iovec struct {
|
||||||
Base *byte
|
Base *byte
|
||||||
Len uint64
|
Len uint64
|
||||||
|
10
vendor/golang.org/x/net/internal/socket/zsys_linux_ppc64le.go
generated
vendored
10
vendor/golang.org/x/net/internal/socket/zsys_linux_ppc64le.go
generated
vendored
@ -1,16 +1,8 @@
|
|||||||
// Created by cgo -godefs - DO NOT EDIT
|
// Code generated by cmd/cgo -godefs; DO NOT EDIT.
|
||||||
// cgo -godefs defs_linux.go
|
// cgo -godefs defs_linux.go
|
||||||
|
|
||||||
package socket
|
package socket
|
||||||
|
|
||||||
const (
|
|
||||||
sysAF_UNSPEC = 0x0
|
|
||||||
sysAF_INET = 0x2
|
|
||||||
sysAF_INET6 = 0xa
|
|
||||||
|
|
||||||
sysSOCK_RAW = 0x3
|
|
||||||
)
|
|
||||||
|
|
||||||
type iovec struct {
|
type iovec struct {
|
||||||
Base *byte
|
Base *byte
|
||||||
Len uint64
|
Len uint64
|
||||||
|
59
vendor/golang.org/x/net/internal/socket/zsys_linux_riscv64.go
generated
vendored
Normal file
59
vendor/golang.org/x/net/internal/socket/zsys_linux_riscv64.go
generated
vendored
Normal file
@ -0,0 +1,59 @@
|
|||||||
|
// Code generated by cmd/cgo -godefs; DO NOT EDIT.
|
||||||
|
// cgo -godefs defs_linux.go
|
||||||
|
|
||||||
|
// +build riscv64
|
||||||
|
|
||||||
|
package socket
|
||||||
|
|
||||||
|
type iovec struct {
|
||||||
|
Base *byte
|
||||||
|
Len uint64
|
||||||
|
}
|
||||||
|
|
||||||
|
type msghdr struct {
|
||||||
|
Name *byte
|
||||||
|
Namelen uint32
|
||||||
|
Iov *iovec
|
||||||
|
Iovlen uint64
|
||||||
|
Control *byte
|
||||||
|
Controllen uint64
|
||||||
|
Flags int32
|
||||||
|
Pad_cgo_0 [4]byte
|
||||||
|
}
|
||||||
|
|
||||||
|
type mmsghdr struct {
|
||||||
|
Hdr msghdr
|
||||||
|
Len uint32
|
||||||
|
Pad_cgo_0 [4]byte
|
||||||
|
}
|
||||||
|
|
||||||
|
type cmsghdr struct {
|
||||||
|
Len uint64
|
||||||
|
Level int32
|
||||||
|
Type int32
|
||||||
|
}
|
||||||
|
|
||||||
|
type sockaddrInet struct {
|
||||||
|
Family uint16
|
||||||
|
Port uint16
|
||||||
|
Addr [4]byte /* in_addr */
|
||||||
|
X__pad [8]uint8
|
||||||
|
}
|
||||||
|
|
||||||
|
type sockaddrInet6 struct {
|
||||||
|
Family uint16
|
||||||
|
Port uint16
|
||||||
|
Flowinfo uint32
|
||||||
|
Addr [16]byte /* in6_addr */
|
||||||
|
Scope_id uint32
|
||||||
|
}
|
||||||
|
|
||||||
|
const (
|
||||||
|
sizeofIovec = 0x10
|
||||||
|
sizeofMsghdr = 0x38
|
||||||
|
sizeofMmsghdr = 0x40
|
||||||
|
sizeofCmsghdr = 0x10
|
||||||
|
|
||||||
|
sizeofSockaddrInet = 0x10
|
||||||
|
sizeofSockaddrInet6 = 0x1c
|
||||||
|
)
|
10
vendor/golang.org/x/net/internal/socket/zsys_linux_s390x.go
generated
vendored
10
vendor/golang.org/x/net/internal/socket/zsys_linux_s390x.go
generated
vendored
@ -1,16 +1,8 @@
|
|||||||
// Created by cgo -godefs - DO NOT EDIT
|
// Code generated by cmd/cgo -godefs; DO NOT EDIT.
|
||||||
// cgo -godefs defs_linux.go
|
// cgo -godefs defs_linux.go
|
||||||
|
|
||||||
package socket
|
package socket
|
||||||
|
|
||||||
const (
|
|
||||||
sysAF_UNSPEC = 0x0
|
|
||||||
sysAF_INET = 0x2
|
|
||||||
sysAF_INET6 = 0xa
|
|
||||||
|
|
||||||
sysSOCK_RAW = 0x3
|
|
||||||
)
|
|
||||||
|
|
||||||
type iovec struct {
|
type iovec struct {
|
||||||
Base *byte
|
Base *byte
|
||||||
Len uint64
|
Len uint64
|
||||||
|
10
vendor/golang.org/x/net/internal/socket/zsys_netbsd_386.go
generated
vendored
10
vendor/golang.org/x/net/internal/socket/zsys_netbsd_386.go
generated
vendored
@ -1,16 +1,8 @@
|
|||||||
// Created by cgo -godefs - DO NOT EDIT
|
// Code generated by cmd/cgo -godefs; DO NOT EDIT.
|
||||||
// cgo -godefs defs_netbsd.go
|
// cgo -godefs defs_netbsd.go
|
||||||
|
|
||||||
package socket
|
package socket
|
||||||
|
|
||||||
const (
|
|
||||||
sysAF_UNSPEC = 0x0
|
|
||||||
sysAF_INET = 0x2
|
|
||||||
sysAF_INET6 = 0x18
|
|
||||||
|
|
||||||
sysSOCK_RAW = 0x3
|
|
||||||
)
|
|
||||||
|
|
||||||
type iovec struct {
|
type iovec struct {
|
||||||
Base *byte
|
Base *byte
|
||||||
Len uint32
|
Len uint32
|
||||||
|
10
vendor/golang.org/x/net/internal/socket/zsys_netbsd_amd64.go
generated
vendored
10
vendor/golang.org/x/net/internal/socket/zsys_netbsd_amd64.go
generated
vendored
@ -1,16 +1,8 @@
|
|||||||
// Created by cgo -godefs - DO NOT EDIT
|
// Code generated by cmd/cgo -godefs; DO NOT EDIT.
|
||||||
// cgo -godefs defs_netbsd.go
|
// cgo -godefs defs_netbsd.go
|
||||||
|
|
||||||
package socket
|
package socket
|
||||||
|
|
||||||
const (
|
|
||||||
sysAF_UNSPEC = 0x0
|
|
||||||
sysAF_INET = 0x2
|
|
||||||
sysAF_INET6 = 0x18
|
|
||||||
|
|
||||||
sysSOCK_RAW = 0x3
|
|
||||||
)
|
|
||||||
|
|
||||||
type iovec struct {
|
type iovec struct {
|
||||||
Base *byte
|
Base *byte
|
||||||
Len uint64
|
Len uint64
|
||||||
|
10
vendor/golang.org/x/net/internal/socket/zsys_netbsd_arm.go
generated
vendored
10
vendor/golang.org/x/net/internal/socket/zsys_netbsd_arm.go
generated
vendored
@ -1,16 +1,8 @@
|
|||||||
// Created by cgo -godefs - DO NOT EDIT
|
// Code generated by cmd/cgo -godefs; DO NOT EDIT.
|
||||||
// cgo -godefs defs_netbsd.go
|
// cgo -godefs defs_netbsd.go
|
||||||
|
|
||||||
package socket
|
package socket
|
||||||
|
|
||||||
const (
|
|
||||||
sysAF_UNSPEC = 0x0
|
|
||||||
sysAF_INET = 0x2
|
|
||||||
sysAF_INET6 = 0x18
|
|
||||||
|
|
||||||
sysSOCK_RAW = 0x3
|
|
||||||
)
|
|
||||||
|
|
||||||
type iovec struct {
|
type iovec struct {
|
||||||
Base *byte
|
Base *byte
|
||||||
Len uint32
|
Len uint32
|
||||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user