Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Correct remote disc streaming with ipv6 #11689

Merged
merged 2 commits into from
Dec 22, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
60 changes: 44 additions & 16 deletions UI/RemoteISOScreen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,19 +37,59 @@ static const int REPORT_PORT = 80;
static bool scanCancelled = false;
static bool scanAborted = false;

static std::string RemoteSubdir() {
if (g_Config.bRemoteISOManual) {
std::string subdir = g_Config.sRemoteISOSubdir;
size_t offset = subdir.find_last_of("/");
if (offset != subdir.length() - 1 && offset != subdir.npos) {
// Truncate everything after last /
subdir.erase(offset + 1);
}
return subdir;
}

return "/";
}

static bool FindServer(std::string &resultHost, int &resultPort) {
http::Client http;
Buffer result;
int code = 500;

std::string subdir = RemoteSubdir();

auto TryServer = [&](const std::string &host, int port) {
// Don't wait as long for a connect - we need a good connection for smooth streaming anyway.
// This way if it's down, we'll find the right one faster.
if (http.Resolve(host.c_str(), port) && http.Connect(1, 10.0, &scanCancelled)) {
code = http.GET(subdir.c_str(), &result);
http.Disconnect();
resultHost = host;
resultPort = port;
return true;

if (code != 200) {
return false;
}

// Make sure this isn't just the debugger. If so, move on.
std::string listing;
std::vector<std::string> items;
result.TakeAll(&listing);
SplitString(listing, '\n', items);

bool supported = false;
for (const std::string &item : items) {
if (!RemoteISOFileSupported(item)) {
continue;
}
supported = true;
break;
}

if (supported) {
resultHost = host;
resultPort = port;
NOTICE_LOG(HLE, "RemoteISO found: %s : %d", host.c_str(), port);
return true;
}
}

return false;
Expand Down Expand Up @@ -94,7 +134,6 @@ static bool FindServer(std::string &resultHost, int &resultPort) {
return false;
}

std::vector<std::string> servers;
for (const auto pentry : entries) {
JsonGet entry = pentry->value;
if (scanCancelled)
Expand All @@ -105,7 +144,6 @@ static bool FindServer(std::string &resultHost, int &resultPort) {

char url[1024] = {};
snprintf(url, sizeof(url), "http://%s:%d", host, port);
servers.push_back(url);

if (TryServer(host, port)) {
return true;
Expand All @@ -121,17 +159,7 @@ static bool LoadGameList(const std::string &host, int port, std::vector<std::str
Buffer result;
int code = 500;
std::vector<std::string> responseHeaders;
std::string subdir = "/";
size_t offset;

if (g_Config.bRemoteISOManual) {
subdir = g_Config.sRemoteISOSubdir;
offset=subdir.find_last_of("/");
if (offset != subdir.length() - 1 && offset != subdir.npos) {
// Truncate everything after last /
subdir.erase(offset + 1);
}
}
std::string subdir = RemoteSubdir();

// Start by requesting the list of games from the server.
if (http.Resolve(host.c_str(), port)) {
Expand Down
2 changes: 1 addition & 1 deletion ext/native/net/url.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ void Url::Split() {
host_ = url_.substr(colonSlashSlash + 3, sep - colonSlashSlash - 3);
resource_ = url_.substr(sep); // include the slash!

size_t portsep = host_.find(':');
size_t portsep = host_.rfind(':');
if (portsep != host_.npos) {
port_ = atoi(host_.substr(portsep + 1).c_str());
host_ = host_.substr(0, portsep);
Expand Down