Browse Source

miner.php disable 'gen' by default

Kano 12 years ago
parent
commit
9f27831c46
2 changed files with 22 additions and 4 deletions
  1. 10 0
      API-README
  2. 12 4
      miner.php

+ 10 - 0
API-README

@@ -1247,6 +1247,16 @@ N.B. the accuracy of the timing used to wait for the replies is
 
 ---------
 
+Default:
+ $allowgen = false;
+
+Set $allowgen to true to allow customsummarypages to use 'gen' 
+false means ignore any 'gen' options
+This is disabled by default due to the possible security risk
+of using it, see the end of this document for an explanation
+
+---------
+
 Default:
  $rigipsecurity = true;
 

+ 12 - 4
miner.php

@@ -3,7 +3,7 @@ session_start();
 #
 global $doctype, $title, $miner, $port, $readonly, $notify, $rigs;
 global $mcast, $mcastexpect, $mcastaddr, $mcastport, $mcastcode;
-global $mcastlistport, $mcasttimeout;
+global $mcastlistport, $mcasttimeout, $allowgen;
 global $rigipsecurity, $rigtotals, $forcerigtotals;
 global $socksndtimeoutsec, $sockrcvtimeoutsec;
 global $checklastshare, $poolinputs, $hidefields;
@@ -70,6 +70,10 @@ $mcastlistport = 4027;
 # to wait for replies to the Multicast message
 $mcasttimeout = 1.5;
 #
+# Set $allowgen to true to allow customsummarypages to use 'gen' 
+# false means ignore any 'gen' options
+$allowgen = false;
+#
 # Set $rigipsecurity to false to show the IP/Port of the rig
 # in the socket error messages and also show the full socket message
 $rigipsecurity = true;
@@ -145,7 +149,7 @@ $poolspage = array(
 			'POOL.Has GBT=GBT', 'STATS.Times Sent=TSent',
 			'STATS.Bytes Sent=BSent', 'STATS.Net Bytes Sent=NSent',
 			'STATS.Times Recv=TRecv', 'STATS.Bytes Recv=BRecv',
-			'STATS.Net Bytes Recv=NRecv'));
+			'STATS.Net Bytes Recv=NRecv', 'GEN.AvShr=AvShr'));
 #
 $poolssum = array(
  'SUMMARY' => array('MHS av', 'Found Blocks', 'Accepted',
@@ -162,7 +166,9 @@ $poolsext = array(
 	'calc' => array('POOL.Difficulty Accepted' => 'sum', 'POOL.Difficulty Rejected' => 'sum',
 			'STATS.Times Sent' => 'sum', 'STATS.Bytes Sent' => 'sum',
 			'STATS.Net Bytes Sent' => 'sum', 'STATS.Times Recv' => 'sum',
-			'STATS.Bytes Recv' => 'sum', 'STATS.Net Bytes Recv' => 'sum'),
+			'STATS.Bytes Recv' => 'sum', 'STATS.Net Bytes Recv' => 'sum',
+			'POOL.Accepted' => 'sum'),
+	'gen' => array('AvShr' => 'round(POOL.Difficulty Accepted/max(POOL.Accepted,1)*100)/100'),
 	'having' => array(array('STATS.Bytes Recv', '>', 0)))
 );
 
@@ -2396,6 +2402,8 @@ function dogen($ext, $section, &$res, &$fields)
 #
 function processext($ext, $section, $res, &$fields)
 {
+ global $allowgen;
+
  $res = processcompare('where', $ext, $section, $res);
 
  if (isset($ext[$section]['group']))
@@ -2464,7 +2472,7 @@ function processext($ext, $section, $res, &$fields)
  }
 
  // Generated fields (functions of other fields)
- if (isset($ext[$section]['gen']))
+ if ($allowgen === true && isset($ext[$section]['gen']))
 	dogen($ext, $section, $res, $fields);
 
  return processcompare('having', $ext, $section, $res);