Skip to content

Commit

Permalink
Merge pull request #251 from inada-s/gdxsv-more-platforminfo
Browse files Browse the repository at this point in the history
Add some platforminfo to survey network issues
  • Loading branch information
inada-s authored Aug 7, 2023
2 parents 43d85d4 + a1b1826 commit 6807882
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 3 deletions.
23 changes: 23 additions & 0 deletions core/gdxsv/gdxsv.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -344,6 +344,23 @@ std::vector<u8> Gdxsv::GeneratePlatformInfoPacket() {
}
}

if (upnp_result_.valid()) {
ss << "upnp_result=" << upnp_result_.get() << "\n";
ss << "upnp_local_ip=" << upnp_.localAddress() << "\n";
ss << "upnp_public_ip=" << upnp_.externalAddress() << "\n";
ss << "upnp_local_ip_differ=" << static_cast<int>(lbs_net_.LocalIP() != std::string(upnp_.localAddress())) << "\n";
if (public_ipv4_.valid()) {
if (public_ipv4_.get().first) {
ss << "upnp_public_ip_differ=" << static_cast<int>(public_ipv4_.get().second != std::string(upnp_.externalAddress()))
<< "\n";
}
}
}

if (port_test_result_v4_.valid()) {
ss << "port_test_v4=" << port_test_result_v4_.get() << "\n";
}

const auto raw_content = ss.str();
std::vector<u8> content;
if (!encode_zlib_deflate(raw_content.c_str(), raw_content.size(), content)) {
Expand Down Expand Up @@ -522,6 +539,12 @@ void Gdxsv::HandleRPC() {

void Gdxsv::StartPingTest() { gcp_ping_test_result_ = gcp_ping_test().share(); }

void Gdxsv::StartUdpPortTest() {
if (config::GdxLocalPort != 0) {
port_test_result_v4_ = test_udp_port_connectivity(config::GdxLocalPort, false).share();
}
}

void Gdxsv::FetchPublicIP() {
public_ipv4_ = get_public_ip_address(false).share();
public_ipv6_ = get_public_ip_address(true).share();
Expand Down
6 changes: 3 additions & 3 deletions core/gdxsv/gdxsv.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ class Gdxsv {
void HandleRPC();
void RestoreOnlinePatch();
void StartPingTest();
void StartUdpPortTest();
void FetchPublicIP();
void NotifyWanPort() const;
bool StartReplayFile(const char* path, int pov);
Expand Down Expand Up @@ -76,11 +77,10 @@ class Gdxsv {

std::shared_future<std::map<std::string, int>> gcp_ping_test_result_;
std::shared_future<std::pair<bool, std::string>> public_ipv4_, public_ipv6_;
std::shared_future<std::string> upnp_result_;
std::shared_future<std::string> port_test_result_v4_;

MiniUPnP upnp_;
std::future<std::string> upnp_result_;
int upnp_port_ = 0;

GdxsvBackendTcp lbs_net_;
GdxsvBackendUdp udp_net_;
GdxsvBackendReplay replay_net_;
Expand Down
1 change: 1 addition & 0 deletions core/gdxsv/gdxsv_emu_hooks.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ void gdxsv_emu_start() {
dc_loadstate(99);
} else {
gdxsv.StartPingTest();
gdxsv.StartUdpPortTest();
gdxsv.FetchPublicIP();
}
}
Expand Down

0 comments on commit 6807882

Please sign in to comment.