miner.php by default don't display IP/Port numbers in error messages
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152
diff --git a/API-README b/API-README
index 4ac86b9..0e66170 100644
--- a/API-README
+++ b/API-README
@@ -925,6 +925,14 @@ e.g. $rigs = array('127.0.0.1:4028','myrig.com:4028:Sugoi');
---------
Default:
+ $rigipsecurity = true;
+
+Set $rigipsecurity to false to show the IP/Port of the rig
+in the socket error messages and also show the full socket message
+
+---------
+
+Default:
$rigtotals = true;
$forcerigtotals = false;
diff --git a/miner.php b/miner.php
index 07a5fb5..7ead4e9 100644
--- a/miner.php
+++ b/miner.php
@@ -2,7 +2,7 @@
session_start();
#
global $title, $miner, $port, $readonly, $notify, $rigs;
-global $rigtotals, $forcerigtotals;
+global $rgisecurity, $rigtotals, $forcerigtotals;
global $socksndtimeoutsec, $sockrcvtimeoutsec;
global $checklastshare, $poolinputs, $hidefields;
global $ignorerefresh, $changerefresh, $autorefresh;
@@ -40,6 +40,10 @@ $poolinputs = false;
# format: 'IP:Port' or 'Host:Port' or 'Host:Port:Name'
$rigs = array('127.0.0.1:4028');
#
+# 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;
+#
# Set $rigtotals to true to display totals on the single rig page
# 'false' means no totals (and ignores $forcerigtotals)
# You can force it to always show rig totals when there is only
@@ -226,7 +230,7 @@ function htmlhead($checkapi, $rig, $pg = null)
if ($readonly === false && $checkapi === true)
{
$error = null;
- $access = api('privileged');
+ $access = api($rig, 'privileged');
if ($error != null
|| !isset($access['STATUS']['STATUS'])
|| $access['STATUS']['STATUS'] != 'S')
@@ -275,8 +279,9 @@ global $haderror, $error;
$haderror = false;
$error = null;
#
-function getsock($addr, $port)
+function getsock($rig, $addr, $port)
{
+ global $rigipsecurity;
global $haderror, $error, $socksndtimeoutsec, $sockrcvtimeoutsec;
$error = null;
@@ -285,9 +290,15 @@ function getsock($addr, $port)
if ($socket === false || $socket === null)
{
$haderror = true;
- $error = socket_strerror(socket_last_error());
- $msg = "socket create(TCP) failed";
- $error = "ERR: $msg '$error'\n";
+ if ($rigipsecurity === false)
+ {
+ $error = socket_strerror(socket_last_error());
+ $msg = "socket create(TCP) failed";
+ $error = "ERR: $msg '$error'\n";
+ }
+ else
+ $error = "ERR: socket create(TCP) failed\n";
+
return null;
}
@@ -301,9 +312,15 @@ function getsock($addr, $port)
if ($res === false)
{
$haderror = true;
- $error = socket_strerror(socket_last_error());
- $msg = "socket connect($addr,$port) failed";
- $error = "ERR: $msg '$error'\n";
+ if ($rigipsecurity === false)
+ {
+ $error = socket_strerror(socket_last_error());
+ $msg = "socket connect($addr,$port) failed";
+ $error = "ERR: $msg '$error'\n";
+ }
+ else
+ $error = "ERR: socket connect($rig) failed\n";
+
socket_close($socket);
return null;
}
@@ -365,12 +382,12 @@ function revert($str)
return str_replace(array("\1", "\2", "\3", "\4"), array("|", "\\", "=", ","), $str);
}
#
-function api($cmd)
+function api($rig, $cmd)
{
global $haderror, $error;
global $miner, $port, $hidefields;
- $socket = getsock($miner, $port);
+ $socket = getsock($rig, $miner, $port);
if ($socket != null)
{
socket_write($socket, $cmd, strlen($cmd));
@@ -1071,7 +1088,7 @@ function processgpus($rig)
global $error;
global $warnfont, $warnoff;
- $gpus = api('gpucount');
+ $gpus = api($rig, 'gpucount');
if ($error != null)
otherrow("<td>Error getting GPU count: $warnfont$error$warnoff</td>");
@@ -1140,7 +1157,7 @@ function process($cmds, $rig)
$count = count($cmds);
foreach ($cmds as $cmd => $des)
{
- $process = api($cmd);
+ $process = api($rig, $cmd);
if ($error != null)
{
@@ -1255,7 +1272,7 @@ function doforeach($cmd, $des, $sum, $head, $datetime)
else
$name = $num;
- $ans = api($cmd);
+ $ans = api($name, $cmd);
if ($error != null)
{
@@ -1767,7 +1784,7 @@ function processcustompage($pagename, $sections, $sum, $namemap)
foreach ($cmds as $cmd => $one)
{
- $process = api($cmd);
+ $process = api($name, $cmd);
if ($error != null)
{