Add cross-platform utun_mkdir() wrapper for Windows compatibility
This commit is contained in:
1 parent
de7841f33a
commit
e438e19f9e
3 files changed
+20
-5
No files matched your search
@@ -192,6 +192,15 @@ int get_interface_ipv6_by_index(uint32_t netif_index, int temporary, uint8_t* ad
|
||||
uint32_t get_default_route_netif_index(int family);
|
||||
|
||||
|
||||
// Cross-platform mkdir
|
||||
#ifdef _WIN32
|
||||
#include <direct.h>
|
||||
#define utun_mkdir(path, mode) _mkdir(path)
|
||||
#else
|
||||
#include <sys/stat.h>
|
||||
#define utun_mkdir(path, mode) mkdir(path, mode)
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
+7
-1
@@ -30,6 +30,7 @@
|
||||
#include "../lib/platform_compat.h"
|
||||
#include "../lib/mem.h"
|
||||
#include "../lib/ll_queue.h"
|
||||
#include <openssl/sha.h>
|
||||
|
||||
|
||||
|
||||
@@ -92,6 +93,11 @@ static int instance_init_common(struct UTUN_INSTANCE* instance, struct UASYNC* u
|
||||
DEBUG_ERROR(DEBUG_CATEGORY_CRYPTO, "Failed to derive Ed25519 pubkey");
|
||||
return -1;
|
||||
}
|
||||
{
|
||||
uint8_t ed_priv_hash[SHA512_DIGEST_LENGTH];
|
||||
SHA512(instance->my_keys.private_key, SC_PRIVKEY_SIZE, ed_priv_hash);
|
||||
memcpy(instance->my_ed25519_privkey, ed_priv_hash, SC_PRIVKEY_SIZE);
|
||||
}
|
||||
DEBUG_INFO(DEBUG_CATEGORY_CRYPTO, "Ed25519 pubkey derived successfully");
|
||||
|
||||
// Initialize networks queue (indexed by 56-bit network id)
|
||||
@@ -287,7 +293,7 @@ struct UTUN_INSTANCE* utun_instance_create(struct UASYNC* ua, const char *config
|
||||
}
|
||||
int remaining = (int)(sizeof(instance->stats_dir) - dir_len - 8);
|
||||
if (remaining > 0) snprintf(instance->stats_dir + dir_len, remaining, "/stats");
|
||||
mkdir(instance->stats_dir, 0755);
|
||||
utun_mkdir(instance->stats_dir, 0755);
|
||||
DEBUG_INFO(DEBUG_CATEGORY_GENERAL, "Metrics stats dir: %s", instance->stats_dir);
|
||||
}
|
||||
|
||||
|
||||
@@ -67,10 +67,10 @@ static int create_temp_configs(void) {
|
||||
|
||||
// Create LMDB directories (parent first, then child)
|
||||
char db_path[320];
|
||||
snprintf(db_path, sizeof(db_path), "%s/db_a", temp_dir); mkdir(db_path, 0755);
|
||||
snprintf(db_path, sizeof(db_path), "%s/db_a/sync", temp_dir); mkdir(db_path, 0755);
|
||||
snprintf(db_path, sizeof(db_path), "%s/db_b", temp_dir); mkdir(db_path, 0755);
|
||||
snprintf(db_path, sizeof(db_path), "%s/db_b/sync", temp_dir); mkdir(db_path, 0755);
|
||||
snprintf(db_path, sizeof(db_path), "%s/db_a", temp_dir); utun_mkdir(db_path, 0755);
|
||||
snprintf(db_path, sizeof(db_path), "%s/db_a/sync", temp_dir); utun_mkdir(db_path, 0755);
|
||||
snprintf(db_path, sizeof(db_path), "%s/db_b", temp_dir); utun_mkdir(db_path, 0755);
|
||||
snprintf(db_path, sizeof(db_path), "%s/db_b/sync", temp_dir); utun_mkdir(db_path, 0755);
|
||||
|
||||
if (write_file(config_a,
|
||||
"[global]\n"
|
||||
|
||||
Reference in new issue
Block a user