From 2e12510bf55c397c43b0c184d57f274e8146f853 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Nieto?= Date: Sun, 12 Apr 2020 19:02:44 -0500 Subject: [PATCH] update travis file --- .travis.yml | 10 +++------- go.mod | 2 -- go.sum | 21 --------------------- pkg/gencert/gencert.go | 6 +++--- pkg/proxy/proxy.go | 4 ++++ pkg/proxy/proxy_test.go | 8 ++++++-- 6 files changed, 16 insertions(+), 35 deletions(-) diff --git a/.travis.yml b/.travis.yml index 636092d..6f62f5e 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,12 +1,8 @@ language: go go: - - "1.8" - - "1.9" - -before_script: - - "go get -u github.com/golang/dep/cmd/dep" - - "dep ensure" + - "1.13" + - "1.14" script: - - "go test -v" + - "go test -v ./..." diff --git a/go.mod b/go.mod index 6369886..78da9c0 100644 --- a/go.mod +++ b/go.mod @@ -12,9 +12,7 @@ require ( github.com/pkg/browser v0.0.0-20180916011732-0a3d74bf9ce4 github.com/rakyll/statik v0.1.7 github.com/stretchr/testify v1.5.1 // indirect - github.com/tv42/httpunix v0.0.0-20150427012821-b75d8614f926 golang.org/x/net v0.0.0-20200226121028-0de0cce0169b - golang.org/x/tools v0.0.0-20200410194907-79a7a3126eef // indirect gopkg.in/mgo.v2 v2.0.0-20190816093944-a6b53ec6cb22 // indirect upper.io/db.v3 v3.6.1+incompatible ) diff --git a/go.sum b/go.sum index 5d8688d..bd7b572 100644 --- a/go.sum +++ b/go.sum @@ -1,6 +1,5 @@ github.com/davecgh/go-spew v1.1.0 h1:ZDRjVQ15GmhC3fiQ8ni8+OwkZQO4DARzQgrnXU1Liz8= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= -github.com/go-chi/chi v1.0.0 h1:s/kv1cTXfivYjdKJdyUzNGyAWZ/2t7duW1gKn5ivu+c= github.com/go-chi/chi v4.0.3+incompatible h1:gakN3pDJnzZN5jqFV2TEdF66rTfKeITyR8qu6ekICEY= github.com/go-chi/chi v4.0.3+incompatible/go.mod h1:eB3wogJHnLi3x/kFX2A+IbTBlXxmMeXJVKy9tTv1XzQ= github.com/go-chi/cors v1.0.1 h1:56TT/uWGoLWZpnMI/AwAmCneikXr5eLsiIq27wrKecw= @@ -26,33 +25,13 @@ github.com/rakyll/statik v0.1.7/go.mod h1:AlZONWzMtEnMs7W4e/1LURLiI49pIMmp6V9Ung github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/testify v1.5.1 h1:nOGnQDM7FYENwehXlg/kFVnos3rEvtKTjRvOWSzb6H4= github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA= -github.com/tv42/httpunix v0.0.0-20150427012821-b75d8614f926 h1:G3dpKMzFDjgEh2q1Z7zUUtKa8ViPtH+ocF0bE0g00O8= -github.com/tv42/httpunix v0.0.0-20150427012821-b75d8614f926/go.mod h1:9ESjWnEqriFuLhtthL60Sar/7RFoluCcXsuvEwTV5KM= -github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= -golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= -golang.org/x/mod v0.2.0 h1:KU7oHjnv3XNWfa5COkzUifxZmxp1TyI7ImMXqFxLwvQ= -golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= -golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= -golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= -golang.org/x/net v0.0.0-20190926025831-c00fd9afed17 h1:qPnAdmjNA41t3QBTx2mFGf/SD1IoslhYu7AmdsVzCcs= -golang.org/x/net v0.0.0-20190926025831-c00fd9afed17/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20200226121028-0de0cce0169b h1:0mm1VjtFUOIlE1SbDlwjYaDxZVDP2S5ou6y0gSgXHu8= golang.org/x/net v0.0.0-20200226121028-0de0cce0169b/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= -golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190222072716-a9d3bda3a223/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= -golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/text v0.3.0 h1:g61tztE5qeGQ89tm6NTjjM9VPIm088od1l6aSorWRWg= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= -golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= -golang.org/x/tools v0.0.0-20200410194907-79a7a3126eef h1:RHORRhs540cYZYrzgU2CPUyykkwZM78hGdzocOo9P8A= -golang.org/x/tools v0.0.0-20200410194907-79a7a3126eef/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= -golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543 h1:E7g+9GITq07hpfrRu66IVDexMakfv52eLZ2CXBWiKr4= -golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/mgo.v2 v2.0.0-20190816093944-a6b53ec6cb22 h1:VpOs+IwYnYBaFnrNAeB8UUWtL3vEUnzSCL1nVjPhqrw= diff --git a/pkg/gencert/gencert.go b/pkg/gencert/gencert.go index 50d723a..ce2657e 100644 --- a/pkg/gencert/gencert.go +++ b/pkg/gencert/gencert.go @@ -47,8 +47,8 @@ const ( ) var ( - rootCACert = "../../ssl/rootCA.crt" - rootCAKey = "../../ssl/rootCA.key" + rootCACert = "../../ca/rootCA.crt" + rootCAKey = "../../ca/rootCA.key" ) var ( @@ -85,7 +85,7 @@ func CreateKeyPair(commonName string) (certFile string, keyFile string, err erro // Attempt to verify certs. if _, err = tls.LoadX509KeyPair(certFile, keyFile); err == nil { // Keys already in place - return "", "", err + return certFile, keyFile, nil } log.Printf("Creating SSL certificate for %s...", commonName) diff --git a/pkg/proxy/proxy.go b/pkg/proxy/proxy.go index 725c0b5..2aa5843 100644 --- a/pkg/proxy/proxy.go +++ b/pkg/proxy/proxy.go @@ -226,6 +226,10 @@ func (p *Proxy) ServeHTTP(w http.ResponseWriter, r *http.Request) { // Proxying client request to destination server. var err error + if p.rt == nil { + log.Printf("Missing RoundTripper") + return + } if pr.Response, err = p.rt.RoundTrip(out); err != nil { log.Printf("RoundTrip: %q", err) w.WriteHeader(http.StatusInternalServerError) diff --git a/pkg/proxy/proxy_test.go b/pkg/proxy/proxy_test.go index 1891fe9..3af82b6 100644 --- a/pkg/proxy/proxy_test.go +++ b/pkg/proxy/proxy_test.go @@ -121,7 +121,7 @@ func TestListenHTTP(t *testing.T) { proxy = NewProxy() go func() { - time.Sleep(time.Second * 5) + time.Sleep(time.Second * 10) proxy.Stop() }() @@ -132,13 +132,15 @@ func TestListenHTTP(t *testing.T) { } } }() + + time.Sleep(time.Second) } func TestListenHTTPs(t *testing.T) { sslProxy = NewProxy() go func() { - time.Sleep(time.Second * 5) + time.Sleep(time.Second * 10) sslProxy.Stop() }() @@ -149,6 +151,8 @@ func TestListenHTTPs(t *testing.T) { } } }() + + time.Sleep(time.Second) } func TestProxyResponse(t *testing.T) {