Skip to content

Commit a794264

Browse files
committedNov 28, 2018
Add config setting to allow unchecksummed nodes
1 parent d5f3bed commit a794264

File tree

2 files changed

+10
-9
lines changed

2 files changed

+10
-9
lines changed
 

‎imports/startup/server/index.js

+7-9
Original file line numberDiff line numberDiff line change
@@ -56,17 +56,18 @@ const loadGrpcClient = (endpoint, callback) => {
5656
console.log(fsErr)
5757
throw fsErr
5858
}
59-
59+
let allowUnchecksummedNodes = Meteor.settings.allowUnchecksummedNodes
60+
if (allowUnchecksummedNodes !== true) { allowUnchecksummedNodes = false }
6061
// Validate proto file matches node version
6162
getQrlProtoShasum(res.version, (verifiedProtoSha256Hash) => {
6263
// If we get null back, we were unable to identify a verified sha256 hash against this qrl node verison.
63-
if(verifiedProtoSha256Hash === null) {
64+
if ((verifiedProtoSha256Hash === null) && (allowUnchecksummedNodes === false)) {
6465
console.log(`Cannot verify QRL node version on: ${endpoint} - Version: ${res.version}`)
6566
const myError = errorCallback(err, `Cannot verify QRL node version on: ${endpoint} - Version: ${res.version}`, '**ERROR/connect**')
6667
callback(myError, null)
6768
} else {
6869
// Now read the saved qrl.proto file so we can calculate a hash from it
69-
fs.readFile(qrlProtoFilePath, function(err, contents) {
70+
fs.readFile(qrlProtoFilePath, (errR, contents) => {
7071
if (fsErr) {
7172
console.log(fsErr)
7273
throw fsErr
@@ -75,25 +76,22 @@ const loadGrpcClient = (endpoint, callback) => {
7576
// Calculate the hash of the qrl.proto file contents
7677
const protoFileWordArray = CryptoJS.lib.WordArray.create(contents)
7778
const calculatedProtoHash = CryptoJS.SHA256(protoFileWordArray).toString(CryptoJS.enc.Hex)
78-
7979
// If the calculated qrl.proto hash matches the verified one for this version,
8080
// continue to verify the grpc object loaded from the proto also matches the correct
8181
// shasum.
82-
83-
if (calculatedProtoHash == verifiedProtoSha256Hash.protoSha256) {
84-
82+
if ((calculatedProtoHash === verifiedProtoSha256Hash.protoSha256) || (allowUnchecksummedNodes === true)) {
8583
// Load gRPC object
8684
const grpcObject = grpc.load(qrlProtoFilePath)
8785

8886
// Inspect the object and convert to string.
89-
const grpcObjectString = JSON.stringify(util.inspect(grpcObject, {showHidden: true, depth: 4}))
87+
const grpcObjectString = JSON.stringify(util.inspect(grpcObject, { showHidden: true, depth: 4 }))
9088

9189
// Calculate the hash of the grpc object string returned
9290
const protoObjectWordArray = CryptoJS.lib.WordArray.create(grpcObjectString)
9391
const calculatedObjectHash = CryptoJS.SHA256(protoObjectWordArray).toString(CryptoJS.enc.Hex)
9492

9593
// If the grpc object shasum matches, establish the grpc connection.
96-
if (calculatedObjectHash == verifiedProtoSha256Hash.objectSha256) {
94+
if ((calculatedObjectHash === verifiedProtoSha256Hash.objectSha256) || (allowUnchecksummedNodes === true)) {
9795
// Create the gRPC Connection
9896
qrlClient[endpoint] =
9997
new grpcObject.qrl.PublicAPI(endpoint, grpc.credentials.createInsecure())

‎unchecksummednode.json

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"allowUnchecksummedNodes": false
3+
}

0 commit comments

Comments
 (0)
Please sign in to comment.