Compare commits

...

2 Commits

Author SHA1 Message Date
Chee Yee eb4184d488 fixed RPI for all remotes which was broken since 1.18 2024-03-17 15:26:26 -07:00
Chee Yee c328b26480 fix google login 2024-02-26 00:25:41 -08:00
7 changed files with 52 additions and 27 deletions
+2 -1
View File
@@ -66,7 +66,7 @@ add_executable(ezremote_client
add_self(ezremote_client)
add_pkg(ezremote_client ${CMAKE_SOURCE_DIR}/data "RMTC00001" "ezRemote Client" "01.20" 32 0)
add_pkg(ezremote_client ${CMAKE_SOURCE_DIR}/data "RMTC00001" "ezRemote Client" "01.22" 32 0)
target_link_libraries(ezremote_client
c
@@ -82,6 +82,7 @@ target_link_libraries(ezremote_client
jbc
crypto
ssl
curl
lexbor
smb2
nfs
+32 -7
View File
@@ -8,9 +8,9 @@
#include "windows.h"
using httplib::Client;
using httplib::DataSink;
using httplib::Headers;
using httplib::Result;
using httplib::DataSink;
BaseClient::BaseClient(){};
@@ -123,7 +123,7 @@ int BaseClient::Get(const std::string &outputfile, const std::string &path, uint
int BaseClient::GetRange(const std::string &path, DataSink &sink, uint64_t size, uint64_t offset)
{
char range_header[64];
sprintf(range_header, "bytes=%lu-%lu", offset, offset+size-1);
sprintf(range_header, "bytes=%lu-%lu", offset, offset + size - 1);
Headers headers = {{"Range", range_header}};
size_t bytes_read = 0;
if (auto res = client->Get(GetFullPath(path), headers,
@@ -146,7 +146,7 @@ int BaseClient::GetRange(const std::string &path, DataSink &sink, uint64_t size,
int BaseClient::GetRange(const std::string &path, void *buffer, uint64_t size, uint64_t offset)
{
char range_header[64];
sprintf(range_header, "bytes=%lu-%lu", offset, offset+size-1);
sprintf(range_header, "bytes=%lu-%lu", offset, offset + size - 1);
Headers headers = {{"Range", range_header}};
size_t bytes_read = 0;
std::vector<char> body;
@@ -311,12 +311,37 @@ uint32_t BaseClient::SupportedActions()
return REMOTE_ACTION_DOWNLOAD | REMOTE_ACTION_INSTALL | REMOTE_ACTION_EXTRACT;
}
std::string BaseClient::EncodeUrl(const std::string &url)
std::string BaseClient::Escape(const std::string &url)
{
return httplib::detail::encode_url(url);
CURL *curl = curl_easy_init();
if (curl)
{
char *output = curl_easy_escape(curl, url.c_str(), url.length());
if (output)
{
std::string encoded_url = std::string(output);
curl_free(output);
return encoded_url;
}
curl_easy_cleanup(curl);
}
return "";
}
std::string BaseClient::DecodeUrl(const std::string &url)
std::string BaseClient::UnEscape(const std::string &url)
{
return httplib::detail::decode_url(url, true);
CURL *curl = curl_easy_init();
if (curl)
{
int decode_len;
char *output = curl_easy_unescape(curl, url.c_str(), url.length(), &decode_len);
if (output)
{
std::string decoded_url = std::string(output, decode_len);
curl_free(output);
return decoded_url;
}
curl_easy_cleanup(curl);
}
return "";
}
+2 -2
View File
@@ -39,8 +39,8 @@ public:
int Quit();
ClientType clientType();
uint32_t SupportedActions();
static std::string EncodeUrl(const std::string &url);
static std::string DecodeUrl(const std::string &url);
static std::string Escape(const std::string &url);
static std::string UnEscape(const std::string &url);
protected:
httplib::Client *client;
+13 -13
View File
@@ -111,7 +111,7 @@ int GDriveClient::RequestAuthorization()
std::string auth_url = std::string(GOOGLE_AUTH_URL "?client_id=") + gg_app.client_id + "&redirect_uri=" + GetRedirectUrl() +
"&response_type=code&access_type=offline&scope=" + GetScopes() + "&include_granted_scopes=true";
auth_url = EncodeUrl(auth_url);
auth_url = Escape(auth_url);
std::string launch_uri = std::string("pswebbrowser:search?url=") + auth_url;
int ret = sceShellUIUtilLaunchByUri(launch_uri.c_str(), &param);
@@ -222,7 +222,7 @@ int GDriveClient::Rename(const std::string &src, const std::string &dst)
if (src_id.compare("root") == 0 || dst_id.compare("root") == 0 || src_id.compare(src_drive_id) == 0 || dst_id.compare(dst_drive_id) == 0)
return 0;
std::string url = std::string("/drive/v3/files/") + BaseClient::EncodeUrl(src_id);
std::string url = std::string("/drive/v3/files/") + BaseClient::Escape(src_id);
if (!src_drive_id.empty())
url += "?supportsAllDrives=true";
std::string filename = dst.substr(dst.find_last_of("/") + 1);
@@ -276,7 +276,7 @@ int GDriveClient::Head(const std::string &path, void *buffer, uint64_t len)
std::string id = GetValue(path_id_map, path);
std::string drive_id = GetDriveId(path);
std::string url = std::string("/drive/v3/files/") + BaseClient::EncodeUrl(id) + "?alt=media";
std::string url = std::string("/drive/v3/files/") + BaseClient::Escape(id) + "?alt=media";
if (!drive_id.empty())
url += "&supportsAllDrives=true";
Headers headers;
@@ -310,7 +310,7 @@ int GDriveClient::Get(const std::string &outputfile, const std::string &path, ui
std::string id = GetValue(path_id_map, path);
std::string drive_id = GetDriveId(path);
std::string url = std::string("/drive/v3/files/") + BaseClient::EncodeUrl(id) + "?alt=media";
std::string url = std::string("/drive/v3/files/") + BaseClient::Escape(id) + "?alt=media";
if (!drive_id.empty())
url += "&supportsAllDrives=true";
if (auto res = client->Get(url,
@@ -337,7 +337,7 @@ int GDriveClient::GetRange(const std::string &path, DataSink &sink, uint64_t siz
std::string id = GetValue(path_id_map, path);
std::string drive_id = GetDriveId(path);
std::string url = std::string("/drive/v3/files/") + BaseClient::EncodeUrl(id) + "?alt=media";
std::string url = std::string("/drive/v3/files/") + BaseClient::Escape(id) + "?alt=media";
if (!drive_id.empty())
url += "&supportsAllDrives=true";
Headers headers;
@@ -367,7 +367,7 @@ int GDriveClient::GetRange(const std::string &path, void *buffer, uint64_t size,
std::string id = GetValue(path_id_map, path);
std::string drive_id = GetDriveId(path);
std::string url = std::string("/drive/v3/files/") + BaseClient::EncodeUrl(id) + "?alt=media";
std::string url = std::string("/drive/v3/files/") + BaseClient::Escape(id) + "?alt=media";
if (!drive_id.empty())
url += "&supportsAllDrives=true";
Headers headers;
@@ -406,7 +406,7 @@ int GDriveClient::Update(const std::string &inputfile, const std::string &path)
std::string id = GetValue(path_id_map, path);
std::string drive_id = GetDriveId(path);
std::string url = "/upload/drive/v3/files/" + BaseClient::EncodeUrl(id) + "?uploadType=resumable";
std::string url = "/upload/drive/v3/files/" + BaseClient::Escape(id) + "?uploadType=resumable";
if (!drive_id.empty())
url += "&supportsAllDrives=true";
Headers headers;
@@ -553,7 +553,7 @@ int GDriveClient::Size(const std::string &path, int64_t *size)
{
std::string id = GetValue(path_id_map, path);
std::string drive_id = GetDriveId(path);
std::string url = std::string("/drive/v3/files/") + BaseClient::EncodeUrl(id) + "?fields=size";
std::string url = std::string("/drive/v3/files/") + BaseClient::Escape(id) + "?fields=size";
if (!drive_id.empty())
url += "&supportsAllDrives=true";
if (auto res = client->Get(url))
@@ -669,7 +669,7 @@ int GDriveClient::Delete(const std::string &path)
if (strcmp(id.c_str(), "root") == 0)
return 0;
std::string url = std::string("/drive/v3/files/") + BaseClient::EncodeUrl(id);
std::string url = std::string("/drive/v3/files/") + BaseClient::Escape(id);
if (!drive_id.empty())
url += "?supportsAllDrives=true";
if (auto res = client->Delete(url))
@@ -779,8 +779,8 @@ std::vector<DirEntry> GDriveClient::ListDir(const std::string &path)
}
std::string drive_id = GetDriveId(path);
std::string base_url = std::string("/drive/v3/files?q=") + BaseClient::EncodeUrl("\"" + id + "\" in parents") +
"&pageSize=1000&fields=" + BaseClient::EncodeUrl("files(id,mimeType,name,modifiedTime,size),nextPageToken");
std::string base_url = std::string("/drive/v3/files?q=") + BaseClient::Escape("\"" + id + "\" in parents") +
"&pageSize=1000&fields=" + BaseClient::Escape("files(id,mimeType,name,modifiedTime,size),nextPageToken");
if (!drive_id.empty())
{
base_url += "&driveId=" + drive_id + "&corpora=drive&includeItemsFromAllDrives=true&supportsAllDrives=true";
@@ -789,7 +789,7 @@ std::vector<DirEntry> GDriveClient::ListDir(const std::string &path)
bool find_no_parent = false;
if (id.compare(shared_with_me) == 0)
{
base_url = std::string("/drive/v3/files?q=sharedWithMe&pageSize=1000&fields=") + BaseClient::EncodeUrl("files(id,mimeType,name,modifiedTime,size),nextPageToken");
base_url = std::string("/drive/v3/files?q=sharedWithMe&pageSize=1000&fields=") + BaseClient::Escape("files(id,mimeType,name,modifiedTime,size),nextPageToken");
}
std::string next_page_url = base_url;
@@ -867,7 +867,7 @@ std::vector<DirEntry> GDriveClient::ListDir(const std::string &path)
}
}
if (next_page_token != nullptr)
next_page_url = base_url + "&pageToken=" + BaseClient::EncodeUrl(json_object_get_string(next_page_token));
next_page_url = base_url + "&pageToken=" + BaseClient::Escape(json_object_get_string(next_page_token));
else
break;
}
+1 -1
View File
@@ -84,7 +84,7 @@ std::vector<DirEntry> NginxClient::ListDir(const std::string &path)
value = lxb_dom_element_get_attribute(lxb_dom_interface_element(node), (const lxb_char_t *)"href", 4, &value_len);
tmp = std::string((const char *)value, value_len);
tmp = Util::Rtrim(tmp, "/");
tmp = BaseClient::DecodeUrl(tmp);
tmp = BaseClient::UnEscape(tmp);
if (tmp.compare("..") != 0)
{
sprintf(entry.directory, "%s", path.c_str());
+1 -1
View File
@@ -141,7 +141,7 @@ std::vector<DirEntry> RCloneClient::ListDir(const std::string &path)
tmp_string = std::string((const char *)value, value_len);
if (tmp_string[tmp_string.length()-1] == '/')
tmp_string = tmp_string.substr(0, tmp_string.length()-1);
tmp_string = BaseClient::DecodeUrl(tmp_string);
tmp_string = BaseClient::UnEscape(tmp_string);
sprintf(entry.name, "%s", tmp_string.c_str());
sprintf(entry.directory, "%s", path.c_str());
if (path.length() > 0 && path[path.length() - 1] == '/')
+1 -2
View File
@@ -221,8 +221,7 @@ namespace INSTALLER
{
std::string encoded_path = httplib::detail::encode_url(path);
std::string encoded_site_name = httplib::detail::encode_url(remote_settings->site_name);
std::string full_url = std::string("http://localhost:") + std::to_string(http_server_port) + "/rmt_inst" + encoded_site_name + encoded_path;
std::string full_url = std::string("http://localhost:") + std::to_string(http_server_port) + "/rmt_inst/" + encoded_site_name + encoded_path;
return full_url;
}