MCPcopy Create free account
hub / github.com/SenseUnit/dumbproxy / NewProxyHandler

Function NewProxyHandler

handler/handler.go:47–79  ·  view source on GitHub ↗
(config *Config)

Source from the content-addressed store, hash-verified

45}
46
47func NewProxyHandler(config *Config) *ProxyHandler {
48 d := config.Dialer
49 if d == nil {
50 d = dialer.NewBoundDialer(nil, "")
51 }
52 httptransport := &http.Transport{
53 DialContext: d.DialContext,
54 DisableKeepAlives: true,
55 }
56 a := config.Auth
57 if a == nil {
58 a = auth.NoAuth{}
59 }
60 l := config.Logger
61 if l == nil {
62 l = clog.NewCondLogger(log.New(io.Discard, "", 0), 0)
63 }
64 f := config.Forward
65 if f == nil {
66 f = forward.PairConnections
67 }
68 return &ProxyHandler{
69 auth: a,
70 directResponse: config.DirectResponse,
71 accessReject: config.AccessReject,
72 logger: l,
73 dialer: d,
74 forward: f,
75 httptransport: httptransport,
76 outbound: make(map[string]string),
77 userIPHints: config.UserIPHints,
78 }
79}
80
81func (s *ProxyHandler) HandleTunnel(wr http.ResponseWriter, req *http.Request, username string) {
82 conn, err := s.dialer.DialContext(req.Context(), "tcp", req.RequestURI)

Callers 3

runFunction · 0.92
TestDirectResponseFunction · 0.85
TestAccessRejectFunction · 0.85

Calls 1

NewBoundDialerFunction · 0.92

Tested by 2

TestDirectResponseFunction · 0.68
TestAccessRejectFunction · 0.68