passive peering

This commit is contained in:
admin@arionum.com
2018-10-25 21:11:24 +03:00
parent 3251f98ebf
commit 88f50fcae1
8 changed files with 27 additions and 15 deletions

View File

@@ -69,7 +69,7 @@ header('Content-Type: application/json');
use Arionum\Blacklist; use Arionum\Blacklist;
require_once("include/init.inc.php"); require_once __DIR__.'/include/init.inc.php';
error_reporting(0); error_reporting(0);
$ip = san_ip($_SERVER['REMOTE_ADDR']); $ip = san_ip($_SERVER['REMOTE_ADDR']);
$ip = filter_var($ip, FILTER_VALIDATE_IP); $ip = filter_var($ip, FILTER_VALIDATE_IP);

View File

@@ -85,6 +85,10 @@ $_config['initial_peer_list'] = [
'http://peer27.arionum.com', 'http://peer27.arionum.com',
]; ];
// does not peer with any of the peers. Uses the seed peers and syncs only from those peers. Requires a cronjob on sanity.php
$_config['passive_peering'] = false;
/* /*
|-------------------------------------------------------------------------- |--------------------------------------------------------------------------
| Mempool Configuration | Mempool Configuration

View File

@@ -1,6 +1,6 @@
<?php <?php
// ARO version // ARO version
define("VERSION", "0.4.2"); define("VERSION", "0.4.3");
// Amsterdam timezone by default, should probably be moved to config // Amsterdam timezone by default, should probably be moved to config
date_default_timezone_set("UTC"); date_default_timezone_set("UTC");
@@ -14,14 +14,14 @@ if (php_sapi_name() !== 'cli' && substr_count($_SERVER['PHP_SELF'], "/") > 1) {
} }
require_once __DIR__.'/Exception.php'; require_once __DIR__.'/Exception.php';
require_once("include/config.inc.php"); require_once __DIR__.'/config.inc.php';
require_once("include/db.inc.php"); require_once __DIR__.'/db.inc.php';
require_once("include/functions.inc.php"); require_once __DIR__.'/functions.inc.php';
require_once __DIR__.'/Blacklist.php'; require_once __DIR__.'/Blacklist.php';
require_once __DIR__.'/InitialPeers.php'; require_once __DIR__.'/InitialPeers.php';
require_once("include/block.inc.php"); require_once __DIR__.'/block.inc.php';
require_once("include/account.inc.php"); require_once __DIR__.'/account.inc.php';
require_once("include/transaction.inc.php"); require_once __DIR__.'/transaction.inc.php';
if ($_config['db_pass'] == "ENTER-DB-PASS") { if ($_config['db_pass'] == "ENTER-DB-PASS") {
die("Please update your config file and set your db password"); die("Please update your config file and set your db password");
@@ -77,7 +77,7 @@ if (file_exists("tmp/db-update")) {
$res = unlink("tmp/db-update"); $res = unlink("tmp/db-update");
if ($res) { if ($res) {
echo "Updating db schema! Please refresh!\n"; echo "Updating db schema! Please refresh!\n";
require_once("include/schema.inc.php"); require_once __DIR__.'/schema.inc.php';
exit; exit;
} }
echo "Could not access the tmp/db-update file. Please give full permissions to this file\n"; echo "Could not access the tmp/db-update file. Please give full permissions to this file\n";

View File

@@ -23,7 +23,7 @@ DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE
OR OTHER DEALINGS IN THE SOFTWARE. OR OTHER DEALINGS IN THE SOFTWARE.
*/ */
require_once("include/init.inc.php"); require_once __DIR__.'/include/init.inc.php';
$block = new Block(); $block = new Block();
$acc = new Account(); $acc = new Account();
set_time_limit(360); set_time_limit(360);

View File

@@ -23,7 +23,7 @@ DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE
OR OTHER DEALINGS IN THE SOFTWARE. OR OTHER DEALINGS IN THE SOFTWARE.
*/ */
require_once("include/init.inc.php"); require_once __DIR__.'/include/init.inc.php';
header('Content-Type: application/json'); header('Content-Type: application/json');
$trx = new Transaction(); $trx = new Transaction();

View File

@@ -24,7 +24,7 @@ OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE
OR OTHER DEALINGS IN THE SOFTWARE. OR OTHER DEALINGS IN THE SOFTWARE.
*/ */
set_time_limit(360); set_time_limit(360);
require_once("include/init.inc.php"); require_once __DIR__.'/include/init.inc.php';
$block = new Block(); $block = new Block();
$type = san($argv[1]); $type = san($argv[1]);

View File

@@ -301,7 +301,15 @@ if ($total_peers == 0 && $_config['testnet'] == false) {
continue; continue;
} }
$peered[$pid] = 1; $peered[$pid] = 1;
$res = peer_post($peer."/peer.php?q=peer", ["hostname" => $_config['hostname'], "repeer" => 1]);
if($_config['passive_peering'] == true){
// does not peer, just add it to DB in passive mode
$db->run("INSERT into peers set hostname=:hostname, ping=0, reserve=0,ip=:ip",[":hostname"=>$peer, ":ip"=>md5($peer)]);
$res=true;
} else {
// forces the other node to peer with us.
$res = peer_post($peer."/peer.php?q=peer", ["hostname" => $_config['hostname'], "repeer" => 1]);
}
if ($res !== false) { if ($res !== false) {
$i++; $i++;
echo "Peering OK - $peer\n"; echo "Peering OK - $peer\n";
@@ -328,7 +336,7 @@ foreach ($r as $x) {
_log("Contacting peer $x[hostname]"); _log("Contacting peer $x[hostname]");
$url = $x['hostname']."/peer.php?q="; $url = $x['hostname']."/peer.php?q=";
// get their peers list // get their peers list
if ($_config['get_more_peers']==true) { if ($_config['get_more_peers']==true && $_config['passive_peering']!=true) {
$data = peer_post($url."getPeers", [], 5); $data = peer_post($url."getPeers", [], 5);
if ($data === false) { if ($data === false) {
_log("Peer $x[hostname] unresponsive"); _log("Peer $x[hostname] unresponsive");

View File

@@ -29,7 +29,7 @@ if (php_sapi_name() !== 'cli') {
die("This should only be run as cli"); die("This should only be run as cli");
} }
require_once("include/init.inc.php"); require_once __DIR__.'/include/init.inc.php';
$cmd = trim($argv[1]); $cmd = trim($argv[1]);
/** /**