map<string,string> response;
// regex for salt
- boost::regex expr_salt("<meta name=\"salt\" content=\"(.*)\">");
+ boost::regex expr_salt("<meta name=\"salt\" content=\"([^\"]*)\"");
// regex for time
- boost::regex expr_time("<meta name=\"time\" content=\"(.*)\">");
+ boost::regex expr_time("<meta name=\"time\" content=\"([^\"]*)\"");
// regex for sign
- boost::regex expr_sign("<meta name=\"sign\" content=\"(.*)\">");
+ boost::regex expr_sign("<meta name=\"sign\" content=\"([^\"]*)\"");
boost::smatch matches;
/**
+ * 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("<meta name=\"retc\" content=\"([^\"]*)\"");
+ boost::smatch matches;
+
+ // Get the return code out of received http data
+ if ( boost::regex_search(curl_data,matches,expr_retc) )
+ {
+ return_code = matches[1].str();
+ get_logger()->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
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=");
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;
std::string assemble_base_url(const std::string& gnudip_server) const;
std::map<std::string,std::string> 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: