Only allow message_bridge to connect with matching config sha256
We've been seeing a ton of crashes becasue the config doesn't match, and
a node is out of range, or the client is asking for a channel which
doesn't exist. Honestly, there is no real use case at this point in
time for accepting connections from clients who aren't running the same
code. We can't read the logs if we were to allow it, and the effort
required to support that is massive. We'll probably run into send too
fast issues, would run into flatbuffer version problems (maybe), and all
sorts of other problems. The cost to reward ratio doesn't work.
So, as part of connecting, send the sha256 sum of the config. The
server will disconnect any clients who don't have a matching config, and
increment a counter in the status message.
Change-Id: I99520713efc644252f2c7cf5dc53720c4fc19974
Signed-off-by: Austin Schuh <austin.schuh@bluerivertech.com>
diff --git a/aos/sha256.h b/aos/sha256.h
new file mode 100644
index 0000000..7fb9b2f
--- /dev/null
+++ b/aos/sha256.h
@@ -0,0 +1,15 @@
+#ifndef AOS_SHA256_H_
+#define AOS_SHA256_H_
+
+#include <string>
+
+#include "absl/types/span.h"
+
+namespace aos {
+
+// Returns the sha256 of a span.
+std::string Sha256(const absl::Span<const uint8_t> str);
+
+} // namespace aos
+
+#endif // AOS_SHA256_H_