MCPcopy Create free account
hub / github.com/M1r0ku/frp-Modify / ConnectHandler

Method ConnectHandler

frp-dev/pkg/plugin/client/http_proxy.go:138–160  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

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.
138func (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
162func (hp *HTTPProxy) Auth(req *http.Request) bool {
163 if hp.AuthUser == "" && hp.AuthPasswd == "" {

Callers 1

ServeHTTPMethod · 0.95

Calls 3

ErrorMethod · 0.80
CloseMethod · 0.65
WriteMethod · 0.45

Tested by

no test coverage detected