def CreatePeerProposalHeaderAndBody(peer, contractName, talkType, listenType, proposedRemoteQuota, proposedLocalQuota, hostName): """ The CreatePeerProposalHeaderAndBody function creates a message to propose a contract to the peer. All the inputs to this function are from the point of view of the peer we are proposing to. For example, the talkType is what the peer would use as the argument to --talk and the proposedRemoteQuota is what the peer would use as the argument to --remote_quota in the add_peer function. """ hdr = MakeMsgHeader(peer, 'DIBS CONTRACT PROPOSAL') pubKey = dibs_utils.RemovePGPHeaders(dibs_crypto.GetPubKey(), dibs_constants.pgpKeyStart, dibs_constants.pgpKeyEnd) body = MakeMsgCmd( dibs_constants.proposalCmdName, ((dibs_constants.contractNameArgName, contractName), (dibs_constants.adminArgName, dibs_options.dibsAdmin), (dibs_constants.talkTypeArgName, talkType), (dibs_constants.listenTypeArgName, listenType), (dibs_constants.remoteQuotaArgName, ` proposedRemoteQuota `), (dibs_constants.localQuotaArgName, ` proposedLocalQuota `), (dibs_constants.hostArgName, hostName), (dibs_constants.portArgName, ` dibs_options.daemonPort `), (dibs_constants.publicKeyNameArgName, dibs_options.dibsPublicKey), (dibs_constants.publicKeyArgName, pubKey))) body = dibs_crypto.SignPiece(body, peer) return (hdr, body)
def CreateForgetYouMsg(peer): hdr = MakeMsgHeader(peer, 'DIBS FORGET YOU') body = MakeMsgCmd(dibs_constants.forgetYouCmdName, ()) body = dibs_crypto.SignPiece(body, peer) return (hdr, body)
def CreateRecoverAllFinishedHdrAndBdy(peer): hdr = MakeMsgHeader(peer, 'DIBS FINISHED RECOVER ALL REQUEST') body = MakeMsgCmd(dibs_constants.doneRecoverAllCmdName, []) body = dibs_crypto.SignPiece(body, peer) return (hdr, body)
def CreateClearDBHeaderAndBody(peer): hdr = MakeMsgHeader(peer, 'DIBS CLEAR REQUEST') body = MakeMsgCmd(dibs_constants.clearCmdName, ()) body = dibs_crypto.SignPiece(body, peer) return (hdr, body)
def CreateRecoverAllRequestHdrAndBdy(peer): hdr = MakeMsgHeader(peer, 'DIBS RECOVER ALL REQUEST') body = MakeMsgCmd(dibs_constants.recoverAllCmdName, []) body = dibs_crypto.SignPiece(body, peer) return (hdr, body)
def CreateUnstoreHeaderAndBody(pieceName, peer): hdr = MakeMsgHeader(peer, 'DIBS UNSTORE REQUEST') body = MakeMsgCmd(dibs_constants.unstoreCmdName, ((dibs_constants.pieceNameArgName, pieceName), )) body = dibs_crypto.SignPiece(body, peer) return (hdr, body)
def CreateRecoverRequestHeaderAndBody(pieceName, peer): hdr = MakeMsgHeader(peer, 'DIBS RECOVER REQUEST') body = MakeMsgCmd(dibs_constants.recoverCmdName, ((dibs_constants.pieceNameArgName, pieceName), )) body = dibs_crypto.SignPiece(body, peer) return (hdr, body)
def CreateProbeRequestHeaderAndBody(pieceName, peer): hdr = MakeMsgHeader(peer, 'DIBS PROBE REQUEST') body = MakeMsgCmd(dibs_constants.probeCmdName, ((dibs_constants.pieceNameArgName, pieceName), )) body = dibs_crypto.SignPiece(body, peer) return (hdr, body)
def CreateRecoverResponseHeaderAndBody(pieceName, peer, data): hdr = MakeMsgHeader(peer, 'DIBS RECOVER RESPONSE') body = MakeMsgCmd( dibs_constants.recoverResponseCmdName, ((dibs_constants.pieceNameArgName, pieceName), (dibs_constants.pieceDataArgName, dibs_utils.RemovePGPHeaders(data)))) body = dibs_crypto.SignPiece(body, peer) return (hdr, body)
def CreateProposalResponseHeaderAndBody(peer, contractName, acceptedP, comment): hdr = MakeMsgHeader(peer, 'DIBS PROPOSAL RESPONSE') assert acceptedP == 'YES' or acceptedP == 'NO' body = MakeMsgCmd(dibs_constants.proposalResponseCmdName, ((dibs_constants.contractNameArgName, contractName), (dibs_constants.proposalDecisionArgName, acceptedP), (dibs_constants.proposalCommentArgName, comment))) body = dibs_crypto.SignPiece(body, peer) return (hdr, body)
def CreateStoreHeaderAndBody(peer, data, pieceName): """ Prepare an email to peer requesting storage of encryptedFile under the name pieceName. Returns header and body of email. """ hdr = MakeMsgHeader(peer, 'DIBS STORE REQUEST') body = MakeMsgCmd( dibs_constants.storeCmdName, ((dibs_constants.pieceNameArgName, pieceName), (dibs_constants.pieceDataArgName, dibs_utils.RemovePGPHeaders(data)))) body = dibs_crypto.SignPiece(body, peer) return (hdr, body)