From 76ae7c28ea6224b2c919122d5dc71bcc00a0ecaa Mon Sep 17 00:00:00 2001 From: yum Date: Mon, 3 Jul 2023 18:44:43 -0700 Subject: Begin work on proxy server Create a simple server with 3 endpoints: * /create_session: Create a session and return its identifier. * /set_transcript: Update a session's transcript. * /get_transcript: Fetch a session's transcript. Right now the session ID provides authentication *and* authorization. There is no public/private ID so you have to trust whoever you share your ID with. IDs are long and generated by the server, so it should be somewhat secure against low-effort hacking. Other updates: * Drop whisper_requirements.txt - no longer needed. * Vendor curl to make it easier to interact with the server. TODO: * Fuzz test the server. --- BrowserSource/Proxy/Utils.h | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 BrowserSource/Proxy/Utils.h (limited to 'BrowserSource/Proxy/Utils.h') diff --git a/BrowserSource/Proxy/Utils.h b/BrowserSource/Proxy/Utils.h new file mode 100644 index 0000000..af5bc65 --- /dev/null +++ b/BrowserSource/Proxy/Utils.h @@ -0,0 +1,31 @@ +#pragma once + +#include +#include +#include + +std::string RandomString(std::size_t length) { + static const std::array characters{ + { + '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', + 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', + 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', + 'U', 'V', 'W', 'X', 'Y', 'Z', 'a', 'b', 'c', 'd', + 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', + 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', + 'y', 'z' + } + }; + + std::random_device rd; + std::default_random_engine generator(rd()); + std::uniform_int_distribution<> distribution(0, characters.size() - 1); + + std::string random_string; + + for (std::size_t i = 0; i < length; ++i) { + random_string += characters[distribution(generator)]; + } + + return random_string; +} -- cgit v1.2.3