Skip to content

Commit

Permalink
Merge pull request #27 from paragonie/certainty-fallback
Browse files Browse the repository at this point in the history
Fix for performance issues:
  • Loading branch information
DivineOmega authored Sep 27, 2019
2 parents 3f000ed + 3a56a95 commit 6ad5613
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
"psr/http-factory-implementation": "^1.0",
"php-http/discovery": "^1.6",
"nyholm/psr7": "^1.0",
"paragonie/certainty": "^1|^2",
"paragonie/certainty": "^2.4",
"divineomega/do-file-cache-psr-6": "^2.0",
"divineomega/psr-18-guzzle-adapter": "^1.0"
},
Expand Down
15 changes: 14 additions & 1 deletion src/PasswordExposedChecker.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

use DivineOmega\DOFileCachePSR6\CacheItemPool;
use DivineOmega\Psr18GuzzleAdapter\Client;
use GuzzleHttp\Exception\ConnectException;
use Http\Discovery\Psr17FactoryDiscovery;
use ParagonIE\Certainty\Bundle;
use ParagonIE\Certainty\Fetch;
Expand Down Expand Up @@ -226,6 +227,18 @@ protected function getBundleFromCertainty(): Bundle

// If the platform can run verification checks well enough, get
// latest remote bundle and verify it.
return (new RemoteFetch($ourCertaintyDataDir))->getLatestBundle();
try {
// Try the replication server first, since the upstream server
// is under tremendous load.
return (new RemoteFetch($ourCertaintyDataDir))
->setChronicle(
'https://php-chronicle-replica.pie-hosted.com/chronicle/replica/_vi6Mgw6KXBSuOFUwYA2H2GEPLawUmjqFJbCCuqtHzGZ',
'MoavD16iqe9-QVhIy-ewD4DMp0QRH-drKfwhfeDAUG0='
)
->getLatestBundle();
} catch (ConnectException $ex) {
// Fallback to the main server.
return (new RemoteFetch($ourCertaintyDataDir))->getLatestBundle();
}
}
}

0 comments on commit 6ad5613

Please sign in to comment.