Fix pastebin

This commit is contained in:
Michael Theall 2024-01-10 22:09:01 -06:00
parent e6e6d83dcf
commit 365945d7e8
3 changed files with 23 additions and 89 deletions

View File

@ -1,74 +0,0 @@
-----BEGIN CERTIFICATE-----
MIIFNzCCBN6gAwIBAgIQDY30H+7eX+UAL96D4Q4pCTAKBggqhkjOPQQDAjBKMQsw
CQYDVQQGEwJVUzEZMBcGA1UEChMQQ2xvdWRmbGFyZSwgSW5jLjEgMB4GA1UEAxMX
Q2xvdWRmbGFyZSBJbmMgRUNDIENBLTMwHhcNMjIwNzA2MDAwMDAwWhcNMjMwNzA2
MjM1OTU5WjB1MQswCQYDVQQGEwJVUzETMBEGA1UECBMKQ2FsaWZvcm5pYTEWMBQG
A1UEBxMNU2FuIEZyYW5jaXNjbzEZMBcGA1UEChMQQ2xvdWRmbGFyZSwgSW5jLjEe
MBwGA1UEAxMVc25pLmNsb3VkZmxhcmVzc2wuY29tMFkwEwYHKoZIzj0CAQYIKoZI
zj0DAQcDQgAEYORbsKsnHR3Fgl5NnfC69t+zjW+thQ8/EsuWWyfJ/BceQF8t1h26
EN6BRaMb1c5UTpX1tI5JMgaXxXpFtESRI6OCA3kwggN1MB8GA1UdIwQYMBaAFKXO
N+rrsHUOlGeItEX62SQQh5YfMB0GA1UdDgQWBBQQcujrZ4f9+4Oh6nEzkQZ52Dku
zzA+BgNVHREENzA1gg4qLmhhc3RlYmluLmNvbYIVc25pLmNsb3VkZmxhcmVzc2wu
Y29tggxoYXN0ZWJpbi5jb20wDgYDVR0PAQH/BAQDAgeAMB0GA1UdJQQWMBQGCCsG
AQUFBwMBBggrBgEFBQcDAjB7BgNVHR8EdDByMDegNaAzhjFodHRwOi8vY3JsMy5k
aWdpY2VydC5jb20vQ2xvdWRmbGFyZUluY0VDQ0NBLTMuY3JsMDegNaAzhjFodHRw
Oi8vY3JsNC5kaWdpY2VydC5jb20vQ2xvdWRmbGFyZUluY0VDQ0NBLTMuY3JsMD4G
A1UdIAQ3MDUwMwYGZ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7gQCvlYpNRhcL0EYWoSihfVCr3FvDB81ukMJY2GQE/szKN+OMY3EU/t3Wgx
jkzSswF07r51XgdIGn9w/xZchMB5hbgF/X++ZRGjD8ACtPhSNzkE1akxehi/oCr0
Epn3o0WC4zxe9Z2etciefC7IpJ5OCBRLbf1wbWsaY71k5h+3zvDyny67G7fyUIhz
ksLi4xaNmjICq44Y3ekQEe5+NauQrz4wlHrQMz2nZQ/1/I6eYs9HRCwBXbsdtTLS
R9I4LtD+gdwyah617jzV/OeBHRnDJELqYzmp
-----END CERTIFICATE-----

View File

@ -110,11 +110,13 @@ if(NINTENDO_SWITCH)
find_package(PkgConfig REQUIRED) find_package(PkgConfig REQUIRED)
pkg_check_modules(CURL libcurl IMPORTED_TARGET) pkg_check_modules(CURL libcurl IMPORTED_TARGET)
pkg_check_modules(ZSTD libzstd IMPORTED_TARGET) pkg_check_modules(ZSTD libzstd IMPORTED_TARGET)
pkg_check_modules(jansson jansson IMPORTED_TARGET)
target_link_libraries(${FTPD_TARGET} PRIVATE target_link_libraries(${FTPD_TARGET} PRIVATE
deko3d$<$<CONFIG:Debug>:d> deko3d$<$<CONFIG:Debug>:d>
PkgConfig::CURL PkgConfig::CURL
PkgConfig::ZSTD PkgConfig::ZSTD
PkgConfig::jansson
) )
target_sources(${FTPD_TARGET} PRIVATE target_sources(${FTPD_TARGET} PRIVATE
@ -217,10 +219,12 @@ elseif(NINTENDO_3DS)
find_package(PkgConfig REQUIRED) find_package(PkgConfig REQUIRED)
pkg_check_modules(CURL libcurl IMPORTED_TARGET) pkg_check_modules(CURL libcurl IMPORTED_TARGET)
pkg_check_modules(jansson jansson IMPORTED_TARGET)
target_link_libraries(${FTPD_TARGET} PRIVATE target_link_libraries(${FTPD_TARGET} PRIVATE
citro3d$<$<CONFIG:Debug>:d> citro3d$<$<CONFIG:Debug>:d>
PkgConfig::CURL PkgConfig::CURL
PkgConfig::jansson
) )
target_sources(${FTPD_TARGET} PRIVATE target_sources(${FTPD_TARGET} PRIVATE
@ -236,10 +240,6 @@ elseif(NINTENDO_3DS)
dkp_add_asset_target(${PROJECT_NAME}_romfs ${CMAKE_CURRENT_BINARY_DIR}/romfs) dkp_add_asset_target(${PROJECT_NAME}_romfs ${CMAKE_CURRENT_BINARY_DIR}/romfs)
add_custom_target(ca_cert DEPENDS 3ds/romfs/sni.cloudflaressl.com.ca)
dkp_set_target_file(ca_cert ${CMAKE_CURRENT_SOURCE_DIR}/3ds/romfs/sni.cloudflaressl.com.ca)
dkp_install_assets(${PROJECT_NAME}_romfs TARGETS ca_cert)
ctr_add_graphics_target(gfx ATLAS ctr_add_graphics_target(gfx ATLAS
OPTIONS OPTIONS
-f rgba -z auto -H gfx.h -f rgba -z auto -H gfx.h
@ -293,11 +293,13 @@ elseif(NINTENDO_DS)
ICON nds/icon.bmp ICON nds/icon.bmp
) )
else() else()
find_package(PkgConfig REQUIRED)
find_package(glfw3 REQUIRED) find_package(glfw3 REQUIRED)
find_package(CURL REQUIRED) find_package(CURL REQUIRED)
find_package(OpenGL REQUIRED) find_package(OpenGL REQUIRED)
pkg_check_modules(jansson jansson IMPORTED_TARGET)
target_link_libraries(${FTPD_TARGET} PRIVATE CURL::libcurl glfw OpenGL::GL) target_link_libraries(${FTPD_TARGET} PRIVATE CURL::libcurl glfw OpenGL::GL PkgConfig::jansson)
target_compile_definitions(${FTPD_TARGET} PRIVATE target_compile_definitions(${FTPD_TARGET} PRIVATE
FTPDCONFIG="${PROJECT_NAME}.cfg" FTPDCONFIG="${PROJECT_NAME}.cfg"

View File

@ -32,6 +32,10 @@
#include <dswifi9.h> #include <dswifi9.h>
#endif #endif
#ifndef CLASSIC
#include <jansson.h>
#endif
#include <arpa/inet.h> #include <arpa/inet.h>
#include <sys/statvfs.h> #include <sys/statvfs.h>
#include <unistd.h> #include <unistd.h>
@ -457,11 +461,6 @@ void FtpServer::showMenu ()
auto const handle = curl_easy_init (); auto const handle = curl_easy_init ();
#ifdef __3DS__
// 3DS CA fails peer verification, so add CA here
curl_easy_setopt (handle, CURLOPT_CAINFO, "romfs:/sni.cloudflaressl.com.ca");
#endif
#ifndef NDEBUG #ifndef NDEBUG
curl_easy_setopt (handle, CURLOPT_DEBUGFUNCTION, &curlDebug); curl_easy_setopt (handle, CURLOPT_DEBUGFUNCTION, &curlDebug);
curl_easy_setopt (handle, CURLOPT_DEBUGDATA, nullptr); curl_easy_setopt (handle, CURLOPT_DEBUGDATA, nullptr);
@ -474,9 +473,9 @@ void FtpServer::showMenu ()
curl_easy_setopt (handle, CURLOPT_WRITEDATA, &m_uploadLogResult); curl_easy_setopt (handle, CURLOPT_WRITEDATA, &m_uploadLogResult);
// set headers // set headers
static char contentType[] = "Content-Type: multipart/form-data"; static char contentType[] = "Content-Type: text/plain";
static curl_slist const headers = {contentType, nullptr}; static curl_slist const headers = {contentType, nullptr};
curl_easy_setopt (handle, CURLOPT_URL, "https://hastebin.com/documents"); curl_easy_setopt (handle, CURLOPT_URL, "https://pastie.io/documents");
curl_easy_setopt (handle, CURLOPT_HTTPHEADER, &headers); curl_easy_setopt (handle, CURLOPT_HTTPHEADER, &headers);
// set form data // set form data
@ -864,11 +863,18 @@ void FtpServer::loop ()
if (msg->data.result != CURLE_OK) if (msg->data.result != CURLE_OK)
info ("cURL finished with status %d\n", msg->data.result); info ("cURL finished with status %d\n", msg->data.result);
if (m_uploadLogResult.starts_with ("{\"key\":\"")) json_error_t err;
auto const root = json_loads (m_uploadLogResult.c_str (), 0, &err);
if (json_is_object (root))
{ {
auto const key = m_uploadLogResult.substr (8, 10); auto const key = json_object_get (root, "key");
info ("https://hastebin.com/%s\n", key.c_str ()); if (json_is_string (key))
info ("Log uploaded to https://pastie.io/%s\n", json_string_value (key));
} }
else
error ("Failed to upload log\n");
json_decref (root);
curl_multi_remove_handle (m_uploadLogCurlM, m_uploadLogCurl); curl_multi_remove_handle (m_uploadLogCurlM, m_uploadLogCurl);
curl_easy_cleanup (m_uploadLogCurl); curl_easy_cleanup (m_uploadLogCurl);