66 "context"
77 "flag"
88 "github.com/docker/go-connections/sockets"
9+ "github.com/linead/docker-socket-firewall/pkg/opa"
10+ "github.com/pkg/errors"
11+ log "github.com/sirupsen/logrus"
912 "golang.org/x/net/context/ctxhttp"
1013 "io"
1114 "io/ioutil"
@@ -15,9 +18,6 @@ import (
1518 "os"
1619 "regexp"
1720 "time"
18- "github.com/linead/docker-socket-firewall/pkg/opa"
19- "github.com/pkg/errors"
20- log "github.com/sirupsen/logrus"
2121)
2222
2323var opaHandler opa.DockerHandler
@@ -41,9 +41,9 @@ func serveReverseProxy(w http.ResponseWriter, req *http.Request) {
4141 req .RequestURI = ""
4242 req .Close = true
4343
44- if ( req .Header .Get ("Connection" ) == "Upgrade" ) {
45- if ( req .Header .Get ("Upgrade" ) != "tcp" && req .Header .Get ("Upgrade" ) != "h2c" ) {
46- http .Error (w , "Unsupported upgrade protocol: " + req .Header .Get ("Protocol" ), http .StatusInternalServerError )
44+ if req .Header .Get ("Connection" ) == "Upgrade" {
45+ if req .Header .Get ("Upgrade" ) != "tcp" && req .Header .Get ("Upgrade" ) != "h2c" {
46+ http .Error (w , "Unsupported upgrade protocol: " + req .Header .Get ("Protocol" ), http .StatusInternalServerError )
4747 return
4848 }
4949 log .Debug ("Connection upgrading" )
@@ -112,7 +112,7 @@ func hijack(req *http.Request, w http.ResponseWriter) {
112112 return
113113 }
114114
115- if ( br .Buffered () > 0 ) {
115+ if br .Buffered () > 0 {
116116 log .Debugf ("Found buffered bytes" )
117117 var bs = make ([]byte , br .Buffered ())
118118 br .Read (bs )
@@ -126,7 +126,7 @@ func hijack(req *http.Request, w http.ResponseWriter) {
126126 log .Debugf ("%s Streaming connections" , desc )
127127 written , err := copyBuffer (dst , src )
128128 log .Debugf ("%s wrote %v, err: %v" , desc , written , err )
129- errc <- err
129+ errc <- err
130130 }
131131
132132 go streamFn (outConn , c , errClient , "docker -> client" )
0 commit comments