From 8dbb43328b6cd8b13faab93cc470336ffdb63e99 Mon Sep 17 00:00:00 2001 From: denes Date: Sat, 9 Feb 2019 00:16:20 +0100 Subject: [PATCH] Updated submodule and README --- README.md | 29 ++++++++++++++++++++++++++--- WebhookMessage.hpp | 9 ++++++--- cpp_utils | 2 +- 3 files changed, 33 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index dd2d796..03a5c96 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,28 @@ -# webfish - +# webfish + An HTTP server which bites on Gitea POST webhooks -It utilizes the http://matetelki.eu:3000/denes/cpp_utils library. \ No newline at end of file +It utilizes the http://matetelki.eu:3000/denes/cpp_utils library. + + +``` +usage: ./webfish [OPTIONS] + +Required arguments: +-c STRING Client hostname to check +-f STRING File to execute on receiving a message +-s STRING Look for a line in the msg body with '"secret": "SECRET"' + +Options: +-h, --help Prints this help message +-p INT Listenning port (default is 5050) +``` + +For example: `./webfish -c matetelki.eu -f ./hugo_updater.sh -s SECRET` + +Todos: + - The `Content-Length: 1900` is disregarded. The secret is in the first chunk anyway: + - bad request? Reply & close connection. + - correct request? Reply after the first chunk, while the client is still talking. + - The `-h` does not work, only `./webfish -h, --help` :P + - The logging needs some tuning diff --git a/WebhookMessage.hpp b/WebhookMessage.hpp index a267526..036f7cd 100644 --- a/WebhookMessage.hpp +++ b/WebhookMessage.hpp @@ -54,8 +54,11 @@ public: TRACE; m_buffer = std::string( (const char*) msgPart, msgLen ); - /// @todo use it! - // not using getExpectedLength + /** @todo use it! + * We are very rude now: + * - bad request? Reply & close connection. + * - correct request? Reply after the first chunk, while the client is still talking + */ onMessageReady(); return true; } @@ -92,7 +95,7 @@ public: } } catch (const std::exception& e) { - LOG (Logger::ERR, e.what()); + LOG (Logger::WARNING, e.what()); m_connection->send(reply.c_str(), reply.length()); m_buffer.clear(); dynamic_cast(m_connection)->disconnect(); diff --git a/cpp_utils b/cpp_utils index 0250d43..67ca668 160000 --- a/cpp_utils +++ b/cpp_utils @@ -1 +1 @@ -Subproject commit 0250d43bbe8b46e021aeca2c6caae20745ed2513 +Subproject commit 67ca668ff36577e70ca1a07564b8d6e81d9d6905