mirror of
https://github.com/tailscale/tailscale.git
synced 2025-06-28 11:08:40 +00:00
replace FindServiceConfig with map lookup
Signed-off-by: KevinLiang10 <37811973+KevinLiang10@users.noreply.github.com>
This commit is contained in:
parent
32cc03db20
commit
59c86c90cd
@ -444,7 +444,7 @@ func (e *serveEnv) validateConfig(sc *ipn.ServeConfig, port uint16, wantServe se
|
||||
forService := ipn.IsServiceName(dnsName)
|
||||
var tcpHandlerForPort *ipn.TCPPortHandler
|
||||
if forService {
|
||||
svc := sc.FindServiceConfig(tailcfg.ServiceName(dnsName))
|
||||
svc := sc.Services[tailcfg.ServiceName(dnsName)]
|
||||
if svc == nil {
|
||||
return nil
|
||||
}
|
||||
@ -591,7 +591,7 @@ func (e *serveEnv) messageForPort(sc *ipn.ServeConfig, st *ipnstate.Status, dnsN
|
||||
ips = serviceIPMaps[0][svcName]
|
||||
}
|
||||
output.WriteString("\n\n")
|
||||
svc := sc.FindServiceConfig(svcName)
|
||||
svc := sc.Services[svcName]
|
||||
if srvType == serveTypeTun && svc.Tun {
|
||||
output.WriteString(fmt.Sprintf(msgRunningTunService, host))
|
||||
output.WriteString("\n")
|
||||
|
12
ipn/serve.go
12
ipn/serve.go
@ -339,18 +339,6 @@ func (sc *ServeConfig) FindConfig(port uint16) (*ServeConfig, bool) {
|
||||
return nil, false
|
||||
}
|
||||
|
||||
// FindServiceConfig finds the ServiceConfig for the given service name when it
|
||||
// is hosting the given port.
|
||||
func (sc *ServeConfig) FindServiceConfig(svcName tailcfg.ServiceName) *ServiceConfig {
|
||||
if sc == nil {
|
||||
return nil
|
||||
}
|
||||
if svc, ok := sc.Services[svcName]; ok && svc != nil {
|
||||
return svc
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// SetWebHandler sets the given HTTPHandler at the specified host, port,
|
||||
// and mount in the serve config. sc.TCP is also updated to reflect web
|
||||
// serving usage of the given port.
|
||||
|
Loading…
x
Reference in New Issue
Block a user