implement AllowUnregisteredUsers
This commit is contained in:
@@ -144,6 +144,12 @@ void populate_state_from_config(shared_ptr<ServerState> s,
|
||||
s->run_dns_server = true;
|
||||
}
|
||||
|
||||
try {
|
||||
s->allow_unregistered_users = d.at("AllowUnregisteredUsers")->as_bool();
|
||||
} catch (const out_of_range&) {
|
||||
s->allow_unregistered_users = true;
|
||||
}
|
||||
|
||||
try {
|
||||
bool run_shell = d.at("RunInteractiveShell")->as_bool();
|
||||
s->run_shell_behavior = run_shell ?
|
||||
|
||||
+24
-16
@@ -179,10 +179,12 @@ void process_verify_license_gc(shared_ptr<ServerState> s, shared_ptr<Client> c,
|
||||
c->license = s->license_manager->verify_gc(serial_number, cmd->access_key,
|
||||
cmd->password);
|
||||
} catch (const exception& e) {
|
||||
u16string message = u"Login failed: " + decode_sjis(e.what());
|
||||
send_message_box(c, message.c_str());
|
||||
c->should_disconnect = true;
|
||||
return;
|
||||
if (!s->allow_unregistered_users) {
|
||||
u16string message = u"Login failed: " + decode_sjis(e.what());
|
||||
send_message_box(c, message.c_str());
|
||||
c->should_disconnect = true;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
c->flags |= flags_for_version(c->version, cmd->sub_version);
|
||||
@@ -210,10 +212,12 @@ void process_login_a_dc_pc_gc(shared_ptr<ServerState> s, shared_ptr<Client> c,
|
||||
NULL);
|
||||
}
|
||||
} catch (const exception& e) {
|
||||
u16string message = u"Login failed: " + decode_sjis(e.what());
|
||||
send_message_box(c, message.c_str());
|
||||
c->should_disconnect = true;
|
||||
return;
|
||||
if (!s->allow_unregistered_users) {
|
||||
u16string message = u"Login failed: " + decode_sjis(e.what());
|
||||
send_message_box(c, message.c_str());
|
||||
c->should_disconnect = true;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
send_command(c, 0x9C, 0x01);
|
||||
@@ -245,10 +249,12 @@ void process_login_c_dc_pc_gc(shared_ptr<ServerState> s, shared_ptr<Client> c,
|
||||
cmd->password);
|
||||
}
|
||||
} catch (const exception& e) {
|
||||
u16string message = u"Login failed: " + decode_sjis(e.what());
|
||||
send_message_box(c, message.c_str());
|
||||
c->should_disconnect = true;
|
||||
return;
|
||||
if (!s->allow_unregistered_users) {
|
||||
u16string message = u"Login failed: " + decode_sjis(e.what());
|
||||
send_message_box(c, message.c_str());
|
||||
c->should_disconnect = true;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
send_command(c, 0x9C, 0x01);
|
||||
@@ -284,10 +290,12 @@ void process_login_d_e_pc_gc(shared_ptr<ServerState> s, shared_ptr<Client> c,
|
||||
NULL);
|
||||
}
|
||||
} catch (const exception& e) {
|
||||
u16string message = u"Login failed: " + decode_sjis(e.what());
|
||||
send_message_box(c, message.c_str());
|
||||
c->should_disconnect = true;
|
||||
return;
|
||||
if (!s->allow_unregistered_users) {
|
||||
u16string message = u"Login failed: " + decode_sjis(e.what());
|
||||
send_message_box(c, message.c_str());
|
||||
c->should_disconnect = true;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
memcpy(&c->config.cfg, &cmd->cfg, sizeof(ClientConfig));
|
||||
|
||||
@@ -11,6 +11,7 @@ using namespace std;
|
||||
|
||||
|
||||
ServerState::ServerState() : run_dns_server(true),
|
||||
allow_unregistered_users(false),
|
||||
run_shell_behavior(RunShellBehavior::Default), next_lobby_id(1) {
|
||||
this->main_menu.emplace_back(MAIN_MENU_GO_TO_LOBBY, u"Go to lobby",
|
||||
u"Join the lobby.", 0);
|
||||
|
||||
@@ -36,6 +36,7 @@ struct ServerState {
|
||||
std::unordered_map<std::string, PortConfiguration> port_configuration;
|
||||
std::string username;
|
||||
bool run_dns_server;
|
||||
bool allow_unregistered_users;
|
||||
RunShellBehavior run_shell_behavior;
|
||||
std::shared_ptr<const QuestIndex> quest_index;
|
||||
std::shared_ptr<const LevelTable> level_table;
|
||||
|
||||
@@ -13,6 +13,12 @@
|
||||
// run if it's not. This option, if present, overrides that behavior.
|
||||
// "RunInteractiveShell": false,
|
||||
|
||||
// By default, the server only allows users who are registered in the license
|
||||
// file. By enabling this option, all users will be allowed to connect. This
|
||||
// option has no effect for Blue Burst clients. Keep in mind that unregistered
|
||||
// users cannot be banned!
|
||||
"AllowUnregisteredUsers": false,
|
||||
|
||||
// User to run the server as. If present, newserv will attempt to switch to
|
||||
// this user's permissions after loading its configuration and opening
|
||||
// listening sockets. The special value $SUDO_USER causes newserv to look up
|
||||
|
||||
Reference in New Issue
Block a user