diff --git a/UI/GameSettingsScreen.cpp b/UI/GameSettingsScreen.cpp index 15016aa225..19aa035e6f 100644 --- a/UI/GameSettingsScreen.cpp +++ b/UI/GameSettingsScreen.cpp @@ -1088,16 +1088,17 @@ UI::EventReturn GameSettingsScreen::OnChangeMacAddress(UI::EventParams &e) { } UI::EventReturn GameSettingsScreen::OnChangeRemoteISOSubdir(UI::EventParams &e) { - //sanity checks + //Conform to HTTP standards for (size_t i = 0; i < g_Config.sRemoteISOSubdir.length(); i++) { if (g_Config.sRemoteISOSubdir[i] == ' ') g_Config.sRemoteISOSubdir[i] = '+'; if (g_Config.sRemoteISOSubdir[i] == '\\') g_Config.sRemoteISOSubdir[i] = '/'; if (g_Config.sRemoteISOSubdir[i] == '?') { - g_Config.sRemoteISOSubdir.erase(i); //truncate + g_Config.sRemoteISOSubdir.erase(i); //truncate for safety break; } } + //Make sure it begins and ends with / if (g_Config.sRemoteISOSubdir[0] != '/') g_Config.sRemoteISOSubdir = "/" + g_Config.sRemoteISOSubdir; if (g_Config.sRemoteISOSubdir[g_Config.sRemoteISOSubdir.length() - 1] != '/') diff --git a/UI/RemoteISOScreen.cpp b/UI/RemoteISOScreen.cpp index 6bafc1f929..782fd3f6eb 100644 --- a/UI/RemoteISOScreen.cpp +++ b/UI/RemoteISOScreen.cpp @@ -198,52 +198,56 @@ static bool FindServer(std::string &resultHost, int &resultPort) { return true; } - if(!g_Config.bRemoteISOManual) { - // Start by requesting a list of recent local ips for this network. - if (http.Resolve(REPORT_HOSTNAME, REPORT_PORT)) { - if (http.Connect()) { - code = http.GET("/match/list", &result); - http.Disconnect(); - } - } + //don't scan if in manual mode + if (g_Config.bRemoteISOManual) { + return false; + } - if (code != 200 || scanCancelled) { - return false; - } - - std::string json; - result.TakeAll(&json); - - JsonReader reader(json.c_str(), json.size()); - if (!reader.ok()) { - return false; - } - - const json_value *entries = reader.root(); - if (!entries) { - return false; - } - - std::vector servers; - const json_value *entry = entries->first_child; - while (entry) { - const char *host = entry->getString("ip", ""); - int port = entry->getInt("p", 0); - - char url[1024] = {}; - snprintf(url, sizeof(url), "http://%s:%d", host, port); - servers.push_back(url); - - if (http.Resolve(host, port) && http.Connect()) { - http.Disconnect(); - resultHost = host; - resultPort = port; - return true; - } - - entry = entry->next_sibling; + // Start by requesting a list of recent local ips for this network. + if (http.Resolve(REPORT_HOSTNAME, REPORT_PORT)) { + if (http.Connect()) { + code = http.GET("/match/list", &result); + http.Disconnect(); } } + + if (code != 200 || scanCancelled) { + return false; + } + + std::string json; + result.TakeAll(&json); + + JsonReader reader(json.c_str(), json.size()); + if (!reader.ok()) { + return false; + } + + const json_value *entries = reader.root(); + if (!entries) { + return false; + } + + std::vector servers; + const json_value *entry = entries->first_child; + while (entry) { + const char *host = entry->getString("ip", ""); + int port = entry->getInt("p", 0); + + char url[1024] = {}; + snprintf(url, sizeof(url), "http://%s:%d", host, port); + servers.push_back(url); + + if (http.Resolve(host, port) && http.Connect()) { + http.Disconnect(); + resultHost = host; + resultPort = port; + return true; + } + + entry = entry->next_sibling; + } + // None of the local IPs were reachable. return false; } @@ -275,7 +279,7 @@ static bool LoadGameList(const std::string &host, int port, std::vector items; result.TakeAll(&listing); - if (startsWith(responseHeaders[0],"Server: SuperDuperServer")) { + if (startsWith(responseHeaders[0],"Server: PPSSPPServer") || startsWith(responseHeaders[0], "Server: SuperDuperServer")) { //ppsspp server SplitString(listing, '\n', items); for (const std::string &item : items) { @@ -289,7 +293,7 @@ static bool LoadGameList(const std::string &host, int port, std::vector& output) +void GetQuotedStrings(const std::string& str, std::vector& output) { size_t next = 0; bool even = 0; diff --git a/ext/native/base/stringutil.h b/ext/native/base/stringutil.h index 8d22425c9c..9205c009b6 100644 --- a/ext/native/base/stringutil.h +++ b/ext/native/base/stringutil.h @@ -113,7 +113,7 @@ static bool TryParse(const std::string &str, N *const output) } void SplitString(const std::string& str, const char delim, std::vector& output); -void FindQuotedStrings(const std::string& str, std::vector& output); +void GetQuotedStrings(const std::string& str, std::vector& output); std::string ReplaceAll(std::string input, const std::string& src, const std::string& dest); diff --git a/ext/native/net/http_server.cpp b/ext/native/net/http_server.cpp index 57ceab984b..9357d2fe69 100644 --- a/ext/native/net/http_server.cpp +++ b/ext/native/net/http_server.cpp @@ -86,7 +86,7 @@ void Request::WriteHttpResponseHeader(int status, int64_t size, const char *mime net::OutputSink *buffer = Out(); buffer->Printf("HTTP/1.0 %03d %s\r\n", status, statusStr); - buffer->Push("Server: SuperDuperServer v0.1\r\n"); + buffer->Push("Server: PPSSPPServer v0.1\r\n"); buffer->Printf("Content-Type: %s\r\n", mimeType ? mimeType : DEFAULT_MIME_TYPE); buffer->Push("Connection: close\r\n"); if (size >= 0) {