Browse Source

Allow GET /reconnect/CHANNEL to work

Georgi Chorbadzhiyski 2 years ago
parent
commit
7011e87b03
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
 	pthread_mutex_unlock(&cfg->channels_lock);
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
 	send_200_ok(clientsock);
113
 	send_200_ok(clientsock);
114
 	send_header_textplain(clientsock);
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
 	struct config *cfg = get_config();
135
 	struct config *cfg = get_config();
116
 	pthread_mutex_lock(&cfg->channels_lock);
136
 	pthread_mutex_lock(&cfg->channels_lock);
117
 	fdputsf(clientsock, "\nReconnecting %d inputs.\n", cfg->chanconf->items);
137
 	fdputsf(clientsock, "\nReconnecting %d inputs.\n", cfg->chanconf->items);

+ 1
- 1
web_pages.h View File

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

+ 3
- 1
web_server.c View File

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

Loading…
Cancel
Save