Browse Source

Add GET /reconnect/CHANNEL to work

Georgi Chorbadzhiyski 2 years ago
parent
commit
d7fb54f45d
3 changed files with 25 additions and 3 deletions
  1. 21
    1
      web_pages.c
  2. 1
    1
      web_pages.h
  3. 3
    1
      web_server.c

+ 21
- 1
web_pages.c View File

@@ -109,9 +109,29 @@ void cmd_getconfig(int clientsock) {
109 109
 	pthread_mutex_unlock(&cfg->channels_lock);
110 110
 }
111 111
 
112
-void cmd_reconnect(int clientsock) {
112
+void cmd_reconnect(int clientsock, char *channel) {
113 113
 	send_200_ok(clientsock);
114 114
 	send_header_textplain(clientsock);
115
+	if (channel) {
116
+		int found = 0;
117
+		struct config *cfg = get_config();
118
+		list_lock(cfg->restreamer);
119
+		LNODE *l, *tmp;
120
+		list_for_each(cfg->restreamer, l, tmp) {
121
+			RESTREAMER *r = l->data;
122
+			if (strcmp(r->name, channel) == 0) {
123
+				found = 1;
124
+				r->reconnect = 1;
125
+				fdputsf(clientsock, "\nReconnecting %s input.\n", r->name);
126
+				break;
127
+			}
128
+		}
129
+		list_unlock(cfg->restreamer);
130
+		if (!found) {
131
+			fdputsf(clientsock, "\nERROR: Can not find %s channel.\n", channel);
132
+		}
133
+		return;
134
+	}
115 135
 	struct config *cfg = get_config();
116 136
 	pthread_mutex_lock(&cfg->channels_lock);
117 137
 	fdputsf(clientsock, "\nReconnecting %d inputs.\n", cfg->chanconf->items);

+ 1
- 1
web_pages.h View File

@@ -21,7 +21,7 @@
21 21
 void cmd_index(int clientsock);
22 22
 void cmd_status(int clientsock);
23 23
 void cmd_getconfig(int clientsock);
24
-void cmd_reconnect(int clientsock);
24
+void cmd_reconnect(int clientsock, char *channel);
25 25
 void cmd_reload(int clientsock);
26 26
 
27 27
 #endif

+ 3
- 1
web_server.c View File

@@ -130,8 +130,10 @@ void *process_web_request(void *in_req) {
130 130
 		cmd_index(clientsock);
131 131
 	} else if (strstr(path,"getconfig")==path) {
132 132
 		cmd_getconfig(clientsock);
133
+	} else if (strstr(path,"reconnect/")==path) {
134
+		cmd_reconnect(clientsock, path + 10); // 10 = reconnect/
133 135
 	} else if (strstr(path,"reconnect")==path) {
134
-		cmd_reconnect(clientsock);
136
+		cmd_reconnect(clientsock, NULL);
135 137
 	} else if (strstr(path,"reload")==path) {
136 138
 		cmd_reload(clientsock);
137 139
 	} else if (strstr(path,"status")==path) {

Loading…
Cancel
Save