Add vendor folder to git

This commit is contained in:
Lucas Käldström 2017-06-26 19:23:05 +03:00
parent 66cf5eaafb
commit 183585f56f
No known key found for this signature in database
GPG key ID: 600FEFBBD0D40D21
6916 changed files with 2629581 additions and 1 deletions

55
vendor/github.com/coreos/pkg/netutil/proxy.go generated vendored Normal file
View file

@ -0,0 +1,55 @@
package netutil
import (
"io"
"net"
"sync"
"time"
"github.com/coreos/pkg/capnslog"
)
var (
log = capnslog.NewPackageLogger("github.com/coreos/pkg/netutil", "main")
)
// ProxyTCP proxies between two TCP connections.
// Because TLS connections don't have CloseRead() and CloseWrite() methods, our
// temporary solution is to use timeouts.
func ProxyTCP(conn1, conn2 net.Conn, tlsWriteDeadline, tlsReadDeadline time.Duration) {
var wg sync.WaitGroup
wg.Add(2)
go copyBytes(conn1, conn2, &wg, tlsWriteDeadline, tlsReadDeadline)
go copyBytes(conn2, conn1, &wg, tlsWriteDeadline, tlsReadDeadline)
wg.Wait()
conn1.Close()
conn2.Close()
}
func copyBytes(dst, src net.Conn, wg *sync.WaitGroup, writeDeadline, readDeadline time.Duration) {
defer wg.Done()
n, err := io.Copy(dst, src)
if err != nil {
log.Errorf("proxy i/o error: %v", err)
}
if cr, ok := src.(*net.TCPConn); ok {
cr.CloseRead()
} else {
// For TLS connections.
wto := time.Now().Add(writeDeadline)
src.SetWriteDeadline(wto)
}
if cw, ok := dst.(*net.TCPConn); ok {
cw.CloseWrite()
} else {
// For TLS connections.
rto := time.Now().Add(readDeadline)
dst.SetReadDeadline(rto)
}
log.Debugf("proxy copied %d bytes %s -> %s", n, src.RemoteAddr(), dst.RemoteAddr())
}

17
vendor/github.com/coreos/pkg/netutil/url.go generated vendored Normal file
View file

@ -0,0 +1,17 @@
package netutil
import (
"net/url"
)
// MergeQuery appends additional query values to an existing URL.
func MergeQuery(u url.URL, q url.Values) url.URL {
uv := u.Query()
for k, vs := range q {
for _, v := range vs {
uv.Add(k, v)
}
}
u.RawQuery = uv.Encode()
return u
}

86
vendor/github.com/coreos/pkg/netutil/url_test.go generated vendored Normal file
View file

@ -0,0 +1,86 @@
package netutil
import (
"net/url"
"reflect"
"testing"
)
func TestMergeQuery(t *testing.T) {
tests := []struct {
u string
q url.Values
w string
}{
// No values
{
u: "http://example.com",
q: nil,
w: "http://example.com",
},
// No additional values
{
u: "http://example.com?foo=bar",
q: nil,
w: "http://example.com?foo=bar",
},
// Simple addition
{
u: "http://example.com",
q: url.Values{
"foo": []string{"bar"},
},
w: "http://example.com?foo=bar",
},
// Addition with existing values
{
u: "http://example.com?dog=boo",
q: url.Values{
"foo": []string{"bar"},
},
w: "http://example.com?dog=boo&foo=bar",
},
// Merge
{
u: "http://example.com?dog=boo",
q: url.Values{
"dog": []string{"elroy"},
},
w: "http://example.com?dog=boo&dog=elroy",
},
// Add and merge
{
u: "http://example.com?dog=boo",
q: url.Values{
"dog": []string{"elroy"},
"foo": []string{"bar"},
},
w: "http://example.com?dog=boo&dog=elroy&foo=bar",
},
// Multivalue merge
{
u: "http://example.com?dog=boo",
q: url.Values{
"dog": []string{"elroy", "penny"},
},
w: "http://example.com?dog=boo&dog=elroy&dog=penny",
},
}
for i, tt := range tests {
ur, err := url.Parse(tt.u)
if err != nil {
t.Errorf("case %d: failed parsing test url: %v, error: %v", i, tt.u, err)
}
got := MergeQuery(*ur, tt.q)
want, err := url.Parse(tt.w)
if err != nil {
t.Errorf("case %d: failed parsing want url: %v, error: %v", i, tt.w, err)
}
if !reflect.DeepEqual(*want, got) {
t.Errorf("case %d: want: %v, got: %v", i, *want, got)
}
}
}