diff --git a/configure.ac b/configure.ac index 41f9e748..468326e1 100644 --- a/configure.ac +++ b/configure.ac @@ -39,6 +39,7 @@ AC_CHECK_HEADERS(sys/types.h sys/socket.h sys/stat.h linux/un.h netdb.h) AC_CHECK_HEADERS(stdint.h netinet/in.h netinet/tcp.h sys/ioctl.h getopt.h) AC_CHECK_HEADERS(sys/epoll.h libpq-fe.h postgresql/libpq-fe.h grp.h) AC_CHECK_HEADERS(gsl/gsl_math.h gsl/gsl_cdf.h) +AC_CHECK_HEADERS(openssl/x509.h openssl/hmac.h) PTHREAD_LIBS="-lpthread" MATH_LIBS="-lm" @@ -64,13 +65,17 @@ if test "x$ckdb" != "xno"; then not found. Install it or disable support with --without-ckdb" && exit 1) AC_CHECK_LIB([gslcblas], [main],[GSLCBLAS=-lgslcblas],echo "Error: Required library gslcblas not found. Install it or disable support with --without-ckdb" && exit 1) + AC_CHECK_LIB([ssl], [main],[SSL=-lssl],echo "Error: Required library ssl + not found. Install it or disable support with --without-ckdb" && exit 1) + AC_CHECK_LIB([crypto], [main],[SSL=-lcrypto],echo "Error: Required library crypto + not found. Install it or disable support with --without-ckdb" && exit 1) AC_DEFINE([USE_CKDB], [1], [Defined to 1 if ckdb support required]) - PQ_LIBS="-lpq -lgsl -lgslcblas" + DB_LIBS="-lpq -lgsl -lgslcblas -lssl -lcrypto" else - PQ_LIBS="" + DB_LIBS="" fi AM_CONDITIONAL([WANT_CKDB], [test "x$ckdb" != "xno"]) -AC_SUBST(PQ_LIBS) +AC_SUBST(DB_LIBS) AC_OUTPUT([Makefile] [src/Makefile]) @@ -80,7 +85,7 @@ echo " CPPFLAGS.............: $CPPFLAGS" echo " CFLAGS...............: $CFLAGS" echo " LDFLAGS..............: $LDFLAGS" echo " LDADD................: $PTHREAD_LIBS $MATH_LIBS $RT_LIBS $JANSSON_LIBS" -echo " db LDADD.............: $PQ_LIBS" +echo " db LDADD.............: $DB_LIBS" echo echo "Installation...........: make install (as root if needed, with 'su' or 'sudo')" echo " prefix...............: $prefix" diff --git a/pool/base.php b/pool/base.php index 496ded31..e388a538 100644 --- a/pool/base.php +++ b/pool/base.php @@ -323,12 +323,12 @@ session_start(); # include_once('db.php'); # -function validUserPass($user, $pass) +function validUserPass($user, $pass, $twofa) { - $rep = checkPass($user, $pass); + $rep = checkPass($user, $pass, $twofa); if ($rep != null) $ans = repDecode($rep); - usleep(100000); // Max 10x per second + usleep(500000); // Max twice per second if ($rep != null && $ans['STATUS'] == 'ok') { $key = 'ckp'.rand(1000000,9999999); @@ -352,7 +352,7 @@ function logout() } } # -function requestRegister() +function requestLoginRegReset() { $reg = getparam('Register', true); $reg2 = getparam('Reset', false); @@ -397,7 +397,9 @@ function tryLogInOut() return; } - $valid = validUserPass($user, $pass); + $twofa = getparam('2fa', false); + + $valid = validUserPass($user, $pass, $twofa); if (!$valid) $loginfailed = true; } diff --git a/pool/db.php b/pool/db.php index 39e9f577..a72591be 100644 --- a/pool/db.php +++ b/pool/db.php @@ -166,23 +166,18 @@ function homeInfo($user) if ($rep === false) $ans = false; else - { $ans = repDecode($rep); -// if ($ans['lastblock'] == '?') -// { -// $ans['lastblock'] = 1401237522; -// $ans['lastblock'] = 1403819191; -// $ans['lastblock'] = 1407113822; -// } - } return $ans; } # -function checkPass($user, $pass) +function checkPass($user, $pass, $twofa) { $passhash = myhash($pass); - $flds = array('username' => $user, 'passwordhash' => $passhash); + if (nuem($twofa)) + $twofa = 0; + $flds = array('username' => $user, 'passwordhash' => $passhash, + '2fa' => $twofa); $msg = msgEncode('chkpass', 'chkpass', $flds, $user); $rep = sendsockreply('checkPass', $msg); if (!$rep) @@ -190,11 +185,14 @@ function checkPass($user, $pass) return $rep; } # -function setPass($user, $oldpass, $newpass) +function setPass($user, $oldpass, $newpass, $twofa) { $oldhash = myhash($oldpass); $newhash = myhash($newpass); - $flds = array('username' => $user, 'oldhash' => $oldhash, 'newhash' => $newhash); + if (nuem($twofa)) + $twofa = 0; + $flds = array('username' => $user, 'oldhash' => $oldhash, + 'newhash' => $newhash, '2fa' => $twofa); $msg = msgEncode('newpass', 'newpass', $flds, $user); $rep = sendsockreply('setPass', $msg); if (!$rep) @@ -202,10 +200,12 @@ function setPass($user, $oldpass, $newpass) return repDecode($rep); } # -function resetPass($user, $newpass) +function resetPass($user, $newpass, $twofa) { $newhash = myhash($newpass); - $flds = array('username' => $user, 'newhash' => $newhash); + if (nuem($twofa)) + $twofa = 0; + $flds = array('username' => $user, 'newhash' => $newhash, '2fa' => $twofa); $msg = msgEncode('newpass', 'newpass', $flds, $user); $rep = sendsockreply('resetPass', $msg); if (!$rep) @@ -213,10 +213,24 @@ function resetPass($user, $newpass) return repDecode($rep); } # +function get2fa($user, $action, $entropy, $value) +{ + if ($value === null) + $value = ''; + $flds = array('username' => $user, 'action' => $action, + 'entropy' => $entropy, 'value' => $value); + $msg = msgEncode('2fa', '2fa', $flds, $user); + $rep = sendsockreply('get2fa', $msg); + if (!$rep) + dbdown(); + return repDecode($rep); +} +# function userReg($user, $email, $pass) { $passhash = myhash($pass); - $flds = array('username' => $user, 'emailaddress' => $email, 'passwordhash' => $passhash); + $flds = array('username' => $user, 'emailaddress' => $email, + 'passwordhash' => $passhash); $msg = msgEncode('adduser', 'reg', $flds, $user); $rep = sendsockreply('userReg', $msg); if (!$rep) @@ -224,7 +238,7 @@ function userReg($user, $email, $pass) return repDecode($rep); } # -function userSettings($user, $email = null, $addr = null, $pass = null) +function userSettings($user, $email = null, $addr = null, $pass = null, $twofa = null) { $tmo = false; $flds = array('username' => $user); @@ -246,7 +260,12 @@ function userSettings($user, $email = null, $addr = null, $pass = null) $tmo = 3; # 3x the timeout } if ($pass != null) + { $flds['passwordhash'] = myhash($pass); + if (nuem($twofa)) + $twofa = 0; + $flds['2fa'] = $twofa; + } $msg = msgEncode('usersettings', 'userset', $flds, $user); $rep = sendsockreply('userSettings', $msg, $tmo); if (!$rep) diff --git a/pool/inc.php b/pool/inc.php index 9710fe8b..dea5baf0 100644 --- a/pool/inc.php +++ b/pool/inc.php @@ -91,6 +91,8 @@ span.login {float:right;margin-left:8px;margin-right:24px;} span.hil {color:blue;} span.user {color:green;} span.addr {color:brown;} +span.hdr {font-weight:bold;text-decoration:underline;} +span.nn {font-weight:bold;color:red;} span.warn {color:orange;font-weight:bold;} span.urg {color:red;font-weight:bold;} span.err {color:red;font-weight:bold;font-size:120%;} diff --git a/pool/page.php b/pool/page.php index 6a64d2eb..3b9780ad 100644 --- a/pool/page.php +++ b/pool/page.php @@ -165,6 +165,7 @@ function pgtop($info, $dotop, $user, $douser) $nlb = '?'; $pac = '0'; $per = '0'; + $perset = false; $uhr = '?GHs'; $u1hr = ''; if ($info !== false) @@ -244,12 +245,46 @@ function pgtop($info, $dotop, $user, $douser) } } + if (isset($info['blockshareinv'])) + { + $shinv = $info['blockshareinv']; + $per = siprefmt($shinv, 1); + $perset = true; + if (isset($info['blockshareacc'])) + { + $shacc = $info['blockshareacc']; + if (($shacc+$shinv) > 0) + { + $amt = 100.0 * $shinv / ($shacc + $shinv); + if (round($amt, 2) > 9.99) + $per .= ' ('.number_format($amt, 1).'%)'; + else + $per .= ' ('.number_format($amt, 2).'%)'; + } + } + } + if (isset($info['blockerr'])) { - $rej = $info['blockerr']; - $per = number_format($info['blockerr'], 0); - if (isset($info['blockacc']) && ($acc+$rej) > 0) - $per .= ' ('.number_format(100.0*$rej/($acc+$rej), 3).'%)'; + if ($perset == false) + $per = ''; + else + $per .= ' · '; + + $inv = $info['blockerr']; + $per .= siprefmt($inv, 1); + if (isset($info['blockacc'])) + { + $acc = $info['blockacc']; + if (($acc+$inv) > 0) + { + $amt = 100.0 * $inv / ($acc + $inv); + if (round($amt, 2) > 9.99) + $per .= ' ('.number_format($amt, 1).'%)'; + else + $per .= ' ('.number_format($amt, 2).'%)'; + } + } } if (isset($info['u_hashrate5m'])) @@ -350,7 +385,7 @@ function pgtop($info, $dotop, $user, $douser) $top .= " $phr"; $top .= 'Shares: '; $top .= " $pac"; - $top .= 'Invalid: '; + $top .= 'Invalids: '; $top .= " $per"; $top .= ''; $top .= ''; @@ -374,17 +409,10 @@ function pgtop($info, $dotop, $user, $douser) list($who, $whoid) = validate(); if ($who == false) { - $top .= makeForm('')." -
- - - - -
User:
Pass:
- - -
 
  
-
"; + $top .= '"; - $pg .= ''; + $pg .= ''; + + if ((($offset++) % 2) == 0) + $row = 'even'; + else + $row = 'odd'; + $pg .= ""; + $pg .= ''; + + $pg .= "'; } - $pg .= ''; $pg .= "
'; + $top .= ' diff --git a/pool/page_addrmgt.php b/pool/page_addrmgt.php index 0ef12d85..d0300796 100644 --- a/pool/page_addrmgt.php +++ b/pool/page_addrmgt.php @@ -72,13 +72,24 @@ function addrmgtuser($data, $user, $err) else $row = 'odd'; $pg .= "
'; + $pg .= ''; $pg .= 'Password: '; - $pg .= ' 
 
'; + $pg .= '*2nd Authentication: '; + $pg .= '
"; + $pg .= "*Leave blank if you haven't enabled it
"; + $pg .= 'You must enter your password to save changes
'; + $pg .= 'A ratio of 0, will remove the address from the payouts
*'; - $pg .= ' You must enter your password to save changes
'; - $pg .= 'A ratio of 0, will remove the address from the payouts
\n"; $pg .= "