allow changing the dns server port
This commit is contained in:
+1
-1
@@ -411,7 +411,7 @@ static void command_ax(shared_ptr<ServerState>, shared_ptr<Lobby>,
|
|||||||
shared_ptr<Client> c, const char16_t* args) {
|
shared_ptr<Client> c, const char16_t* args) {
|
||||||
check_privileges(c, Privilege::Announce);
|
check_privileges(c, Privilege::Announce);
|
||||||
string message = encode_sjis(args);
|
string message = encode_sjis(args);
|
||||||
log(INFO, "[$ax from %010u] %s\n", c->license->serial_number, message.c_str());
|
log(INFO, "[Client message from %010u] %s\n", c->license->serial_number, message.c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
static void command_announce(shared_ptr<ServerState> s, shared_ptr<Lobby>,
|
static void command_announce(shared_ptr<ServerState> s, shared_ptr<Lobby>,
|
||||||
|
|||||||
+2
-1
@@ -59,7 +59,8 @@ LicenseManager::LicenseManager(const string& filename) : filename(filename) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
} catch (const cannot_open_file&) {
|
} catch (const cannot_open_file&) {
|
||||||
log(WARNING, "%s does not exist; no licenses are registered", this->filename.c_str());
|
log(WARNING, "File %s does not exist; no licenses are registered",
|
||||||
|
this->filename.c_str());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+13
-13
@@ -119,11 +119,11 @@ void populate_state_from_config(shared_ptr<ServerState> s,
|
|||||||
try {
|
try {
|
||||||
s->local_address = s->all_addresses.at(local_address_str);
|
s->local_address = s->all_addresses.at(local_address_str);
|
||||||
string addr_str = string_for_address(s->local_address);
|
string addr_str = string_for_address(s->local_address);
|
||||||
log(INFO, "added local address: %s (%s)", addr_str.c_str(),
|
log(INFO, "Added local address: %s (%s)", addr_str.c_str(),
|
||||||
local_address_str.c_str());
|
local_address_str.c_str());
|
||||||
} catch (const out_of_range&) {
|
} catch (const out_of_range&) {
|
||||||
s->local_address = address_for_string(local_address_str.c_str());
|
s->local_address = address_for_string(local_address_str.c_str());
|
||||||
log(INFO, "added local address: %s", local_address_str.c_str());
|
log(INFO, "Added local address: %s", local_address_str.c_str());
|
||||||
}
|
}
|
||||||
s->all_addresses.emplace("<local>", s->local_address);
|
s->all_addresses.emplace("<local>", s->local_address);
|
||||||
|
|
||||||
@@ -131,11 +131,11 @@ void populate_state_from_config(shared_ptr<ServerState> s,
|
|||||||
try {
|
try {
|
||||||
s->external_address = s->all_addresses.at(external_address_str);
|
s->external_address = s->all_addresses.at(external_address_str);
|
||||||
string addr_str = string_for_address(s->external_address);
|
string addr_str = string_for_address(s->external_address);
|
||||||
log(INFO, "added external address: %s (%s)", addr_str.c_str(),
|
log(INFO, "Added external address: %s (%s)", addr_str.c_str(),
|
||||||
external_address_str.c_str());
|
external_address_str.c_str());
|
||||||
} catch (const out_of_range&) {
|
} catch (const out_of_range&) {
|
||||||
s->external_address = address_for_string(external_address_str.c_str());
|
s->external_address = address_for_string(external_address_str.c_str());
|
||||||
log(INFO, "added external address: %s", external_address_str.c_str());
|
log(INFO, "Added external address: %s", external_address_str.c_str());
|
||||||
}
|
}
|
||||||
s->all_addresses.emplace("<external>", s->external_address);
|
s->all_addresses.emplace("<external>", s->external_address);
|
||||||
|
|
||||||
@@ -155,12 +155,12 @@ void populate_state_from_config(shared_ptr<ServerState> s,
|
|||||||
string key_file_name = d.at("BlueBurstKeyFile")->as_string();
|
string key_file_name = d.at("BlueBurstKeyFile")->as_string();
|
||||||
string key_file_contents = load_file("system/blueburst/keys/" + key_file_name + ".nsk");
|
string key_file_contents = load_file("system/blueburst/keys/" + key_file_name + ".nsk");
|
||||||
if (key_file_contents.size() != sizeof(PSOBBEncryption::KeyFile)) {
|
if (key_file_contents.size() != sizeof(PSOBBEncryption::KeyFile)) {
|
||||||
log(WARNING, "key file is the wrong size (%zu bytes; should be %zu bytes)",
|
log(WARNING, "Blue Burst key file is the wrong size (%zu bytes; should be %zu bytes)",
|
||||||
key_file_contents.size(), sizeof(PSOBBEncryption::KeyFile));
|
key_file_contents.size(), sizeof(PSOBBEncryption::KeyFile));
|
||||||
log(WARNING, "ignoring key file; Blue Burst clients will not be able to connect");
|
log(WARNING, "Ignoring key file; Blue Burst clients will not be able to connect");
|
||||||
} else {
|
} else {
|
||||||
memcpy(&s->default_key_file, key_file_contents.data(), sizeof(PSOBBEncryption::KeyFile));
|
memcpy(&s->default_key_file, key_file_contents.data(), sizeof(PSOBBEncryption::KeyFile));
|
||||||
log(INFO, "loaded key file: %s", key_file_name.c_str());
|
log(INFO, "Loaded Blue Burst key file: %s", key_file_name.c_str());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -198,15 +198,13 @@ void drop_privileges(const string& username) {
|
|||||||
throw runtime_error(string_printf("can\'t switch to user %d (%s)",
|
throw runtime_error(string_printf("can\'t switch to user %d (%s)",
|
||||||
pw->pw_uid, error.c_str()));
|
pw->pw_uid, error.c_str()));
|
||||||
}
|
}
|
||||||
log(INFO, "switched to user %s (%d:%d)", username.c_str(), pw->pw_uid,
|
log(INFO, "Switched to user %s (%d:%d)", username.c_str(), pw->pw_uid,
|
||||||
pw->pw_gid);
|
pw->pw_gid);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
int main(int argc, char* argv[]) {
|
int main(int argc, char* argv[]) {
|
||||||
log(INFO, "fuzziqer software newserv");
|
|
||||||
|
|
||||||
string proxy_hostname;
|
string proxy_hostname;
|
||||||
int proxy_port = 0;
|
int proxy_port = 0;
|
||||||
GameVersion proxy_version = GameVersion::GC;
|
GameVersion proxy_version = GameVersion::GC;
|
||||||
@@ -243,11 +241,13 @@ int main(int argc, char* argv[]) {
|
|||||||
populate_state_from_config(state, config_json);
|
populate_state_from_config(state, config_json);
|
||||||
|
|
||||||
shared_ptr<DNSServer> dns_server;
|
shared_ptr<DNSServer> dns_server;
|
||||||
if (state->run_dns_server) {
|
if (state->dns_server_port) {
|
||||||
log(INFO, "starting dns server");
|
log(INFO, "Starting DNS server");
|
||||||
dns_server.reset(new DNSServer(base, state->local_address,
|
dns_server.reset(new DNSServer(base, state->local_address,
|
||||||
state->external_address));
|
state->external_address));
|
||||||
dns_server->listen("", 53);
|
dns_server->listen("", state->dns_server_port);
|
||||||
|
} else {
|
||||||
|
log(INFO, "DNS server is disabled");
|
||||||
}
|
}
|
||||||
|
|
||||||
shared_ptr<ProxyServer> proxy_server;
|
shared_ptr<ProxyServer> proxy_server;
|
||||||
|
|||||||
+2
-1
@@ -12,7 +12,8 @@ using namespace std;
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
ServerState::ServerState() : run_dns_server(true),
|
ServerState::ServerState()
|
||||||
|
: dns_server_port(0),
|
||||||
allow_unregistered_users(false),
|
allow_unregistered_users(false),
|
||||||
run_shell_behavior(RunShellBehavior::Default), next_lobby_id(1),
|
run_shell_behavior(RunShellBehavior::Default), next_lobby_id(1),
|
||||||
pre_lobby_event(0) {
|
pre_lobby_event(0) {
|
||||||
|
|||||||
+1
-1
@@ -34,7 +34,7 @@ struct ServerState {
|
|||||||
std::u16string name;
|
std::u16string name;
|
||||||
std::unordered_map<std::string, PortConfiguration> port_configuration;
|
std::unordered_map<std::string, PortConfiguration> port_configuration;
|
||||||
std::string username;
|
std::string username;
|
||||||
bool run_dns_server;
|
uint16_t dns_server_port;
|
||||||
bool allow_unregistered_users;
|
bool allow_unregistered_users;
|
||||||
RunShellBehavior run_shell_behavior;
|
RunShellBehavior run_shell_behavior;
|
||||||
PSOBBEncryption::KeyFile default_key_file;
|
PSOBBEncryption::KeyFile default_key_file;
|
||||||
|
|||||||
+3
-2
@@ -7,8 +7,9 @@
|
|||||||
"LocalAddress": "192.168.0.5",
|
"LocalAddress": "192.168.0.5",
|
||||||
// Address to connect external clients to (IP address or interface name)
|
// Address to connect external clients to (IP address or interface name)
|
||||||
"ExternalAddress": "en0",
|
"ExternalAddress": "en0",
|
||||||
// Set to false to disable the DNS server
|
// Port to listen for DNS queries on. Set this to zero (or comment it out) to
|
||||||
"RunDNSServer": true,
|
// disable the DNS server.
|
||||||
|
"DNSServerPort": 53,
|
||||||
// By default, the interactive shell runs if stdin is a terminal, and doesn't
|
// By default, the interactive shell runs if stdin is a terminal, and doesn't
|
||||||
// run if it's not. This option, if present, overrides that behavior.
|
// run if it's not. This option, if present, overrides that behavior.
|
||||||
// "RunInteractiveShell": false,
|
// "RunInteractiveShell": false,
|
||||||
|
|||||||
Reference in New Issue
Block a user