diff --git a/api.php b/api.php index 347709c..e8185d9 100755 --- a/api.php +++ b/api.php @@ -69,7 +69,7 @@ header('Content-Type: application/json'); use Arionum\Blacklist; -require_once("include/init.inc.php"); +require_once __DIR__.'/include/init.inc.php'; error_reporting(0); $ip = san_ip($_SERVER['REMOTE_ADDR']); $ip = filter_var($ip, FILTER_VALIDATE_IP); diff --git a/include/config-sample.inc.php b/include/config-sample.inc.php index 63f13d4..1ba32a3 100755 --- a/include/config-sample.inc.php +++ b/include/config-sample.inc.php @@ -85,6 +85,10 @@ $_config['initial_peer_list'] = [ '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 diff --git a/include/init.inc.php b/include/init.inc.php index b833864..e540a1f 100755 --- a/include/init.inc.php +++ b/include/init.inc.php @@ -1,6 +1,6 @@ 1) { } require_once __DIR__.'/Exception.php'; -require_once("include/config.inc.php"); -require_once("include/db.inc.php"); -require_once("include/functions.inc.php"); +require_once __DIR__.'/config.inc.php'; +require_once __DIR__.'/db.inc.php'; +require_once __DIR__.'/functions.inc.php'; require_once __DIR__.'/Blacklist.php'; require_once __DIR__.'/InitialPeers.php'; -require_once("include/block.inc.php"); -require_once("include/account.inc.php"); -require_once("include/transaction.inc.php"); +require_once __DIR__.'/block.inc.php'; +require_once __DIR__.'/account.inc.php'; +require_once __DIR__.'/transaction.inc.php'; if ($_config['db_pass'] == "ENTER-DB-PASS") { 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"); if ($res) { echo "Updating db schema! Please refresh!\n"; - require_once("include/schema.inc.php"); + require_once __DIR__.'/schema.inc.php'; exit; } echo "Could not access the tmp/db-update file. Please give full permissions to this file\n"; diff --git a/mine.php b/mine.php index 616b87f..18eeb66 100755 --- a/mine.php +++ b/mine.php @@ -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 OR OTHER DEALINGS IN THE SOFTWARE. */ -require_once("include/init.inc.php"); +require_once __DIR__.'/include/init.inc.php'; $block = new Block(); $acc = new Account(); set_time_limit(360); diff --git a/peer.php b/peer.php index e5f3844..5ac9dc4 100755 --- a/peer.php +++ b/peer.php @@ -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 OR OTHER DEALINGS IN THE SOFTWARE. */ -require_once("include/init.inc.php"); +require_once __DIR__.'/include/init.inc.php'; header('Content-Type: application/json'); $trx = new Transaction(); diff --git a/propagate.php b/propagate.php index 03636b9..b8f0138 100755 --- a/propagate.php +++ b/propagate.php @@ -24,7 +24,7 @@ OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ set_time_limit(360); -require_once("include/init.inc.php"); +require_once __DIR__.'/include/init.inc.php'; $block = new Block(); $type = san($argv[1]); diff --git a/sanity.php b/sanity.php index ba3fc75..aba4939 100755 --- a/sanity.php +++ b/sanity.php @@ -301,7 +301,15 @@ if ($total_peers == 0 && $_config['testnet'] == false) { continue; } $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) { $i++; echo "Peering OK - $peer\n"; @@ -328,7 +336,7 @@ foreach ($r as $x) { _log("Contacting peer $x[hostname]"); $url = $x['hostname']."/peer.php?q="; // 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); if ($data === false) { _log("Peer $x[hostname] unresponsive"); diff --git a/util.php b/util.php index 5a39822..71190d6 100755 --- a/util.php +++ b/util.php @@ -29,7 +29,7 @@ if (php_sapi_name() !== '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]); /**