MCPcopy Create free account
hub / github.com/tailscale/tailcat / FetchDERPMap

Function FetchDERPMap

tailcat.go:789–806  ·  view source on GitHub ↗

FetchDERPMap fetches and decodes the JSON DERP map. The opts may contain any of the following types: - [DERPMapURL]: fetch from an alternate URL instead of [DefaultDERPMapURL]. - [ExpandForServer]: mark the fetch as being on behalf of a tailcat server rather than a client. - [DERPMapCache]: cache fe

(ctx context.Context, opts ...any)

Source from the content-addressed store, hash-verified

787// - [DERPMapCache]: cache fetched DERP maps (defaults to a
788// process-wide in-memory cache).
789func FetchDERPMap(ctx context.Context, opts ...any) (*tailcfg.DERPMap, error) {
790 fetchURL := DefaultDERPMapURL
791 mode := "client"
792 var cache DERPMapCache
793 for _, opt := range opts {
794 switch v := opt.(type) {
795 case DERPMapURL:
796 fetchURL = string(v)
797 case expandForServer:
798 mode = "server"
799 case DERPMapCache:
800 cache = v
801 default:
802 return nil, fmt.Errorf("unknown FetchDERPMap option type %T", opt)
803 }
804 }
805 return fetchDERPMap(ctx, fetchURL, mode, cache)
806}
807
808// memDERPMapCache is a process-wide in-memory [DERPMapCache], the
809// default when no cache option is provided.

Callers 2

genKeyFunction · 0.92

Calls 1

fetchDERPMapFunction · 0.85

Tested by 1