-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathno-html.patch
87 lines (81 loc) · 2.22 KB
/
no-html.patch
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
From 295dd50295fb8fc829f64e96a4c71e9b4b1e6886 Mon Sep 17 00:00:00 2001
From: Massimiliano Torromeo <massimiliano.torromeo@gmail.com>
Date: Wed, 17 Mar 2021 00:29:06 +0100
Subject: [PATCH] Allow starting websocket server without outputting html to a
file
---
src/goaccess.c | 23 ++++++++++-------------
src/output.c | 9 +++++++++
2 files changed, 19 insertions(+), 13 deletions(-)
diff --git a/src/goaccess.c b/src/goaccess.c
index e8d37956..bfd3b5c6 100644
--- a/src/goaccess.c
+++ b/src/goaccess.c
@@ -873,10 +873,13 @@ process_html (const char *filename) {
.tv_nsec = 0,
};
- /* render report */
- pthread_mutex_lock (&gdns_thread.mutex);
- output_html (holder, filename);
- pthread_mutex_unlock (&gdns_thread.mutex);
+ if (filename) {
+ /* render report */
+ pthread_mutex_lock (&gdns_thread.mutex);
+ output_html (holder, filename);
+ pthread_mutex_unlock (&gdns_thread.mutex);
+ }
+
/* not real time? */
if (!conf.real_time_html)
return;
@@ -1445,14 +1448,8 @@ spawn_ws (void) {
static void
set_standard_output (void) {
- int html = 0;
-
- /* HTML */
- if (find_output_type (NULL, "html", 0) == 0 || conf.output_format_idx == 0)
- html = 1;
-
/* Spawn WebSocket server threads */
- if (html && conf.real_time_html) {
+ if (conf.real_time_html) {
if (spawn_ws ())
return;
}
@@ -1514,7 +1511,7 @@ main (int argc, char **argv) {
if (conf.process_and_exit) {
}
/* set stdout */
- else if (conf.output_stdout) {
+ else if (conf.output_stdout || conf.real_time_html) {
set_standard_output ();
}
/* set curses */
@@ -1553,7 +1550,7 @@ main (int argc, char **argv) {
if (conf.process_and_exit) {
}
/* stdout */
- else if (conf.output_stdout) {
+ else if (conf.output_stdout || conf.real_time_html) {
standard_output ();
}
/* curses */
diff --git a/src/output.c b/src/output.c
index ec8b9a09..f96c8b9b 100644
--- a/src/output.c
+++ b/src/output.c
@@ -501,6 +501,15 @@ print_conn_def (FILE * fp) {
if (!conf.real_time_html)
return;
+ int html = 0;
+
+ /* HTML */
+ if (find_output_type (NULL, "html", 0) == 0)
+ html = 1;
+
+ if (!html)
+ return;
+
fprintf (fp, "<script type='text/javascript'>");
fprintf (fp, "var connection = ");