TUN-3461: Show all origin services in the UI
This commit is contained in:
parent
8c6181db9f
commit
4698ec8dee
|
@ -246,7 +246,7 @@ type OriginRequestConfig struct {
|
||||||
ProxyAddress *string `yaml:"proxyAddress"`
|
ProxyAddress *string `yaml:"proxyAddress"`
|
||||||
// Listen port for the proxy.
|
// Listen port for the proxy.
|
||||||
ProxyPort *uint `yaml:"proxyPort"`
|
ProxyPort *uint `yaml:"proxyPort"`
|
||||||
// Valid options are 'socks', 'ssh' or empty.
|
// Valid options are 'socks' or empty.
|
||||||
ProxyType *string `yaml:"proxyType"`
|
ProxyType *string `yaml:"proxyType"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -395,7 +395,7 @@ func StartServer(
|
||||||
hostname,
|
hostname,
|
||||||
metricsListener.Addr().String(),
|
metricsListener.Addr().String(),
|
||||||
// TODO (TUN-3461): Update UI to show multiple origin URLs
|
// TODO (TUN-3461): Update UI to show multiple origin URLs
|
||||||
tunnelConfig.IngressRules.CatchAll().Service.String(),
|
&tunnelConfig.IngressRules,
|
||||||
tunnelConfig.HAConnections,
|
tunnelConfig.HAConnections,
|
||||||
)
|
)
|
||||||
logLevels, err := logger.ParseLevelString(c.String("loglevel"))
|
logLevels, err := logger.ParseLevelString(c.String("loglevel"))
|
||||||
|
|
|
@ -3,8 +3,10 @@ package ui
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
"github.com/cloudflare/cloudflared/ingress"
|
||||||
"github.com/cloudflare/cloudflared/logger"
|
"github.com/cloudflare/cloudflared/logger"
|
||||||
|
|
||||||
"github.com/gdamore/tcell"
|
"github.com/gdamore/tcell"
|
||||||
|
@ -34,11 +36,11 @@ type TunnelEvent struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
type uiModel struct {
|
type uiModel struct {
|
||||||
version string
|
version string
|
||||||
edgeURL string
|
edgeURL string
|
||||||
metricsURL string
|
metricsURL string
|
||||||
proxyURL string
|
localServices []string
|
||||||
connections []connState
|
connections []connState
|
||||||
}
|
}
|
||||||
|
|
||||||
type palette struct {
|
type palette struct {
|
||||||
|
@ -49,13 +51,17 @@ type palette struct {
|
||||||
reconnecting string
|
reconnecting string
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewUIModel(version, hostname, metricsURL, proxyURL string, haConnections int) *uiModel {
|
func NewUIModel(version, hostname, metricsURL string, ing *ingress.Ingress, haConnections int) *uiModel {
|
||||||
|
localServices := make([]string, len(ing.Rules))
|
||||||
|
for i, rule := range ing.Rules {
|
||||||
|
localServices[i] = rule.Service.String()
|
||||||
|
}
|
||||||
return &uiModel{
|
return &uiModel{
|
||||||
version: version,
|
version: version,
|
||||||
edgeURL: hostname,
|
edgeURL: hostname,
|
||||||
metricsURL: metricsURL,
|
metricsURL: metricsURL,
|
||||||
proxyURL: proxyURL,
|
localServices: localServices,
|
||||||
connections: make([]connState, haConnections),
|
connections: make([]connState, haConnections),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -107,7 +113,8 @@ func (data *uiModel) LaunchUI(
|
||||||
tunnelHostText := tview.NewTextView().SetText(data.edgeURL)
|
tunnelHostText := tview.NewTextView().SetText(data.edgeURL)
|
||||||
|
|
||||||
grid.AddItem(tunnelHostText, 0, 1, 1, 1, 0, 0, false)
|
grid.AddItem(tunnelHostText, 0, 1, 1, 1, 0, 0, false)
|
||||||
grid.AddItem(NewDynamicColorTextView().SetText(fmt.Sprintf("[%s]\u2022[%s] Proxying to [%s::b]%s", palette.connected, palette.defaultText, palette.url, data.proxyURL)), 1, 1, 1, 1, 0, 0, false)
|
status := fmt.Sprintf("[%s]\u2022[%s] Proxying to [%s::b]%s", palette.connected, palette.defaultText, palette.url, strings.Join(data.localServices, ", "))
|
||||||
|
grid.AddItem(NewDynamicColorTextView().SetText(status), 1, 1, 1, 1, 0, 0, false)
|
||||||
|
|
||||||
grid.AddItem(connTable, 2, 1, 1, 1, 0, 0, false)
|
grid.AddItem(connTable, 2, 1, 1, 1, 0, 0, false)
|
||||||
|
|
||||||
|
|
|
@ -114,13 +114,12 @@ func (ing Ingress) IsEmpty() bool {
|
||||||
}
|
}
|
||||||
|
|
||||||
// StartOrigins will start any origin services managed by cloudflared, e.g. proxy servers or Hello World.
|
// StartOrigins will start any origin services managed by cloudflared, e.g. proxy servers or Hello World.
|
||||||
func (ing Ingress) StartOrigins(wg *sync.WaitGroup, log logger.Service, shutdownC <-chan struct{}, errC chan error) error {
|
func (ing Ingress) StartOrigins(wg *sync.WaitGroup, log logger.Service, shutdownC <-chan struct{}, errC chan error) {
|
||||||
for _, rule := range ing.Rules {
|
for _, rule := range ing.Rules {
|
||||||
if err := rule.Service.start(wg, log, shutdownC, errC, rule.Config); err != nil {
|
if err := rule.Service.start(wg, log, shutdownC, errC, rule.Config); err != nil {
|
||||||
return err
|
log.Errorf("Error starting local service %s: %s", rule.Service, err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return nil
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// CatchAll returns the catch-all rule (i.e. the last rule)
|
// CatchAll returns the catch-all rule (i.e. the last rule)
|
||||||
|
|
Loading…
Reference in New Issue