add checks for disabled proxy server; fixes #580
This commit is contained in:
@@ -107,12 +107,20 @@ static void check_is_leader(shared_ptr<Lobby> l, shared_ptr<Client> c) {
|
||||
static void server_command_server_info(shared_ptr<Client> c, const std::string&) {
|
||||
auto s = c->require_server_state();
|
||||
string uptime_str = phosg::format_duration(phosg::now() - s->creation_time);
|
||||
if (s->proxy_server) {
|
||||
send_text_message_printf(c,
|
||||
"Uptime: $C6%s$C7\nLobbies: $C6%zu$C7\nClients: $C6%zu$C7(g) $C6%zu$C7(p)",
|
||||
uptime_str.c_str(),
|
||||
s->id_to_lobby.size(),
|
||||
s->channel_to_client.size(),
|
||||
s->proxy_server->num_sessions());
|
||||
} else {
|
||||
send_text_message_printf(c,
|
||||
"Uptime: $C6%s$C7\nLobbies: $C6%zu$C7\nClients: $C6%zu",
|
||||
uptime_str.c_str(),
|
||||
s->id_to_lobby.size(),
|
||||
s->channel_to_client.size());
|
||||
}
|
||||
}
|
||||
|
||||
static void server_command_lobby_info(shared_ptr<Client> c, const std::string&) {
|
||||
|
||||
+1
-2
@@ -2918,7 +2918,7 @@ Action a_run_server_replay_log(
|
||||
config_log.info("Starting proxy server");
|
||||
state->proxy_server = make_shared<ProxyServer>(base, state);
|
||||
}
|
||||
if (state->proxy_server.get()) {
|
||||
|
||||
// For PC and GC, proxy sessions are dynamically created when a client
|
||||
// picks a destination from the menu. For patch and BB clients, there's
|
||||
// no way to ask the client which destination they want, so only one
|
||||
@@ -2937,7 +2937,6 @@ Action a_run_server_replay_log(
|
||||
} else {
|
||||
state->proxy_server->listen(pc->addr, pc->port, pc->version);
|
||||
}
|
||||
}
|
||||
|
||||
} else if (pc->behavior == ServerBehavior::PATCH_SERVER_PC) {
|
||||
if (!state->pc_patch_server.get()) {
|
||||
|
||||
@@ -234,6 +234,11 @@ void send_client_to_lobby_server(shared_ptr<Client> c) {
|
||||
}
|
||||
|
||||
void send_client_to_proxy_server(shared_ptr<Client> c) {
|
||||
auto s = c->require_server_state();
|
||||
if (!s->proxy_server) {
|
||||
throw logic_error("send_client_to_proxy_server called without proxy server present");
|
||||
}
|
||||
|
||||
send_first_pre_lobby_commands(c, [wc = weak_ptr(c)]() {
|
||||
auto c = wc.lock();
|
||||
if (!c) {
|
||||
|
||||
@@ -1191,6 +1191,10 @@ CommandDefinition c_close_idle_sessions(
|
||||
"close-idle-sessions", "close-idle-sessions\n\
|
||||
Close all proxy sessions that don\'t have a client and server connected.",
|
||||
true, +[](CommandArgs& args) {
|
||||
if (args.s->proxy_server) {
|
||||
size_t count = args.s->proxy_server->delete_disconnected_sessions();
|
||||
fprintf(stderr, "%zu sessions closed\n", count);
|
||||
} else {
|
||||
throw runtime_error("the proxy server is disabled");
|
||||
}
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user