Skip to content
Permalink
Browse files

(dockerv2): Remove the User-Agent header check

  • Loading branch information
erbesharat committed Dec 19, 2019
1 parent d8c0429 commit 36d70eacc713df442aba5fd218c68275134a11aa
Showing with 0 additions and 15 deletions.
  1. +0 −10 dockerv2.go
  2. +0 −5 txtdirect.go
@@ -79,16 +79,6 @@ func (d *Dockerv2) Redirect() error {
return nil
}

// ValidAgent checks the User-Agent header to be sure it's Docker-Client
func (d *Dockerv2) ValidAgent() bool {
if !strings.Contains(d.req.Header.Get("User-Agent"), "Docker-Client") {
log.Println("[txtdirect]: The request is not from docker client, fallback triggered.")
fallback(d.rw, d.req, "to", d.rec.Code, d.c)
return false
}
return true
}

func createDockerv2URI(to string, path string) (string, error) {
uri, err := url.Parse(to)
if err != nil {
@@ -248,11 +248,6 @@ func Redirect(w http.ResponseWriter, r *http.Request, c Config) error {

docker := NewDockerv2(w, r, rec, c)

// Fallback gets triggered if the User-Agent isn't valid
if !docker.ValidAgent() {
return nil
}

if err := docker.Redirect(); err != nil {
log.Printf("[txtdirect]: couldn't redirect to the requested container: %s", err.Error())
fallback(w, r, "to", rec.Code, c)

0 comments on commit 36d70ea

Please sign in to comment.
You can’t perform that action at this time.