Skip to content

Commit 5a12e8f

Browse files
committed
fix: go test build failed
1 parent ad16215 commit 5a12e8f

File tree

1 file changed

+0
-49
lines changed

1 file changed

+0
-49
lines changed

cmd/server/http_proxy/main.go

-49
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,6 @@ package http_proxy
33
import (
44
"context"
55
"errors"
6-
"io"
7-
"net"
86
"net/http"
97
"net/http/httputil"
108
"os"
@@ -23,53 +21,6 @@ func logRequest(next http.HandlerFunc) http.HandlerFunc {
2321
}
2422
}
2523

26-
func tunnel(w http.ResponseWriter, r *http.Request) {
27-
dialer := net.Dialer{}
28-
serverConn, err := dialer.DialContext(r.Context(), "tcp", r.Host)
29-
if err != nil {
30-
log.Error("failed to connect to upstream %s", r.Host)
31-
http.Error(w, http.StatusText(http.StatusServiceUnavailable), http.StatusServiceUnavailable)
32-
return
33-
}
34-
defer serverConn.Close()
35-
36-
hj, ok := w.(http.Hijacker)
37-
if !ok {
38-
log.Error("hijack of connection failed")
39-
http.Error(w, http.StatusText(http.StatusInternalServerError), http.StatusInternalServerError)
40-
return
41-
}
42-
43-
w.WriteHeader(http.StatusOK)
44-
45-
clientConn, bufClientConn, err := hj.Hijack()
46-
if err != nil {
47-
log.Error(err)
48-
http.Error(w, http.StatusText(http.StatusInternalServerError), http.StatusInternalServerError)
49-
return
50-
}
51-
defer clientConn.Close()
52-
53-
go io.Copy(serverConn, bufClientConn)
54-
io.Copy(bufClientConn, serverConn)
55-
}
56-
57-
func forward(w http.ResponseWriter, r *http.Request) {
58-
resp, err := http.DefaultTransport.RoundTrip(r)
59-
if err != nil {
60-
log.Error(err)
61-
http.Error(w, http.StatusText(http.StatusServiceUnavailable), http.StatusServiceUnavailable)
62-
return
63-
}
64-
for header, values := range resp.Header {
65-
for _, value := range values {
66-
w.Header().Add(header, value)
67-
}
68-
}
69-
w.WriteHeader(resp.StatusCode)
70-
io.Copy(w, resp.Body)
71-
}
72-
7324
func CreateHttpProxyServer(TargetConn *websocket.Conn, Port string, rch chan define.RelayCommandResp, stop chan struct{}) {
7425
var (
7526
caCertFile = "cert/cert.pem"

0 commit comments

Comments
 (0)