]> git.ipfire.org Git - telemetry.git/commitdiff
request: Add option to send requests to Unix sockets
authorMichael Tremer <michael.tremer@ipfire.org>
Fri, 10 Jul 2026 11:12:38 +0000 (11:12 +0000)
committerMichael Tremer <michael.tremer@ipfire.org>
Fri, 10 Jul 2026 11:12:38 +0000 (11:12 +0000)
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
src/daemon/request.c
src/daemon/request.h

index 0be94ad2deab02587ea5aef726b1f4d29eae4dee..a1f5809fa3c7d9eb17b35712c626907c27c4e239 100644 (file)
@@ -26,6 +26,7 @@
 #include "buffer.h"
 #include "client.h"
 #include "ctx.h"
+#include "file.h"
 #include "request.h"
 
 struct td_request {
@@ -269,6 +270,19 @@ int td_request_set_url(td_request* self, const char* url) {
        return 0;
 }
 
+int td_request_set_socket(td_request* self, const char* path) {
+       int r;
+
+       // Set the socket path
+       r = curl_easy_setopt(self->handle, CURLOPT_ABSTRACT_UNIX_SOCKET, path);
+       if (r < 0) {
+               ERROR(self->ctx, "Failed to set socket: %s\n", curl_easy_strerror(r));
+               return -EINVAL;
+       }
+
+       return 0;
+}
+
 void td_request_on_success(td_request* self,
                td_request_success_callback callback, void* data) {
        self->callbacks.on_success = callback;
index effbef8204a373aee54f92d8f8df4337d5cb799b..52abbc51984495ffc49c55042ac343ca653e4137 100644 (file)
@@ -37,6 +37,8 @@ td_request* td_request_unref(td_request* self);
 char* td_request_get_url(td_request* self);
 int td_request_set_url(td_request* self, const char* url);
 
+int td_request_set_socket(td_request* self, const char* path);
+
 typedef int (*td_request_success_callback)
        (td_ctx* ctx, td_file* file, void* data);
 typedef int (*td_request_failure_callback)