Skip to content

Commit 0edf0af

Browse files
committed
friendly name displayed on AutoTLS as suggested at #1578
1 parent 22e25c3 commit 0edf0af

File tree

2 files changed

+9
-3
lines changed

2 files changed

+9
-3
lines changed

core/host/supervisor.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ type Configurator func(su *Supervisor)
3131
// Interfaces are separated to return relative functionality to them.
3232
type Supervisor struct {
3333
Server *http.Server
34+
friendlyAddr string // e.g mydomain.com instead of :443 when AutoTLS is used, see `WriteStartupLogOnServe` task.
3435
disableHTTP1ToHTTP2Redirection bool
3536
closedManually uint32 // future use, accessed atomically (non-zero means we've called the Shutdown)
3637
closedByInterruptHandler uint32 // non-zero means that the end-developer interrupted it by-purpose.
@@ -347,8 +348,9 @@ func (su *Supervisor) ListenAndServeAutoTLS(domain string, email string, cacheDi
347348
cache = autocert.DirCache(cacheDir)
348349
}
349350

350-
if domain != "" {
351+
if strings.TrimSpace(domain) != "" {
351352
domains := strings.Split(domain, " ")
353+
su.friendlyAddr = domains[0]
352354
hostPolicy = autocert.HostWhitelist(domains...)
353355
}
354356

core/host/task.go

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,12 @@ import (
2222
// This function should be registered on Serve.
2323
func WriteStartupLogOnServe(w io.Writer) func(TaskHost) {
2424
return func(h TaskHost) {
25-
guessScheme := netutil.ResolveScheme(h.Supervisor.manuallyTLS)
26-
listeningURI := netutil.ResolveURL(guessScheme, h.Supervisor.Server.Addr)
25+
guessScheme := netutil.ResolveScheme(h.Supervisor.manuallyTLS || h.Supervisor.Fallback != nil)
26+
addr := h.Supervisor.friendlyAddr
27+
if addr == "" {
28+
addr = h.Supervisor.Server.Addr
29+
}
30+
listeningURI := netutil.ResolveURL(guessScheme, addr)
2731
interruptkey := "CTRL"
2832
if runtime.GOOS == "darwin" {
2933
interruptkey = "CMD"

0 commit comments

Comments
 (0)