summary refs log tree commit diff stats
path: root/server_main.cpp
diff options
context:
space:
mode:
authorStar Rauchenberger <fefferburbia@gmail.com>2024-11-04 13:22:20 -0500
committerStar Rauchenberger <fefferburbia@gmail.com>2024-11-04 13:22:20 -0500
commitec9690bbf82829d1ba3bd0fc18831a43fe6405fe (patch)
tree070e8c20a33fd5c8e919836a299a88f8dc415ad7 /server_main.cpp
parent35bf76ea71e153fab140af166ec07b3a961af3f0 (diff)
downloadwizard-ec9690bbf82829d1ba3bd0fc18831a43fe6405fe.tar.gz
wizard-ec9690bbf82829d1ba3bd0fc18831a43fe6405fe.tar.bz2
wizard-ec9690bbf82829d1ba3bd0fc18831a43fe6405fe.zip
Add maximum input length for server
Diffstat (limited to 'server_main.cpp')
-rw-r--r--server_main.cpp13
1 files changed, 13 insertions, 0 deletions
diff --git a/server_main.cpp b/server_main.cpp index 00a4e7a..8d2c4aa 100644 --- a/server_main.cpp +++ b/server_main.cpp
@@ -81,6 +81,19 @@ class server {
81 } 81 }
82 82
83 void cmd_generate(websocketpp::connection_hdl connection, std::string text) { 83 void cmd_generate(websocketpp::connection_hdl connection, std::string text) {
84 if (text.size() > 150) {
85 std::string response = R"(
86 {
87 "type": "error",
88 "msg": "Input is too long (>150 characters)."
89 }
90 )";
91
92 socket_.send(connection, response,
93 websocketpp::frame::opcode::value::TEXT);
94 return;
95 }
96
84 asio::post(std::bind(&server::generate_thread, this, connection, text)); 97 asio::post(std::bind(&server::generate_thread, this, connection, text));
85 } 98 }
86 99