v0.1.6 - Just catching up
This commit is contained in:
12
src/bud04.c
12
src/bud04.c
@@ -427,8 +427,16 @@ void handle_mirror_request(void) {
|
||||
const char* extension = mime_to_extension(content_type_final);
|
||||
|
||||
// Save file to storage directory using global g_storage_dir variable
|
||||
char filepath[512];
|
||||
snprintf(filepath, sizeof(filepath), "%s/%s%s", g_storage_dir, sha256_hex, extension);
|
||||
char filepath[4096];
|
||||
int filepath_len = snprintf(filepath, sizeof(filepath), "%s/%s%s", g_storage_dir, sha256_hex, extension);
|
||||
if (filepath_len >= (int)sizeof(filepath)) {
|
||||
free_mirror_download(download);
|
||||
send_error_response(500, "file_error",
|
||||
"File path too long",
|
||||
"Internal server error during file path construction");
|
||||
log_request("PUT", "/mirror", uploader_pubkey ? "authenticated" : "anonymous", 500);
|
||||
return;
|
||||
}
|
||||
|
||||
FILE* outfile = fopen(filepath, "wb");
|
||||
if (!outfile) {
|
||||
|
||||
@@ -10,8 +10,8 @@
|
||||
// Version information (auto-updated by build system)
|
||||
#define VERSION_MAJOR 0
|
||||
#define VERSION_MINOR 1
|
||||
#define VERSION_PATCH 5
|
||||
#define VERSION "v0.1.5"
|
||||
#define VERSION_PATCH 6
|
||||
#define VERSION "v0.1.6"
|
||||
|
||||
#include <stddef.h>
|
||||
#include <stdint.h>
|
||||
|
||||
111
src/main.c
111
src/main.c
@@ -1390,11 +1390,66 @@ if (!config_loaded /* && !initialize_server_config() */) {
|
||||
/////////////////////////////////////////////////////////////////////
|
||||
// CENTRALIZED REQUEST VALIDATION SYSTEM
|
||||
/////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
// Special case: Root endpoint is public and doesn't require authentication
|
||||
if (strcmp(request_method, "GET") == 0 && strcmp(request_uri, "/") == 0) {
|
||||
// Handle GET / requests - Server info endpoint
|
||||
printf("Status: 200 OK\r\n");
|
||||
printf("Content-Type: application/json\r\n\r\n");
|
||||
printf("{\n");
|
||||
printf(" \"server\": \"ginxsom\",\n");
|
||||
printf(" \"version\": \"%s\",\n", VERSION);
|
||||
printf(" \"description\": \"Ginxsom Blossom Server\",\n");
|
||||
printf(" \"endpoints\": {\n");
|
||||
printf(" \"blob_get\": \"GET /<sha256>\",\n");
|
||||
printf(" \"blob_head\": \"HEAD /<sha256>\",\n");
|
||||
printf(" \"upload\": \"PUT /upload\",\n");
|
||||
printf(" \"upload_requirements\": \"HEAD /upload\",\n");
|
||||
printf(" \"list\": \"GET /list/<pubkey>\",\n");
|
||||
printf(" \"delete\": \"DELETE /<sha256>\",\n");
|
||||
printf(" \"mirror\": \"PUT /mirror\",\n");
|
||||
printf(" \"report\": \"PUT /report\",\n");
|
||||
printf(" \"health\": \"GET /health\",\n");
|
||||
printf(" \"auth\": \"GET /auth\"\n");
|
||||
printf(" },\n");
|
||||
printf(" \"supported_buds\": [\n");
|
||||
printf(" \"BUD-01\",\n");
|
||||
printf(" \"BUD-02\",\n");
|
||||
printf(" \"BUD-04\",\n");
|
||||
printf(" \"BUD-06\",\n");
|
||||
printf(" \"BUD-08\",\n");
|
||||
printf(" \"BUD-09\"\n");
|
||||
printf(" ],\n");
|
||||
printf(" \"limits\": {\n");
|
||||
printf(" \"max_upload_size\": 104857600,\n");
|
||||
printf(" \"supported_mime_types\": [\n");
|
||||
printf(" \"image/jpeg\",\n");
|
||||
printf(" \"image/png\",\n");
|
||||
printf(" \"image/webp\",\n");
|
||||
printf(" \"image/gif\",\n");
|
||||
printf(" \"video/mp4\",\n");
|
||||
printf(" \"video/webm\",\n");
|
||||
printf(" \"audio/mpeg\",\n");
|
||||
printf(" \"audio/ogg\",\n");
|
||||
printf(" \"text/plain\",\n");
|
||||
printf(" \"application/pdf\"\n");
|
||||
printf(" ]\n");
|
||||
printf(" },\n");
|
||||
printf(" \"authentication\": {\n");
|
||||
printf(" \"required_for_upload\": false,\n");
|
||||
printf(" \"required_for_delete\": true,\n");
|
||||
printf(" \"required_for_list\": false,\n");
|
||||
printf(" \"nip42_enabled\": true\n");
|
||||
printf(" }\n");
|
||||
printf("}\n");
|
||||
log_request("GET", "/", "server_info", 200);
|
||||
continue;
|
||||
}
|
||||
|
||||
// Determine operation from request method and URI
|
||||
const char *operation = "unknown";
|
||||
const char *resource_hash = NULL;
|
||||
|
||||
|
||||
if (strcmp(request_method, "HEAD") == 0 && strcmp(request_uri, "/upload") == 0) {
|
||||
operation = "head_upload";
|
||||
} else if (strcmp(request_method, "HEAD") == 0) {
|
||||
@@ -1562,6 +1617,58 @@ if (!config_loaded /* && !initialize_server_config() */) {
|
||||
"Pubkey must be 64 hex characters");
|
||||
log_request("GET", request_uri, "none", 400);
|
||||
}
|
||||
} else if (strcmp(request_method, "GET") == 0 &&
|
||||
strcmp(request_uri, "/") == 0) {
|
||||
// Handle GET / requests - Server info endpoint
|
||||
printf("Status: 200 OK\r\n");
|
||||
printf("Content-Type: application/json\r\n\r\n");
|
||||
printf("{\n");
|
||||
printf(" \"server\": \"ginxsom\",\n");
|
||||
printf(" \"version\": \"%s\",\n", VERSION);
|
||||
printf(" \"description\": \"Ginxsom Blossom Server\",\n");
|
||||
printf(" \"endpoints\": {\n");
|
||||
printf(" \"blob_get\": \"GET /<sha256>\",\n");
|
||||
printf(" \"blob_head\": \"HEAD /<sha256>\",\n");
|
||||
printf(" \"upload\": \"PUT /upload\",\n");
|
||||
printf(" \"upload_requirements\": \"HEAD /upload\",\n");
|
||||
printf(" \"list\": \"GET /list/<pubkey>\",\n");
|
||||
printf(" \"delete\": \"DELETE /<sha256>\",\n");
|
||||
printf(" \"mirror\": \"PUT /mirror\",\n");
|
||||
printf(" \"report\": \"PUT /report\",\n");
|
||||
printf(" \"health\": \"GET /health\",\n");
|
||||
printf(" \"auth\": \"GET /auth\"\n");
|
||||
printf(" },\n");
|
||||
printf(" \"supported_buds\": [\n");
|
||||
printf(" \"BUD-01\",\n");
|
||||
printf(" \"BUD-02\",\n");
|
||||
printf(" \"BUD-04\",\n");
|
||||
printf(" \"BUD-06\",\n");
|
||||
printf(" \"BUD-08\",\n");
|
||||
printf(" \"BUD-09\"\n");
|
||||
printf(" ],\n");
|
||||
printf(" \"limits\": {\n");
|
||||
printf(" \"max_upload_size\": 104857600,\n");
|
||||
printf(" \"supported_mime_types\": [\n");
|
||||
printf(" \"image/jpeg\",\n");
|
||||
printf(" \"image/png\",\n");
|
||||
printf(" \"image/webp\",\n");
|
||||
printf(" \"image/gif\",\n");
|
||||
printf(" \"video/mp4\",\n");
|
||||
printf(" \"video/webm\",\n");
|
||||
printf(" \"audio/mpeg\",\n");
|
||||
printf(" \"audio/ogg\",\n");
|
||||
printf(" \"text/plain\",\n");
|
||||
printf(" \"application/pdf\"\n");
|
||||
printf(" ]\n");
|
||||
printf(" },\n");
|
||||
printf(" \"authentication\": {\n");
|
||||
printf(" \"required_for_upload\": false,\n");
|
||||
printf(" \"required_for_delete\": true,\n");
|
||||
printf(" \"required_for_list\": false,\n");
|
||||
printf(" \"nip42_enabled\": true\n");
|
||||
printf(" }\n");
|
||||
printf("}\n");
|
||||
log_request("GET", "/", "server_info", 200);
|
||||
} else if (strcmp(request_method, "GET") == 0 &&
|
||||
strcmp(request_uri, "/auth") == 0) {
|
||||
// Handle GET /auth requests using the existing handler
|
||||
|
||||
Reference in New Issue
Block a user