Skip to content

Commit c4b4bd8

Browse files
committed
Pull request 2510: AGDNS-2591-web-start-time
Squashed commit of the following: commit 5dfdf2a Merge: c4b2a56 594849b Author: Ainar Garipov <[email protected]> Date: Sat Nov 1 15:16:17 2025 +0300 Merge branch 'master' into AGDNS-2591-web-start-time commit c4b2a56 Merge: a0466dd 3bebde6 Author: Ainar Garipov <[email protected]> Date: Fri Oct 31 15:50:34 2025 +0300 Merge branch 'master' into AGDNS-2591-web-start-time commit a0466dd Author: Stanislav Chzhen <[email protected]> Date: Fri Oct 24 09:47:20 2025 +0300 all: imp code commit 5e09356 Author: Stanislav Chzhen <[email protected]> Date: Thu Oct 23 09:14:32 2025 +0300 all: web start time
1 parent 594849b commit c4b4bd8

File tree

8 files changed

+31
-2
lines changed

8 files changed

+31
-2
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,10 @@ See also the [v0.107.70 GitHub milestone][ms-v0.107.70].
1818
NOTE: Add new changes BELOW THIS COMMENT.
1919
-->
2020

21+
### Added
22+
23+
- New field `"start_time"` in the `GET /control/status` response.
24+
2125
<!--
2226
NOTE: Add new changes ABOVE THIS COMMENT.
2327
-->

client/src/actions/index.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -222,7 +222,7 @@ const checkStatus = async (handleRequestSuccess: any, handleRequestError: any, a
222222
};
223223

224224
export const getUpdate = () => async (dispatch: any, getState: any) => {
225-
const { dnsVersion } = getState().dashboard;
225+
const { dnsVersion, dnsStartTime } = getState().dashboard;
226226

227227
dispatch(getUpdateRequest());
228228
const handleRequestError = () => {
@@ -238,8 +238,9 @@ export const getUpdate = () => async (dispatch: any, getState: any) => {
238238

239239
const handleRequestSuccess = (response: any) => {
240240
const responseVersion = response.data?.version;
241+
const responseStartTime = response.data?.start_time;
241242

242-
if (dnsVersion !== responseVersion) {
243+
if (dnsVersion !== responseVersion || dnsStartTime !== responseStartTime) {
243244
dispatch(getUpdateSuccess());
244245

245246
window.location.reload();

client/src/initialState.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,7 @@ export type DashboardData = {
128128
dnsPort: number;
129129
dnsAddresses: string[];
130130
dnsVersion: string;
131+
dnsStartTime: number | null;
131132
clients: Client[];
132133
autoClients: AutoClient[];
133134
supportedTags: string[];
@@ -445,6 +446,7 @@ export const initialState: RootState = {
445446
dnsPort: STANDARD_DNS_PORT,
446447
dnsAddresses: [],
447448
dnsVersion: '',
449+
dnsStartTime: null,
448450
clients: [],
449451
autoClients: [],
450452
supportedTags: [],

client/src/reducers/dashboard.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ const dashboard = handleActions(
2121
[actions.dnsStatusSuccess.toString()]: (state: any, { payload }: any) => {
2222
const {
2323
version,
24+
start_time: dnsStartTime,
2425
dns_port: dnsPort,
2526
dns_addresses: dnsAddresses,
2627
protection_enabled: protectionEnabled,
@@ -33,6 +34,7 @@ const dashboard = handleActions(
3334
isCoreRunning: true,
3435
processing: false,
3536
dnsVersion: version,
37+
dnsStartTime,
3638
dnsPort,
3739
dnsAddresses,
3840
protectionEnabled,
@@ -183,6 +185,7 @@ const dashboard = handleActions(
183185
dnsPort: STANDARD_DNS_PORT,
184186
dnsAddresses: [],
185187
dnsVersion: '',
188+
dnsStartTime: null,
186189
clients: [],
187190
autoClients: [],
188191
supportedTags: [],

internal/home/control.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,9 @@ type statusResponse struct {
107107
// milliseconds.
108108
ProtectionDisabledDuration int64 `json:"protection_disabled_duration"`
109109

110+
// StartTime is the start time of the web API server in Unix milliseconds.
111+
StartTime aghhttp.JSONTime `json:"start_time"`
112+
110113
ProtectionEnabled bool `json:"protection_enabled"`
111114
// TODO(e.burkov): Inspect if front-end doesn't requires this field as
112115
// openapi.yaml declares.
@@ -158,6 +161,7 @@ func (web *webAPI) handleStatus(w http.ResponseWriter, r *http.Request) {
158161
DNSPort: config.DNS.Port,
159162
HTTPPort: config.HTTPConfig.Address.Port(),
160163
ProtectionDisabledDuration: protectionDisabledDuration,
164+
StartTime: aghhttp.JSONTime(web.startTime),
161165
ProtectionEnabled: protEnabled,
162166
IsRunning: isRunning(),
163167
}

internal/home/web.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,9 @@ type webAPI struct {
158158
// httpsServer is the server that handles HTTPS traffic. If it is not nil,
159159
// [Web.http3Server] must also not be nil.
160160
httpsServer httpsServer
161+
162+
// startTime is the start time of the web API server in Unix milliseconds.
163+
startTime time.Time
161164
}
162165

163166
// newWebAPI creates a new instance of the web UI and API server. conf must be
@@ -176,6 +179,7 @@ func newWebAPI(ctx context.Context, conf *webConfig) (w *webAPI) {
176179
baseLogger: conf.baseLogger,
177180
tlsManager: conf.tlsManager,
178181
auth: conf.auth,
182+
startTime: time.Now(),
179183
}
180184

181185
clientFS := http.FileServer(http.FS(conf.clientFS))

openapi/CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,12 @@
22

33
<!-- TODO(a.garipov): Reformat in accordance with the KeepAChangelog spec. -->
44

5+
## v0.107.70: API changes
6+
7+
### New `"start_time"` field in 'GET /control/status'
8+
9+
- New field `"start_time"` indicates the start time of the web API server (Unix time in milliseconds).
10+
511
## v0.107.68: API changes
612

713
### New HTTP APIs 'GET /control/rewrite/settings' and 'PUT /control/rewrite/settings/update'

openapi/openapi.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1500,6 +1500,11 @@
15001500
'language':
15011501
'type': 'string'
15021502
'example': 'en'
1503+
'start_time':
1504+
'type': 'number'
1505+
'format': 'double'
1506+
'example': 1700000000000
1507+
'description': 'Start time of the web API server (Unix time in milliseconds).'
15031508
'DNSConfig':
15041509
'type': 'object'
15051510
'description': 'DNS server configuration'

0 commit comments

Comments
 (0)