diff -Nru softether-vpn-5.02.0~202105242329~nightly~ubuntu21.10.1/debian/changelog softether-vpn-5.02.0~202105261914~nightly~ubuntu21.10.1/debian/changelog --- softether-vpn-5.02.0~202105242329~nightly~ubuntu21.10.1/debian/changelog 2021-05-25 00:56:35.000000000 +0000 +++ softether-vpn-5.02.0~202105261914~nightly~ubuntu21.10.1/debian/changelog 2021-05-27 06:53:38.000000000 +0000 @@ -1,8 +1,8 @@ -softether-vpn (5.02.0~202105242329~nightly~ubuntu21.10.1) impish; urgency=low +softether-vpn (5.02.0~202105261914~nightly~ubuntu21.10.1) impish; urgency=low * Auto build. - -- Dmitry Verkhoturov Tue, 25 May 2021 00:56:35 +0000 + -- Dmitry Verkhoturov Thu, 27 May 2021 06:53:38 +0000 softether-vpn (0:5.01.9674-0) unstable; urgency=low diff -Nru softether-vpn-5.02.0~202105242329~nightly~ubuntu21.10.1/debian/git-build-recipe.manifest softether-vpn-5.02.0~202105261914~nightly~ubuntu21.10.1/debian/git-build-recipe.manifest --- softether-vpn-5.02.0~202105242329~nightly~ubuntu21.10.1/debian/git-build-recipe.manifest 2021-05-25 00:56:35.000000000 +0000 +++ softether-vpn-5.02.0~202105261914~nightly~ubuntu21.10.1/debian/git-build-recipe.manifest 2021-05-27 06:53:38.000000000 +0000 @@ -1,7 +1,7 @@ -# git-build-recipe format 0.4 deb-version 5.02.0~202105242329~nightly -lp:~paskal-07/softether-vpn git-commit:97d9761a9b49bc539945045a54733b6ff29b4106 +# git-build-recipe format 0.4 deb-version 5.02.0~202105261914~nightly +lp:~paskal-07/softether-vpn git-commit:2262b8a1605e643e88004006ec8c047ba4c1f956 nest cpu_features lp:~paskal-07/softether-vpn/+git/cpu_features src/Mayaqua/3rdparty/cpu_features git-commit:bc2846e78faeb26b8a46c17df369d4e5f1f9e2bb nest tinydir lp:~paskal-07/softether-vpn/+git/tinydir 3rdparty/tinydir git-commit:ec6bff2043eaac3ad25423705e63a781762a0dfd nest BLAKE2 lp:~paskal-07/softether-vpn/+git/BLAKE2 3rdparty/BLAKE2 git-commit:b52178a376ca85a8ffe50492263c2a5bc0fa4f46 -nest libhamcore lp:~paskal-07/softether-vpn/+git/libhamcore src/libhamcore git-commit:79fd4aa6a140222fb186e4966771b19f8e733075 +nest libhamcore lp:~paskal-07/softether-vpn/+git/libhamcore src/libhamcore git-commit:2951ae5b61b16c1f4e03ceee88d6db7e1e45362b nest-part packaging lp:~paskal-07/softether-vpn/+git/SoftEtherVPN-debianisation debian debian git-commit:f730673a58a6478def432da7df3513a2ee6f3306 diff -Nru softether-vpn-5.02.0~202105242329~nightly~ubuntu21.10.1/src/Cedar/Protocol.c softether-vpn-5.02.0~202105261914~nightly~ubuntu21.10.1/src/Cedar/Protocol.c --- softether-vpn-5.02.0~202105242329~nightly~ubuntu21.10.1/src/Cedar/Protocol.c 2021-05-25 00:56:08.000000000 +0000 +++ softether-vpn-5.02.0~202105261914~nightly~ubuntu21.10.1/src/Cedar/Protocol.c 2021-05-27 06:52:24.000000000 +0000 @@ -6011,7 +6011,7 @@ if (server->DisableJsonRpcWebApi == false) { - b = ReadDump("|wwwroot\\index.html"); + b = ReadDump("|wwwroot/index.html"); } if (b != NULL) diff -Nru softether-vpn-5.02.0~202105242329~nightly~ubuntu21.10.1/src/Cedar/Proto_PPP.c softether-vpn-5.02.0~202105261914~nightly~ubuntu21.10.1/src/Cedar/Proto_PPP.c --- softether-vpn-5.02.0~202105242329~nightly~ubuntu21.10.1/src/Cedar/Proto_PPP.c 2021-05-25 00:56:08.000000000 +0000 +++ softether-vpn-5.02.0~202105261914~nightly~ubuntu21.10.1/src/Cedar/Proto_PPP.c 2021-05-27 06:52:24.000000000 +0000 @@ -257,7 +257,8 @@ case PPP_EAP_TYPE_TLS: // Sending TLS Start... flags |= PPP_EAP_TLS_FLAG_SSLSTARTED; - lcpEap = BuildEAPTlsRequest(p->Eap_PacketId++, 0, flags); + p->Eap_PacketId = p->NextId++; + lcpEap = BuildEAPTlsRequest(p->Eap_PacketId, 0, flags); PPPSetStatus(p, PPP_STATUS_AUTHENTICATING); if (!PPPSendAndRetransmitRequest(p, PPP_PROTOCOL_EAP, lcpEap)) { @@ -269,7 +270,8 @@ case PPP_EAP_TYPE_IDENTITY: default: // We treat the unspecified protocol as the IDENTITY protocol p->Eap_Protocol = PPP_EAP_TYPE_IDENTITY; - lcpEap = BuildEAPPacketEx(PPP_EAP_CODE_REQUEST, p->Eap_PacketId++, PPP_EAP_TYPE_IDENTITY, StrLen(welcomeMessage) + 1); + p->Eap_PacketId = p->NextId++; + lcpEap = BuildEAPPacketEx(PPP_EAP_CODE_REQUEST, p->Eap_PacketId, PPP_EAP_TYPE_IDENTITY, StrLen(welcomeMessage) + 1); eapPacket = lcpEap->Data; Copy(eapPacket->Data, welcomeMessage, StrLen(welcomeMessage)); PPPSetStatus(p, PPP_STATUS_AUTHENTICATING); @@ -1251,7 +1253,8 @@ eap = req->Lcp->Data; if (eap->Type == PPP_EAP_TYPE_TLS) { - PPP_LCP *lcp = BuildEAPTlsRequest(p->Eap_PacketId++, 0, PPP_EAP_TLS_FLAG_NONE); + p->Eap_PacketId = p->NextId++; + PPP_LCP *lcp = BuildEAPTlsRequest(p->Eap_PacketId, 0, PPP_EAP_TLS_FLAG_NONE); if (!PPPSendAndRetransmitRequest(p, PPP_PROTOCOL_EAP, lcp)) { PPPSetStatus(p, PPP_STATUS_FAIL); @@ -3218,7 +3221,8 @@ dataSize = sizeLeft; flags = PPP_EAP_TLS_FLAG_NONE; // Clearing the M flag because it is the last packet } - lcp = BuildEAPTlsRequest(p->Eap_PacketId++, dataSize, flags); + p->Eap_PacketId = p->NextId++; + lcp = BuildEAPTlsRequest(p->Eap_PacketId, dataSize, flags); eap = lcp->Data; Copy(eap->Tls.TlsDataWithoutLength, p->Eap_TlsCtx.CachedBufferSendPntr, dataSize); p->Eap_TlsCtx.CachedBufferSendPntr += (UINT64)dataSize; @@ -3252,7 +3256,8 @@ /*if (!p->Eap_TlsCtx.SslPipe->IsDisconnected) { dataSize = FifoSize(p->Eap_TlsCtx.SslPipe->RawOut->RecvFifo); - lcp = BuildEAPTlsRequest(p->Eap_PacketId++, dataSize, 0); + p->Eap_PacketId = p->NextId++; + lcp = BuildEAPTlsRequest(p->Eap_PacketId, dataSize, 0); eap = lcp->Data; ReadFifo(p->Eap_TlsCtx.SslPipe->RawOut->RecvFifo, &(eap->Tls.TlsDataWithoutLength), dataSize); if (!PPPSendAndRetransmitRequest(p, PPP_PROTOCOL_EAP, lcp)) @@ -3275,7 +3280,7 @@ if (ipc != NULL) { PPP_PACKET *pack; - UINT identificator = p->Eap_PacketId - 1; // THIS IS A HACK TO SUPPORT VPN Client Pro on Android!!! + UINT identificator = p->Eap_PacketId; p->Ipc = ipc; PPPSetStatus(p, PPP_STATUS_AUTH_SUCCESS); @@ -3298,7 +3303,7 @@ else { PPP_PACKET *pack; - UINT identificator = p->Eap_PacketId - 1; // THIS IS A HACK TO SUPPORT VPN Client Pro on Android!!! + UINT identificator = p->Eap_PacketId; PPPSetStatus(p, PPP_STATUS_AUTH_FAIL); @@ -3321,7 +3326,8 @@ { // Some clients needs a little help it seems - namely VPN Client Pro on Android flags |= PPP_EAP_TLS_FLAG_SSLSTARTED; - lcp = BuildEAPTlsRequest(p->Eap_PacketId++, 0, flags); + p->Eap_PacketId = p->NextId++; + lcp = BuildEAPTlsRequest(p->Eap_PacketId, 0, flags); PPPSetStatus(p, PPP_STATUS_AUTHENTICATING); if (!PPPSendAndRetransmitRequest(p, PPP_PROTOCOL_EAP, lcp)) { @@ -3399,7 +3405,8 @@ // Just acknoweldge that we buffered the fragmented data if (isFragmented) { - PPP_LCP *lcp = BuildEAPPacketEx(PPP_EAP_CODE_REQUEST, p->Eap_PacketId++, PPP_EAP_TYPE_TLS, 0); + p->Eap_PacketId = p->NextId++; + PPP_LCP *lcp = BuildEAPPacketEx(PPP_EAP_CODE_REQUEST, p->Eap_PacketId, PPP_EAP_TYPE_TLS, 0); if (!PPPSendAndRetransmitRequest(p, PPP_PROTOCOL_EAP, lcp)) { PPPSetStatus(p, PPP_STATUS_FAIL); @@ -3445,7 +3452,8 @@ dataSize = p->Mru1 - 8 - 1 - 1 - 4; // Calculating the maximum payload size (adjusting for including TlsLength) flags = PPP_EAP_TLS_FLAG_TLS_LENGTH; // L flag flags |= PPP_EAP_TLS_FLAG_FRAGMENTED; // M flag - lcp = BuildEAPTlsRequest(p->Eap_PacketId++, dataSize, flags); + p->Eap_PacketId = p->NextId++; + lcp = BuildEAPTlsRequest(p->Eap_PacketId, dataSize, flags); eap = lcp->Data; eap->Tls.TlsDataWithLength.TlsLength = Endian32(tlsLength); Copy(eap->Tls.TlsDataWithLength.Data, p->Eap_TlsCtx.CachedBufferSend, dataSize); @@ -3460,7 +3468,8 @@ } else { - lcp = BuildEAPTlsRequest(p->Eap_PacketId++, dataSize, 0); + p->Eap_PacketId = p->NextId++; + lcp = BuildEAPTlsRequest(p->Eap_PacketId, dataSize, 0); eap = lcp->Data; ReadFifo(p->Eap_TlsCtx.SslPipe->RawOut->RecvFifo, &(eap->Tls.TlsDataWithoutLength), dataSize); if (!PPPSendAndRetransmitRequest(p, PPP_PROTOCOL_EAP, lcp)) diff -Nru softether-vpn-5.02.0~202105242329~nightly~ubuntu21.10.1/src/GlobalConst.h softether-vpn-5.02.0~202105261914~nightly~ubuntu21.10.1/src/GlobalConst.h --- softether-vpn-5.02.0~202105242329~nightly~ubuntu21.10.1/src/GlobalConst.h 2021-05-25 00:56:08.000000000 +0000 +++ softether-vpn-5.02.0~202105261914~nightly~ubuntu21.10.1/src/GlobalConst.h 2021-05-27 06:52:24.000000000 +0000 @@ -64,9 +64,4 @@ #define GC_UI_APPID_CM L"SoftEther.SoftEther VPN Client Developer Edition" -//// Hamcore - -#define HAMCORE_HEADER_DATA "HamCore" -#define HAMCORE_HEADER_SIZE 7 - #endif // GLOBAL_CONST_H diff -Nru softether-vpn-5.02.0~202105242329~nightly~ubuntu21.10.1/src/libhamcore/CMakeLists.txt softether-vpn-5.02.0~202105261914~nightly~ubuntu21.10.1/src/libhamcore/CMakeLists.txt --- softether-vpn-5.02.0~202105242329~nightly~ubuntu21.10.1/src/libhamcore/CMakeLists.txt 2021-05-25 00:56:24.000000000 +0000 +++ softether-vpn-5.02.0~202105261914~nightly~ubuntu21.10.1/src/libhamcore/CMakeLists.txt 2021-05-27 06:53:18.000000000 +0000 @@ -8,6 +8,8 @@ add_library(libhamcore STATIC) +set_property(TARGET libhamcore PROPERTY POSITION_INDEPENDENT_CODE ON) + test_big_endian(BIG_ENDIAN) if(BIG_ENDIAN) target_compile_definitions(libhamcore PRIVATE "BYTE_ORDER_BIG_ENDIAN") @@ -19,7 +21,7 @@ target_compile_definitions(libhamcore PRIVATE "_CRT_SECURE_NO_WARNINGS") endif() -target_include_directories(libhamcore PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}) +target_include_directories(libhamcore PUBLIC "include") target_sources(libhamcore PRIVATE @@ -29,7 +31,7 @@ Memory.c Memory.h PUBLIC - ${CMAKE_CURRENT_SOURCE_DIR}/Hamcore.h + "${CMAKE_CURRENT_SOURCE_DIR}/include/Hamcore.h" ) find_package(ZLIB REQUIRED) diff -Nru softether-vpn-5.02.0~202105242329~nightly~ubuntu21.10.1/src/libhamcore/FileSystem.c softether-vpn-5.02.0~202105261914~nightly~ubuntu21.10.1/src/libhamcore/FileSystem.c --- softether-vpn-5.02.0~202105242329~nightly~ubuntu21.10.1/src/libhamcore/FileSystem.c 2021-05-25 00:56:24.000000000 +0000 +++ softether-vpn-5.02.0~202105261914~nightly~ubuntu21.10.1/src/libhamcore/FileSystem.c 2021-05-27 06:53:18.000000000 +0000 @@ -4,7 +4,7 @@ #include -FILE *FileOpen(const char *path, const bool write) +FILE *Ham_FileOpen(const char *path, const bool write) { if (!path) { @@ -14,7 +14,7 @@ return fopen(path, write ? "wb" : "rb"); } -bool FileClose(FILE *file) +bool Ham_FileClose(FILE *file) { if (!file) { @@ -24,7 +24,7 @@ return fclose(file) == 0; } -bool FileRead(FILE *file, void *dst, const size_t size) +bool Ham_FileRead(FILE *file, void *dst, const size_t size) { if (!file || !dst || size == 0) { @@ -34,7 +34,7 @@ return fread(dst, 1, size, file) == size; } -bool FileWrite(FILE *file, const void *src, const size_t size) +bool Ham_FileWrite(FILE *file, const void *src, const size_t size) { if (!file || !src || size == 0) { @@ -44,7 +44,7 @@ return fwrite(src, 1, size, file) == size; } -bool FileSeek(FILE *file, const size_t offset) +bool Ham_FileSeek(FILE *file, const size_t offset) { if (!file) { @@ -54,7 +54,7 @@ return fseek(file, (long)offset, SEEK_SET) == 0; } -size_t FileSize(const char *path) +size_t Ham_FileSize(const char *path) { if (!path) { @@ -70,7 +70,7 @@ return st.st_size; } -const char *PathRelativeToBase(const char *full, const char *base) +const char *Ham_PathRelativeToBase(const char *full, const char *base) { if (!full || !base) { diff -Nru softether-vpn-5.02.0~202105242329~nightly~ubuntu21.10.1/src/libhamcore/FileSystem.h softether-vpn-5.02.0~202105261914~nightly~ubuntu21.10.1/src/libhamcore/FileSystem.h --- softether-vpn-5.02.0~202105242329~nightly~ubuntu21.10.1/src/libhamcore/FileSystem.h 2021-05-25 00:56:24.000000000 +0000 +++ softether-vpn-5.02.0~202105261914~nightly~ubuntu21.10.1/src/libhamcore/FileSystem.h 2021-05-27 06:53:18.000000000 +0000 @@ -4,16 +4,16 @@ #include #include -FILE *FileOpen(const char *path, const bool write); -bool FileClose(FILE *file); +FILE *Ham_FileOpen(const char *path, const bool write); +bool Ham_FileClose(FILE *file); -bool FileRead(FILE *file, void *dst, const size_t size); -bool FileWrite(FILE *file, const void *src, const size_t size); +bool Ham_FileRead(FILE *file, void *dst, const size_t size); +bool Ham_FileWrite(FILE *file, const void *src, const size_t size); -bool FileSeek(FILE *file, const size_t offset); +bool Ham_FileSeek(FILE *file, const size_t offset); -size_t FileSize(const char *path); +size_t Ham_FileSize(const char *path); -const char *PathRelativeToBase(const char *full, const char *base); +const char *Ham_PathRelativeToBase(const char *full, const char *base); #endif diff -Nru softether-vpn-5.02.0~202105242329~nightly~ubuntu21.10.1/src/libhamcore/Hamcore.c softether-vpn-5.02.0~202105261914~nightly~ubuntu21.10.1/src/libhamcore/Hamcore.c --- softether-vpn-5.02.0~202105242329~nightly~ubuntu21.10.1/src/libhamcore/Hamcore.c 2021-05-25 00:56:24.000000000 +0000 +++ softether-vpn-5.02.0~202105261914~nightly~ubuntu21.10.1/src/libhamcore/Hamcore.c 2021-05-27 06:53:18.000000000 +0000 @@ -28,7 +28,7 @@ } memset(hamcore, 0, sizeof(HAMCORE)); - hamcore->File = FileOpen(path, false); + hamcore->File = Ham_FileOpen(path, false); if (!hamcore->File) { free(hamcore); @@ -38,7 +38,7 @@ bool ok = false; uint8_t header[HAMCORE_HEADER_SIZE]; - if (!FileRead(hamcore->File, header, sizeof(header))) + if (!Ham_FileRead(hamcore->File, header, sizeof(header))) { goto FINAL; } @@ -49,7 +49,7 @@ } uint32_t tmp; - if (!FileRead(hamcore->File, &tmp, sizeof(tmp))) + if (!Ham_FileRead(hamcore->File, &tmp, sizeof(tmp))) { goto FINAL; } @@ -66,7 +66,7 @@ for (size_t i = 0; i < files->Num; ++i) { - if (!FileRead(hamcore->File, &tmp, sizeof(tmp))) + if (!Ham_FileRead(hamcore->File, &tmp, sizeof(tmp))) { goto FINAL; } @@ -81,26 +81,26 @@ --tmp; } - if (!FileRead(hamcore->File, file->Path, tmp)) + if (!Ham_FileRead(hamcore->File, file->Path, tmp)) { goto FINAL; } - if (!FileRead(hamcore->File, &tmp, sizeof(tmp))) + if (!Ham_FileRead(hamcore->File, &tmp, sizeof(tmp))) { goto FINAL; } file->OriginalSize = BigEndian32(tmp); - if (!FileRead(hamcore->File, &tmp, sizeof(tmp))) + if (!Ham_FileRead(hamcore->File, &tmp, sizeof(tmp))) { goto FINAL; } file->Size = BigEndian32(tmp); - if (!FileRead(hamcore->File, &tmp, sizeof(tmp))) + if (!Ham_FileRead(hamcore->File, &tmp, sizeof(tmp))) { goto FINAL; } @@ -126,7 +126,7 @@ return; } - FileClose(hamcore->File); + Ham_FileClose(hamcore->File); HAMCORE_FILES *files = &hamcore->Files; if (!files->List) @@ -175,7 +175,7 @@ return false; } - if (!FileSeek(hamcore->File, hamcore_file->Offset)) + if (!Ham_FileSeek(hamcore->File, hamcore_file->Offset)) { return false; } @@ -183,7 +183,7 @@ bool ok = false; void *buf = malloc(hamcore_file->Size); - if (!FileRead(hamcore->File, buf, hamcore_file->Size)) + if (!Ham_FileRead(hamcore->File, buf, hamcore_file->Size)) { goto FINAL; } @@ -229,7 +229,7 @@ continue; } - FILE *handle = FileOpen(path, false); + FILE *handle = Ham_FileOpen(path, false); if (!handle) { fprintf(stderr, "HamcoreBuild(): Failed to open \"%s\", skipping...\n", path); @@ -239,10 +239,10 @@ COMPRESSED_FILE *compressed_file = &compressed_files[i]; HAMCORE_FILE *file = &compressed_file->File; - file->OriginalSize = FileSize(path); + file->OriginalSize = Ham_FileSize(path); void *content = malloc(file->OriginalSize); - int ret = FileRead(handle, content, file->OriginalSize); - FileClose(handle); + int ret = Ham_FileRead(handle, content, file->OriginalSize); + Ham_FileClose(handle); if (!ret) { @@ -271,7 +271,7 @@ continue; } - const char *relative_path = base_path ? PathRelativeToBase(path, base_path) : path; + const char *relative_path = base_path ? Ham_PathRelativeToBase(path, base_path) : path; if (!relative_path) { fprintf(stderr, "HamcoreBuild(): Failed to get relative path for \"%s\", skipping...\n", path); @@ -343,9 +343,9 @@ } void *ptr = buffer; - WriteAndSeek(&ptr, HAMCORE_HEADER_DATA, HAMCORE_HEADER_SIZE); + Ham_WriteAndSeek(&ptr, HAMCORE_HEADER_DATA, HAMCORE_HEADER_SIZE); uint32_t tmp = BigEndian32((uint32_t)num); - WriteAndSeek(&ptr, &tmp, sizeof(tmp)); + Ham_WriteAndSeek(&ptr, &tmp, sizeof(tmp)); for (size_t i = 0; i < num; ++i) { @@ -357,24 +357,24 @@ const size_t path_length = strlen(file->Path); tmp = BigEndian32((uint32_t)path_length + 1); - WriteAndSeek(&ptr, &tmp, sizeof(tmp)); - WriteAndSeek(&ptr, file->Path, path_length); + Ham_WriteAndSeek(&ptr, &tmp, sizeof(tmp)); + Ham_WriteAndSeek(&ptr, file->Path, path_length); free(file->Path); tmp = BigEndian32((uint32_t)file->OriginalSize); - WriteAndSeek(&ptr, &tmp, sizeof(tmp)); + Ham_WriteAndSeek(&ptr, &tmp, sizeof(tmp)); tmp = BigEndian32((uint32_t)file->Size); - WriteAndSeek(&ptr, &tmp, sizeof(tmp)); + Ham_WriteAndSeek(&ptr, &tmp, sizeof(tmp)); tmp = BigEndian32((uint32_t)file->Offset); - WriteAndSeek(&ptr, &tmp, sizeof(tmp)); + Ham_WriteAndSeek(&ptr, &tmp, sizeof(tmp)); } for (size_t i = 0; i < num; ++i) { COMPRESSED_FILE *compressed_file = &compressed_files[i]; - WriteAndSeek(&ptr, compressed_file->Data, compressed_file->File.Size); + Ham_WriteAndSeek(&ptr, compressed_file->Data, compressed_file->File.Size); free(compressed_file->Data); } @@ -382,14 +382,14 @@ bool ok = false; - FILE *handle = FileOpen(dst_path, true); + FILE *handle = Ham_FileOpen(dst_path, true); if (!handle) { fprintf(stderr, "HamcoreBuild(): Failed to open \"%s\"!\n", dst_path); goto FINAL; } - if (!FileWrite(handle, buffer, buffer_size)) + if (!Ham_FileWrite(handle, buffer, buffer_size)) { fprintf(stderr, "HamcoreBuild(): Failed to write \"%s\"!\n", dst_path); goto FINAL; @@ -397,7 +397,7 @@ ok = true; FINAL: - FileClose(handle); + Ham_FileClose(handle); free(buffer); return ok; } diff -Nru softether-vpn-5.02.0~202105242329~nightly~ubuntu21.10.1/src/libhamcore/Hamcore.h softether-vpn-5.02.0~202105261914~nightly~ubuntu21.10.1/src/libhamcore/Hamcore.h --- softether-vpn-5.02.0~202105242329~nightly~ubuntu21.10.1/src/libhamcore/Hamcore.h 2021-05-25 00:56:24.000000000 +0000 +++ softether-vpn-5.02.0~202105261914~nightly~ubuntu21.10.1/src/libhamcore/Hamcore.h 1970-01-01 00:00:00.000000000 +0000 @@ -1,39 +0,0 @@ -#ifndef HAMCORE_H -#define HAMCORE_H - -#include -#include -#include - -#define HAMCORE_HEADER_DATA "HamCore" -#define HAMCORE_HEADER_SIZE 7 - -typedef struct HAMCORE_FILE -{ - char *Path; - size_t Offset; - size_t Size; - size_t OriginalSize; -} HAMCORE_FILE; - -typedef struct HAMCORE_FILES -{ - size_t Num; - HAMCORE_FILE *List; -} HAMCORE_FILES; - -typedef struct HAMCORE -{ - FILE *File; - HAMCORE_FILES Files; -} HAMCORE; - -HAMCORE *HamcoreOpen(const char *path); -void HamcoreClose(HAMCORE *hamcore); - -const HAMCORE_FILE *HamcoreFind(const HAMCORE *hamcore, const char *path); -bool HamcoreRead(HAMCORE *hamcore, void *dst, const HAMCORE_FILE *file); - -bool HamcoreBuild(const char *dst_path, const char *base_path, const char **src_paths, const size_t num); - -#endif diff -Nru softether-vpn-5.02.0~202105242329~nightly~ubuntu21.10.1/src/libhamcore/include/Hamcore.h softether-vpn-5.02.0~202105261914~nightly~ubuntu21.10.1/src/libhamcore/include/Hamcore.h --- softether-vpn-5.02.0~202105242329~nightly~ubuntu21.10.1/src/libhamcore/include/Hamcore.h 1970-01-01 00:00:00.000000000 +0000 +++ softether-vpn-5.02.0~202105261914~nightly~ubuntu21.10.1/src/libhamcore/include/Hamcore.h 2021-05-27 06:53:18.000000000 +0000 @@ -0,0 +1,39 @@ +#ifndef HAMCORE_H +#define HAMCORE_H + +#include +#include +#include + +#define HAMCORE_HEADER_DATA "HamCore" +#define HAMCORE_HEADER_SIZE 7 + +typedef struct HAMCORE_FILE +{ + char *Path; + size_t Offset; + size_t Size; + size_t OriginalSize; +} HAMCORE_FILE; + +typedef struct HAMCORE_FILES +{ + size_t Num; + HAMCORE_FILE *List; +} HAMCORE_FILES; + +typedef struct HAMCORE +{ + FILE *File; + HAMCORE_FILES Files; +} HAMCORE; + +HAMCORE *HamcoreOpen(const char *path); +void HamcoreClose(HAMCORE *hamcore); + +const HAMCORE_FILE *HamcoreFind(const HAMCORE *hamcore, const char *path); +bool HamcoreRead(HAMCORE *hamcore, void *dst, const HAMCORE_FILE *file); + +bool HamcoreBuild(const char *dst_path, const char *base_path, const char **src_paths, const size_t num); + +#endif diff -Nru softether-vpn-5.02.0~202105242329~nightly~ubuntu21.10.1/src/libhamcore/Memory.c softether-vpn-5.02.0~202105261914~nightly~ubuntu21.10.1/src/libhamcore/Memory.c --- softether-vpn-5.02.0~202105242329~nightly~ubuntu21.10.1/src/libhamcore/Memory.c 2021-05-25 00:56:24.000000000 +0000 +++ softether-vpn-5.02.0~202105261914~nightly~ubuntu21.10.1/src/libhamcore/Memory.c 2021-05-27 06:53:18.000000000 +0000 @@ -2,9 +2,7 @@ #include -size_t CompressionBufferSize(const size_t original_size) { return original_size * 2 + 256; } - -uint32_t Swap32(const uint32_t value) +uint32_t Ham_Swap32(const uint32_t value) { uint32_t swapped; ((uint8_t *)&swapped)[0] = ((uint8_t *)&value)[3]; @@ -14,7 +12,7 @@ return swapped; } -void WriteAndSeek(void **dst, const void *src, const size_t size) +void Ham_WriteAndSeek(void **dst, const void *src, const size_t size) { if (!dst || !*dst) { diff -Nru softether-vpn-5.02.0~202105242329~nightly~ubuntu21.10.1/src/libhamcore/Memory.h softether-vpn-5.02.0~202105261914~nightly~ubuntu21.10.1/src/libhamcore/Memory.h --- softether-vpn-5.02.0~202105242329~nightly~ubuntu21.10.1/src/libhamcore/Memory.h 2021-05-25 00:56:24.000000000 +0000 +++ softether-vpn-5.02.0~202105261914~nightly~ubuntu21.10.1/src/libhamcore/Memory.h 2021-05-27 06:53:18.000000000 +0000 @@ -7,13 +7,13 @@ #ifdef BYTE_ORDER_BIG_ENDIAN #define BigEndian32 #else -#define BigEndian32 Swap32 +#define BigEndian32 Ham_Swap32 #endif -size_t CompressionBufferSize(const size_t original_size); +#define CompressionBufferSize(original_size) (original_size * 2 + 256) -uint32_t Swap32(const uint32_t value); +uint32_t Ham_Swap32(const uint32_t value); -void WriteAndSeek(void **dst, const void *src, const size_t size); +void Ham_WriteAndSeek(void **dst, const void *src, const size_t size); #endif diff -Nru softether-vpn-5.02.0~202105242329~nightly~ubuntu21.10.1/src/Mayaqua/CMakeLists.txt softether-vpn-5.02.0~202105261914~nightly~ubuntu21.10.1/src/Mayaqua/CMakeLists.txt --- softether-vpn-5.02.0~202105242329~nightly~ubuntu21.10.1/src/Mayaqua/CMakeLists.txt 2021-05-25 00:56:08.000000000 +0000 +++ softether-vpn-5.02.0~202105261914~nightly~ubuntu21.10.1/src/Mayaqua/CMakeLists.txt 2021-05-27 06:52:24.000000000 +0000 @@ -22,7 +22,13 @@ # Required because we include in Encrypt.h. target_include_directories(mayaqua PUBLIC ${OPENSSL_INCLUDE_DIR}) -target_link_libraries(mayaqua PRIVATE OpenSSL::SSL OpenSSL::Crypto ZLIB::ZLIB) +target_link_libraries(mayaqua + PRIVATE + libhamcore + OpenSSL::SSL + OpenSSL::Crypto + ZLIB::ZLIB +) if(WIN32) set_target_properties(mayaqua diff -Nru softether-vpn-5.02.0~202105242329~nightly~ubuntu21.10.1/src/Mayaqua/FileIO.c softether-vpn-5.02.0~202105261914~nightly~ubuntu21.10.1/src/Mayaqua/FileIO.c --- softether-vpn-5.02.0~202105242329~nightly~ubuntu21.10.1/src/Mayaqua/FileIO.c 2021-05-25 00:56:08.000000000 +0000 +++ softether-vpn-5.02.0~202105261914~nightly~ubuntu21.10.1/src/Mayaqua/FileIO.c 2021-05-27 06:52:24.000000000 +0000 @@ -18,10 +18,12 @@ #include "Unix.h" #include "Win32.h" +#include + static char exe_file_name[MAX_SIZE] = "/tmp/a.out"; static wchar_t exe_file_name_w[MAX_SIZE] = L"/tmp/a.out"; static LIST *hamcore = NULL; -static IO *hamcore_io = NULL; +static HAMCORE *hamcore_io = NULL; #define NUM_CRC32_TABLE 256 static UINT crc32_table[NUM_CRC32_TABLE]; @@ -554,25 +556,6 @@ return true; } -// Rename to replace the file -bool FileReplaceRenameW(wchar_t *old_name, wchar_t *new_name) -{ - // Validate arguments - if (old_name == NULL || new_name == NULL) - { - return false; - } - - if (FileCopyW(old_name, new_name) == false) - { - return false; - } - - FileDeleteW(old_name); - - return true; -} - // Make the file name safe void ConvertSafeFileName(char *dst, UINT size, char *src) { @@ -735,244 +718,135 @@ } BUF *ReadHamcore(char *name) { - wchar_t tmp[MAX_SIZE]; - wchar_t exe_dir[MAX_SIZE]; - BUF *b; - char filename[MAX_PATH]; - // Validate arguments - if (name == NULL) + if (name == NULL || MayaquaIsMinimalMode()) { return NULL; } - if (name[0] == '|') + if (name[0] == '/') { - name++; + ++name; } - if (name[0] == '/' || name[0] == '\\') - { - name++; - } - - StrCpy(filename, sizeof(filename), name); - - ReplaceStrEx(filename, sizeof(filename), filename, "/", "\\", true); + char path[MAX_PATH]; + GetExeDir(path, sizeof(path)); + Format(path, sizeof(path), "%s/%s/%s", path, HAMCORE_DIR_NAME, name); - if (MayaquaIsMinimalMode()) + BUF *buf = ReadDump(path); + if (buf != NULL) { - return NULL; + return buf; } - // If the file exist in hamcore/ directory on the local disk, read it - GetExeDirW(exe_dir, sizeof(exe_dir)); - - UniFormat(tmp, sizeof(tmp), L"%s/%S/%S", exe_dir, HAMCORE_DIR_NAME, filename); - - b = ReadDumpW(tmp); - if (b != NULL) - { - return b; - } - - // Search from HamCore file system if it isn't found LockList(hamcore); { - HC t, *c; - UINT i; - - Zero(&t, sizeof(t)); - t.FileName = filename; - c = Search(hamcore, &t); - + HC t = {0}; + t.Path = name; + HC *c = Search(hamcore, &t); if (c == NULL) { - // File does not exist - b = NULL; - } - else - { - // File exists - if (c->Buffer != NULL) + const HAMCORE_FILE *file = HamcoreFind(hamcore_io, name); + if (file) { - // It is already loaded - b = NewBuf(); - WriteBuf(b, c->Buffer, c->Size); - SeekBuf(b, 0, 0); - c->LastAccess = Tick64(); - } - else - { - // Read from a file is if it is not read - if (FileSeek(hamcore_io, 0, c->Offset) == false) + c = Malloc(sizeof(HC)); + c->Size = file->OriginalSize; + c->Path = CopyStr(name); + c->Buffer = Malloc(c->Size); + + if (HamcoreRead(hamcore_io, c->Buffer, file)) { - // Failed to seek - b = NULL; + Add(hamcore, c); } else { - // Read the compressed data - void *data = Malloc(c->SizeCompressed); - if (FileRead(hamcore_io, data, c->SizeCompressed) == false) - { - // Failed to read - Free(data); - b = NULL; - } - else - { - // Expand - c->Buffer = ZeroMalloc(c->Size); - if (Uncompress(c->Buffer, c->Size, data, c->SizeCompressed) != c->Size) - { - // Failed to expand - Free(data); - Free(c->Buffer); - b = NULL; - } - else - { - // Successful - Free(data); - b = NewBuf(); - WriteBuf(b, c->Buffer, c->Size); - SeekBuf(b, 0, 0); - c->LastAccess = Tick64(); - } - } + Free(c->Buffer); + Free(c->Path); + Free(c); + + c = NULL; } } } - // Delete the expired cache - for (i = 0;i < LIST_NUM(hamcore);i++) + if (c != NULL) { - HC *c = LIST_DATA(hamcore, i); + buf = NewBuf(); + WriteBuf(buf, c->Buffer, c->Size); + SeekBuf(buf, 0, 0); + c->LastAccess = Tick64(); + } - if (c->Buffer != NULL) + LIST *to_delete = NewListFast(NULL); + + for (UINT i = 0; i < LIST_NUM(hamcore); ++i) + { + HC *c = LIST_DATA(hamcore, i); + if (c->LastAccess + HAMCORE_CACHE_EXPIRES <= Tick64()) { - if (((c->LastAccess + HAMCORE_CACHE_EXPIRES) <= Tick64()) || - (StartWith(c->FileName, "Li"))) - { - Free(c->Buffer); - c->Buffer = NULL; - } + Add(to_delete, c); } } + + for (UINT i = 0; i < LIST_NUM(to_delete); ++i) + { + HC *c = LIST_DATA(to_delete, i); + + Delete(hamcore, c); + + Free(c->Buffer); + Free(c->Path); + Free(c); + } + + ReleaseList(to_delete); } UnlockList(hamcore); - return b; + return buf; } // Initialization of HamCore file system void InitHamcore() { - wchar_t tmp[MAX_PATH]; - wchar_t tmp2[MAX_PATH]; - wchar_t exe_dir[MAX_PATH]; - UINT i, num; - char header[HAMCORE_HEADER_SIZE]; - - hamcore = NewList(CompareHamcore); - if (MayaquaIsMinimalMode()) { return; } - GetExeDirW(exe_dir, sizeof(exe_dir)); - UniFormat(tmp, sizeof(tmp), L"%s/%S", exe_dir, HAMCORE_FILE_NAME); - - UniFormat(tmp2, sizeof(tmp2), L"%s/%S", exe_dir, HAMCORE_FILE_NAME_2); - - // If there is _hamcore.se2, overwrite it yo the hamcore.se2 - FileReplaceRenameW(tmp2, tmp); - - // Read if there is a file hamcore.se2 - hamcore_io = FileOpenW(tmp, false); - if (hamcore_io == NULL) - { - // Look in other locations if it isn't found -#ifdef OS_WIN32 - UniFormat(tmp, sizeof(tmp), L"%S/%S", MsGetSystem32Dir(), HAMCORE_FILE_NAME); -#else // OS_WIN32 - UniFormat(tmp, sizeof(tmp), L"/bin/%S", HAMCORE_FILE_NAME); -#endif // OS_WIN32 - - hamcore_io = FileOpenW(tmp, false); - if (hamcore_io == NULL) - { - return; - } - } - - // Read the file header - Zero(header, sizeof(header)); - FileRead(hamcore_io, header, HAMCORE_HEADER_SIZE); - - if (Cmp(header, HAMCORE_HEADER_DATA, HAMCORE_HEADER_SIZE) != 0) + hamcore = NewList(CompareHamcore); +#ifdef HAMCORE_FILE_PATH + hamcore_io = HamcoreOpen(HAMCORE_FILE_PATH); + if (hamcore_io != NULL) { - // Invalid header - FileClose(hamcore_io); - hamcore_io = NULL; + Debug("InitHamcore(): Loaded from \"%s\".\n", HAMCORE_FILE_PATH); return; } +#endif + char path[MAX_PATH]; + GetExeDir(path, sizeof(path)); + Format(path, sizeof(path), "%s/%s", path, HAMCORE_FILE_NAME); - // The number of the File - num = 0; - FileRead(hamcore_io, &num, sizeof(num)); - num = Endian32(num); - for (i = 0;i < num;i++) + hamcore_io = HamcoreOpen(path); + if (hamcore_io != NULL) { - // File name - char tmp[MAX_SIZE]; - UINT str_size = 0; - HC *c; - - FileRead(hamcore_io, &str_size, sizeof(str_size)); - str_size = Endian32(str_size); - if (str_size >= 1) - { - str_size--; - } - - Zero(tmp, sizeof(tmp)); - FileRead(hamcore_io, tmp, str_size); - - c = ZeroMalloc(sizeof(HC)); - c->FileName = CopyStr(tmp); - - FileRead(hamcore_io, &c->Size, sizeof(UINT)); - c->Size = Endian32(c->Size); - - FileRead(hamcore_io, &c->SizeCompressed, sizeof(UINT)); - c->SizeCompressed = Endian32(c->SizeCompressed); - - FileRead(hamcore_io, &c->Offset, sizeof(UINT)); - c->Offset = Endian32(c->Offset); - - Insert(hamcore, c); + Debug("InitHamcore(): Loaded from \"%s\".\n", path); } } // Release of HamCore file system void FreeHamcore() { - UINT i; - for (i = 0;i < LIST_NUM(hamcore);i++) + for (UINT i = 0; i < LIST_NUM(hamcore); ++i) { HC *c = LIST_DATA(hamcore, i); - Free(c->FileName); - if (c->Buffer != NULL) - { - Free(c->Buffer); - } + + Free(c->Buffer); + Free(c->Path); Free(c); } ReleaseList(hamcore); - FileClose(hamcore_io); + HamcoreClose(hamcore_io); hamcore_io = NULL; hamcore = NULL; } @@ -991,7 +865,7 @@ { return 0; } - return StrCmpi(c1->FileName, c2->FileName); + return StrCmpi(c1->Path, c2->Path); } // Getting the name of the directory where the EXE file is in diff -Nru softether-vpn-5.02.0~202105242329~nightly~ubuntu21.10.1/src/Mayaqua/FileIO.h softether-vpn-5.02.0~202105261914~nightly~ubuntu21.10.1/src/Mayaqua/FileIO.h --- softether-vpn-5.02.0~202105242329~nightly~ubuntu21.10.1/src/Mayaqua/FileIO.h 2021-05-25 00:56:08.000000000 +0000 +++ softether-vpn-5.02.0~202105261914~nightly~ubuntu21.10.1/src/Mayaqua/FileIO.h 2021-05-27 06:52:24.000000000 +0000 @@ -10,11 +10,8 @@ #include "Mayaqua.h" -// Constant #define HAMCORE_DIR_NAME "hamcore" #define HAMCORE_FILE_NAME "hamcore.se2" -#define HAMCORE_FILE_NAME_2 "_hamcore.se2" -#define HAMCORE_TEXT_NAME "hamcore.txt" #define HAMCORE_CACHE_EXPIRES (5 * 60 * 1000) // IO structure @@ -33,12 +30,10 @@ // HC structure typedef struct HC { - char *FileName; // File name - UINT Size; // File size - UINT SizeCompressed; // Compressed file size - UINT Offset; // Offset - void *Buffer; // Buffer - UINT64 LastAccess; // Access Date + char *Path; + void *Buffer; + size_t Size; + UINT64 LastAccess; } HC; // DIRENT structure @@ -242,7 +237,6 @@ int CompareDirListByName(void *p1, void *p2); bool GetDiskFree(char *path, UINT64 *free_size, UINT64 *used_size, UINT64 *total_size); void ConvertSafeFileName(char *dst, UINT size, char *src); -bool FileReplaceRenameW(wchar_t *old_name, wchar_t *new_name); bool IsFile(char *name); bool IsFileW(wchar_t *name); bool SaveFileW(wchar_t *name, void *data, UINT size);