deprecated Hijack needs to SetReadDeadline on the Conn of the request, but if we use stream compression here, we may always get i/o timeout error.
(rw http.ResponseWriter, req *http.Request)
| 136 | // Hijack needs to SetReadDeadline on the Conn of the request, but if we use stream compression here, |
| 137 | // we may always get i/o timeout error. |
| 138 | func (hp *HTTPProxy) ConnectHandler(rw http.ResponseWriter, req *http.Request) { |
| 139 | hj, ok := rw.(http.Hijacker) |
| 140 | if !ok { |
| 141 | rw.WriteHeader(http.StatusInternalServerError) |
| 142 | return |
| 143 | } |
| 144 | |
| 145 | client, _, err := hj.Hijack() |
| 146 | if err != nil { |
| 147 | rw.WriteHeader(http.StatusInternalServerError) |
| 148 | return |
| 149 | } |
| 150 | |
| 151 | remote, err := net.Dial("tcp", req.URL.Host) |
| 152 | if err != nil { |
| 153 | http.Error(rw, "Failed", http.StatusBadRequest) |
| 154 | client.Close() |
| 155 | return |
| 156 | } |
| 157 | _, _ = client.Write([]byte("HTTP/1.1 200 OK\r\n\r\n")) |
| 158 | |
| 159 | go frpIo.Join(remote, client) |
| 160 | } |
| 161 | |
| 162 | func (hp *HTTPProxy) Auth(req *http.Request) bool { |
| 163 | if hp.AuthUser == "" && hp.AuthPasswd == "" { |