Browse Source
- Добавлен platform_compat.c с кроссплатформенной генерацией случайных чисел - Исправлена генерация ключей и node_id на Windows (вместо /dev/urandom) - PID файл отключен по умолчанию на Windows - Добавлено двойное логирование: файл utun.log + консоль - Добавлен манифест Windows для запроса прав администратора - Исправлено завершение программы при ошибках отправки (Network unreachable) - TUN инициализация включена по умолчанию - Исправлен main loop (instance->running = 1)nodeinfo-routing-update
11 changed files with 234 additions and 88 deletions
@ -0,0 +1,37 @@
|
||||
/* platform_compat.c - Platform compatibility layer implementation */ |
||||
|
||||
#include "platform_compat.h" |
||||
#include <stddef.h> |
||||
#include <stdint.h> |
||||
|
||||
#ifdef _WIN32 |
||||
#include <windows.h> |
||||
#include <bcrypt.h> |
||||
#ifndef STATUS_SUCCESS |
||||
#define STATUS_SUCCESS ((NTSTATUS)0x00000000L) |
||||
#endif |
||||
#else |
||||
#include <fcntl.h> |
||||
#include <unistd.h> |
||||
#endif |
||||
|
||||
/*
|
||||
* Generate cryptographically secure random bytes |
||||
* Returns 0 on success, -1 on error |
||||
*/ |
||||
int random_bytes(uint8_t *buffer, size_t len) { |
||||
if (!buffer || len == 0) return -1; |
||||
|
||||
#ifdef _WIN32 |
||||
NTSTATUS status = BCryptGenRandom(NULL, buffer, (ULONG)len, BCRYPT_USE_SYSTEM_PREFERRED_RNG); |
||||
return (status == STATUS_SUCCESS) ? 0 : -1; |
||||
#else |
||||
int fd = open("/dev/urandom", O_RDONLY); |
||||
if (fd < 0) return -1; |
||||
|
||||
ssize_t ret = read(fd, buffer, len); |
||||
close(fd); |
||||
|
||||
return (ret == (ssize_t)len) ? 0 : -1; |
||||
#endif |
||||
} |
||||
@ -0,0 +1,12 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="yes"?> |
||||
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0"> |
||||
<assemblyIdentity version="1.0.0.0" name="utun.exe" type="win32"/> |
||||
<description>uTun VPN Tunnel</description> |
||||
<trustInfo xmlns="urn:schemas-microsoft-com:asm.v2"> |
||||
<security> |
||||
<requestedPrivileges> |
||||
<requestedExecutionLevel level="requireAdministrator" uiAccess="false"/> |
||||
</requestedPrivileges> |
||||
</security> |
||||
</trustInfo> |
||||
</assembly> |
||||
Loading…
Reference in new issue