MCPcopy Create free account
hub / github.com/coder/coder / basicDERPMap

Function basicDERPMap

tailnet/test/integration/integration.go:545–593  ·  view source on GitHub ↗
(serverURLStr string)

Source from the content-addressed store, hash-verified

543}
544
545func basicDERPMap(serverURLStr string) (*tailcfg.DERPMap, error) {
546 serverURL, err := url.Parse(serverURLStr)
547 if err != nil {
548 return nil, xerrors.Errorf("parse server URL %q: %w", serverURLStr, err)
549 }
550
551 portStr := serverURL.Port()
552 port, err := strconv.Atoi(portStr)
553 if err != nil {
554 return nil, xerrors.Errorf("parse port %q: %w", portStr, err)
555 }
556
557 hostname := serverURL.Hostname()
558 ipv4 := "none"
559 ipv6 := "none"
560 ip, err := netip.ParseAddr(hostname)
561 if err == nil {
562 hostname = ""
563 if ip.Is4() {
564 ipv4 = ip.String()
565 }
566 if ip.Is6() {
567 ipv6 = ip.String()
568 }
569 }
570
571 return &tailcfg.DERPMap{
572 Regions: map[int]*tailcfg.DERPRegion{
573 1: {
574 RegionID: 1,
575 RegionCode: "test",
576 RegionName: "test server",
577 Nodes: []*tailcfg.DERPNode{
578 {
579 Name: "test0",
580 RegionID: 1,
581 HostName: hostname,
582 IPv4: ipv4,
583 IPv6: ipv6,
584 DERPPort: port,
585 STUNPort: -1,
586 ForceHTTP: true,
587 InsecureForTests: true,
588 },
589 },
590 },
591 },
592 }, nil
593}
594
595// ExecBackground starts a subprocess with the given flags and returns a
596// channel that will receive the error when the subprocess exits. The returned

Callers 1

ResolveDERPMapMethod · 0.85

Calls 3

ParseMethod · 0.65
ErrorfMethod · 0.45
StringMethod · 0.45

Tested by

no test coverage detected