Fix integration issues: ssl_ctx init + test API updates #89
@@ -16,16 +16,16 @@ DirectoryScanner* directory_scanner_create(char* root_directory, bool use_metada
|
||||
int exclude_count, char** include_patterns,
|
||||
int include_count, unsigned long long max_size,
|
||||
unsigned long long min_size) {
|
||||
return directory_scanner_create_full(root_directory, use_metadata, chunk_size,
|
||||
exclude_patterns, exclude_count,
|
||||
include_patterns, include_count,
|
||||
max_size, min_size, true);
|
||||
return directory_scanner_create_full(root_directory, use_metadata, chunk_size, exclude_patterns,
|
||||
exclude_count, include_patterns, include_count, max_size,
|
||||
min_size, true);
|
||||
}
|
||||
|
||||
DirectoryScanner* directory_scanner_create_full(char* root_directory, bool use_metadata,
|
||||
unsigned long long chunk_size, char** exclude_patterns,
|
||||
int exclude_count, char** include_patterns,
|
||||
int include_count, unsigned long long max_size,
|
||||
unsigned long long chunk_size,
|
||||
char** exclude_patterns, int exclude_count,
|
||||
char** include_patterns, int include_count,
|
||||
unsigned long long max_size,
|
||||
unsigned long long min_size, bool follow_symlinks) {
|
||||
DirectoryScanner* scanner = malloc(sizeof(DirectoryScanner));
|
||||
if (scanner == NULL)
|
||||
|
||||
@@ -27,9 +27,10 @@ DirectoryScanner* directory_scanner_create(char* root_directory, bool use_metada
|
||||
int include_count, unsigned long long max_size,
|
||||
unsigned long long min_size);
|
||||
DirectoryScanner* directory_scanner_create_full(char* root_directory, bool use_metadata,
|
||||
unsigned long long chunk_size, char** exclude_patterns,
|
||||
int exclude_count, char** include_patterns,
|
||||
int include_count, unsigned long long max_size,
|
||||
unsigned long long chunk_size,
|
||||
char** exclude_patterns, int exclude_count,
|
||||
char** include_patterns, int include_count,
|
||||
unsigned long long max_size,
|
||||
unsigned long long min_size, bool follow_symlinks);
|
||||
Chunk* directory_scanner_next(DirectoryScanner* scanner);
|
||||
void directory_scanner_destroy(DirectoryScanner* scanner);
|
||||
|
||||
+10
-12
@@ -44,9 +44,11 @@ Server* server_create(int port) {
|
||||
server->ssl_ctx = NULL;
|
||||
|
||||
// Try IPv6 first, fall back to IPv4
|
||||
int fd = socket(AF_INET6, SOCK_STREAM, 0);
|
||||
int domain = AF_INET6;
|
||||
int fd = socket(domain, SOCK_STREAM, 0);
|
||||
if (fd < 0) {
|
||||
fd = socket(AF_INET, SOCK_STREAM, 0);
|
||||
domain = AF_INET;
|
||||
fd = socket(domain, SOCK_STREAM, 0);
|
||||
}
|
||||
if (fd < 0) {
|
||||
perror("Could not create Socket!");
|
||||
@@ -69,17 +71,11 @@ Server* server_create(int port) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
// Determine address family from the actual socket
|
||||
struct sockaddr_storage* addr = &server->address;
|
||||
socklen_t addr_len = sizeof(*addr);
|
||||
if (getsockname(fd, (struct sockaddr*)addr, &addr_len) == 0) {
|
||||
// Use the family of the socket we actually created
|
||||
}
|
||||
|
||||
struct sockaddr_in* addr4 = (struct sockaddr_in*)addr;
|
||||
struct sockaddr_in6* addr6 = (struct sockaddr_in6*)addr;
|
||||
|
||||
if (addr->ss_family == AF_INET6) {
|
||||
if (domain == AF_INET6) {
|
||||
addr6->sin6_family = AF_INET6;
|
||||
addr6->sin6_addr = in6addr_any;
|
||||
addr6->sin6_port = htons(port);
|
||||
@@ -94,7 +90,7 @@ Server* server_create(int port) {
|
||||
if (bind(server->file_descriptor, (struct sockaddr*)&server->address, server->address_length) <
|
||||
0) {
|
||||
// If IPv6 bind failed (maybe no IPv6), try IPv4
|
||||
if (addr->ss_family == AF_INET6) {
|
||||
if (domain == AF_INET6) {
|
||||
close(fd);
|
||||
fd = socket(AF_INET, SOCK_STREAM, 0);
|
||||
if (fd < 0) {
|
||||
@@ -254,8 +250,10 @@ bool client_connect(Client* client, char* host, int port) {
|
||||
}
|
||||
|
||||
// Save the connected address
|
||||
memcpy(&client->address, rp->ai_addr, rp->ai_addrlen);
|
||||
client->address_length = rp->ai_addrlen;
|
||||
size_t copy_len =
|
||||
rp->ai_addrlen < sizeof(client->address) ? rp->ai_addrlen : sizeof(client->address);
|
||||
memcpy(&client->address, rp->ai_addr, copy_len);
|
||||
client->address_length = (int)copy_len;
|
||||
freeaddrinfo(res);
|
||||
|
||||
// Close old fd if any and set new one
|
||||
|
||||
@@ -22,8 +22,8 @@ static void test_sendfile_basic() {
|
||||
/* Set the size so file_send_sendfile can report it */
|
||||
file->data->size = len;
|
||||
|
||||
Config* cfg = config_create(str_dup(PROTOCOL_VERSION), str_dup("/tmp"), str_dup("/tmp"),
|
||||
false, false, false, false, false, 0, false, 0);
|
||||
Config* cfg = config_create(str_dup(PROTOCOL_VERSION), str_dup("/tmp"), str_dup("/tmp"), false,
|
||||
false, false, false, false, 0, false, 0);
|
||||
EXPECT_NOT_NULL(cfg);
|
||||
|
||||
int p[2];
|
||||
@@ -80,8 +80,8 @@ static void test_sendfile_empty_file() {
|
||||
EXPECT_NOT_NULL(file);
|
||||
file->data->size = 0;
|
||||
|
||||
Config* cfg = config_create(str_dup(PROTOCOL_VERSION), str_dup("/tmp"), str_dup("/tmp"),
|
||||
false, false, false, false, false, 0, false, 0);
|
||||
Config* cfg = config_create(str_dup(PROTOCOL_VERSION), str_dup("/tmp"), str_dup("/tmp"), false,
|
||||
false, false, false, false, 0, false, 0);
|
||||
EXPECT_NOT_NULL(cfg);
|
||||
|
||||
int p[2];
|
||||
@@ -161,8 +161,8 @@ static void test_sendfile_compression_fallback() {
|
||||
file->data->size = (size_t)st.st_size;
|
||||
EXPECT_TRUE(file_load_data(file));
|
||||
|
||||
Config* cfg = config_create(str_dup(PROTOCOL_VERSION), str_dup("/tmp"), str_dup("/tmp"),
|
||||
false, false, false, true, false, 3, false, 0);
|
||||
Config* cfg = config_create(str_dup(PROTOCOL_VERSION), str_dup("/tmp"), str_dup("/tmp"), false,
|
||||
false, false, true, false, 3, false, 0);
|
||||
EXPECT_NOT_NULL(cfg);
|
||||
|
||||
int p[2];
|
||||
|
||||
@@ -8,8 +8,8 @@
|
||||
|
||||
/* Test pipeline_context_sender_create/destroy with valid arguments */
|
||||
static void test_sender_create_destroy() {
|
||||
Config* cfg = config_create(str_dup("1.0"), str_dup("/src"), str_dup("/dst"),
|
||||
false, false, false, false, false, 0, false, 0);
|
||||
Config* cfg = config_create(str_dup("1.0"), str_dup("/src"), str_dup("/dst"), false, false, false,
|
||||
false, false, 0, false, 0);
|
||||
EXPECT_NOT_NULL(cfg);
|
||||
|
||||
Queue* q_scanner = queue_create(5, NULL);
|
||||
@@ -32,8 +32,8 @@ static void test_sender_create_destroy() {
|
||||
|
||||
/* Test pipeline_context_receiver_create/destroy with valid arguments */
|
||||
static void test_receiver_create_destroy() {
|
||||
Config* cfg = config_create(str_dup("2.0"), str_dup("/src"), str_dup("/dst"),
|
||||
true, true, false, false, false, 0, false, 0);
|
||||
Config* cfg = config_create(str_dup("2.0"), str_dup("/src"), str_dup("/dst"), true, true, false,
|
||||
false, false, 0, false, 0);
|
||||
EXPECT_NOT_NULL(cfg);
|
||||
|
||||
Queue* q = queue_create(20, NULL);
|
||||
@@ -51,8 +51,8 @@ static void test_receiver_create_destroy() {
|
||||
|
||||
/* Test that create handles various queue capacities */
|
||||
static void test_sender_queue_capacities() {
|
||||
Config* cfg = config_create(str_dup("3.0"), str_dup("/src"), str_dup("/dst"),
|
||||
false, false, false, false, false, 0, false, 0);
|
||||
Config* cfg = config_create(str_dup("3.0"), str_dup("/src"), str_dup("/dst"), false, false, false,
|
||||
false, false, 0, false, 0);
|
||||
EXPECT_NOT_NULL(cfg);
|
||||
|
||||
/* Single-element queues */
|
||||
@@ -67,8 +67,8 @@ static void test_sender_queue_capacities() {
|
||||
|
||||
/* Test that create handles zero-capacity queues */
|
||||
static void test_sender_zero_capacity() {
|
||||
Config* cfg = config_create(str_dup("4.0"), str_dup("/src"), str_dup("/dst"),
|
||||
false, false, false, false, false, 0, false, 0);
|
||||
Config* cfg = config_create(str_dup("4.0"), str_dup("/src"), str_dup("/dst"), false, false, false,
|
||||
false, false, 0, false, 0);
|
||||
EXPECT_NOT_NULL(cfg);
|
||||
|
||||
Queue* q1 = queue_create(0, NULL);
|
||||
@@ -82,8 +82,8 @@ static void test_sender_zero_capacity() {
|
||||
|
||||
/* Test receiver with zero file_descriptor */
|
||||
static void test_receiver_fd_zero() {
|
||||
Config* cfg = config_create(str_dup("5.0"), str_dup("/src"), str_dup("/dst"),
|
||||
false, false, false, false, false, 0, false, 0);
|
||||
Config* cfg = config_create(str_dup("5.0"), str_dup("/src"), str_dup("/dst"), false, false, false,
|
||||
false, false, 0, false, 0);
|
||||
Queue* q = queue_create(5, NULL);
|
||||
PipelineContextReceiver* ctx = pipeline_context_receiver_create(cfg, q, 0);
|
||||
EXPECT_NOT_NULL(ctx);
|
||||
|
||||
Reference in New Issue
Block a user