зеркало из https://github.com/Azure/ARO-RP.git
bug fix: correct connection close behaviour
This commit is contained in:
Родитель
07270d5654
Коммит
d7ddb2571b
|
@ -329,16 +329,20 @@ func (s *ssh) proxyChannel(ch1, ch2 cryptossh.Channel, rs1, rs2 <-chan *cryptoss
|
|||
defer recover.Panic(s.log)
|
||||
|
||||
defer wg.Done()
|
||||
defer func() {
|
||||
_ = ch1.CloseWrite()
|
||||
}()
|
||||
_, _ = io.Copy(ch1, ch2)
|
||||
_ = ch1.CloseWrite()
|
||||
}()
|
||||
|
||||
go func() {
|
||||
defer recover.Panic(s.log)
|
||||
|
||||
defer wg.Done()
|
||||
defer func() {
|
||||
_ = ch2.CloseWrite()
|
||||
}()
|
||||
_, _ = io.Copy(ch2, ch1)
|
||||
_ = ch2.CloseWrite()
|
||||
}()
|
||||
|
||||
go func() {
|
||||
|
|
|
@ -115,6 +115,7 @@ func proxy(w http.ResponseWriter, r *http.Request) {
|
|||
hijacker, ok := w.(http.Hijacker)
|
||||
if !ok {
|
||||
http.Error(w, "hijacking not supported", http.StatusInternalServerError)
|
||||
c2.Close()
|
||||
return
|
||||
}
|
||||
|
||||
|
@ -123,14 +124,20 @@ func proxy(w http.ResponseWriter, r *http.Request) {
|
|||
c1, buf, err := hijacker.Hijack()
|
||||
if err != nil {
|
||||
http.Error(w, err.Error(), http.StatusInternalServerError)
|
||||
c1.Close()
|
||||
c2.Close()
|
||||
return
|
||||
}
|
||||
|
||||
go func() {
|
||||
defer func() {
|
||||
_ = c2.(*net.TCPConn).CloseWrite()
|
||||
}()
|
||||
_, _ = io.Copy(c2, buf)
|
||||
_ = c2.(*net.TCPConn).CloseWrite()
|
||||
}()
|
||||
|
||||
defer func() {
|
||||
_ = c1.(*tls.Conn).CloseWrite()
|
||||
}()
|
||||
_, _ = io.Copy(c1, c2)
|
||||
_ = c1.(*tls.Conn).CloseWrite()
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче