summaryrefslogtreecommitdiffstats
path: root/web/server
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2022-11-30 18:47:05 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2022-11-30 18:47:05 +0000
commit97e01009d69b8fbebfebf68f51e3d126d0ed43fc (patch)
tree02e8b836c3a9d89806f3e67d4a5fe9f52dbb0061 /web/server
parentReleasing debian version 1.36.1-1. (diff)
downloadnetdata-97e01009d69b8fbebfebf68f51e3d126d0ed43fc.tar.xz
netdata-97e01009d69b8fbebfebf68f51e3d126d0ed43fc.zip
Merging upstream version 1.37.0.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'web/server')
-rw-r--r--web/server/static/static-threaded.c4
-rw-r--r--web/server/static/static-threaded.h2
-rw-r--r--web/server/web_client.c69
-rw-r--r--web/server/web_client.h21
-rw-r--r--web/server/web_client_cache.c8
-rw-r--r--web/server/web_client_cache.h8
-rw-r--r--web/server/web_server.h14
7 files changed, 56 insertions, 70 deletions
diff --git a/web/server/static/static-threaded.c b/web/server/static/static-threaded.c
index 8b9122f87..26e9a47bd 100644
--- a/web/server/static/static-threaded.c
+++ b/web/server/static/static-threaded.c
@@ -196,7 +196,7 @@ static void *web_server_add_callback(POLLINFO *pi, short int *events, void *data
}
#ifdef ENABLE_HTTPS
- if ((!web_client_check_unix(w)) && ( netdata_srv_ctx )) {
+ if ((!web_client_check_unix(w)) && (netdata_ssl_srv_ctx)) {
if( sock_delnonblock(w->ifd) < 0 ){
error("Web server cannot remove the non-blocking flag from socket %d",w->ifd);
}
@@ -218,7 +218,7 @@ static void *web_server_add_callback(POLLINFO *pi, short int *events, void *data
//The next two ifs are not together because I am reusing SSL structure
if (!w->ssl.conn)
{
- w->ssl.conn = SSL_new(netdata_srv_ctx);
+ w->ssl.conn = SSL_new(netdata_ssl_srv_ctx);
if ( w->ssl.conn ) {
SSL_set_accept_state(w->ssl.conn);
} else {
diff --git a/web/server/static/static-threaded.h b/web/server/static/static-threaded.h
index 5f4862e5b..a8c5335ef 100644
--- a/web/server/static/static-threaded.h
+++ b/web/server/static/static-threaded.h
@@ -5,6 +5,6 @@
#include "web/server/web_server.h"
-extern void *socket_listen_main_static_threaded(void *ptr);
+void *socket_listen_main_static_threaded(void *ptr);
#endif //NETDATA_WEB_SERVER_STATIC_THREADED_H
diff --git a/web/server/web_client.c b/web/server/web_client.c
index d287cec03..b3c5ada7a 100644
--- a/web/server/web_client.c
+++ b/web/server/web_client.c
@@ -85,11 +85,11 @@ void web_client_request_done(struct web_client *w) {
// --------------------------------------------------------------------
// global statistics
- finished_web_request_statistics(dt_usec(&tv, &w->tv_in),
- w->stats_received_bytes,
- w->stats_sent_bytes,
- size,
- sent);
+ global_statistics_web_request_completed(dt_usec(&tv, &w->tv_in),
+ w->stats_received_bytes,
+ w->stats_sent_bytes,
+ size,
+ sent);
w->stats_received_bytes = 0;
w->stats_sent_bytes = 0;
@@ -1018,7 +1018,7 @@ static inline HTTP_VALIDATION http_request_validate(struct web_client *w) {
// TODO -- ideally we we should avoid copying buffers around
snprintfz(w->last_url, NETDATA_WEB_REQUEST_URL_SIZE, "%s%s", w->decoded_url, w->decoded_query_string);
#ifdef ENABLE_HTTPS
- if ( (!web_client_check_unix(w)) && (netdata_srv_ctx) ) {
+ if ( (!web_client_check_unix(w)) && (netdata_ssl_srv_ctx) ) {
if ((w->ssl.conn) && ((w->ssl.flags & NETDATA_SSL_NO_HANDSHAKE) && (web_client_is_using_ssl_force(w) || web_client_is_using_ssl_default(w)) && (w->mode != WEB_CLIENT_MODE_STREAM)) ) {
w->header_parse_tries = 0;
w->header_parse_last_size = 0;
@@ -1054,9 +1054,9 @@ static inline ssize_t web_client_send_data(struct web_client *w,const void *buf,
{
ssize_t bytes;
#ifdef ENABLE_HTTPS
- if ( (!web_client_check_unix(w)) && (netdata_srv_ctx) ) {
+ if ( (!web_client_check_unix(w)) && (netdata_ssl_srv_ctx) ) {
if ( ( w->ssl.conn ) && ( !w->ssl.flags ) ){
- bytes = SSL_write(w->ssl.conn,buf, len) ;
+ bytes = netdata_ssl_write(w->ssl.conn, buf, len) ;
} else {
bytes = send(w->ofd,buf, len , flags);
}
@@ -1211,26 +1211,10 @@ static inline void web_client_send_http_header(struct web_client *w) {
size_t count = 0;
ssize_t bytes;
#ifdef ENABLE_HTTPS
- if ( (!web_client_check_unix(w)) && (netdata_srv_ctx) ) {
- if ( ( w->ssl.conn ) && ( !w->ssl.flags ) ){
- while((bytes = SSL_write(w->ssl.conn, buffer_tostring(w->response.header_output), buffer_strlen(w->response.header_output))) < 0) {
- count++;
- if(count > 100 || (errno != EAGAIN && errno != EWOULDBLOCK)) {
- error("Cannot send HTTPS headers to web client.");
- break;
- }
- }
- } else {
- while((bytes = send(w->ofd, buffer_tostring(w->response.header_output), buffer_strlen(w->response.header_output), 0)) == -1) {
- count++;
-
- if(count > 100 || (errno != EAGAIN && errno != EWOULDBLOCK)) {
- error("Cannot send HTTP headers to web client.");
- break;
- }
- }
- }
- } else {
+ if ( (!web_client_check_unix(w)) && (netdata_ssl_srv_ctx) ) {
+ if ( ( w->ssl.conn ) && ( w->ssl.flags == NETDATA_SSL_HANDSHAKE_COMPLETE ) )
+ bytes = netdata_ssl_write(w->ssl.conn, buffer_tostring(w->response.header_output), buffer_strlen(w->response.header_output));
+ else {
while((bytes = send(w->ofd, buffer_tostring(w->response.header_output), buffer_strlen(w->response.header_output), 0)) == -1) {
count++;
@@ -1239,6 +1223,17 @@ static inline void web_client_send_http_header(struct web_client *w) {
break;
}
}
+ }
+ }
+ else {
+ while((bytes = send(w->ofd, buffer_tostring(w->response.header_output), buffer_strlen(w->response.header_output), 0)) == -1) {
+ count++;
+
+ if(count > 100 || (errno != EAGAIN && errno != EWOULDBLOCK)) {
+ error("Cannot send HTTP headers to web client.");
+ break;
+ }
+ }
}
#else
while((bytes = send(w->ofd, buffer_tostring(w->response.header_output), buffer_strlen(w->response.header_output), 0)) == -1) {
@@ -1305,19 +1300,9 @@ static inline int web_client_switch_host(RRDHOST *host, struct web_client *w, ch
if(url && *url) strncpyz(&w->last_url[1], url, NETDATA_WEB_REQUEST_URL_SIZE - 1);
else w->last_url[1] = '\0';
- uint32_t hash = simple_hash(tok);
-
- host = rrdhost_find_by_hostname(tok, hash);
+ host = rrdhost_find_by_hostname(tok);
if (!host)
- host = rrdhost_find_by_guid(tok, hash);
- if (!host) {
- host = sql_create_host_by_uuid(tok);
- if (likely(host)) {
- int rc = web_client_process_url(host, w, url);
- free_temporary_host(host);
- return rc;
- }
- }
+ host = rrdhost_find_by_guid(tok);
if (host) return web_client_process_url(host, w, url);
}
@@ -1917,9 +1902,9 @@ ssize_t web_client_receive(struct web_client *w)
buffer_need_bytes(w->response.data, NETDATA_WEB_REQUEST_RECEIVE_SIZE);
#ifdef ENABLE_HTTPS
- if ( (!web_client_check_unix(w)) && (netdata_srv_ctx) ) {
+ if ( (!web_client_check_unix(w)) && (netdata_ssl_srv_ctx) ) {
if ( ( w->ssl.conn ) && (!w->ssl.flags)) {
- bytes = SSL_read(w->ssl.conn, &w->response.data->buffer[w->response.data->len], (size_t) (left - 1));
+ bytes = netdata_ssl_read(w->ssl.conn, &w->response.data->buffer[w->response.data->len], (size_t) (left - 1));
}else {
bytes = recv(w->ifd, &w->response.data->buffer[w->response.data->len], (size_t) (left - 1), MSG_DONTWAIT);
}
diff --git a/web/server/web_client.h b/web/server/web_client.h
index 50e08fb33..630d71a8a 100644
--- a/web/server/web_client.h
+++ b/web/server/web_client.h
@@ -27,6 +27,7 @@ extern int web_enable_gzip, web_gzip_level, web_gzip_strategy;
#define HTTP_RESP_INTERNAL_SERVER_ERROR 500
#define HTTP_RESP_BACKEND_FETCH_FAILED 503
#define HTTP_RESP_GATEWAY_TIMEOUT 504
+#define HTTP_RESP_BACKEND_RESPONSE_INVALID 591
extern int respect_web_browser_do_not_track_policy;
extern char *web_x_frame_options;
@@ -189,21 +190,21 @@ struct web_client {
#endif
};
-extern int web_client_permission_denied(struct web_client *w);
+int web_client_permission_denied(struct web_client *w);
-extern ssize_t web_client_send(struct web_client *w);
-extern ssize_t web_client_receive(struct web_client *w);
-extern ssize_t web_client_read_file(struct web_client *w);
+ssize_t web_client_send(struct web_client *w);
+ssize_t web_client_receive(struct web_client *w);
+ssize_t web_client_read_file(struct web_client *w);
-extern void web_client_process_request(struct web_client *w);
-extern void web_client_request_done(struct web_client *w);
+void web_client_process_request(struct web_client *w);
+void web_client_request_done(struct web_client *w);
-extern void buffer_data_options2string(BUFFER *wb, uint32_t options);
+void buffer_data_options2string(BUFFER *wb, uint32_t options);
-extern int mysendfile(struct web_client *w, char *filename);
+int mysendfile(struct web_client *w, char *filename);
-extern void web_client_build_http_header(struct web_client *w);
-extern char *strip_control_characters(char *url);
+void web_client_build_http_header(struct web_client *w);
+char *strip_control_characters(char *url);
#include "daemon/common.h"
diff --git a/web/server/web_client_cache.c b/web/server/web_client_cache.c
index 5d7865762..1fa593580 100644
--- a/web/server/web_client_cache.c
+++ b/web/server/web_client_cache.c
@@ -9,7 +9,7 @@
#ifdef ENABLE_HTTPS
static void web_client_reuse_ssl(struct web_client *w) {
- if (netdata_srv_ctx) {
+ if (netdata_ssl_srv_ctx) {
if (w->ssl.conn) {
SSL_clear(w->ssl.conn);
}
@@ -48,7 +48,7 @@ static void web_client_free(struct web_client *w) {
buffer_free(w->response.data);
freez(w->user_agent);
#ifdef ENABLE_HTTPS
- if ((!web_client_check_unix(w)) && ( netdata_srv_ctx )) {
+ if ((!web_client_check_unix(w)) && (netdata_ssl_srv_ctx)) {
if (w->ssl.conn) {
SSL_free(w->ssl.conn);
w->ssl.conn = NULL;
@@ -209,7 +209,7 @@ struct web_client *web_client_get_from_cache_or_allocate() {
web_clients_cache.used_count++;
// initialize it
- w->id = web_client_connected();
+ w->id = global_statistics_web_client_connected();
w->mode = WEB_CLIENT_MODE_NORMAL;
netdata_thread_enable_cancelability();
@@ -230,7 +230,7 @@ void web_client_release(struct web_client *w) {
web_server_log_connection(w, "DISCONNECTED");
web_client_request_done(w);
- web_client_disconnected();
+ global_statistics_web_client_disconnected();
netdata_thread_disable_cancelability();
diff --git a/web/server/web_client_cache.h b/web/server/web_client_cache.h
index f63888000..324f23ed9 100644
--- a/web/server/web_client_cache.h
+++ b/web/server/web_client_cache.h
@@ -21,10 +21,10 @@ struct clients_cache {
extern __thread struct clients_cache web_clients_cache;
-extern void web_client_release(struct web_client *w);
-extern struct web_client *web_client_get_from_cache_or_allocate();
-extern void web_client_cache_destroy(void);
-extern void web_client_cache_verify(int force);
+void web_client_release(struct web_client *w);
+struct web_client *web_client_get_from_cache_or_allocate();
+void web_client_cache_destroy(void);
+void web_client_cache_verify(int force);
#include "web_server.h"
diff --git a/web/server/web_server.h b/web/server/web_server.h
index 7bfc81c9d..51230ed2b 100644
--- a/web/server/web_server.h
+++ b/web/server/web_server.h
@@ -36,10 +36,10 @@ extern int web_allow_mgmt_dns;
extern WEB_SERVER_MODE web_server_mode;
-extern WEB_SERVER_MODE web_server_mode_id(const char *mode);
-extern const char *web_server_mode_name(WEB_SERVER_MODE id);
+WEB_SERVER_MODE web_server_mode_id(const char *mode);
+const char *web_server_mode_name(WEB_SERVER_MODE id);
-extern void api_listen_sockets_setup(void);
+void api_listen_sockets_setup(void);
#define DEFAULT_TIMEOUT_TO_RECEIVE_FIRST_WEB_REQUEST 60
#define DEFAULT_DISCONNECT_IDLE_WEB_CLIENTS_AFTER_SECONDS 60
@@ -49,10 +49,10 @@ extern long web_client_streaming_rate_t;
#ifdef WEB_SERVER_INTERNALS
extern LISTEN_SOCKETS api_sockets;
-extern void web_client_update_acl_matches(struct web_client *w);
-extern void web_server_log_connection(struct web_client *w, const char *msg);
-extern void web_client_initialize_connection(struct web_client *w);
-extern struct web_client *web_client_create_on_listenfd(int listener);
+void web_client_update_acl_matches(struct web_client *w);
+void web_server_log_connection(struct web_client *w, const char *msg);
+void web_client_initialize_connection(struct web_client *w);
+struct web_client *web_client_create_on_listenfd(int listener);
#include "web_client_cache.h"
#endif // WEB_SERVER_INTERNALS