server dashboard v3 static files, when available (#18507)
Costa Tsaousis committed
Sep 10, 2024 at 13:09 UTC
739a0a53d8abdaf614fbd29e70f6d181538c83f4
2 files changed
+23
-12
src/web/server/web_client.c
+15
-5
@@ -381,12 +381,14 @@ static inline int dashboard_version(struct web_client *w) {
381
if(!web_client_flag_check(w, WEB_CLIENT_FLAG_PATH_WITH_VERSION))
382
return -1;
383
384
- if(web_client_flag_check(w, WEB_CLIENT_FLAG_PATH_IS_V0))
385
- return 0;
386
- if(web_client_flag_check(w, WEB_CLIENT_FLAG_PATH_IS_V1))
387
- return 1;
384
+ if(web_client_flag_check(w, WEB_CLIENT_FLAG_PATH_IS_V3))
385
+ return 3;
386
if(web_client_flag_check(w, WEB_CLIENT_FLAG_PATH_IS_V2))
387
return 2;
388
+ if(web_client_flag_check(w, WEB_CLIENT_FLAG_PATH_IS_V1))
389
+ return 1;
390
+ if(web_client_flag_check(w, WEB_CLIENT_FLAG_PATH_IS_V0))
391
+ return 0;
392
393
return -1;
394
}
@@ -1140,7 +1142,8 @@ static inline int web_client_process_url(RRDHOST *host, struct web_client *w, ch
1142
hash_node = 0,
1143
hash_v0 = 0,
1144
hash_v1 = 0,
1143
- hash_v2 = 0;
1145
+ hash_v2 = 0,
1146
+ hash_v3 = 0;
1147
1148
#ifdef NETDATA_INTERNAL_CHECKS
1149
static uint32_t hash_exit = 0, hash_debug = 0, hash_mirror = 0;
@@ -1154,6 +1157,7 @@ static inline int web_client_process_url(RRDHOST *host, struct web_client *w, ch
1157
hash_v0 = simple_hash("v0");
1158
hash_v1 = simple_hash("v1");
1159
hash_v2 = simple_hash("v2");
1160
+ hash_v3 = simple_hash("v3");
1161
#ifdef NETDATA_INTERNAL_CHECKS
1162
hash_exit = simple_hash("exit");
1163
hash_debug = simple_hash("debug");
@@ -1178,6 +1182,12 @@ static inline int web_client_process_url(RRDHOST *host, struct web_client *w, ch
1182
netdata_log_debug(D_WEB_CLIENT_ACCESS, "%llu: host switch request ...", w->id);
1183
return web_client_switch_host(host, w, decoded_url_path, hash == hash_node, web_client_process_url);
1184
}
1185
+ else if(unlikely(hash == hash_v3 && strcmp(tok, "v3") == 0)) {
1186
+ if(web_client_flag_check(w, WEB_CLIENT_FLAG_PATH_WITH_VERSION))
1187
+ return bad_request_multiple_dashboard_versions(w);
1188
+ web_client_flag_set(w, WEB_CLIENT_FLAG_PATH_IS_V3);
1189
+ return web_client_process_url(host, w, decoded_url_path);
1190
+ }
1191
else if(unlikely(hash == hash_v2 && strcmp(tok, "v2") == 0)) {
1192
if(web_client_flag_check(w, WEB_CLIENT_FLAG_PATH_WITH_VERSION))
1193
return bad_request_multiple_dashboard_versions(w);
src/web/server/web_client.h
+8
-7
@@ -56,19 +56,20 @@ typedef enum __attribute__((packed)) {
56
WEB_CLIENT_FLAG_PATH_IS_V0 = (1 << 16), // v0 dashboard found on the path
57
WEB_CLIENT_FLAG_PATH_IS_V1 = (1 << 17), // v1 dashboard found on the path
58
WEB_CLIENT_FLAG_PATH_IS_V2 = (1 << 18), // v2 dashboard found on the path
59
- WEB_CLIENT_FLAG_PATH_HAS_TRAILING_SLASH = (1 << 19), // the path has a trailing hash
60
- WEB_CLIENT_FLAG_PATH_HAS_FILE_EXTENSION = (1 << 20), // the path ends with a filename extension
59
+ WEB_CLIENT_FLAG_PATH_IS_V3 = (1 << 19), // v3 dashboard found on the path
60
+ WEB_CLIENT_FLAG_PATH_HAS_TRAILING_SLASH = (1 << 20), // the path has a trailing hash
61
+ WEB_CLIENT_FLAG_PATH_HAS_FILE_EXTENSION = (1 << 21), // the path ends with a filename extension
62
63
// authorization
63
- WEB_CLIENT_FLAG_AUTH_CLOUD = (1 << 21),
64
- WEB_CLIENT_FLAG_AUTH_BEARER = (1 << 22),
65
- WEB_CLIENT_FLAG_AUTH_GOD = (1 << 23),
64
+ WEB_CLIENT_FLAG_AUTH_CLOUD = (1 << 22),
65
+ WEB_CLIENT_FLAG_AUTH_BEARER = (1 << 23),
66
+ WEB_CLIENT_FLAG_AUTH_GOD = (1 << 24),
67
68
// transient settings
68
- WEB_CLIENT_FLAG_PROGRESS_TRACKING = (1 << 24), // flag to avoid redoing progress work
69
+ WEB_CLIENT_FLAG_PROGRESS_TRACKING = (1 << 25), // flag to avoid redoing progress work
70
} WEB_CLIENT_FLAGS;
71
71
-#define WEB_CLIENT_FLAG_PATH_WITH_VERSION (WEB_CLIENT_FLAG_PATH_IS_V0|WEB_CLIENT_FLAG_PATH_IS_V1|WEB_CLIENT_FLAG_PATH_IS_V2)
72
+#define WEB_CLIENT_FLAG_PATH_WITH_VERSION (WEB_CLIENT_FLAG_PATH_IS_V0|WEB_CLIENT_FLAG_PATH_IS_V1|WEB_CLIENT_FLAG_PATH_IS_V2|WEB_CLIENT_FLAG_PATH_IS_V3)
73
#define web_client_reset_path_flags(w) (w)->flags &= ~(WEB_CLIENT_FLAG_PATH_WITH_VERSION|WEB_CLIENT_FLAG_PATH_HAS_TRAILING_SLASH|WEB_CLIENT_FLAG_PATH_HAS_FILE_EXTENSION)
74
75
#define web_client_flag_check(w, flag) ((w)->flags & (flag))