handle proper loading of ezremote server payload
This commit is contained in:
+1
-1
Submodule ps4-ezremote-server updated: 81533f5a28...2c38d24f2e
+67
-4
@@ -1238,6 +1238,9 @@ namespace INSTALLER
|
||||
|
||||
std::string EzRemoteServerVersion()
|
||||
{
|
||||
if (!IsPortOpen("127.0.0.1", 6701, 1))
|
||||
return "";
|
||||
|
||||
httplib::Client tmp_client = httplib::Client("http://127.0.0.1:6701");
|
||||
|
||||
tmp_client.set_connection_timeout(1);
|
||||
@@ -1253,6 +1256,68 @@ namespace INSTALLER
|
||||
return "";
|
||||
}
|
||||
|
||||
bool IsPortOpen(const char *ip, uint16_t port, int timeout_sec)
|
||||
{
|
||||
int sockfd = socket(AF_INET, SOCK_STREAM, 0);
|
||||
if (sockfd < 0)
|
||||
return 0;
|
||||
|
||||
// Set socket to non-blocking mode
|
||||
int flags = fcntl(sockfd, F_GETFL, 0);
|
||||
fcntl(sockfd, F_SETFL, flags | O_NONBLOCK);
|
||||
|
||||
struct sockaddr_in addr;
|
||||
memset(&addr, 0, sizeof(addr));
|
||||
addr.sin_family = AF_INET;
|
||||
addr.sin_port = htons(port);
|
||||
inet_pton(AF_INET, ip, &addr.sin_addr);
|
||||
|
||||
// Attempt connection
|
||||
int res = connect(sockfd, (struct sockaddr *)&addr, sizeof(addr));
|
||||
|
||||
if (res < 0)
|
||||
{
|
||||
if (errno == EINPROGRESS)
|
||||
{
|
||||
// Wait for connection completion using select()
|
||||
fd_set write_fds;
|
||||
struct timeval timeout;
|
||||
|
||||
FD_ZERO(&write_fds);
|
||||
FD_SET(sockfd, &write_fds);
|
||||
|
||||
timeout.tv_sec = timeout_sec;
|
||||
timeout.tv_usec = 0;
|
||||
|
||||
res = select(sockfd + 1, NULL, &write_fds, NULL, &timeout);
|
||||
|
||||
if (res > 0)
|
||||
{
|
||||
// Check if connection succeeded or failed with an error
|
||||
int so_error;
|
||||
socklen_t len = sizeof(so_error);
|
||||
getsockopt(sockfd, SOL_SOCKET, SO_ERROR, &so_error, &len);
|
||||
|
||||
if (so_error == 0)
|
||||
{
|
||||
// Port is open! Clean up and return success
|
||||
close(sockfd);
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// Connected instantly (e.g., local loopback)
|
||||
close(sockfd);
|
||||
return 1;
|
||||
}
|
||||
|
||||
close(sockfd);
|
||||
return 0; // Port is closed or timed out
|
||||
}
|
||||
|
||||
int StartEzRemoteServer()
|
||||
{
|
||||
char buffer[8192];
|
||||
@@ -1266,13 +1331,11 @@ namespace INSTALLER
|
||||
struct sockaddr_in sockaddr_in;
|
||||
unsigned short server_port = 9090;
|
||||
|
||||
/*
|
||||
if (EzRemoteServerVersion().empty())
|
||||
if (IsPortOpen("127.0.0.1", 6701, 1))
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
*/
|
||||
|
||||
|
||||
filefd = open(SERVER_ELF_PATH, O_RDONLY);
|
||||
if (filefd == -1)
|
||||
{
|
||||
|
||||
@@ -171,4 +171,5 @@ namespace INSTALLER
|
||||
std::string StoreBgInstallHostData(RemoteSettings *remote_settings, const std::string &path);
|
||||
RemoteClient *GetRemoteClient(int site_idx);
|
||||
RemoteClient *GetRemoteClient(RemoteSettings *settings);
|
||||
bool IsPortOpen(const char *ip, uint16_t port, int timeout_sec);
|
||||
}
|
||||
|
||||
+1
-1
@@ -183,7 +183,7 @@ char lang_strings[LANG_STRINGS_NUM][LANG_STR_SIZE] = {
|
||||
"Stop Server", // STR_STOP_SERVER
|
||||
"Warning", // STR_WARNING
|
||||
"The version of ezRemote Server payload running does not match the required version needed by ezRemote Client.", // STR_WARNING_MSG_1
|
||||
"If you are using an auto payload loader, then update the elf that comes with ezRemoteClient package.", // STR_WARNING_MSG_2
|
||||
"If you are using Goldhen payload loader, then update the elf that comes with ezRemoteClient package.", // STR_WARNING_MSG_2
|
||||
"You may goto the Global Settings and restart ezRemote Server with the version that came packaged.", // STR_WARNING_MSG_3
|
||||
"Enable background download", // STR_ENABLE_BG_DOWNLOAD
|
||||
"Minimum background file size (bytes)", // STR_BG_DOWNLOAD_MIN_SIZE
|
||||
|
||||
+4
-1
@@ -329,7 +329,10 @@ int main()
|
||||
atexit(terminate);
|
||||
|
||||
HttpServer::Start();
|
||||
INSTALLER::StartEzRemoteServer();
|
||||
if (INSTALLER::StartEzRemoteServer() < 0)
|
||||
{
|
||||
Util::Notify("Cloud not load ezRemote Server. It is needed for background install and download. Please ensure Bin loader is enabled");
|
||||
}
|
||||
|
||||
GUI::RenderLoop(renderer);
|
||||
SDL_DestroyRenderer(renderer);
|
||||
|
||||
@@ -62,13 +62,11 @@ int mount_large_fs(const char* device, const char* mountpoint, const char* fstyp
|
||||
build_iovec(&iov, &iovlen, "mask", mode, -1);
|
||||
}
|
||||
|
||||
dbglogger_log("##^ [I] Mounting %s \"%s\" to \"%s\"", fstype, device, mountpoint);
|
||||
ret = nmount(iov, iovlen, flags);
|
||||
if (ret < 0) {
|
||||
goto error;
|
||||
}
|
||||
else {
|
||||
dbglogger_log("##^ [I] Success.");
|
||||
}
|
||||
|
||||
error:
|
||||
|
||||
@@ -19,7 +19,6 @@
|
||||
#include "textures.h"
|
||||
#include "sfo.h"
|
||||
#include "system.h"
|
||||
#include "dbglogger.h"
|
||||
|
||||
#define MAX_IMAGE_HEIGHT 980
|
||||
#define MAX_IMAGE_WIDTH 1820
|
||||
@@ -142,7 +141,6 @@ namespace Windows
|
||||
std::string cur_version = INSTALLER::EzRemoteServerVersion();
|
||||
ezremote_server_version_match = cur_version.empty() || (cur_version.compare(EZREMOTE_SERVER_REQUIRED_VERSION) == 0);
|
||||
show_ezremote_server_warning = !ezremote_server_version_match;
|
||||
dbglogger_log("verion=%s, show_warning=%d", cur_version.c_str(), show_ezremote_server_warning);
|
||||
|
||||
Actions::RefreshLocalFiles(false);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user