Skip to content

Commit 9794914

Browse files
committed
chore: upgrade goVirtualHost
1 parent 97ced9f commit 9794914

File tree

1 file changed

+34
-29
lines changed

1 file changed

+34
-29
lines changed

src/goVirtualHost/service.go

Lines changed: 34 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,7 @@ func (svc *Service) GetAccessibleURLs(includeLoopback bool) [][]string {
193193

194194
for _, l := range svc.listenables {
195195
s := l.serveable
196-
defaultVh := s.getDefaultVhost()
196+
s.updateDefaultVhost()
197197

198198
port := ""
199199
if !isDefaultPort(l.port, s.useTLS) {
@@ -219,34 +219,39 @@ func (svc *Service) GetAccessibleURLs(includeLoopback bool) [][]string {
219219
vhUrls[vh] = append(vhUrls[vh], url)
220220
}
221221
}
222-
if vh == defaultVh {
223-
var url string
224-
if s.useTLS {
225-
url = httpsUrl
226-
} else {
227-
url = httpUrl
228-
}
229-
if len(l.ip) > 0 {
230-
url = url + l.ip + port
231-
vhUrls[vh] = append(vhUrls[vh], url)
232-
} else {
233-
if !gotIPList {
234-
gotIPList = true
235-
ipv46s, ipv4s, ipv6s = getAllIfaceIPs(includeLoopback)
236-
}
237-
var ips []string
238-
switch l.proto {
239-
case tcp46:
240-
ips = ipv46s
241-
case tcp4:
242-
ips = ipv4s
243-
case tcp6:
244-
ips = ipv6s
245-
}
246-
for _, ip := range ips {
247-
ipUrl := url + ip + port
248-
vhUrls[vh] = append(vhUrls[vh], ipUrl)
249-
}
222+
223+
if vh != s.defaultVhost {
224+
continue
225+
}
226+
var url string
227+
if s.useTLS {
228+
url = httpsUrl
229+
} else {
230+
url = httpUrl
231+
}
232+
if len(l.ip) > 0 {
233+
url = url + l.ip + port
234+
vhUrls[vh] = append(vhUrls[vh], url)
235+
continue
236+
}
237+
238+
if !gotIPList {
239+
gotIPList = true
240+
ipv46s, ipv4s, ipv6s = getAllIfaceIPs(includeLoopback)
241+
}
242+
var ips []string
243+
switch l.proto {
244+
case tcp46:
245+
ips = ipv46s
246+
case tcp4:
247+
ips = ipv4s
248+
case tcp6:
249+
ips = ipv6s
250+
}
251+
for _, ip := range ips {
252+
if ipVh := s.lookupVhost(ip); ipVh == vh {
253+
ipUrl := url + ip + port
254+
vhUrls[vh] = append(vhUrls[vh], ipUrl)
250255
}
251256
}
252257
}

0 commit comments

Comments
 (0)