if no dig then no hijack
parent
9a60d782e3
commit
e5ba5c9777
10
server.go
10
server.go
|
|
@ -9,6 +9,7 @@ import (
|
|||
"log"
|
||||
"net"
|
||||
"net/http"
|
||||
"net/http/httputil"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
|
|
@ -78,6 +79,11 @@ func (s *Server) Connect(w http.ResponseWriter, r *http.Request) {
|
|||
return
|
||||
}
|
||||
|
||||
if host == r.Host {
|
||||
s.connectHTTPReverseProxy(w, r)
|
||||
return
|
||||
}
|
||||
|
||||
dest, err := net.DialTimeout("tcp", host, s.Timeout)
|
||||
if err != nil {
|
||||
s.Error(r, w, fmt.Errorf("error dialing w timeout %s=>%s: %w", r.Host, host, err))
|
||||
|
|
@ -102,6 +108,10 @@ func (s *Server) Connect(w http.ResponseWriter, r *http.Request) {
|
|||
go s.xfer(r.Context(), client, dest)
|
||||
}
|
||||
|
||||
func (s *Server) connectHTTPReverseProxy(w http.ResponseWriter, r *http.Request) {
|
||||
httputil.NewSingleHostReverseProxy(r.URL).ServeHTTP(w, r)
|
||||
}
|
||||
|
||||
func (s *Server) Serve(w http.ResponseWriter, r *http.Request) {
|
||||
resp, err := s.Transport.RoundTrip(r)
|
||||
if err != nil {
|
||||
|
|
|
|||
Loading…
Reference in New Issue