WebUI: add udp pages

This commit is contained in:
Matthieu Hostache 2020-02-26 11:12:06 +01:00 committed by GitHub
parent 336dd1d5ba
commit 7a5d2a3bd9
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
23 changed files with 842 additions and 10 deletions

View file

@ -32,6 +32,7 @@ type features struct {
type overview struct {
HTTP schemeOverview `json:"http"`
TCP schemeOverview `json:"tcp"`
UDP schemeOverview `json:"udp"`
Features features `json:"features,omitempty"`
Providers []string `json:"providers,omitempty"`
}
@ -47,6 +48,10 @@ func (h Handler) getOverview(rw http.ResponseWriter, request *http.Request) {
Routers: getTCPRouterSection(h.runtimeConfiguration.TCPRouters),
Services: getTCPServiceSection(h.runtimeConfiguration.TCPServices),
},
UDP: schemeOverview{
Routers: getUDPRouterSection(h.runtimeConfiguration.UDPRouters),
Services: getUDPServiceSection(h.runtimeConfiguration.UDPServices),
},
Features: getFeatures(h.staticConfig),
Providers: getProviders(h.staticConfig),
}
@ -155,6 +160,44 @@ func getTCPServiceSection(services map[string]*runtime.TCPServiceInfo) *section
}
}
func getUDPRouterSection(routers map[string]*runtime.UDPRouterInfo) *section {
var countErrors int
var countWarnings int
for _, rt := range routers {
switch rt.Status {
case runtime.StatusDisabled:
countErrors++
case runtime.StatusWarning:
countWarnings++
}
}
return &section{
Total: len(routers),
Warnings: countWarnings,
Errors: countErrors,
}
}
func getUDPServiceSection(services map[string]*runtime.UDPServiceInfo) *section {
var countErrors int
var countWarnings int
for _, svc := range services {
switch svc.Status {
case runtime.StatusDisabled:
countErrors++
case runtime.StatusWarning:
countWarnings++
}
}
return &section{
Total: len(services),
Warnings: countWarnings,
Errors: countErrors,
}
}
func getProviders(conf static.Configuration) []string {
if conf.Providers == nil {
return nil