diff --git a/src/community/community.cpp b/src/community/community.cpp index df1fd459..e390ce55 100644 --- a/src/community/community.cpp +++ b/src/community/community.cpp @@ -93,14 +93,14 @@ bool mc_EnterpriseFeatures::OFF_GetScriptsToVerify(map& mapReadPerm return true; } -bool mc_EnterpriseFeatures::OFF_VerifySignatureScripts(uint32_t msg_type_in,mc_OffchainMessageID& msg_id_received,mc_OffchainMessageID& msg_id_to_respond,uint32_t flags_in, - vector& vPayloadIn,vector& vSigScriptsToVerify,string& strError) +bool mc_EnterpriseFeatures::OFF_VerifySignatureScripts(uint32_t msg_type,mc_OffchainMessageID& msg_id,mc_OffchainMessageID& msg_id_to_respond,uint32_t flags, + vector& vPayload,vector& vSigScriptsToVerify,string& strError,int& dos_score) { return true; } -bool mc_EnterpriseFeatures::OFF_CreateSignatureScripts(uint32_t msg_type_in,mc_OffchainMessageID& msg_id_received,mc_OffchainMessageID& msg_id_to_respond,uint32_t flags_in, - vector& vPayloadIn,set& vAddresses,vector& vSigScripts,string& strError) +bool mc_EnterpriseFeatures::OFF_CreateSignatureScripts(uint32_t msg_type,mc_OffchainMessageID& msg_id,mc_OffchainMessageID& msg_id_to_respond,uint32_t flags, + vector& vPayload,set& vAddresses,vector& vSigScripts,string& strError) { return true; } diff --git a/src/community/community.h b/src/community/community.h index 9081e973..ae0c434a 100644 --- a/src/community/community.h +++ b/src/community/community.h @@ -54,10 +54,10 @@ typedef struct mc_EnterpriseFeatures map& mapReadPermissionedStreams,string& strError); bool OFF_ProcessChunkResponse(mc_RelayRequest *request,mc_RelayResponse *response,map * request_pairs,mc_ChunkCollector* collector); bool OFF_GetScriptsToVerify(map& mapReadPermissionedStreams,vector& vSigScriptsIn,vector& vSigScriptsToVerify,string& strError); - bool OFF_VerifySignatureScripts(uint32_t msg_type_in,mc_OffchainMessageID& msg_id_received,mc_OffchainMessageID& msg_id_to_respond,uint32_t flags_in, - vector& vPayloadIn,vector& vSigScriptsToVerify,string& strError); - bool OFF_CreateSignatureScripts(uint32_t msg_type_in,mc_OffchainMessageID& msg_id_received,mc_OffchainMessageID& msg_id_to_respond,uint32_t flags_in, - vector& vPayloadIn,set& vAddresses,vector& vSigScripts,string& strError); + bool OFF_VerifySignatureScripts(uint32_t msg_type,mc_OffchainMessageID& msg_id,mc_OffchainMessageID& msg_id_to_respond,uint32_t flags, + vector& vPayload,vector& vSigScriptsToVerify,string& strError,int& dos_score); + bool OFF_CreateSignatureScripts(uint32_t msg_type,mc_OffchainMessageID& msg_id,mc_OffchainMessageID& msg_id_to_respond,uint32_t flags, + vector& vPayload,set& vAddresses,vector& vSigScripts,string& strError); bool OFF_GetPayloadForReadPermissioned(vector* payload,string& strError); uint32_t OFF_SupportedEncryptionOptions(uint32_t min_options); diff --git a/src/protocol/relay.cpp b/src/protocol/relay.cpp index 174a908a..34dd4c2e 100644 --- a/src/protocol/relay.cpp +++ b/src/protocol/relay.cpp @@ -2399,11 +2399,16 @@ bool mc_RelayManager::ProcessRelay( CNode* pfrom, msg_type_response_ptr,&flags_response,vPayloadResponse,vSigScriptsRespond, msg_type_relay_ptr,&flags_relay,vPayloadRelay,vSigScriptsRelay,strError)) { - if(!pEF->OFF_VerifySignatureScripts(msg_type_in,msg_id_received,msg_id_to_respond,flags_in,vPayloadIn,vSigScriptsToVerify,strError)) + int dos_score=0; + if(!pEF->OFF_VerifySignatureScripts(msg_type_in,msg_id_received,msg_id_to_respond,flags_in,vPayloadIn,vSigScriptsToVerify,strError,dos_score)) { LogPrintf("ProcessOffchain() : Error processing %s (request %s) from peer %d: %s\n",mc_MsgTypeStr(msg_type_in).c_str(), msg_id_received.ToString().c_str(),pfrom->GetId(),strError.c_str()); - return false; + if(dos_score) + { + return state.DoS(dos_score, error("ProcessOffchain() : Invalid sigScript"),REJECT_INVALID, "bad-sigscript"); + } + return false; } if(msg_type_response_ptr && *msg_type_response_ptr) {