Skip to content

Commit 7ddf223

Browse files
committed
Fixed tls host lookup
Signed-off-by: Vishal Rana <[email protected]>
1 parent 953f9ea commit 7ddf223

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

armor.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ type (
4242

4343
TLS struct {
4444
Address string `json:"address"`
45+
Port string `json:"-"`
4546
CertFile string `json:"cert_file"`
4647
KeyFile string `json:"key_file"`
4748
Auto bool `json:"auto"`
@@ -134,9 +135,11 @@ func (a *Armor) FindHost(name string, add bool) (h *Host) {
134135

135136
// Initialize host
136137
if !h.initialized {
138+
h.Name = name
137139
h.Paths = make(Paths)
138140
h.Group = a.Echo.Host(net.JoinHostPort(name, a.Port))
139-
h.Name = name
141+
routers := a.Echo.Routers()
142+
routers[net.JoinHostPort(name, a.TLS.Port)] = routers[name]
140143
h.initialized = true
141144
}
142145

http.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ func (a *Armor) NewHTTP() (h *HTTP) {
4343
WriteTimeout: a.WriteTimeout * time.Second,
4444
}
4545
if a.TLS != nil {
46+
_, a.TLS.Port, _ = net.SplitHostPort(a.TLS.Address)
4647
e.TLSServer = &http.Server{
4748
Addr: a.TLS.Address,
4849
TLSConfig: a.setupTLSConfig(),
@@ -89,8 +90,7 @@ func (h *HTTP) Start() error {
8990
a.Colorer.Printf("⇨ serving from %s (Local)\n", a.Colorer.Green("http://localhost"+a.Address))
9091
ip := util.PrivateIP()
9192
if ip != "" {
92-
_, port, _ := net.SplitHostPort(a.Address)
93-
a.Colorer.Printf("⇨ serving from %s (Intranet)\n", a.Colorer.Green(fmt.Sprintf("http://%s:%s", ip, port)))
93+
a.Colorer.Printf("⇨ serving from %s (Intranet)\n", a.Colorer.Green(fmt.Sprintf("http://%s:%s", ip, a.Port)))
9494
}
9595
} else {
9696
a.Colorer.Printf("⇨ http server started on %s\n", a.Colorer.Green(a.Address))

0 commit comments

Comments
 (0)