@@ -56,17 +56,18 @@ const loadGrpcClient = (endpoint, callback) => {
56
56
console . log ( fsErr )
57
57
throw fsErr
58
58
}
59
-
59
+ let allowUnchecksummedNodes = Meteor . settings . allowUnchecksummedNodes
60
+ if ( allowUnchecksummedNodes !== true ) { allowUnchecksummedNodes = false }
60
61
// Validate proto file matches node version
61
62
getQrlProtoShasum ( res . version , ( verifiedProtoSha256Hash ) => {
62
63
// 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 ) ) {
64
65
console . log ( `Cannot verify QRL node version on: ${ endpoint } - Version: ${ res . version } ` )
65
66
const myError = errorCallback ( err , `Cannot verify QRL node version on: ${ endpoint } - Version: ${ res . version } ` , '**ERROR/connect**' )
66
67
callback ( myError , null )
67
68
} else {
68
69
// 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 ) => {
70
71
if ( fsErr ) {
71
72
console . log ( fsErr )
72
73
throw fsErr
@@ -75,25 +76,22 @@ const loadGrpcClient = (endpoint, callback) => {
75
76
// Calculate the hash of the qrl.proto file contents
76
77
const protoFileWordArray = CryptoJS . lib . WordArray . create ( contents )
77
78
const calculatedProtoHash = CryptoJS . SHA256 ( protoFileWordArray ) . toString ( CryptoJS . enc . Hex )
78
-
79
79
// If the calculated qrl.proto hash matches the verified one for this version,
80
80
// continue to verify the grpc object loaded from the proto also matches the correct
81
81
// shasum.
82
-
83
- if ( calculatedProtoHash == verifiedProtoSha256Hash . protoSha256 ) {
84
-
82
+ if ( ( calculatedProtoHash === verifiedProtoSha256Hash . protoSha256 ) || ( allowUnchecksummedNodes === true ) ) {
85
83
// Load gRPC object
86
84
const grpcObject = grpc . load ( qrlProtoFilePath )
87
85
88
86
// 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 } ) )
90
88
91
89
// Calculate the hash of the grpc object string returned
92
90
const protoObjectWordArray = CryptoJS . lib . WordArray . create ( grpcObjectString )
93
91
const calculatedObjectHash = CryptoJS . SHA256 ( protoObjectWordArray ) . toString ( CryptoJS . enc . Hex )
94
92
95
93
// If the grpc object shasum matches, establish the grpc connection.
96
- if ( calculatedObjectHash == verifiedProtoSha256Hash . objectSha256 ) {
94
+ if ( ( calculatedObjectHash === verifiedProtoSha256Hash . objectSha256 ) || ( allowUnchecksummedNodes === true ) ) {
97
95
// Create the gRPC Connection
98
96
qrlClient [ endpoint ] =
99
97
new grpcObject . qrl . PublicAPI ( endpoint , grpc . credentials . createInsecure ( ) )
0 commit comments