ipn: add WebServerConfig, add views

cmd/viewer couldn't deal with that map-of-map. Add a wrapper type
instead, which also gives us a place to add future stuff.

Updates tailscale/corp#7515

Change-Id: I44a4ca1915300ea8678e5b0385056f0642ccb155
Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>
This commit is contained in:
Brad Fitzpatrick
2022-11-09 06:10:06 -08:00
committed by Brad Fitzpatrick
parent 79472a4a6e
commit df5e40f731
6 changed files with 330 additions and 6 deletions

View File

@@ -55,3 +55,89 @@ var _PrefsCloneNeedsRegeneration = Prefs(struct {
OperatorUser string
Persist *persist.Persist
}{})
// Clone makes a deep copy of ServeConfig.
// The result aliases no memory with the original.
func (src *ServeConfig) Clone() *ServeConfig {
if src == nil {
return nil
}
dst := new(ServeConfig)
*dst = *src
if dst.TCP != nil {
dst.TCP = map[int]*TCPPortHandler{}
for k, v := range src.TCP {
dst.TCP[k] = v.Clone()
}
}
if dst.Web != nil {
dst.Web = map[HostPort]*WebServerConfig{}
for k, v := range src.Web {
dst.Web[k] = v.Clone()
}
}
return dst
}
// A compilation failure here means this code must be regenerated, with the command at the top of this file.
var _ServeConfigCloneNeedsRegeneration = ServeConfig(struct {
TCP map[int]*TCPPortHandler
Web map[HostPort]*WebServerConfig
}{})
// Clone makes a deep copy of TCPPortHandler.
// The result aliases no memory with the original.
func (src *TCPPortHandler) Clone() *TCPPortHandler {
if src == nil {
return nil
}
dst := new(TCPPortHandler)
*dst = *src
return dst
}
// A compilation failure here means this code must be regenerated, with the command at the top of this file.
var _TCPPortHandlerCloneNeedsRegeneration = TCPPortHandler(struct {
HTTPS bool
TCPForward string
TerminateTLS bool
}{})
// Clone makes a deep copy of HTTPHandler.
// The result aliases no memory with the original.
func (src *HTTPHandler) Clone() *HTTPHandler {
if src == nil {
return nil
}
dst := new(HTTPHandler)
*dst = *src
return dst
}
// A compilation failure here means this code must be regenerated, with the command at the top of this file.
var _HTTPHandlerCloneNeedsRegeneration = HTTPHandler(struct {
Path string
Proxy string
}{})
// Clone makes a deep copy of WebServerConfig.
// The result aliases no memory with the original.
func (src *WebServerConfig) Clone() *WebServerConfig {
if src == nil {
return nil
}
dst := new(WebServerConfig)
*dst = *src
if dst.Handlers != nil {
dst.Handlers = map[string]*HTTPHandler{}
for k, v := range src.Handlers {
dst.Handlers[k] = v.Clone()
}
}
return dst
}
// A compilation failure here means this code must be regenerated, with the command at the top of this file.
var _WebServerConfigCloneNeedsRegeneration = WebServerConfig(struct {
Handlers map[string]*HTTPHandler
}{})