mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-25 20:53:33 +00:00
Merge pull request #47024 from CaoShuFeng/legacy_hijack
Automatic merge from submit-queue [legacy audit] add response audit for hijack Fixes #47097 **Release note**: ``` NONE ```
This commit is contained in:
commit
507ca73218
@ -43,12 +43,15 @@ type legacyAuditResponseWriter struct {
|
|||||||
id string
|
id string
|
||||||
}
|
}
|
||||||
|
|
||||||
func (a *legacyAuditResponseWriter) WriteHeader(code int) {
|
func (a *legacyAuditResponseWriter) printResponse(code int) {
|
||||||
line := fmt.Sprintf("%s AUDIT: id=%q response=\"%d\"\n", time.Now().Format(time.RFC3339Nano), a.id, code)
|
line := fmt.Sprintf("%s AUDIT: id=%q response=\"%d\"\n", time.Now().Format(time.RFC3339Nano), a.id, code)
|
||||||
if _, err := fmt.Fprint(a.out, line); err != nil {
|
if _, err := fmt.Fprint(a.out, line); err != nil {
|
||||||
glog.Errorf("Unable to write audit log: %s, the error is: %v", line, err)
|
glog.Errorf("Unable to write audit log: %s, the error is: %v", line, err)
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (a *legacyAuditResponseWriter) WriteHeader(code int) {
|
||||||
|
a.printResponse(code)
|
||||||
a.ResponseWriter.WriteHeader(code)
|
a.ResponseWriter.WriteHeader(code)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -68,6 +71,8 @@ func (f *fancyLegacyResponseWriterDelegator) Flush() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (f *fancyLegacyResponseWriterDelegator) Hijack() (net.Conn, *bufio.ReadWriter, error) {
|
func (f *fancyLegacyResponseWriterDelegator) Hijack() (net.Conn, *bufio.ReadWriter, error) {
|
||||||
|
// fake a response status before protocol switch happens
|
||||||
|
f.printResponse(http.StatusSwitchingProtocols)
|
||||||
return f.ResponseWriter.(http.Hijacker).Hijack()
|
return f.ResponseWriter.(http.Hijacker).Hijack()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user