coinbase / mongobetween

Apache License 2.0
116 stars 47 forks source link

Add OP_MSG checksum support #27

Closed divjotarora closed 3 years ago

divjotarora commented 3 years ago

The 4.2 version of the mongo shell sets an optional checksum on OP_MSG wire messages. Per this section of the OP_MSG spec, a message will have the checksumPresent flag set and the last four bytes will be a uint32 checksum. This PR adds support to detect and parse these checksums so we can use a 4.2 shell to connect to mongobetween.

divjotarora commented 3 years ago

I'm looking into adding a test for this. Integration tests are likely not possible because drivers don't currently add checksums, but I might be able to add a unit test.

mdehoog commented 3 years ago

Looks good 👍

For the unit test, we could add the flag / checksum to the opmsg here? https://github.com/coinbase/mongobetween/blob/b72171f27d65d79dc77db06f4561978c2cb13d64/mongo/operations_test.go#L71-L80

divjotarora commented 3 years ago

@mdehoog Added a test in my most recent commit.