|
|
@ -3,7 +3,7 @@ session_start(); |
|
|
|
# |
|
|
|
# |
|
|
|
global $doctype, $title, $miner, $port, $readonly, $notify, $rigs; |
|
|
|
global $doctype, $title, $miner, $port, $readonly, $notify, $rigs; |
|
|
|
global $mcast, $mcastexpect, $mcastaddr, $mcastport, $mcastcode; |
|
|
|
global $mcast, $mcastexpect, $mcastaddr, $mcastport, $mcastcode; |
|
|
|
global $mcastlistport, $mcasttimeout, $allowgen; |
|
|
|
global $mcastlistport, $mcasttimeout, $mcastretries, $allowgen; |
|
|
|
global $rigipsecurity, $rigtotals, $forcerigtotals; |
|
|
|
global $rigipsecurity, $rigtotals, $forcerigtotals; |
|
|
|
global $socksndtimeoutsec, $sockrcvtimeoutsec; |
|
|
|
global $socksndtimeoutsec, $sockrcvtimeoutsec; |
|
|
|
global $checklastshare, $poolinputs, $hidefields; |
|
|
|
global $checklastshare, $poolinputs, $hidefields; |
|
|
@ -70,6 +70,9 @@ $mcastlistport = 4027; |
|
|
|
# to wait for replies to the Multicast message |
|
|
|
# to wait for replies to the Multicast message |
|
|
|
$mcasttimeout = 1.5; |
|
|
|
$mcasttimeout = 1.5; |
|
|
|
# |
|
|
|
# |
|
|
|
|
|
|
|
# Set $mcastretries to the number of times to retry the multicast |
|
|
|
|
|
|
|
$mcastretries = 0; |
|
|
|
|
|
|
|
# |
|
|
|
# Set $allowgen to true to allow customsummarypages to use 'gen' |
|
|
|
# Set $allowgen to true to allow customsummarypages to use 'gen' |
|
|
|
# false means ignore any 'gen' options |
|
|
|
# false means ignore any 'gen' options |
|
|
|
$allowgen = false; |
|
|
|
$allowgen = false; |
|
|
@ -375,8 +378,8 @@ $error = null; |
|
|
|
# |
|
|
|
# |
|
|
|
function getrigs() |
|
|
|
function getrigs() |
|
|
|
{ |
|
|
|
{ |
|
|
|
global $rigs, $mcastaddr, $mcastport, $mcastcode; |
|
|
|
global $rigs, $mcastexpect, $mcastaddr, $mcastport, $mcastcode; |
|
|
|
global $mcastlistport, $mcasttimeout, $error; |
|
|
|
global $mcastlistport, $mcasttimeout, $mcastretries, $error; |
|
|
|
|
|
|
|
|
|
|
|
$listname = "0.0.0.0"; |
|
|
|
$listname = "0.0.0.0"; |
|
|
|
|
|
|
|
|
|
|
@ -414,56 +417,66 @@ function getrigs() |
|
|
|
return; |
|
|
|
return; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
$mcast_soc = socket_create(AF_INET, SOCK_DGRAM, SOL_UDP); |
|
|
|
$retries = $mcastretries; |
|
|
|
if ($mcast_soc === false || $mcast_soc == null) |
|
|
|
$doretry = ($retries > 0); |
|
|
|
|
|
|
|
do |
|
|
|
{ |
|
|
|
{ |
|
|
|
$msg = "ERR: mcast send socket create(UDP) failed"; |
|
|
|
$mcast_soc = socket_create(AF_INET, SOCK_DGRAM, SOL_UDP); |
|
|
|
if ($rigipsecurity === false) |
|
|
|
if ($mcast_soc === false || $mcast_soc == null) |
|
|
|
{ |
|
|
|
{ |
|
|
|
$error = socket_strerror(socket_last_error()); |
|
|
|
$msg = "ERR: mcast send socket create(UDP) failed"; |
|
|
|
$error = "$msg '$error'\n"; |
|
|
|
if ($rigipsecurity === false) |
|
|
|
} |
|
|
|
{ |
|
|
|
else |
|
|
|
$error = socket_strerror(socket_last_error()); |
|
|
|
$error = "$msg\n"; |
|
|
|
$error = "$msg '$error'\n"; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
else |
|
|
|
|
|
|
|
$error = "$msg\n"; |
|
|
|
|
|
|
|
|
|
|
|
socket_close($rep_soc); |
|
|
|
socket_close($rep_soc); |
|
|
|
return; |
|
|
|
return; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
$buf = "cgminer-$mcastcode-$mcastlistport"; |
|
|
|
$buf = "cgminer-$mcastcode-$mcastlistport"; |
|
|
|
socket_sendto($mcast_soc, $buf, strlen($buf), 0, $mcastaddr, $mcastport); |
|
|
|
socket_sendto($mcast_soc, $buf, strlen($buf), 0, $mcastaddr, $mcastport); |
|
|
|
socket_close($mcast_soc); |
|
|
|
socket_close($mcast_soc); |
|
|
|
|
|
|
|
|
|
|
|
$stt = microtime(true); |
|
|
|
$stt = microtime(true); |
|
|
|
while (true) |
|
|
|
while (true) |
|
|
|
{ |
|
|
|
|
|
|
|
$got = @socket_recvfrom($rep_soc, $buf, 32, MSG_DONTWAIT, $ip, $p); |
|
|
|
|
|
|
|
if ($got !== false && $got > 0) |
|
|
|
|
|
|
|
{ |
|
|
|
{ |
|
|
|
$ans = explode('-', $buf, 4); |
|
|
|
$got = @socket_recvfrom($rep_soc, $buf, 32, MSG_DONTWAIT, $ip, $p); |
|
|
|
if (count($ans) >= 3 && $ans[0] == 'cgm' && $ans[1] == 'FTW') |
|
|
|
if ($got !== false && $got > 0) |
|
|
|
{ |
|
|
|
{ |
|
|
|
$rp = intval($ans[2]); |
|
|
|
$ans = explode('-', $buf, 4); |
|
|
|
|
|
|
|
if (count($ans) >= 3 && $ans[0] == 'cgm' && $ans[1] == 'FTW') |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
$rp = intval($ans[2]); |
|
|
|
|
|
|
|
|
|
|
|
if (count($ans) > 3) |
|
|
|
if (count($ans) > 3) |
|
|
|
$mdes = str_replace("\0", '', $ans[3]); |
|
|
|
$mdes = str_replace("\0", '', $ans[3]); |
|
|
|
else |
|
|
|
else |
|
|
|
$mdes = ''; |
|
|
|
$mdes = ''; |
|
|
|
|
|
|
|
|
|
|
|
if (strlen($mdes) > 0) |
|
|
|
if (strlen($mdes) > 0) |
|
|
|
$rig = "$ip:$rp:$mdes"; |
|
|
|
$rig = "$ip:$rp:$mdes"; |
|
|
|
else |
|
|
|
else |
|
|
|
$rig = "$ip:$rp"; |
|
|
|
$rig = "$ip:$rp"; |
|
|
|
|
|
|
|
|
|
|
|
if (!in_array($rig, $rigs)) |
|
|
|
if (!in_array($rig, $rigs)) |
|
|
|
$rigs[] = $rig; |
|
|
|
$rigs[] = $rig; |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
if ((microtime(true) - $stt) >= $mcasttimeout) |
|
|
|
|
|
|
|
break; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
usleep(100000); |
|
|
|
} |
|
|
|
} |
|
|
|
if ((microtime(true) - $stt) >= $mcasttimeout) |
|
|
|
|
|
|
|
break; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
usleep(100000); |
|
|
|
if ($mcastexpect > 0 && count($rigs) >= $mcastexpect) |
|
|
|
} |
|
|
|
$doretry = false; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} while ($doretry && --$retries > 0); |
|
|
|
|
|
|
|
|
|
|
|
socket_close($rep_soc); |
|
|
|
socket_close($rep_soc); |
|
|
|
} |
|
|
|
} |
|
|
|
# |
|
|
|
# |
|
|
|