From 3208f713925dfe8bd760c10b53f80c89e6847621 Mon Sep 17 00:00:00 2001 From: Bjoern Sikora Date: Mon, 21 Jun 2010 13:06:09 +0200 Subject: [PATCH] Corrected implementation of GnuDIP HTTP update protocol. --- src/service_gnudip.cpp | 42 +++++++++++++++++++++++++++++++++++++----- src/service_gnudip.hpp | 1 + 2 files changed, 38 insertions(+), 5 deletions(-) diff --git a/src/service_gnudip.cpp b/src/service_gnudip.cpp index 8c332c5..4f757e2 100644 --- a/src/service_gnudip.cpp +++ b/src/service_gnudip.cpp @@ -97,11 +97,11 @@ map ServiceGnudip::parse_initial_request(const string& curl_data) map response; // regex for salt - boost::regex expr_salt(""); + boost::regex expr_salt(""); + boost::regex expr_time(""); + boost::regex expr_sign(" ServiceGnudip::parse_initial_request(const string& curl_data) /** + * Parses the data received from the update request, which should contain the return code. + * @param curl_data The complete received curl data. + * @return A string containing the return code of the update request. + */ +string ServiceGnudip::parse_return_code(const string& curl_data) const +{ + string return_code; + + // regex for return code + boost::regex expr_retc("print_regex_match(expr_retc.str(),matches[1].str()); + } + else + { + get_logger()->print_no_regex_match(expr_retc.str(),curl_data); + return return_code; + } + + return return_code; +} + + +/** * Get the assembled update url. * @param salt Salt from the initial request * @param time Time from the initial request @@ -170,7 +199,9 @@ string ServiceGnudip::assemble_update_url(const string& salt, const string& curr url.append("&user="); url.append(get_login()); url.append("&domn="); - url.append(get_hostname()); + string fqhn = get_hostname(); + string domain = fqhn.substr(fqhn.find('.')+1); + url.append(domain); url.append("&pass="); url.append(secret); url.append("&reqc=0&addr="); @@ -274,7 +305,8 @@ int ServiceGnudip::perform_update(const std::string& ip) if ( http_status_code == 200 ) { // parse the update request return code - string update_return_code = HTTPHelp->get_curl_data(); + curl_data = HTTPHelp->get_curl_data(); + string update_return_code = parse_return_code(curl_data); if ( update_return_code == "0" ) { return 0; diff --git a/src/service_gnudip.hpp b/src/service_gnudip.hpp index 3c61aaf..885ed54 100644 --- a/src/service_gnudip.hpp +++ b/src/service_gnudip.hpp @@ -39,6 +39,7 @@ private: std::string assemble_base_url(const std::string& gnudip_server) const; std::map parse_initial_request(const std::string& curl_data) const; std::string assemble_update_url(const std::string& salt, const std::string& curr_time, const std::string& sign, const std::string& secret, const std::string& ip) const; + std::string parse_return_code(const std::string& curl_data) const; public: -- 1.7.1