proxyserver
This commit is contained in:
parent
4c944c8c72
commit
7866a5a369
|
@ -209,22 +209,22 @@ func NewBackend(mux *http.ServeMux, httpAddress string, muxPaths ...string) *Bac
|
||||||
target := url.URL{Scheme: "ws", Host: strings.Split(backend.HttpAddress, "//")[1], Path: r.URL.Path}
|
target := url.URL{Scheme: "ws", Host: strings.Split(backend.HttpAddress, "//")[1], Path: r.URL.Path}
|
||||||
|
|
||||||
var transfer = func(src, dest *websocket.Conn) {
|
var transfer = func(src, dest *websocket.Conn) {
|
||||||
|
defer src.Close()
|
||||||
|
defer dest.Close()
|
||||||
|
// TODO: 可以做错误处理
|
||||||
for {
|
for {
|
||||||
mType, msg, err := src.ReadMessage()
|
mType, msg, err := src.ReadMessage()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Println(err)
|
log.Println(err)
|
||||||
break
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
err = dest.WriteMessage(mType, msg)
|
err = dest.WriteMessage(mType, msg)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Println(err)
|
log.Println(err)
|
||||||
break
|
return
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
src.Close()
|
|
||||||
dest.Close()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
header := r.Header.Clone()
|
header := r.Header.Clone()
|
||||||
|
|
Loading…
Reference in New Issue
Block a user