Fixed campaignd allways send data back using same format as client
This commit is contained in:
parent
b207268648
commit
5a87401ed2
1 changed files with 21 additions and 21 deletions
|
@ -371,13 +371,13 @@ namespace {
|
|||
config response;
|
||||
response.add_child("campaigns",campaign_list);
|
||||
|
||||
network::send_data(response, sock, *gzipped);
|
||||
network::send_data(response, sock, gzipped);
|
||||
} else if(const config* req = data.child("request_campaign")) {
|
||||
LOG_CS << "sending campaign '" << (*req)["name"] << "' to " << network::ip_address(sock) << "\n";
|
||||
config* const campaign = campaigns().find_child("campaign","name",(*req)["name"]);
|
||||
if(campaign == NULL) {
|
||||
|
||||
network::send_data(construct_error("Add-on '" + (*req)["name"] + "'not found."), sock, *gzipped);
|
||||
network::send_data(construct_error("Add-on '" + (*req)["name"] + "'not found."), sock, gzipped);
|
||||
} else {
|
||||
size_t size = file_size((*campaign)["filename"]);
|
||||
scoped_istream stream = istream_file((*campaign)["filename"]);
|
||||
|
@ -401,7 +401,7 @@ namespace {
|
|||
} else if(data.child("request_terms") != NULL) {
|
||||
LOG_CS << "sending terms " << network::ip_address(sock) << "\n";
|
||||
|
||||
network::send_data(construct_message("All add-ons uploaded to this server must be licensed under the terms of the GNU General Public License (GPL). By uploading content to this server, you certify that you have the right to place the content under the conditions of the GPL, and choose to do so."), sock, *gzipped);
|
||||
network::send_data(construct_message("All add-ons uploaded to this server must be licensed under the terms of the GNU General Public License (GPL). By uploading content to this server, you certify that you have the right to place the content under the conditions of the GPL, and choose to do so."), sock, gzipped);
|
||||
LOG_CS << " Done\n";
|
||||
} else if(config* upload = data.child("upload")) {
|
||||
LOG_CS << "uploading campaign '" << (*upload)["name"] << "' from " << network::ip_address(sock) << ".\n";
|
||||
|
@ -410,15 +410,15 @@ namespace {
|
|||
if(data == NULL) {
|
||||
|
||||
LOG_CS << "Upload aborted no data.\n";
|
||||
network::send_data(construct_error("No add-on data was supplied."), sock, *gzipped);
|
||||
network::send_data(construct_error("No add-on data was supplied."), sock, gzipped);
|
||||
} else if(campaign_name_legal((*upload)["name"]) == false) {
|
||||
|
||||
LOG_CS << "Upload aborted invalid name.\n";
|
||||
network::send_data(construct_error("The name of the add-on is invalid"), sock, *gzipped);
|
||||
network::send_data(construct_error("The name of the add-on is invalid"), sock, gzipped);
|
||||
} else if(check_names_legal(*data) == false) {
|
||||
|
||||
LOG_CS << "Upload aborted invalid file name.\n";
|
||||
network::send_data(construct_error("The add-on contains an illegal file or directory name."), sock, *gzipped);
|
||||
network::send_data(construct_error("The add-on contains an illegal file or directory name."), sock, gzipped);
|
||||
} else if(campaign != NULL && (*campaign)["passphrase"] != (*upload)["passphrase"]) {
|
||||
// the user password failed, now test for the master password, in master password
|
||||
// mode the upload behaves different since it's only intended to update translations.
|
||||
|
@ -454,12 +454,12 @@ namespace {
|
|||
scoped_ostream cfgfile = ostream_file(file_);
|
||||
write(*cfgfile, cfg_);
|
||||
|
||||
network::send_data(construct_message(message), sock, *gzipped);
|
||||
network::send_data(construct_message(message), sock, gzipped);
|
||||
|
||||
} else {
|
||||
|
||||
LOG_CS << "Upload aborted invalid passphrase.\n";
|
||||
network::send_data(construct_error("The add-on already exists, and your passphrase was incorrect."), sock, *gzipped);
|
||||
network::send_data(construct_error("The add-on already exists, and your passphrase was incorrect."), sock, gzipped);
|
||||
}
|
||||
} else {
|
||||
LOG_CS << "Upload is owner upload.\n";
|
||||
|
@ -517,7 +517,7 @@ namespace {
|
|||
scoped_ostream cfgfile = ostream_file(file_);
|
||||
write(*cfgfile, cfg_);
|
||||
|
||||
network::send_data(construct_message(message), sock, *gzipped);
|
||||
network::send_data(construct_message(message), sock, gzipped);
|
||||
|
||||
fire("hook_post_upload", (*upload)["name"]);
|
||||
}
|
||||
|
@ -526,7 +526,7 @@ namespace {
|
|||
config* const campaign = campaigns().find_child("campaign","name",(*erase)["name"]);
|
||||
if(campaign == NULL) {
|
||||
|
||||
network::send_data(construct_error("The add-on does not exist."), sock, *gzipped);
|
||||
network::send_data(construct_error("The add-on does not exist."), sock, gzipped);
|
||||
continue;
|
||||
}
|
||||
|
||||
|
@ -535,7 +535,7 @@ namespace {
|
|||
|| campaigns()["master_password"] != (*erase)["passphrase"])) {
|
||||
|
||||
|
||||
network::send_data(construct_error("The passphrase is incorrect."), sock, *gzipped);
|
||||
network::send_data(construct_error("The passphrase is incorrect."), sock, gzipped);
|
||||
continue;
|
||||
}
|
||||
|
||||
|
@ -549,7 +549,7 @@ namespace {
|
|||
scoped_ostream cfgfile = ostream_file(file_);
|
||||
write(*cfgfile, cfg_);
|
||||
|
||||
network::send_data(construct_message("Add-on deleted."), sock, *gzipped);
|
||||
network::send_data(construct_message("Add-on deleted."), sock, gzipped);
|
||||
|
||||
fire("hook_post_erase", (*erase)["name"]);
|
||||
|
||||
|
@ -557,34 +557,34 @@ namespace {
|
|||
config* campaign = campaigns().find_child("campaign","name",(*cpass)["name"]);
|
||||
if(campaign == NULL) {
|
||||
|
||||
network::send_data(construct_error("No add-on with that name exists."), sock, *gzipped);
|
||||
network::send_data(construct_error("No add-on with that name exists."), sock, gzipped);
|
||||
} else if((*campaign)["passphrase"] != (*cpass)["passphrase"]) {
|
||||
|
||||
network::send_data(construct_error("Your old passphrase was incorrect."), sock, *gzipped);
|
||||
network::send_data(construct_error("Your old passphrase was incorrect."), sock, gzipped);
|
||||
} else if((const t_string)(*cpass)["new_passphrase"] == "") {
|
||||
|
||||
network::send_data(construct_error("No new passphrase was supplied."), sock, *gzipped);
|
||||
network::send_data(construct_error("No new passphrase was supplied."), sock, gzipped);
|
||||
} else {
|
||||
(*campaign)["passphrase"] = (*cpass)["new_passphrase"];
|
||||
scoped_ostream cfgfile = ostream_file(file_);
|
||||
write(*cfgfile, cfg_);
|
||||
|
||||
network::send_data(construct_message("Passphrase changed."), sock, *gzipped);
|
||||
network::send_data(construct_message("Passphrase changed."), sock, gzipped);
|
||||
}
|
||||
} else if(const config* cvalidate = data.child("validate_scripts")) {
|
||||
config* campaign = campaigns().find_child("campaign","name",(*cvalidate)["name"]);
|
||||
if(campaign == NULL) {
|
||||
|
||||
network::send_data(construct_error(
|
||||
"No add-on with that name exists."), sock, *gzipped);
|
||||
"No add-on with that name exists."), sock, gzipped);
|
||||
} else if(campaigns()["master_password"] == "") {
|
||||
|
||||
network::send_data(construct_error(
|
||||
"Sever does not allow scripts."), sock, *gzipped);
|
||||
"Sever does not allow scripts."), sock, gzipped);
|
||||
} else if (campaigns()["master_password"] != (*cvalidate)["master_password"]) {
|
||||
|
||||
network::send_data(construct_error(
|
||||
"Password was incorrect."), sock, *gzipped);
|
||||
"Password was incorrect."), sock, gzipped);
|
||||
} else {
|
||||
// Read the campaign from disk.
|
||||
config campaign_file;
|
||||
|
@ -600,10 +600,10 @@ namespace {
|
|||
|
||||
|
||||
network::send_data(construct_message("The following scripts have been validated: " +
|
||||
scripts), sock, *gzipped);
|
||||
scripts), sock, gzipped);
|
||||
} else {
|
||||
|
||||
network::send_data(construct_message("No unchecked scripts found!"), sock, *gzipped);
|
||||
network::send_data(construct_message("No unchecked scripts found!"), sock, gzipped);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue