[MediaWiki-commits] [Gerrit] Converted node cache to using getMainStashInstance() - change (mediawiki...TorBlock)
Aaron Schulz has uploaded a new change for review. https://gerrit.wikimedia.org/r/243113 Change subject: Converted node cache to using getMainStashInstance() .. Converted node cache to using getMainStashInstance() * This make the loadExitNodes.php maintenance script updates the node list in all datacenters. * Also bumped the expiry to one day since relying on a "once every 20 min" cron job in puppet when the key is cached for 30 minutes seems too risky. One or two chron failures should not result in an empty node list (given that $wgTorLoadNodes may be off). Change-Id: Ie7c607e0d816dce8d1aa0d0e35a5efcf2c1a237b --- M includes/TorExitNodes.php 1 file changed, 9 insertions(+), 9 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/TorBlock refs/changes/13/243113/1 diff --git a/includes/TorExitNodes.php b/includes/TorExitNodes.php index a6f464f..c9b41bf 100644 --- a/includes/TorExitNodes.php +++ b/includes/TorExitNodes.php @@ -60,22 +60,21 @@ return self::$mExitNodes; } - global $wgMemc; - - $nodes = $wgMemc->get( 'mw-tor-exit-nodes' ); // No use of wfMemcKey because it should be multi-wiki. + $cache = ObjectCache::getMainStashInstance(); + $nodes = $cache->get( 'mw-tor-exit-nodes' ); // No use of wfMemcKey because it should be multi-wiki. if ( is_array( $nodes ) ) { // wfDebugLog( 'torblock', "Loading Tor exit node list from memcached.\n" ); // Lucky. return self::$mExitNodes = $nodes; } else { - $liststatus = $wgMemc->get( 'mw-tor-list-status' ); + $liststatus = $cache->get( 'mw-tor-list-status' ); if ( $liststatus == 'loading' ) { // Somebody else is loading it. wfDebugLog( 'torblock', "Old Tor list expired and we are still loading the new one.\n" ); return array(); } elseif ( $liststatus == 'loaded' ) { - $nodes = $wgMemc->get( 'mw-tor-exit-nodes' ); + $nodes = $cache->get( 'mw-tor-exit-nodes' ); if ( is_array( $nodes ) ) { return self::$mExitNodes = $nodes; } else { @@ -105,10 +104,10 @@ * for future use. */ public static function loadExitNodes() { - global $wgMemc; + $cache = ObjectCache::getMainStashInstance(); // Set loading key, to prevent DoS of server. - $wgMemc->set( 'mw-tor-list-status', 'loading', intval( ini_get( 'max_execution_time' ) ) ); + $cache->set( 'mw-tor-list-status', 'loading', intval( ini_get( 'max_execution_time' ) ) ); $nodes = self::loadExitNodes_Onionoo(); if( !$nodes ) { @@ -118,8 +117,8 @@ self::$mExitNodes = $nodes; // Save to cache - $wgMemc->set( 'mw-tor-exit-nodes', $nodes, 1800 ); // Store for half an hour. - $wgMemc->set( 'mw-tor-list-status', 'loaded', 1800 ); + $cache->set( 'mw-tor-exit-nodes', $nodes, 86400 ); + $cache->set( 'mw-tor-list-status', 'loaded', 86400 ); } /** @@ -160,6 +159,7 @@ */ protected static function loadExitNodes_Onionoo() { global $wgTorOnionooServer, $wgTorOnionooCA, $wgTorBlockProxy; + $url = wfExpandUrl( "$wgTorOnionooServer/details?type=relay=true=Exit", PROTO_HTTPS ); $options = array( 'caInfo' => is_readable( $wgTorOnionooCA ) ? $wgTorOnionooCA : null -- To view, visit https://gerrit.wikimedia.org/r/243113 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: Ie7c607e0d816dce8d1aa0d0e35a5efcf2c1a237b Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/TorBlock Gerrit-Branch: master Gerrit-Owner: Aaron Schulz___ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits
[MediaWiki-commits] [Gerrit] Converted node cache to using getMainStashInstance() - change (mediawiki...TorBlock)
jenkins-bot has submitted this change and it was merged. Change subject: Converted node cache to using getMainStashInstance() .. Converted node cache to using getMainStashInstance() * This make the loadExitNodes.php maintenance script updates the node list in all datacenters. * Also bumped the expiry to one day since relying on a "once every 20 min" cron job in puppet when the key is cached for 30 minutes seems too risky. One or two chron failures should not result in an empty node list (given that $wgTorLoadNodes may be off). Bug: T97686 Change-Id: Ie7c607e0d816dce8d1aa0d0e35a5efcf2c1a237b --- M includes/TorExitNodes.php 1 file changed, 9 insertions(+), 9 deletions(-) Approvals: Krinkle: Looks good to me, approved jenkins-bot: Verified diff --git a/includes/TorExitNodes.php b/includes/TorExitNodes.php index a6f464f..c9b41bf 100644 --- a/includes/TorExitNodes.php +++ b/includes/TorExitNodes.php @@ -60,22 +60,21 @@ return self::$mExitNodes; } - global $wgMemc; - - $nodes = $wgMemc->get( 'mw-tor-exit-nodes' ); // No use of wfMemcKey because it should be multi-wiki. + $cache = ObjectCache::getMainStashInstance(); + $nodes = $cache->get( 'mw-tor-exit-nodes' ); // No use of wfMemcKey because it should be multi-wiki. if ( is_array( $nodes ) ) { // wfDebugLog( 'torblock', "Loading Tor exit node list from memcached.\n" ); // Lucky. return self::$mExitNodes = $nodes; } else { - $liststatus = $wgMemc->get( 'mw-tor-list-status' ); + $liststatus = $cache->get( 'mw-tor-list-status' ); if ( $liststatus == 'loading' ) { // Somebody else is loading it. wfDebugLog( 'torblock', "Old Tor list expired and we are still loading the new one.\n" ); return array(); } elseif ( $liststatus == 'loaded' ) { - $nodes = $wgMemc->get( 'mw-tor-exit-nodes' ); + $nodes = $cache->get( 'mw-tor-exit-nodes' ); if ( is_array( $nodes ) ) { return self::$mExitNodes = $nodes; } else { @@ -105,10 +104,10 @@ * for future use. */ public static function loadExitNodes() { - global $wgMemc; + $cache = ObjectCache::getMainStashInstance(); // Set loading key, to prevent DoS of server. - $wgMemc->set( 'mw-tor-list-status', 'loading', intval( ini_get( 'max_execution_time' ) ) ); + $cache->set( 'mw-tor-list-status', 'loading', intval( ini_get( 'max_execution_time' ) ) ); $nodes = self::loadExitNodes_Onionoo(); if( !$nodes ) { @@ -118,8 +117,8 @@ self::$mExitNodes = $nodes; // Save to cache - $wgMemc->set( 'mw-tor-exit-nodes', $nodes, 1800 ); // Store for half an hour. - $wgMemc->set( 'mw-tor-list-status', 'loaded', 1800 ); + $cache->set( 'mw-tor-exit-nodes', $nodes, 86400 ); + $cache->set( 'mw-tor-list-status', 'loaded', 86400 ); } /** @@ -160,6 +159,7 @@ */ protected static function loadExitNodes_Onionoo() { global $wgTorOnionooServer, $wgTorOnionooCA, $wgTorBlockProxy; + $url = wfExpandUrl( "$wgTorOnionooServer/details?type=relay=true=Exit", PROTO_HTTPS ); $options = array( 'caInfo' => is_readable( $wgTorOnionooCA ) ? $wgTorOnionooCA : null -- To view, visit https://gerrit.wikimedia.org/r/243113 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: merged Gerrit-Change-Id: Ie7c607e0d816dce8d1aa0d0e35a5efcf2c1a237b Gerrit-PatchSet: 2 Gerrit-Project: mediawiki/extensions/TorBlock Gerrit-Branch: master Gerrit-Owner: Aaron SchulzGerrit-Reviewer: Krinkle Gerrit-Reviewer: jenkins-bot <> ___ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits