mirror of https://github.com/k3s-io/k3s
Merge pull request #44113 from mikkeloscar/update-goproxy
Automatic merge from submit-queue
vendor: Update elazarl/goproxy to fix e2e test with go1.8
**What this PR does / why we need it**:
This updates the dependency `github.com/elazarl/goproxy` to include this fix c4fc26588b
which makes kubernetes e2e tests build with go1.8. It was crashing before as described in https://github.com/elazarl/goproxy/issues/188#issuecomment-281092250 and #38228
**Which issue this PR fixes**
This is part of the fix for #38228
**Special notes for your reviewer**:
**Release note**:
```release-note
```
pull/6/head
commit
dee81ed56a
|
@ -960,8 +960,8 @@
|
|||
},
|
||||
{
|
||||
"ImportPath": "github.com/elazarl/goproxy",
|
||||
"Comment": "v1.0-66-g07b16b6",
|
||||
"Rev": "07b16b6e30fcac0ad8c0435548e743bcf2ca7e92"
|
||||
"Comment": "v1.0-104-gc4fc265",
|
||||
"Rev": "c4fc26588b6ef8af07a191fcb6476387bdd46711"
|
||||
},
|
||||
{
|
||||
"ImportPath": "github.com/emicklei/go-restful",
|
||||
|
|
|
@ -28,7 +28,7 @@
|
|||
},
|
||||
{
|
||||
"ImportPath": "github.com/elazarl/goproxy",
|
||||
"Rev": "07b16b6e30fcac0ad8c0435548e743bcf2ca7e92"
|
||||
"Rev": "c4fc26588b6ef8af07a191fcb6476387bdd46711"
|
||||
},
|
||||
{
|
||||
"ImportPath": "github.com/emicklei/go-restful",
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
# Introduction
|
||||
|
||||
[![GoDoc](https://godoc.org/github.com/elazarl/goproxy?status.svg)](https://godoc.org/github.com/elazarl/goproxy)
|
||||
[![Join the chat at https://gitter.im/elazarl/goproxy](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/elazarl/goproxy?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
|
||||
|
||||
Package goproxy provides a customizable HTTP proxy library for Go (golang),
|
||||
|
@ -8,7 +9,7 @@ It supports regular HTTP proxy, HTTPS through CONNECT, and "hijacking" HTTPS
|
|||
connection using "Man in the Middle" style attack.
|
||||
|
||||
The intent of the proxy, is to be usable with reasonable amount of traffic
|
||||
yet, customizable and programable.
|
||||
yet, customizable and programmable.
|
||||
|
||||
The proxy itself is simply a `net/http` handler.
|
||||
|
||||
|
@ -35,7 +36,7 @@ as customable as goproxy intend to be. The main difference is, Fiddler is not
|
|||
intended to be used as a real proxy.
|
||||
|
||||
A possible use case that suits goproxy but
|
||||
not Fiddler, is, gathering statisitics on page load times for a certain website over a week.
|
||||
not Fiddler, is, gathering statistics on page load times for a certain website over a week.
|
||||
With goproxy you could ask all your users to set their proxy to a dedicated machine running a
|
||||
goproxy server. Fiddler is a GUI app not designed to be ran like a server for multiple users.
|
||||
|
||||
|
@ -43,27 +44,31 @@ goproxy server. Fiddler is a GUI app not designed to be ran like a server for mu
|
|||
|
||||
To get a taste of `goproxy`, a basic HTTP/HTTPS transparent proxy
|
||||
|
||||
```go
|
||||
package main
|
||||
|
||||
import (
|
||||
"github.com/elazarl/goproxy"
|
||||
"log"
|
||||
"net/http"
|
||||
)
|
||||
|
||||
func main() {
|
||||
proxy := goproxy.NewProxyHttpServer()
|
||||
proxy.Verbose = true
|
||||
log.Fatal(http.ListenAndServe(":8080", proxy))
|
||||
}
|
||||
import (
|
||||
"github.com/elazarl/goproxy"
|
||||
"log"
|
||||
"net/http"
|
||||
)
|
||||
|
||||
func main() {
|
||||
proxy := goproxy.NewProxyHttpServer()
|
||||
proxy.Verbose = true
|
||||
log.Fatal(http.ListenAndServe(":8080", proxy))
|
||||
}
|
||||
```
|
||||
|
||||
This line will add `X-GoProxy: yxorPoG-X` header to all requests sent through the proxy
|
||||
|
||||
proxy.OnRequest().DoFunc(
|
||||
func(r *http.Request,ctx *goproxy.ProxyCtx)(*http.Request,*http.Response) {
|
||||
r.Header.Set("X-GoProxy","yxorPoG-X")
|
||||
return r,nil
|
||||
})
|
||||
```go
|
||||
proxy.OnRequest().DoFunc(
|
||||
func(r *http.Request,ctx *goproxy.ProxyCtx)(*http.Request,*http.Response) {
|
||||
r.Header.Set("X-GoProxy","yxorPoG-X")
|
||||
return r,nil
|
||||
})
|
||||
```
|
||||
|
||||
`DoFunc` will process all incoming requests to the proxy. It will add a header to the request
|
||||
and return it. The proxy will send the modified request.
|
||||
|
@ -73,21 +78,23 @@ have discarded the request and sent the new response to the client.
|
|||
|
||||
In order to refuse connections to reddit at work time
|
||||
|
||||
proxy.OnRequest(goproxy.DstHostIs("www.reddit.com")).DoFunc(
|
||||
func(r *http.Request,ctx *goproxy.ProxyCtx)(*http.Request,*http.Response) {
|
||||
if h,_,_ := time.Now().Clock(); h >= 8 && h <= 17 {
|
||||
return r,goproxy.NewResponse(r,
|
||||
goproxy.ContentTypeText,http.StatusForbidden,
|
||||
"Don't waste your time!")
|
||||
}
|
||||
return r,nil
|
||||
})
|
||||
```go
|
||||
proxy.OnRequest(goproxy.DstHostIs("www.reddit.com")).DoFunc(
|
||||
func(r *http.Request,ctx *goproxy.ProxyCtx)(*http.Request,*http.Response) {
|
||||
if h,_,_ := time.Now().Clock(); h >= 8 && h <= 17 {
|
||||
return r,goproxy.NewResponse(r,
|
||||
goproxy.ContentTypeText,http.StatusForbidden,
|
||||
"Don't waste your time!")
|
||||
}
|
||||
return r,nil
|
||||
})
|
||||
```
|
||||
|
||||
`DstHostIs` returns a `ReqCondition`, that is a function receiving a `Request` and returning a boolean
|
||||
we will only process requests that matches the condition. `DstHostIs("www.reddit.com")` will return
|
||||
a `ReqCondition` accepting only requests directed to "www.reddit.com".
|
||||
|
||||
`DoFunc` will recieve a function that will preprocess the request. We can change the request, or
|
||||
`DoFunc` will receive a function that will preprocess the request. We can change the request, or
|
||||
return a response. If the time is between 8:00am and 17:00pm, we will neglect the request, and
|
||||
return a precanned text response saying "do not waste your time".
|
||||
|
||||
|
@ -102,7 +109,7 @@ See additional examples in the examples directory.
|
|||
# License
|
||||
|
||||
I put the software temporarily under the Go-compatible BSD license,
|
||||
if this prevents someone from using the software, do let mee know and I'll consider changing it.
|
||||
if this prevents someone from using the software, do let me know and I'll consider changing it.
|
||||
|
||||
At any rate, user feedback is very important for me, so I'll be delighted to know if you're using this package.
|
||||
|
||||
|
@ -111,5 +118,5 @@ At any rate, user feedback is very important for me, so I'll be delighted to kno
|
|||
I've received a positive feedback from a few people who use goproxy in production settings.
|
||||
I believe it is good enough for usage.
|
||||
|
||||
I'll try to keep reasonable backwards compatability. In case of a major API change,
|
||||
I'll try to keep reasonable backwards compatibility. In case of a major API change,
|
||||
I'll change the import path.
|
||||
|
|
|
@ -22,35 +22,90 @@ var defaultTLSConfig = &tls.Config{
|
|||
}
|
||||
|
||||
var CA_CERT = []byte(`-----BEGIN CERTIFICATE-----
|
||||
MIICSjCCAbWgAwIBAgIBADALBgkqhkiG9w0BAQUwSjEjMCEGA1UEChMaZ2l0aHVi
|
||||
LmNvbS9lbGF6YXJsL2dvcHJveHkxIzAhBgNVBAMTGmdpdGh1Yi5jb20vZWxhemFy
|
||||
bC9nb3Byb3h5MB4XDTAwMDEwMTAwMDAwMFoXDTQ5MTIzMTIzNTk1OVowSjEjMCEG
|
||||
A1UEChMaZ2l0aHViLmNvbS9lbGF6YXJsL2dvcHJveHkxIzAhBgNVBAMTGmdpdGh1
|
||||
Yi5jb20vZWxhemFybC9nb3Byb3h5MIGdMAsGCSqGSIb3DQEBAQOBjQAwgYkCgYEA
|
||||
vz9BbCaJjxs73Tvcq3leP32hAGerQ1RgvlZ68Z4nZmoVHfl+2Nr/m0dmW+GdOfpT
|
||||
cs/KzfJjYGr/84x524fiuR8GdZ0HOtXJzyF5seoWnbBIuyr1PbEpgRhGQMqqOUuj
|
||||
YExeLbfNHPIoJ8XZ1Vzyv3YxjbmjWA+S/uOe9HWtDbMCAwEAAaNGMEQwDgYDVR0P
|
||||
AQH/BAQDAgCkMBMGA1UdJQQMMAoGCCsGAQUFBwMBMA8GA1UdEwEB/wQFMAMBAf8w
|
||||
DAYDVR0RBAUwA4IBKjALBgkqhkiG9w0BAQUDgYEAIcL8huSmGMompNujsvePTUnM
|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OYb0zm67EfAQl3TW8Ky5fl5CcxpVCD360Bzi6hwjYixa3qEeBggOixFQBFWft
|
||||
8wrkKTHpOQXjn4sDPtet8imm9UYEtzWrFX6T9MFYkBR0/yye0FIh9+YPiTA6WB86
|
||||
NCNwK5Yl6HuvF97CIH5CdgO+5C7KifUtqTOL8pQKbNwy0S3sNYvB+njGvRpR7pKV
|
||||
BUnFpB/Atptqr4CUlTXrc5IPLAqAfmwk5IKcwy3EXUbruf9Dwz69YA==
|
||||
-----END CERTIFICATE-----`)
|
||||
|
||||
var CA_KEY = []byte(`-----BEGIN RSA PRIVATE KEY-----
|
||||
MIICXQIBAAKBgQC/P0FsJomPGzvdO9yreV4/faEAZ6tDVGC+VnrxnidmahUd+X7Y
|
||||
2v+bR2Zb4Z05+lNyz8rN8mNgav/zjHnbh+K5HwZ1nQc61cnPIXmx6hadsEi7KvU9
|
||||
sSmBGEZAyqo5S6NgTF4tt80c8ignxdnVXPK/djGNuaNYD5L+4570da0NswIDAQAB
|
||||
AoGBALzIv1b4D7ARTR3NOr6V9wArjiOtMjUrdLhO+9vIp9IEA8ZsA9gjDlCEwbkP
|
||||
VDnoLjnWfraff5Os6+3JjHy1fYpUiCdnk2XA6iJSL1XWKQZPt3wOunxP4lalDgED
|
||||
QTRReFbA/y/Z4kSfTXpVj68ytcvSRW/N7q5/qRtbN9804jpBAkEA0s6lvH2btSLA
|
||||
mcEdwhs7zAslLbdld7rvfUeP82gPPk0S6yUqTNyikqshM9AwAktHY7WvYdKl+ghZ
|
||||
HTxKVC4DoQJBAOg/IAW5RbXknP+Lf7AVtBgw3E+Yfa3mcdLySe8hjxxyZq825Zmu
|
||||
Rt5Qj4Lw6ifSFNy4kiiSpE/ZCukYvUXGENMCQFkPxSWlS6tzSzuqQxBGwTSrYMG3
|
||||
wb6b06JyIXcMd6Qym9OMmBpw/J5KfnSNeDr/4uFVWQtTG5xO+pdHaX+3EQECQQDl
|
||||
qcbY4iX1gWVfr2tNjajSYz751yoxVbkpiT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tCxS7Y1blQ2c
|
||||
ue4erZKmFP1u8wTNHQ03T6sECZbnIfEywRD/esHpclfF3kYAKDRqIP4K905Rb0iH
|
||||
759ZWt2iCbqZznf50XTvptdmjm5KxvouJzScnQ52gIV6L+QrCKIPelLBEIqCJREh
|
||||
pmcjjocD/UCCSuHgbAYNNnO/JdhnSylz1tIg26I+2iLNyeTKIepSNlsBxnkLmqM1
|
||||
cj/azKBaT04IOMLaN8xfSqitJYSraWMVNgGJM5vfcVaivZnNh0lZBv+qu6YkdM88
|
||||
4/avCJ8IutT+FcMM+GbGazOm5ALWqUyhrnbLGc4CQMPfe7Il6NxwcrOxT8w=
|
||||
-----END RSA PRIVATE KEY-----`)
|
||||
|
||||
var GoproxyCa, goproxyCaErr = tls.X509KeyPair(CA_CERT, CA_KEY)
|
||||
|
|
|
@ -124,10 +124,15 @@ func DstHostIs(host string) ReqConditionFunc {
|
|||
}
|
||||
}
|
||||
|
||||
// SrcIpIs returns a ReqCondition testing wether the source IP of the request is the given string
|
||||
func SrcIpIs(ip string) ReqCondition {
|
||||
// SrcIpIs returns a ReqCondition testing whether the source IP of the request is one of the given strings
|
||||
func SrcIpIs(ips ...string) ReqCondition {
|
||||
return ReqConditionFunc(func(req *http.Request, ctx *ProxyCtx) bool {
|
||||
return strings.HasPrefix(req.RemoteAddr, ip+":")
|
||||
for _, ip := range ips {
|
||||
if strings.HasPrefix(req.RemoteAddr, ip+":") {
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
})
|
||||
}
|
||||
|
||||
|
|
|
@ -10,8 +10,10 @@ import (
|
|||
"net/http"
|
||||
"net/url"
|
||||
"os"
|
||||
"regexp"
|
||||
"strconv"
|
||||
"strings"
|
||||
"sync"
|
||||
"sync/atomic"
|
||||
)
|
||||
|
||||
|
@ -23,6 +25,7 @@ const (
|
|||
ConnectMitm
|
||||
ConnectHijack
|
||||
ConnectHTTPMitm
|
||||
ConnectProxyAuthHijack
|
||||
)
|
||||
|
||||
var (
|
||||
|
@ -30,6 +33,7 @@ var (
|
|||
MitmConnect = &ConnectAction{Action: ConnectMitm, TLSConfig: TLSConfigFromCA(&GoproxyCa)}
|
||||
HTTPMitmConnect = &ConnectAction{Action: ConnectHTTPMitm, TLSConfig: TLSConfigFromCA(&GoproxyCa)}
|
||||
RejectConnect = &ConnectAction{Action: ConnectReject, TLSConfig: TLSConfigFromCA(&GoproxyCa)}
|
||||
httpsRegexp = regexp.MustCompile(`^https:\/\/`)
|
||||
)
|
||||
|
||||
type ConnectAction struct {
|
||||
|
@ -97,8 +101,25 @@ func (proxy *ProxyHttpServer) handleHttps(w http.ResponseWriter, r *http.Request
|
|||
}
|
||||
ctx.Logf("Accepting CONNECT to %s", host)
|
||||
proxyClient.Write([]byte("HTTP/1.0 200 OK\r\n\r\n"))
|
||||
go copyAndClose(ctx, targetSiteCon, proxyClient)
|
||||
go copyAndClose(ctx, proxyClient, targetSiteCon)
|
||||
|
||||
targetTCP, targetOK := targetSiteCon.(*net.TCPConn)
|
||||
proxyClientTCP, clientOK := proxyClient.(*net.TCPConn)
|
||||
if targetOK && clientOK {
|
||||
go copyAndClose(ctx, targetTCP, proxyClientTCP)
|
||||
go copyAndClose(ctx, proxyClientTCP, targetTCP)
|
||||
} else {
|
||||
go func() {
|
||||
var wg sync.WaitGroup
|
||||
wg.Add(2)
|
||||
go copyOrWarn(ctx, targetSiteCon, proxyClient, &wg)
|
||||
go copyOrWarn(ctx, proxyClient, targetSiteCon, &wg)
|
||||
wg.Wait()
|
||||
proxyClient.Close()
|
||||
targetSiteCon.Close()
|
||||
|
||||
}()
|
||||
}
|
||||
|
||||
case ConnectHijack:
|
||||
ctx.Logf("Hijacking CONNECT to %s", host)
|
||||
proxyClient.Write([]byte("HTTP/1.0 200 OK\r\n\r\n"))
|
||||
|
@ -132,6 +153,7 @@ func (proxy *ProxyHttpServer) handleHttps(w http.ResponseWriter, r *http.Request
|
|||
httpError(proxyClient, ctx, err)
|
||||
return
|
||||
}
|
||||
defer resp.Body.Close()
|
||||
}
|
||||
resp = proxy.filterResponse(resp, ctx)
|
||||
if err := resp.Write(proxyClient); err != nil {
|
||||
|
@ -166,6 +188,7 @@ func (proxy *ProxyHttpServer) handleHttps(w http.ResponseWriter, r *http.Request
|
|||
clientTlsReader := bufio.NewReader(rawClientTls)
|
||||
for !isEof(clientTlsReader) {
|
||||
req, err := http.ReadRequest(clientTlsReader)
|
||||
var ctx = &ProxyCtx{Req: req, Session: atomic.AddInt64(&proxy.sess, 1), proxy: proxy}
|
||||
if err != nil && err != io.EOF {
|
||||
return
|
||||
}
|
||||
|
@ -175,7 +198,10 @@ func (proxy *ProxyHttpServer) handleHttps(w http.ResponseWriter, r *http.Request
|
|||
}
|
||||
req.RemoteAddr = r.RemoteAddr // since we're converting the request, need to carry over the original connecting IP as well
|
||||
ctx.Logf("req %v", r.Host)
|
||||
req.URL, err = url.Parse("https://" + r.Host + req.URL.String())
|
||||
|
||||
if !httpsRegexp.MatchString(req.URL.String()) {
|
||||
req.URL, err = url.Parse("https://" + r.Host + req.URL.String())
|
||||
}
|
||||
|
||||
// Bug fix which goproxy fails to provide request
|
||||
// information URL in the context when does HTTPS MITM
|
||||
|
@ -196,6 +222,8 @@ func (proxy *ProxyHttpServer) handleHttps(w http.ResponseWriter, r *http.Request
|
|||
ctx.Logf("resp %v", resp.Status)
|
||||
}
|
||||
resp = proxy.filterResponse(resp, ctx)
|
||||
defer resp.Body.Close()
|
||||
|
||||
text := resp.Status
|
||||
statusCode := strconv.Itoa(resp.StatusCode) + " "
|
||||
if strings.HasPrefix(text, statusCode) {
|
||||
|
@ -234,6 +262,9 @@ func (proxy *ProxyHttpServer) handleHttps(w http.ResponseWriter, r *http.Request
|
|||
}
|
||||
ctx.Logf("Exiting on EOF")
|
||||
}()
|
||||
case ConnectProxyAuthHijack:
|
||||
proxyClient.Write([]byte("HTTP/1.1 407 Proxy Authentication Required\r\n"))
|
||||
todo.Hijack(r, proxyClient, ctx)
|
||||
case ConnectReject:
|
||||
if ctx.Resp != nil {
|
||||
if err := ctx.Resp.Write(proxyClient); err != nil {
|
||||
|
@ -253,15 +284,20 @@ func httpError(w io.WriteCloser, ctx *ProxyCtx, err error) {
|
|||
}
|
||||
}
|
||||
|
||||
func copyAndClose(ctx *ProxyCtx, w, r net.Conn) {
|
||||
connOk := true
|
||||
if _, err := io.Copy(w, r); err != nil {
|
||||
connOk = false
|
||||
func copyOrWarn(ctx *ProxyCtx, dst io.Writer, src io.Reader, wg *sync.WaitGroup) {
|
||||
if _, err := io.Copy(dst, src); err != nil {
|
||||
ctx.Warnf("Error copying to client: %s", err)
|
||||
}
|
||||
if err := r.Close(); err != nil && connOk {
|
||||
ctx.Warnf("Error closing: %s", err)
|
||||
wg.Done()
|
||||
}
|
||||
|
||||
func copyAndClose(ctx *ProxyCtx, dst, src *net.TCPConn) {
|
||||
if _, err := io.Copy(dst, src); err != nil {
|
||||
ctx.Warnf("Error copying to client: %s", err)
|
||||
}
|
||||
|
||||
dst.CloseWrite()
|
||||
src.CloseRead()
|
||||
}
|
||||
|
||||
func dialerFromEnv(proxy *ProxyHttpServer) func(network, addr string) (net.Conn, error) {
|
||||
|
@ -305,8 +341,12 @@ func (proxy *ProxyHttpServer) NewConnectDialToProxy(https_proxy string) func(net
|
|||
c.Close()
|
||||
return nil, err
|
||||
}
|
||||
defer resp.Body.Close()
|
||||
if resp.StatusCode != 200 {
|
||||
resp, _ := ioutil.ReadAll(resp.Body)
|
||||
resp, err := ioutil.ReadAll(resp.Body)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
c.Close()
|
||||
return nil, errors.New("proxy refused connection" + string(resp))
|
||||
}
|
||||
|
@ -339,9 +379,12 @@ func (proxy *ProxyHttpServer) NewConnectDialToProxy(https_proxy string) func(net
|
|||
c.Close()
|
||||
return nil, err
|
||||
}
|
||||
defer resp.Body.Close()
|
||||
if resp.StatusCode != 200 {
|
||||
body, _ := ioutil.ReadAll(io.LimitReader(resp.Body, 500))
|
||||
resp.Body.Close()
|
||||
body, err := ioutil.ReadAll(io.LimitReader(resp.Body, 500))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
c.Close()
|
||||
return nil, errors.New("proxy refused connection" + string(body))
|
||||
}
|
||||
|
|
|
@ -78,7 +78,7 @@ func removeProxyHeaders(ctx *ProxyCtx, r *http.Request) {
|
|||
// and would wrap the response body with the relevant reader.
|
||||
r.Header.Del("Accept-Encoding")
|
||||
// curl can add that, see
|
||||
// http://homepage.ntlworld.com/jonathan.deboynepollard/FGA/web-proxy-connection-header.html
|
||||
// https://jdebp.eu./FGA/web-proxy-connection-header.html
|
||||
r.Header.Del("Proxy-Connection")
|
||||
r.Header.Del("Proxy-Authenticate")
|
||||
r.Header.Del("Proxy-Authorization")
|
||||
|
@ -123,7 +123,7 @@ func (proxy *ProxyHttpServer) ServeHTTP(w http.ResponseWriter, r *http.Request)
|
|||
}
|
||||
origBody := resp.Body
|
||||
resp = proxy.filterResponse(resp, ctx)
|
||||
|
||||
defer origBody.Close()
|
||||
ctx.Logf("Copying response to client %v [%d]", resp.Status, resp.StatusCode)
|
||||
// http.ResponseWriter will take care of filling the correct response length
|
||||
// Setting it now, might impose wrong value, contradicting the actual new
|
||||
|
|
Loading…
Reference in New Issue