-
Notifications
You must be signed in to change notification settings - Fork 4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add passthrough handler #16
Conversation
118fb9b
to
73639d6
Compare
This passes through GET requests other than get-entries to the CT backend. This is particularly useful for some log scanning tools that call `/ct/v1/get-sth` before beginning their scan. This is mainly intended as a convenience for small scale testing. In production we plan to bypass this tool for all request paths other than /ct/v1/get-entries.
73639d6
to
41e4ee0
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. Once this lands, #17 will need to be updated to pass the mux
instead of the handler
on line 464.
main.go
Outdated
return | ||
} | ||
url := fmt.Sprintf("%s%s", p.logURL, r.URL.Path) | ||
r, err := http.NewRequestWithContext(r.Context(), http.MethodGet, url, nil) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You are reusing the input r *http.Request
here.
r, err := http.NewRequestWithContext(r.Context(), http.MethodGet, url, nil) | |
req, err := http.NewRequestWithContext(r.Context(), http.MethodGet, url, nil) |
w.WriteHeader(http.StatusInternalServerError) | ||
fmt.Fprintf(w, "fetching %s: %s\n", url, err) | ||
return | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think resp.Body
needs to be closed before we return.
} | |
} | |
defer resp.Body.Close() |
main.go
Outdated
} | ||
|
||
w.WriteHeader(resp.StatusCode) | ||
io.Copy(w, resp.Body) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
io.Copy
could return an error and it would be going unchecked.
This changed in #16 to accept only the exact request path `/ct/v1/get-entries`. But it turns out it's easier for the reverse-proxy configuration if we go back to the old behavior: accepting any request path ending in `/ct/v1/get-entries`.
This passes through GET requests other than get-entries to the CT backend. This is particularly useful for some log scanning tools that call
/ct/v1/get-sth
before beginning their scan.This is mainly intended as a convenience for small scale testing. In production we plan to bypass this tool for all request paths other than /ct/v1/get-entries.