v2.31.1 f37fe67

traffic.go RawHistoryFolder

1package dto
2
3import "github.com/bnema/gordon/internal/domain"
4
5type TrafficStatusResponse struct {
6	LastReloadStatus string                    `json:"last_reload_status"`
7	LastReloadError  string                    `json:"last_reload_error,omitempty"`
8	EntryPoints      []TrafficEntryPointStatus `json:"entrypoints"`
9	Routers          []TrafficRouterStatus     `json:"routers"`
10	Services         []TrafficServiceStatus    `json:"services"`
11	Counters         TrafficCounters           `json:"counters"`
12}
13
14type TrafficEntryPointStatus struct {
15	Name                 string                    `json:"name"`
16	Address              string                    `json:"address"`
17	Protocol             domain.EntryPointProtocol `json:"protocol"`
18	Active               bool                      `json:"active"`
19	ActiveTCPConnections int64                     `json:"active_tcp_connections"`
20	ActiveUDPSessions    int64                     `json:"active_udp_sessions"`
21	TotalAccepted        int64                     `json:"total_accepted"`
22	TotalRefused         int64                     `json:"total_refused"`
23	TotalErrors          int64                     `json:"total_errors"`
24	BytesIn              int64                     `json:"bytes_in"`
25	BytesOut             int64                     `json:"bytes_out"`
26	SmartTCP             SmartTCPCounters          `json:"smart_tcp"`
27}
28
29type TrafficRouterStatus struct {
30	Name       string                `json:"name"`
31	EntryPoint string                `json:"entrypoint"`
32	Protocol   domain.RouterProtocol `json:"protocol"`
33	Rule       TrafficRule           `json:"rule"`
34	Service    string                `json:"service"`
35	Active     bool                  `json:"active"`
36}
37
38type TrafficServiceStatus struct {
39	Name     string                 `json:"name"`
40	Active   bool                   `json:"active"`
41	Backends []TrafficBackendStatus `json:"backends"`
42}
43
44type TrafficRule struct {
45	Host string `json:"host,omitempty"`
46	SNI  string `json:"sni,omitempty"`
47}
48
49type TrafficBackendStatus struct {
50	Name     string                 `json:"name"`
51	Host     string                 `json:"host"`
52	Port     int                    `json:"port"`
53	Protocol domain.NetworkProtocol `json:"protocol"`
54	Active   bool                   `json:"active"`
55}
56
57type TrafficCounters struct {
58	ActiveTCPConnections int64            `json:"active_tcp_connections"`
59	ActiveUDPSessions    int64            `json:"active_udp_sessions"`
60	TotalAccepted        int64            `json:"total_accepted"`
61	TotalRefused         int64            `json:"total_refused"`
62	TotalErrors          int64            `json:"total_errors"`
63	BytesIn              int64            `json:"bytes_in"`
64	BytesOut             int64            `json:"bytes_out"`
65	SmartTCP             SmartTCPCounters `json:"smart_tcp"`
66}
67
68type SmartTCPCounters struct {
69	HTTPAccepted             int64 `json:"http_accepted"`
70	H2CAccepted              int64 `json:"h2c_accepted"`
71	HTTPSFallbackAccepted    int64 `json:"https_fallback_accepted"`
72	TLSPassthroughAccepted   int64 `json:"tls_passthrough_accepted"`
73	RawFallbackAccepted      int64 `json:"raw_fallback_accepted"`
74	EntrypointCIDRRefused    int64 `json:"entrypoint_cidr_refused"`
75	RawFallbackCIDRRefused   int64 `json:"raw_fallback_cidr_refused"`
76	PROXYRefused             int64 `json:"proxy_refused"`
77	UnknownNoFallbackRefused int64 `json:"unknown_no_fallback_refused"`
78	MalformedRejected        int64 `json:"malformed_rejected"`
79	SniffTimeout             int64 `json:"sniff_timeout"`
80	ClientHelloTooLarge      int64 `json:"client_hello_too_large"`
81}
82
83func TrafficStatusFromDomain(status domain.TrafficStatus) TrafficStatusResponse {
84	return TrafficStatusResponse{
85		LastReloadStatus: status.LastReloadStatus,
86		LastReloadError:  status.LastReloadError,
87		EntryPoints:      trafficEntryPointsFromDomain(status.EntryPoints),
88		Routers:          trafficRoutersFromDomain(status.Routers),
89		Services:         trafficServicesFromDomain(status.Services),
90		Counters:         trafficCountersFromDomain(status.Counters),
91	}
92}
93
94func trafficEntryPointsFromDomain(values []domain.EntryPointStatus) []TrafficEntryPointStatus {
95	out := make([]TrafficEntryPointStatus, 0, len(values))
96	for _, value := range values {
97		out = append(out, TrafficEntryPointStatus{
98			Name: value.Name, Address: value.Address, Protocol: value.Protocol, Active: value.Active,
99			ActiveTCPConnections: value.ActiveTCPConnections, ActiveUDPSessions: value.ActiveUDPSessions,
100			TotalAccepted: value.TotalAccepted, TotalRefused: value.TotalRefused, TotalErrors: value.TotalErrors,
101			BytesIn: value.BytesIn, BytesOut: value.BytesOut, SmartTCP: smartTCPCountersFromDomain(value.SmartTCP),
102		})
103	}
104	return out
105}
106
107func trafficRoutersFromDomain(values []domain.TrafficRouterStatus) []TrafficRouterStatus {
108	out := make([]TrafficRouterStatus, 0, len(values))
109	for _, value := range values {
110		out = append(out, TrafficRouterStatus{
111			Name: value.Name, EntryPoint: value.EntryPoint, Protocol: value.Protocol,
112			Rule: TrafficRule{Host: value.Rule.Host, SNI: value.Rule.SNI}, Service: value.Service, Active: value.Active,
113		})
114	}
115	return out
116}
117
118func trafficServicesFromDomain(values []domain.TrafficServiceStatus) []TrafficServiceStatus {
119	out := make([]TrafficServiceStatus, 0, len(values))
120	for _, value := range values {
121		out = append(out, TrafficServiceStatus{Name: value.Name, Active: value.Active, Backends: trafficBackendsFromDomain(value.Backends)})
122	}
123	return out
124}
125
126func trafficBackendsFromDomain(values []domain.TrafficBackendStatus) []TrafficBackendStatus {
127	out := make([]TrafficBackendStatus, 0, len(values))
128	for _, value := range values {
129		out = append(out, TrafficBackendStatus{
130			Name: value.Name, Host: value.Host, Port: value.Port, Protocol: value.Protocol, Active: value.Active,
131		})
132	}
133	return out
134}
135
136func trafficCountersFromDomain(value domain.TrafficCounters) TrafficCounters {
137	return TrafficCounters{
138		ActiveTCPConnections: value.ActiveTCPConnections,
139		ActiveUDPSessions:    value.ActiveUDPSessions,
140		TotalAccepted:        value.TotalAccepted,
141		TotalRefused:         value.TotalRefused,
142		TotalErrors:          value.TotalErrors,
143		BytesIn:              value.BytesIn,
144		BytesOut:             value.BytesOut,
145		SmartTCP:             smartTCPCountersFromDomain(value.SmartTCP),
146	}
147}
148
149func smartTCPCountersFromDomain(value domain.SmartTCPCounters) SmartTCPCounters {
150	return SmartTCPCounters{
151		HTTPAccepted:             value.HTTPAccepted,
152		H2CAccepted:              value.H2CAccepted,
153		HTTPSFallbackAccepted:    value.HTTPSFallbackAccepted,
154		TLSPassthroughAccepted:   value.TLSPassthroughAccepted,
155		RawFallbackAccepted:      value.RawFallbackAccepted,
156		EntrypointCIDRRefused:    value.EntrypointCIDRRefused,
157		RawFallbackCIDRRefused:   value.RawFallbackCIDRRefused,
158		PROXYRefused:             value.PROXYRefused,
159		UnknownNoFallbackRefused: value.UnknownNoFallbackRefused,
160		MalformedRejected:        value.MalformedRejected,
161		SniffTimeout:             value.SniffTimeout,
162		ClientHelloTooLarge:      value.ClientHelloTooLarge,
163	}
164}

Keyboard shortcuts

Single-key shortcuts are on. ctrl k and esc work whatever this says.

ctrl k :
go to a section, branch, tag, file or repository
?
this list
j k
move the row cursor down / up
enter
open the row under the cursor; on Files, a directory opens or closes in place
↑ ↓ ← → home end
in the file tree (focus on a row): previous / next row, close / open a directory or go to its parent / first entry, first / last row. They never open a file
l h
on Files: open a directory or a file / close a directory or go up to its parent, then to the parent page. Elsewhere: into the side panel (on a merge request, its files) / back to the content; there j k move between its controls
g g G
first / last row
/
filter the list; on Files, find a file anywhere in the repository (esc clears, enter opens the best match)
b
switch branch or tag
g s g f g c g b g m g i g r g a
tabs: summary, files, commits, branches & tags, merge requests, issues, releases, actions (when available)
g h
home
w
wide mode: use the whole width of the screen, or not (remembered)
y
copy a permalink pinned to the commit
d u x
diff: split / unified / collapse or expand all
e E
diff: the whole file in view / every file, with the lines the hunks hide
n
merge request: next note in the diff
esc
close a dialog, leave a field

Branches 7

Tags 106

↑↓ moveenter openesc close