Skip to content

Commit 935e6f5

Browse files
committed
Merge branch 'add_s3' into s3
2 parents 1ad882a + 9495430 commit 935e6f5

File tree

18 files changed

+2357
-39
lines changed

18 files changed

+2357
-39
lines changed

configuration.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1619,10 +1619,17 @@ static struct config_array_setting *populate_settings_array(
16191619

16201620
#ifdef HAVE_NETWORKING
16211621
SETTING_ARRAY("netplay_mitm_server", settings->arrays.netplay_mitm_server, false, NULL, true);
1622+
#ifdef HAVE_CLOUDSYNC
16221623
SETTING_ARRAY("webdav_url", settings->arrays.webdav_url, false, NULL, true);
16231624
SETTING_ARRAY("webdav_username", settings->arrays.webdav_username, false, NULL, true);
16241625
SETTING_ARRAY("webdav_password", settings->arrays.webdav_password, false, NULL, true);
16251626
SETTING_ARRAY("google_drive_refresh_token", settings->arrays.google_drive_refresh_token, false, NULL, true);
1627+
#ifdef HAVE_S3
1628+
SETTING_ARRAY("s3_url", settings->arrays.s3_url, false, NULL, true);
1629+
SETTING_ARRAY("access_key_id", settings->arrays.access_key_id, false, NULL, true);
1630+
SETTING_ARRAY("secret_access_key", settings->arrays.secret_access_key, false, NULL, true);
1631+
#endif
1632+
#endif
16261633
SETTING_ARRAY("youtube_stream_key", settings->arrays.youtube_stream_key, true, NULL, true);
16271634
SETTING_ARRAY("twitch_stream_key", settings->arrays.twitch_stream_key, true, NULL, true);
16281635
SETTING_ARRAY("facebook_stream_key", settings->arrays.facebook_stream_key, true, NULL, true);

configuration.h

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -541,10 +541,19 @@ typedef struct settings
541541
char audio_device[NAME_MAX_LENGTH];
542542
char camera_device[NAME_MAX_LENGTH];
543543
char netplay_mitm_server[NAME_MAX_LENGTH];
544+
#ifdef HAVE_NETWORKING
545+
#ifdef HAVE_CLOUDSYNC
544546
char webdav_url[NAME_MAX_LENGTH];
545547
char webdav_username[NAME_MAX_LENGTH];
546548
char webdav_password[NAME_MAX_LENGTH];
547549
char google_drive_refresh_token[2048];
550+
#ifdef HAVE_S3
551+
char s3_url[NAME_MAX_LENGTH];
552+
char access_key_id[128];
553+
char secret_access_key[186]; /* TODO/RESEARCH - check size, ex https://github.com/winscp/winscp/pull/15/files */
554+
#endif
555+
#endif
556+
#endif
548557

549558
char crt_switch_timings[NAME_MAX_LENGTH];
550559
char input_reserved_devices[MAX_USERS][NAME_MAX_LENGTH];

griffin/griffin.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1721,6 +1721,9 @@ CLOUD SYNC
17211721
#ifdef HAVE_SMBCLIENT
17221722
#include "../network/cloud_sync/smb.c"
17231723
#endif
1724+
#ifdef HAVE_S3
1725+
#include "../network/cloud_sync/s3.c"
1726+
#endif
17241727
#endif
17251728

17261729
/*============================================================

intl/msg_hash_lbl.h

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3550,6 +3550,18 @@ MSG_HASH(
35503550
MENU_ENUM_LABEL_CLOUD_SYNC_PASSWORD,
35513551
"cloud_sync_password"
35523552
)
3553+
MSG_HASH(
3554+
MENU_ENUM_LABEL_CLOUD_SYNC_ACCESS_KEY_ID,
3555+
"cloud_sync_access_key_id"
3556+
)
3557+
MSG_HASH(
3558+
MENU_ENUM_LABEL_CLOUD_SYNC_SECRET_ACCESS_KEY,
3559+
"cloud_sync_secret_access_key"
3560+
)
3561+
MSG_HASH(
3562+
MENU_ENUM_LABEL_CLOUD_SYNC_S3_URL,
3563+
"cloud_sync_s3_url"
3564+
)
35533565
MSG_HASH(
35543566
MENU_ENUM_LABEL_SCAN_DIRECTORY,
35553567
"scan_directory"

intl/msg_hash_us.h

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1158,6 +1158,30 @@ MSG_HASH(
11581158
MENU_ENUM_SUBLABEL_CLOUD_SYNC_PASSWORD,
11591159
"Your password for your cloud storage account."
11601160
)
1161+
MSG_HASH(
1162+
MENU_ENUM_LABEL_VALUE_CLOUD_SYNC_ACCESS_KEY_ID,
1163+
"Access Key ID"
1164+
)
1165+
MSG_HASH(
1166+
MENU_ENUM_SUBLABEL_CLOUD_SYNC_ACCESS_KEY_ID,
1167+
"Your access key ID for your cloud storage account."
1168+
)
1169+
MSG_HASH(
1170+
MENU_ENUM_LABEL_VALUE_CLOUD_SYNC_SECRET_ACCESS_KEY,
1171+
"Secret Access Key"
1172+
)
1173+
MSG_HASH(
1174+
MENU_ENUM_SUBLABEL_CLOUD_SYNC_SECRET_ACCESS_KEY,
1175+
"Your secret access key for your cloud storage account."
1176+
)
1177+
MSG_HASH(
1178+
MENU_ENUM_LABEL_VALUE_CLOUD_SYNC_S3_URL,
1179+
"S3 URL"
1180+
)
1181+
MSG_HASH(
1182+
MENU_ENUM_SUBLABEL_CLOUD_SYNC_S3_URL,
1183+
"Your S3 endpoint URL for cloud storage."
1184+
)
11611185
MSG_HASH(
11621186
MENU_ENUM_LABEL_VALUE_LOGGING_SETTINGS,
11631187
"Logging"

libretro-common/include/net/net_http.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,7 @@ bool net_http_error(struct http_t *state);
106106
* If the status is not 20x and accept_error is false, it returns NULL.
107107
**/
108108
struct string_list *net_http_headers(struct http_t *state);
109+
struct string_list *net_http_headers_ex(struct http_t *state, bool accept_error);
109110

110111
/**
111112
* net_http_data:

libretro-common/net/net_http.c

Lines changed: 79 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
#include <stdio.h>
2424
#include <stdlib.h>
2525
#include <ctype.h>
26+
#include <errno.h>
2627

2728
#include <net/net_http.h>
2829
#include <net/net_compat.h>
@@ -133,6 +134,54 @@ struct http_connection_t
133134
bool ssl;
134135
};
135136

137+
static void net_http_log_transport_state(
138+
const struct http_t *state, const char *stage, ssize_t io_len)
139+
{
140+
#if defined(DEBUG)
141+
const char *method = "GET";
142+
const char *domain = "<null>";
143+
const char *path = "<null>";
144+
int port = 0;
145+
int fd = -1;
146+
int connected = 0;
147+
148+
if (state)
149+
{
150+
method = state->request.method ? state->request.method : "GET";
151+
domain = state->request.domain ? state->request.domain : "<null>";
152+
path = state->request.path ? state->request.path : "<null>";
153+
port = state->request.port;
154+
155+
if (state->conn)
156+
{
157+
fd = state->conn->fd;
158+
connected = state->conn->connected ? 1 : 0;
159+
}
160+
}
161+
162+
fprintf(stderr,
163+
"[net_http] %s: method=%s host=%s port=%d path=/%s ssl=%d fd=%d connected=%d request_sent=%d err=%d io_len=%ld errno=%d (%s)\n",
164+
stage ? stage : "unknown",
165+
method,
166+
domain,
167+
port,
168+
path,
169+
state ? (state->ssl ? 1 : 0) : 0,
170+
fd,
171+
connected,
172+
state ? (state->request_sent ? 1 : 0) : 0,
173+
state ? (state->err ? 1 : 0) : 0,
174+
(long)io_len,
175+
errno,
176+
strerror(errno));
177+
fflush(stderr);
178+
#else
179+
(void)state;
180+
(void)stage;
181+
(void)io_len;
182+
#endif
183+
}
184+
136185
struct dns_cache_entry
137186
{
138187
char *domain;
@@ -920,13 +969,16 @@ static bool net_http_new_socket(struct http_t *state)
920969
int fd;
921970
if (!entry->addr)
922971
{
972+
net_http_log_transport_state(state, "dns_lookup_failed", -1);
923973
UNLOCK_DNS_CACHE();
924974
return false;
925975
}
926976
addr = entry->addr;
927977
fd = socket(addr->ai_family, addr->ai_socktype, addr->ai_protocol);
928978
if (fd >= 0)
929979
state->conn = net_http_conn_pool_add(state->request.domain, state->request.port, fd, state->ssl);
980+
else
981+
net_http_log_transport_state(state, "socket_create_failed", -1);
930982
/* still waiting on thread */
931983
UNLOCK_DNS_CACHE();
932984
return (fd >= 0);
@@ -969,12 +1021,15 @@ static bool net_http_connect(struct http_t *state)
9691021
if (state->ssl)
9701022
{
9711023
if (!conn)
1024+
{
1025+
net_http_log_transport_state(state, "connect_missing_dns_or_conn", -1);
9721026
return false;
973-
1027+
}
9741028
for (next_addr = addr; conn->fd >= 0; conn->fd = socket_next((void**)&next_addr))
9751029
{
9761030
if (!(conn->ssl_ctx = ssl_socket_init(conn->fd, state->request.domain)))
9771031
{
1032+
net_http_log_transport_state(state, "ssl_init_failed", -1);
9781033
socket_close(conn->fd);
9791034
break;
9801035
}
@@ -992,6 +1047,7 @@ static bool net_http_connect(struct http_t *state)
9921047

9931048
if (ssl_socket_connect(conn->ssl_ctx, next_addr, timeout, true) < 0)
9941049
{
1050+
net_http_log_transport_state(state, "ssl_connect_failed", -1);
9951051
ssl_socket_close(conn->ssl_ctx);
9961052
ssl_socket_free(conn->ssl_ctx);
9971053
conn->ssl_ctx = NULL;
@@ -1019,6 +1075,7 @@ static bool net_http_connect(struct http_t *state)
10191075
return true;
10201076
}
10211077

1078+
net_http_log_transport_state(state, "socket_connect_failed", -1);
10221079
socket_close(conn->fd);
10231080
}
10241081
conn->fd = -1; /* already closed */
@@ -1039,14 +1096,20 @@ static void net_http_send_str(
10391096
{
10401097
if (!ssl_socket_send_all_blocking(
10411098
state->conn->ssl_ctx, text, text_size, true))
1099+
{
10421100
state->err = true;
1101+
net_http_log_transport_state(state, "ssl_send_failed", -1);
1102+
}
10431103
}
10441104
else
10451105
#endif
10461106
{
10471107
if (!socket_send_all_blocking(
10481108
state->conn->fd, text, text_size, true))
1109+
{
10491110
state->err = true;
1111+
net_http_log_transport_state(state, "socket_send_failed", -1);
1112+
}
10501113
}
10511114
}
10521115

@@ -1097,9 +1160,12 @@ static bool net_http_send_request(struct http_t *state)
10971160
size_t _len, len;
10981161
char *len_str = NULL;
10991162

1100-
if (!request->postdata && !string_is_equal(request->method, "PUT"))
1163+
if (!request->postdata &&
1164+
!string_is_equal(request->method, "PUT") &&
1165+
request->contentlength > 0)
11011166
{
11021167
state->err = true;
1168+
net_http_log_transport_state(state, "post_without_payload", -1);
11031169
return true;
11041170
}
11051171

@@ -1460,6 +1526,7 @@ bool net_http_update(struct http_t *state, size_t* progress, size_t* total)
14601526
{
14611527
if (_len < 0 || state->err)
14621528
{
1529+
net_http_log_transport_state(state, "receive_header_failed", _len);
14631530
net_http_conn_pool_remove(state->conn);
14641531
state->conn = NULL;
14651532
state->err = true;
@@ -1474,6 +1541,7 @@ bool net_http_update(struct http_t *state, size_t* progress, size_t* total)
14741541
{
14751542
if (!net_http_receive_body(state, _len))
14761543
{
1544+
net_http_log_transport_state(state, "receive_body_failed", _len);
14771545
net_http_conn_pool_remove(state->conn);
14781546
state->conn = NULL;
14791547
state->err = true;
@@ -1548,13 +1616,20 @@ int net_http_status(struct http_t *state)
15481616
* caller of net_http_new; it is not freed by net_http_delete().
15491617
* If the status is not 20x and accept_err is false, it returns NULL.
15501618
**/
1551-
struct string_list *net_http_headers(struct http_t *state)
1619+
struct string_list *net_http_headers_ex(struct http_t *state, bool accept_err)
15521620
{
1553-
if (!state || !state->err)
1621+
if (!state)
1622+
return NULL;
1623+
if (!accept_err && !state->err)
15541624
return NULL;
15551625
return state->response.headers;
15561626
}
15571627

1628+
struct string_list *net_http_headers(struct http_t *state)
1629+
{
1630+
return net_http_headers_ex(state, false);
1631+
}
1632+
15581633
/**
15591634
* net_http_data:
15601635
*

menu/cbs/menu_cbs_sublabel.c

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -262,8 +262,11 @@ DEFAULT_SUBLABEL_MACRO(action_bind_sublabel_cloud_sync_sync_thumbs, MENU_
262262
DEFAULT_SUBLABEL_MACRO(action_bind_sublabel_cloud_sync_sync_system, MENU_ENUM_SUBLABEL_CLOUD_SYNC_SYNC_SYSTEM)
263263
DEFAULT_SUBLABEL_MACRO(action_bind_sublabel_cloud_sync_driver, MENU_ENUM_SUBLABEL_CLOUD_SYNC_DRIVER)
264264
DEFAULT_SUBLABEL_MACRO(action_bind_sublabel_cloud_sync_url, MENU_ENUM_SUBLABEL_CLOUD_SYNC_URL)
265+
DEFAULT_SUBLABEL_MACRO(action_bind_sublabel_cloud_sync_s3_url, MENU_ENUM_SUBLABEL_CLOUD_SYNC_S3_URL)
265266
DEFAULT_SUBLABEL_MACRO(action_bind_sublabel_cloud_sync_username, MENU_ENUM_SUBLABEL_CLOUD_SYNC_USERNAME)
266267
DEFAULT_SUBLABEL_MACRO(action_bind_sublabel_cloud_sync_password, MENU_ENUM_SUBLABEL_CLOUD_SYNC_PASSWORD)
268+
DEFAULT_SUBLABEL_MACRO(action_bind_sublabel_cloud_sync_access_key_id, MENU_ENUM_SUBLABEL_CLOUD_SYNC_ACCESS_KEY_ID)
269+
DEFAULT_SUBLABEL_MACRO(action_bind_sublabel_cloud_sync_secret_access_key, MENU_ENUM_SUBLABEL_CLOUD_SYNC_SECRET_ACCESS_KEY)
267270
DEFAULT_SUBLABEL_MACRO(action_bind_sublabel_logging_settings_list, MENU_ENUM_SUBLABEL_LOGGING_SETTINGS)
268271
DEFAULT_SUBLABEL_MACRO(action_bind_sublabel_user_interface_settings_list, MENU_ENUM_SUBLABEL_USER_INTERFACE_SETTINGS)
269272
DEFAULT_SUBLABEL_MACRO(action_bind_sublabel_ai_service_settings_list, MENU_ENUM_SUBLABEL_AI_SERVICE_SETTINGS)
@@ -5249,12 +5252,21 @@ int menu_cbs_init_bind_sublabel(menu_file_list_cbs_t *cbs,
52495252
case MENU_ENUM_LABEL_CLOUD_SYNC_URL:
52505253
BIND_ACTION_SUBLABEL(cbs, action_bind_sublabel_cloud_sync_url);
52515254
break;
5255+
case MENU_ENUM_LABEL_CLOUD_SYNC_S3_URL:
5256+
BIND_ACTION_SUBLABEL(cbs, action_bind_sublabel_cloud_sync_s3_url);
5257+
break;
52525258
case MENU_ENUM_LABEL_CLOUD_SYNC_USERNAME:
52535259
BIND_ACTION_SUBLABEL(cbs, action_bind_sublabel_cloud_sync_username);
52545260
break;
52555261
case MENU_ENUM_LABEL_CLOUD_SYNC_PASSWORD:
52565262
BIND_ACTION_SUBLABEL(cbs, action_bind_sublabel_cloud_sync_password);
52575263
break;
5264+
case MENU_ENUM_LABEL_CLOUD_SYNC_ACCESS_KEY_ID:
5265+
BIND_ACTION_SUBLABEL(cbs, action_bind_sublabel_cloud_sync_access_key_id);
5266+
break;
5267+
case MENU_ENUM_LABEL_CLOUD_SYNC_SECRET_ACCESS_KEY:
5268+
BIND_ACTION_SUBLABEL(cbs, action_bind_sublabel_cloud_sync_secret_access_key);
5269+
break;
52585270
case MENU_ENUM_LABEL_LOGGING_SETTINGS:
52595271
BIND_ACTION_SUBLABEL(cbs, action_bind_sublabel_logging_settings_list);
52605272
break;

0 commit comments

Comments
 (0)