I added a passphrase changing function on the server
(but not the normal client) so that campaigns can have their passphrases reset by admins without shutting the server down. I also add two perl scripts for changing passphrases and for deleting campaigns.
This commit is contained in:
parent
e42908b206
commit
9141130ed9
4 changed files with 113 additions and 0 deletions
|
@ -118,6 +118,7 @@ SVN trunk (1.1.x):
|
|||
* campaign_list response now contains the time the request was processed
|
||||
* campaign_list response now contains information about translations
|
||||
* fixed problem with duplicate translations being saved with each upload
|
||||
* added a passphrass change function
|
||||
* utils
|
||||
* added weblist.pl and webtgz.pl web interface programs
|
||||
* changed wml.pm to use substr instead of split to convert string to array:
|
||||
|
@ -125,6 +126,8 @@ SVN trunk (1.1.x):
|
|||
* changed wml_net.pm to insert into preallocated string instead of
|
||||
appending: should save memory and time, but not benchmarked
|
||||
* added prkill script, to calculate probabilities to kill in a skirmish
|
||||
* added campaign_passphrase.pl for changing passphrases
|
||||
* added campaign_delete.pl for deleing campaigns
|
||||
* WML improvements:
|
||||
* added swarm attack special
|
||||
* random map generator now uses island_size (#4458)
|
||||
|
|
|
@ -242,6 +242,7 @@ void campaign_server::run()
|
|||
|
||||
//erase the campaign
|
||||
write_file((*campaign)["filename"],"");
|
||||
remove((*campaign)["filename"].c_str());
|
||||
|
||||
const config::child_list& campaigns_list = campaigns().get_children("campaign");
|
||||
const size_t index = std::find(campaigns_list.begin(),campaigns_list.end(),campaign) - campaigns_list.begin();
|
||||
|
@ -249,6 +250,20 @@ void campaign_server::run()
|
|||
scoped_ostream cfgfile = ostream_file(file_);
|
||||
write(*cfgfile, cfg_);
|
||||
network::send_data(construct_message("Campaign erased."),sock);
|
||||
} else if(const config* cpass = data.child("change_passphrase")) {
|
||||
config* campaign = campaigns().find_child("campaign","name",(*cpass)["name"]);
|
||||
if(campaign == NULL) {
|
||||
network::send_data(construct_error("No campaign with that name exists."),sock);
|
||||
} else if((*campaign)["passphrase"] != (*cpass)["passphrase"]) {
|
||||
network::send_data(construct_error("Your old passphrase was incorrect."),sock);
|
||||
} else if((const t_string)(*cpass)["new_passphrase"] == "") {
|
||||
network::send_data(construct_error("No new passphrase was supplied."),sock);
|
||||
} else {
|
||||
(*campaign)["passphrase"] = (*cpass)["new_passphrase"];
|
||||
scoped_ostream cfgfile = ostream_file(file_);
|
||||
write(*cfgfile, cfg_);
|
||||
network::send_data(construct_message("Passphrase changed."),sock);
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch(network::error& e) {
|
||||
|
|
45
utils/campaign_delete.pl
Executable file
45
utils/campaign_delete.pl
Executable file
|
@ -0,0 +1,45 @@
|
|||
#!/usr/bin/perl
|
||||
|
||||
use wml;
|
||||
use wml_net;
|
||||
use strict;
|
||||
|
||||
my ($host, $port) = ("campaigns.wesnoth.org", 15002);
|
||||
|
||||
$| = 1;
|
||||
|
||||
print "Campaign name to be deleted: ";
|
||||
my $name = <STDIN>;
|
||||
chomp $name;
|
||||
|
||||
print "Passphrase: ";
|
||||
my $old = <STDIN>;
|
||||
chomp $old;
|
||||
|
||||
my $socket = &wml_net::connect($host,$port);
|
||||
|
||||
if (!defined($socket)) {
|
||||
print "Error connecting to the campaign server\n";
|
||||
exit;
|
||||
}
|
||||
|
||||
&wml_net::write_packet($socket,&wml::read_text( << "EOF" ));
|
||||
[delete]
|
||||
name=\"$name\"
|
||||
passphrase=\"$old\"
|
||||
[/delete]
|
||||
EOF
|
||||
|
||||
my $response = &wml_net::read_packet($socket);
|
||||
|
||||
if (!defined($response)) {
|
||||
print "Error accessing the campaign server.\n";
|
||||
exit;
|
||||
}
|
||||
|
||||
if (my $error = &wml::has_child($response, 'error')) {
|
||||
printf "Error: %s\n", $error->{'attr'}->{'message'};
|
||||
exit;
|
||||
}
|
||||
|
||||
print "Campaign deleted.\n";
|
50
utils/campaign_passphrase.pl
Executable file
50
utils/campaign_passphrase.pl
Executable file
|
@ -0,0 +1,50 @@
|
|||
#!/usr/bin/perl
|
||||
|
||||
use wml;
|
||||
use wml_net;
|
||||
use strict;
|
||||
|
||||
my ($host, $port) = ("campaigns.wesnoth.org", 15002);
|
||||
|
||||
$| = 1;
|
||||
|
||||
print "Campaign name to change passphrase of: ";
|
||||
my $name = <STDIN>;
|
||||
chomp $name;
|
||||
|
||||
print "Old passphrase: ";
|
||||
my $old = <STDIN>;
|
||||
chomp $old;
|
||||
|
||||
print "New passphrase: ";
|
||||
my $new = <STDIN>;
|
||||
chomp $new;
|
||||
|
||||
my $socket = &wml_net::connect($host,$port);
|
||||
|
||||
if (!defined($socket)) {
|
||||
print "Error connecting to the campaign server\n";
|
||||
exit;
|
||||
}
|
||||
|
||||
&wml_net::write_packet($socket,&wml::read_text( << "EOF" ));
|
||||
[change_passphrase]
|
||||
name=\"$name\"
|
||||
passphrase=\"$old\"
|
||||
new_passphrase=\"$new\"
|
||||
[/change_passphrase]
|
||||
EOF
|
||||
|
||||
my $response = &wml_net::read_packet($socket);
|
||||
|
||||
if (!defined($response)) {
|
||||
print "Error accessing the campaign server.\n";
|
||||
exit;
|
||||
}
|
||||
|
||||
if (my $error = &wml::has_child($response, 'error')) {
|
||||
printf "Error: %s\n", $error->{'attr'}->{'message'};
|
||||
exit;
|
||||
}
|
||||
|
||||
print "Passphrase updated.\n";
|
Loading…
Add table
Reference in a new issue