MCPcopy Create free account
hub / github.com/subtrace/subtrace / start

Method start

cmd/proxy/proxy.go:179–198  ·  view source on GitHub ↗
(ctx context.Context)

Source from the content-addressed store, hash-verified

177}
178
179func (c *Command) start(ctx context.Context) error {
180 addr := fmt.Sprintf(":%d", c.from)
181 lis, err := net.Listen("tcp", addr)
182 if err != nil {
183 return fmt.Errorf("listen: %w", err)
184 }
185
186 p := martian.NewProxy()
187 p.SetRequestModifier(c)
188 p.SetRoundTripper(c)
189 p.SetDial(func(network string, addr string) (net.Conn, error) {
190 return new(net.Dialer).DialContext(ctx, network, addr)
191 })
192
193 slog.Debug("listening for new connections", "addr", addr)
194 if err := p.Serve(lis); err != nil {
195 return fmt.Errorf("serve: %w", err)
196 }
197 return nil
198}
199
200func (c *Command) ModifyRequest(req *http.Request) error {
201 if c.global.Devtools.HijackPath != "" && req.URL.Path == c.global.Devtools.HijackPath {

Callers 1

entrypointMethod · 0.95

Calls 1

ListenMethod · 0.80

Tested by

no test coverage detected