Browse Source

RPC: setconfig can now change http-port (enabling or disabling the http service included)

Luke Dashjr 12 years ago
parent
commit
6531f30056
3 changed files with 20 additions and 0 deletions
  1. 7 0
      README.RPC
  2. 12 0
      api.c
  3. 1 0
      miner.h

+ 7 - 0
README.RPC

@@ -427,6 +427,13 @@ api-example.py - a Python script to access the API
 Feature Changelog for external applications using the API:
 Feature Changelog for external applications using the API:
 
 
 
 
+API V1.25.3
+
+Modified API commands:
+ 'setconfig' - add 'http-port' number
+
+----------
+
 API V1.25.2
 API V1.25.2
 
 
 Modified API commands:
 Modified API commands:

+ 12 - 0
api.c

@@ -26,6 +26,9 @@
 #include <sys/types.h>
 #include <sys/types.h>
 
 
 #include "compat.h"
 #include "compat.h"
+#ifdef USE_LIBMICROHTTPD
+#include "httpsrv.h"
+#endif
 #include "miner.h"
 #include "miner.h"
 #include "util.h"
 #include "util.h"
 #include "driver-cpu.h" /* for algo_names[], TODO: re-factor dependency */
 #include "driver-cpu.h" /* for algo_names[], TODO: re-factor dependency */
@@ -3092,6 +3095,15 @@ static void setconfig(struct io_data *io_data, __maybe_unused SOCKETTYPE c, char
 		opt_scantime = value;
 		opt_scantime = value;
 	else if (strcasecmp(param, "expiry") == 0)
 	else if (strcasecmp(param, "expiry") == 0)
 		opt_expiry = value;
 		opt_expiry = value;
+#ifdef USE_LIBMICROHTTPD
+	else if (strcasecmp(param, "http-port") == 0)
+	{
+		httpsrv_stop();
+		httpsrv_port = value;
+		if (httpsrv_port != -1)
+			httpsrv_start(httpsrv_port);
+	}
+#endif
 	else {
 	else {
 		message(io_data, MSG_UNKCON, 0, param, isjson);
 		message(io_data, MSG_UNKCON, 0, param, isjson);
 		return;
 		return;

+ 1 - 0
miner.h

@@ -855,6 +855,7 @@ extern bool opt_fail_only;
 extern bool opt_autofan;
 extern bool opt_autofan;
 extern bool opt_autoengine;
 extern bool opt_autoengine;
 extern bool use_curses;
 extern bool use_curses;
+extern int httpsrv_port;
 extern char *opt_api_allow;
 extern char *opt_api_allow;
 extern char *opt_api_groups;
 extern char *opt_api_groups;
 extern char *opt_api_description;
 extern char *opt_api_description;