make LocalAddress and ExternalAddress optional
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
# newserv <img align="right" src="static/s-newserv.png" />
|
||||
|
||||
newserv is a game server, proxy, and reverse-engineering tool for Phantasy Star Online (PSO).
|
||||
newserv is a game server, proxy, and reverse-engineering tool for Phantasy Star Online (PSO). To get started using newserv as a PSO server or as a proxy, see the [Server setup](#server-setup) section.
|
||||
|
||||
This project includes code that was reverse-engineered by the community in ages long past, and has been included in many projects since then. It also includes some game data from Phantasy Star Online itself, which was originally created by Sega.
|
||||
|
||||
@@ -111,14 +111,14 @@ Currently newserv works on macOS, Windows, and Ubuntu Linux. It will likely work
|
||||
### Windows/macOS
|
||||
|
||||
1. Download the latest release-windows-amd64.zip or release-macos-arm64.zip file from the [releases page](https://github.com/fuzziqersoftware/newserv/releases).
|
||||
2. Extract the contents of the release folder to a location on your computer.
|
||||
3. Edit the config.example.json file in the system folder as needed, then rename it to config.json.
|
||||
2. Extract the contents of the archive to some location on your computer.
|
||||
3. If you want to change any options, go into the system/ folder, open config.json in a text editor, and edit it to your liking.
|
||||
4. If you plan to play Blue Burst on newserv, set up the patch directory. See [client patch directories](#client-patch-directories) for more information.
|
||||
5. Run the newserv executable.
|
||||
|
||||
### Linux
|
||||
|
||||
There are currently no precompiled releases for Linux. To run newserv on Linux, see the "Building from source" section below.
|
||||
There are currently no precompiled releases for Linux. To run newserv on Linux, you'll have to build it from source - see the "Building from source" section below.
|
||||
|
||||
### Building from source
|
||||
|
||||
@@ -130,7 +130,7 @@ There are currently no precompiled releases for Linux. To run newserv on Linux,
|
||||
4. Optionally, install [resource_dasm](https://github.com/fuzziqersoftware/resource_dasm). This will enable newserv to send memory patches and load DOL files on PSO GC clients. PSO GC clients can play PSO normally on newserv without this.
|
||||
5. Run `cmake . && make` in the newserv directory.
|
||||
|
||||
After building newserv, edit system/config.example.json as needed and rename it to system/config.json, set up [client patch directories](#client-patch-directories) if you're planning to play Blue Burst, then run `./newserv` in newserv's directory.
|
||||
After building newserv, edit system/config.example.json as needed **and rename it to system/config.json** (note that this step is not necessary for the precompiled releases!), set up [client patch directories](#client-patch-directories) if you're planning to play Blue Burst, then run `./newserv` in newserv's directory.
|
||||
|
||||
To use newserv in other ways (e.g. for translating data), see the end of this document.
|
||||
|
||||
@@ -475,7 +475,7 @@ There are many options available when starting a proxy session. All options are
|
||||
* **Chat commands**: enables chat commands in the proxy session (on by default).
|
||||
* **Chat filter**: enables escape sequences in chat messages and info board (on by default).
|
||||
* **Player notifications**: shows a message when any player joins or leaves the game or lobby you're in.
|
||||
* **Block pings**: blocks automatic pings sent by the client, and responds to ping commands from the server automatically. This works around a bug in Sylverant's login server.
|
||||
* **Block pings**: blocks automatic pings sent by the client, and responds to ping commands from the server automatically.
|
||||
* **Infinite HP**: automatically heals you whenever you get hit. An attack that kills you in one hit will still kill you, however.
|
||||
* **Infinite TP**: automatically restores your TP whenever you use any technique.
|
||||
* **Switch assist**: attempts to unlock doors that require two or four players in a one-player game.
|
||||
|
||||
+40
-26
@@ -257,15 +257,21 @@ uint32_t ServerState::connect_address_for_client(shared_ptr<Client> c) const {
|
||||
}
|
||||
const auto* sin = reinterpret_cast<const sockaddr_in*>(&c->channel.remote_addr);
|
||||
return IPStackSimulator::connect_address_for_remote_address(ntohl(sin->sin_addr.s_addr));
|
||||
} else {
|
||||
// TODO: we can do something smarter here, like use the sockname to find
|
||||
// out which interface the client is connected to, and return that address
|
||||
if (is_local_address(c->channel.remote_addr)) {
|
||||
return this->local_address;
|
||||
} else {
|
||||
return this->external_address;
|
||||
}
|
||||
}
|
||||
|
||||
uint32_t ret = is_local_address(c->channel.remote_addr) ? this->local_address : this->external_address;
|
||||
if (ret != 0) {
|
||||
return ret;
|
||||
}
|
||||
|
||||
struct sockaddr_storage addr;
|
||||
phosg::get_socket_addresses(bufferevent_getfd(c->channel.bev.get()), &addr, nullptr);
|
||||
if (addr.ss_family == AF_INET) {
|
||||
const sockaddr_in* sin = reinterpret_cast<const sockaddr_in*>(&addr);
|
||||
return ntohl(sin->sin_addr.s_addr);
|
||||
}
|
||||
|
||||
throw runtime_error("no connect address available");
|
||||
}
|
||||
|
||||
shared_ptr<const Menu> ServerState::information_menu(Version version) const {
|
||||
@@ -684,31 +690,39 @@ void ServerState::load_config_early() {
|
||||
this->one_time_config_loaded = true;
|
||||
}
|
||||
|
||||
auto local_address_str = this->config_json->at("LocalAddress").as_string();
|
||||
try {
|
||||
this->local_address = this->all_addresses.at(local_address_str);
|
||||
string addr_str = string_for_address(this->local_address);
|
||||
config_log.info("Added local address: %s (%s)", addr_str.c_str(),
|
||||
local_address_str.c_str());
|
||||
auto local_address_str = this->config_json->at("LocalAddress").as_string();
|
||||
try {
|
||||
this->local_address = this->all_addresses.at(local_address_str);
|
||||
string addr_str = string_for_address(this->local_address);
|
||||
config_log.info("Added local address: %s (%s)", addr_str.c_str(),
|
||||
local_address_str.c_str());
|
||||
} catch (const out_of_range&) {
|
||||
this->local_address = address_for_string(local_address_str.c_str());
|
||||
config_log.info("Added local address: %s", local_address_str.c_str());
|
||||
}
|
||||
this->all_addresses.erase("<local>");
|
||||
this->all_addresses.emplace("<local>", this->local_address);
|
||||
} catch (const out_of_range&) {
|
||||
this->local_address = address_for_string(local_address_str.c_str());
|
||||
config_log.info("Added local address: %s", local_address_str.c_str());
|
||||
config_log.warning("Local address not specified; interface defaults will be used");
|
||||
}
|
||||
this->all_addresses.erase("<local>");
|
||||
this->all_addresses.emplace("<local>", this->local_address);
|
||||
|
||||
auto external_address_str = this->config_json->at("ExternalAddress").as_string();
|
||||
try {
|
||||
this->external_address = this->all_addresses.at(external_address_str);
|
||||
string addr_str = string_for_address(this->external_address);
|
||||
config_log.info("Added external address: %s (%s)", addr_str.c_str(),
|
||||
external_address_str.c_str());
|
||||
auto external_address_str = this->config_json->at("ExternalAddress").as_string();
|
||||
try {
|
||||
this->external_address = this->all_addresses.at(external_address_str);
|
||||
string addr_str = string_for_address(this->external_address);
|
||||
config_log.info("Added external address: %s (%s)", addr_str.c_str(),
|
||||
external_address_str.c_str());
|
||||
} catch (const out_of_range&) {
|
||||
this->external_address = address_for_string(external_address_str.c_str());
|
||||
config_log.info("Added external address: %s", external_address_str.c_str());
|
||||
}
|
||||
this->all_addresses.erase("<external>");
|
||||
this->all_addresses.emplace("<external>", this->external_address);
|
||||
} catch (const out_of_range&) {
|
||||
this->external_address = address_for_string(external_address_str.c_str());
|
||||
config_log.info("Added external address: %s", external_address_str.c_str());
|
||||
config_log.warning("External address not specified; only local clients will be able to connect");
|
||||
}
|
||||
this->all_addresses.erase("<external>");
|
||||
this->all_addresses.emplace("<external>", this->external_address);
|
||||
|
||||
try {
|
||||
this->banned_ipv4_ranges = make_shared<IPV4RangeSet>(this->config_json->at("BannedIPV4Ranges"));
|
||||
|
||||
Reference in New Issue
Block a user