Browse Source

Merge branch 'master' of github.com:ckolivas/cgminer

Con Kolivas 12 years ago
parent
commit
51b070166f
4 changed files with 28 additions and 6 deletions
  1. 2 2
      api.c
  2. 13 0
      cgminer.c
  3. 1 0
      miner.h
  4. 12 4
      miner.php

+ 2 - 2
api.c

@@ -4403,8 +4403,8 @@ static void mcast()
 				reply_sock = socket(AF_INET, SOCK_DGRAM, 0);
 				reply_sock = socket(AF_INET, SOCK_DGRAM, 0);
 
 
 				snprintf(replybuf, sizeof(replybuf),
 				snprintf(replybuf, sizeof(replybuf),
-							"cgm-" API_MCAST_CODE "-%d",
-							opt_api_port);
+							"cgm-" API_MCAST_CODE "-%d-%s",
+							opt_api_port, opt_api_mcast_des);
 
 
 				rep = sendto(reply_sock, replybuf, strlen(replybuf)+1,
 				rep = sendto(reply_sock, replybuf, strlen(replybuf)+1,
 						0, (struct sockaddr *)(&came_from),
 						0, (struct sockaddr *)(&came_from),

+ 13 - 0
cgminer.c

@@ -148,6 +148,7 @@ bool opt_api_listen;
 bool opt_api_mcast;
 bool opt_api_mcast;
 char *opt_api_mcast_addr = API_MCAST_ADDR;
 char *opt_api_mcast_addr = API_MCAST_ADDR;
 char *opt_api_mcast_code = API_MCAST_CODE;
 char *opt_api_mcast_code = API_MCAST_CODE;
+char *opt_api_mcast_des = "";
 int opt_api_mcast_port = 4028;
 int opt_api_mcast_port = 4028;
 bool opt_api_network;
 bool opt_api_network;
 bool opt_delaynet;
 bool opt_delaynet;
@@ -908,6 +909,13 @@ static char *set_api_mcast_code(const char *arg)
 	return NULL;
 	return NULL;
 }
 }
 
 
+static char *set_api_mcast_des(const char *arg)
+{
+	opt_set_charp(arg, &opt_api_mcast_des);
+
+	return NULL;
+}
+
 #ifdef USE_ICARUS
 #ifdef USE_ICARUS
 static char *set_icarus_options(const char *arg)
 static char *set_icarus_options(const char *arg)
 {
 {
@@ -970,6 +978,9 @@ static struct opt_table opt_config_table[] = {
 	OPT_WITH_ARG("--api-mcast-code",
 	OPT_WITH_ARG("--api-mcast-code",
 		     set_api_mcast_code, NULL, NULL,
 		     set_api_mcast_code, NULL, NULL,
 		     "Code expected in the API Multicast message, don't use '-'"),
 		     "Code expected in the API Multicast message, don't use '-'"),
+	OPT_WITH_ARG("--api-mcast-des",
+		     set_api_mcast_des, NULL, NULL,
+		     "Description appended to the API Multicast reply, default: ''"),
 	OPT_WITH_ARG("--api-mcast-port",
 	OPT_WITH_ARG("--api-mcast-port",
 		     set_int_1_to_65535, opt_show_intval, &opt_api_mcast_port,
 		     set_int_1_to_65535, opt_show_intval, &opt_api_mcast_port,
 		     "API Multicast listen port"),
 		     "API Multicast listen port"),
@@ -4214,6 +4225,8 @@ void write_config(FILE *fcfg)
 		fprintf(fcfg, ",\n\"api-mcast-addr\" : \"%s\"", json_escape(opt_api_mcast_addr));
 		fprintf(fcfg, ",\n\"api-mcast-addr\" : \"%s\"", json_escape(opt_api_mcast_addr));
 	if (strcmp(opt_api_mcast_code, API_MCAST_CODE) != 0)
 	if (strcmp(opt_api_mcast_code, API_MCAST_CODE) != 0)
 		fprintf(fcfg, ",\n\"api-mcast-code\" : \"%s\"", json_escape(opt_api_mcast_code));
 		fprintf(fcfg, ",\n\"api-mcast-code\" : \"%s\"", json_escape(opt_api_mcast_code));
+	if (*opt_api_mcast_des)
+		fprintf(fcfg, ",\n\"api-mcast-des\" : \"%s\"", json_escape(opt_api_mcast_des));
 	if (strcmp(opt_api_description, PACKAGE_STRING) != 0)
 	if (strcmp(opt_api_description, PACKAGE_STRING) != 0)
 		fprintf(fcfg, ",\n\"api-description\" : \"%s\"", json_escape(opt_api_description));
 		fprintf(fcfg, ",\n\"api-description\" : \"%s\"", json_escape(opt_api_description));
 	if (opt_api_groups)
 	if (opt_api_groups)

+ 1 - 0
miner.h

@@ -883,6 +883,7 @@ extern char *opt_api_allow;
 extern bool opt_api_mcast;
 extern bool opt_api_mcast;
 extern char *opt_api_mcast_addr;
 extern char *opt_api_mcast_addr;
 extern char *opt_api_mcast_code;
 extern char *opt_api_mcast_code;
+extern char *opt_api_mcast_des;
 extern int opt_api_mcast_port;
 extern int opt_api_mcast_port;
 extern char *opt_api_groups;
 extern char *opt_api_groups;
 extern char *opt_api_description;
 extern char *opt_api_description;

+ 12 - 4
miner.php

@@ -412,11 +412,20 @@ function getrigs()
 	$got = @socket_recvfrom($rep_soc, $buf, 32, MSG_DONTWAIT, $ip, $p);
 	$got = @socket_recvfrom($rep_soc, $buf, 32, MSG_DONTWAIT, $ip, $p);
 	if ($got !== false && $got > 0)
 	if ($got !== false && $got > 0)
 	{
 	{
-		$ans = explode('-', $buf);
-		if (count($ans) == 3 && $ans[0] == 'cgm' && $ans[1] == 'FTW')
+		$ans = explode('-', $buf, 4);
+		if (count($ans) >= 3 && $ans[0] == 'cgm' && $ans[1] == 'FTW')
 		{
 		{
 			$rp = intval($ans[2]);
 			$rp = intval($ans[2]);
-			$rigs[] = "$ip:$rp";
+
+			if (count($ans) > 3)
+				$mdes = str_replace("\0", '', $ans[3]);
+			else
+				$mdes = '';
+
+			if (strlen($mdes) > 0)
+				$rigs[] = "$ip:$rp:$mdes";
+			else
+				$rigs[] = "$ip:$rp";
 		}
 		}
 	}
 	}
 	if ((microtime(true) - $stt) >= $mcasttimeout)
 	if ((microtime(true) - $stt) >= $mcasttimeout)
@@ -424,7 +433,6 @@ function getrigs()
 
 
 	usleep(100000);
 	usleep(100000);
  }
  }
-
  socket_close($rep_soc);
  socket_close($rep_soc);
 }
 }
 #
 #