MCPcopy
hub / github.com/tailscale/tailscale / Start

Method Start

control/controlhttp/http_test.go:413–442  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

411}
412
413func (h *httpProxy) Start(t *testing.T) (url string) {
414 t.Helper()
415 h.Lock()
416 defer h.Unlock()
417 ln, err := net.Listen("tcp", "127.0.0.1:0")
418 if err != nil {
419 t.Fatalf("listening for HTTP proxy: %v", err)
420 }
421 h.ln = ln
422 h.rp = httputil.ReverseProxy{
423 Director: func(*http.Request) {},
424 Transport: &http.Transport{
425 DialContext: h.dialAndRecord,
426 TLSClientConfig: &tls.Config{
427 InsecureSkipVerify: true,
428 },
429 TLSNextProto: map[string]func(string, *tls.Conn) http.RoundTripper{},
430 },
431 }
432 h.clientConnAddrs = map[string]bool{}
433 h.s.Handler = h
434 if h.useTLS {
435 h.s.TLSConfig = tlsConfig(t)
436 go h.s.ServeTLS(h.ln, "", "")
437 return fmt.Sprintf("https://%s", ln.Addr().String())
438 } else {
439 go h.s.Serve(h.ln)
440 return fmt.Sprintf("http://%s", ln.Addr().String())
441 }
442}
443
444func (h *httpProxy) Close() {
445 h.Lock()

Callers

nothing calls this directly

Calls 9

tlsConfigFunction · 0.85
HelperMethod · 0.65
LockMethod · 0.65
UnlockMethod · 0.65
ListenMethod · 0.65
FatalfMethod · 0.65
StringMethod · 0.65
AddrMethod · 0.45
ServeMethod · 0.45

Tested by

no test coverage detected