replace all assemble of host name for service with strings.Join

Signed-off-by: KevinLiang10 <37811973+KevinLiang10@users.noreply.github.com>
This commit is contained in:
KevinLiang10 2025-06-26 15:38:18 -04:00
parent 8d861680d2
commit d40755be85
2 changed files with 4 additions and 4 deletions

View File

@ -932,7 +932,7 @@ func (e *serveEnv) removeWebServe(sc *ipn.ServeConfig, st *ipnstate.Status, dnsN
if svc == nil {
return errors.New("service does not exist")
}
hostName = svcName.WithoutPrefix() + "." + st.CurrentTailnet.MagicDNSSuffix
hostName = strings.Join([]string{svcName.WithoutPrefix(), st.CurrentTailnet.MagicDNSSuffix}, ".")
webServeMap = svc.Web
}

View File

@ -348,7 +348,7 @@ func (sc *ServeConfig) SetWebHandler(st *ipnstate.Status, handler *HTTPHandler,
webServerMap := &sc.Web
hostName := host
if svcName, ok := tailcfg.AsServiceName(host); ok {
hostName = svcName.WithoutPrefix() + "." + st.CurrentTailnet.MagicDNSSuffix
hostName = strings.Join([]string{svcName.WithoutPrefix(), st.CurrentTailnet.MagicDNSSuffix}, ".")
if _, ok := sc.Services[svcName]; !ok {
mak.Set(&sc.Services, svcName, new(ServiceConfig))
}
@ -458,8 +458,8 @@ func (sc *ServeConfig) RemoveWebHandler(host string, port uint16, mounts []strin
// RemoveServiceWebHandler deletes the web handlers at all of the given mount points
// for the provided host and port in the serve config for the given service.
func (sc *ServeConfig) RemoveServiceWebHandler(st *ipnstate.Status, svcName tailcfg.ServiceName, port uint16, mounts []string) {
dnsNameForService := svcName.WithoutPrefix() + "." + st.CurrentTailnet.MagicDNSSuffix
hp := HostPort(net.JoinHostPort(dnsNameForService, strconv.Itoa(int(port))))
hostName := strings.Join([]string{svcName.WithoutPrefix(), st.CurrentTailnet.MagicDNSSuffix}, ".")
hp := HostPort(net.JoinHostPort(hostName, strconv.Itoa(int(port))))
svc, ok := sc.Services[svcName]
if !ok || svc == nil {