MCPcopy
hub / github.com/caddyserver/caddy / RegisterServerNames

Method RegisterServerNames

modules/caddytls/tls.go:666–698  ·  view source on GitHub ↗

RegisterServerNames registers the provided DNS names with the TLS app and associates them with the given HTTPS RR ALPN values, if any. This is currently used to auto-publish Encrypted ClientHello (ECH) configurations, if enabled. Use of this function by apps using the TLS app removes the need for th

(dnsNames, alpnValues []string)

Source from the content-addressed store, hash-verified

664//
665// EXPERIMENTAL: This function and its semantics/behavior are subject to change.
666func (t *TLS) RegisterServerNames(dnsNames, alpnValues []string) {
667 t.serverNamesMu.Lock()
668 defer t.serverNamesMu.Unlock()
669
670 for _, name := range dnsNames {
671 host, _, err := net.SplitHostPort(name)
672 if err != nil {
673 host = name
674 }
675 host = strings.ToLower(strings.TrimSpace(host))
676 if host == "" || certmagic.SubjectIsIP(host) {
677 continue
678 }
679
680 registration := t.serverNames[host]
681
682 if len(alpnValues) == 0 {
683 t.serverNames[host] = registration
684 continue
685 }
686
687 if registration.alpnValues == nil {
688 registration.alpnValues = make(map[string]struct{}, len(alpnValues))
689 }
690 for _, alpn := range alpnValues {
691 if alpn == "" {
692 continue
693 }
694 registration.alpnValues[alpn] = struct{}{}
695 }
696 t.serverNames[host] = registration
697 }
698}
699
700func (t *TLS) alpnValuesForServerNames(dnsNames []string) map[string][]string {
701 t.serverNamesMu.Lock()

Callers 3

TLSConfigMethod · 0.80
automaticHTTPSPhase1Method · 0.80

Calls

no outgoing calls

Tested by 1