implement missing libabyss functionality

remove some finished TODOs
pull/283/head
Rick V 5 years ago
parent ad1179a333
commit 3931b7d9d7
No known key found for this signature in database
GPG Key ID: C0EDC8723FDC3465

@ -705,11 +705,11 @@ if(USE_LIBABYSS)
${ABYSS}/src/json.cpp)
add_library(${ABYSS_LIB} STATIC ${ABYSS_SRC})
set(ALL_SRC ${ALL_SRC} ${ABYSS_SRC} ${ABYSS}/main.cpp)
add_executable(${ABYSS_EXE} ${ABYSS}/main.cpp)
if (NOT WIN32)
add_executable(${ABYSS_EXE} ${ABYSS}/main.cpp)
target_link_libraries(${ABYSS_EXE} ${STATIC_LIB} ${UTIL_LIB} ${PLATFORM_LIB} Threads::Threads)
else()
add_executable(${ABYSS_EXE} ${ABYSS}/main.cpp llarp/win32/abyss.rc)
target_link_libraries(${ABYSS_EXE} ${STATIC_LIB} ${UTIL_LIB} ${PLATFORM_LIB} ws2_32 iphlpapi Threads::Threads)
endif(NOT WIN32)
@ -734,8 +734,8 @@ else()
add_executable(${TEST_EXE} ${TEST_SRC})
add_executable(${EXE} ${EXE_SRC})
else()
add_executable(${TEST_EXE} ${TEST_SRC} llarp/constants/version.rc)
add_executable(${EXE} ${EXE_SRC} llarp/constants/version.rc)
add_executable(${TEST_EXE} ${TEST_SRC} llarp/win32/test.rc)
add_executable(${EXE} ${EXE_SRC} llarp/win32/version.rc)
endif(NOT WIN32)
target_include_directories(${TEST_EXE} PRIVATE test)

@ -233,7 +233,7 @@ main(int argc, char *argv[])
}
// this is important, can downgrade from Info though
llarp::LogInfo("Running from: ", fs::current_path());
llarp::LogInfo("Running from: ", fs::current_path().string());
llarp::LogInfo("Using config file: ", conffname);
ctx = llarp_main_init(conffname.c_str(), multiThreaded);
int code = 1;

@ -28,6 +28,7 @@ llarp_ev_loop_alloc(struct llarp_ev_loop **ev)
#elif defined(_WIN32) || defined(_WIN64) || defined(__NT__)
*ev = new llarp_win32_loop;
#else
// TODO: fall back to a generic select-based event loop
#error no event loop subclass
#endif
(*ev)->init();

@ -259,7 +259,8 @@ namespace llarp
llarp::LogDebug("connected immedidately");
connected();
}
else if(WSAGetLastError() == WSAEINPROGRESS)
// Winsock 2.x no longer returns WSAEINPROGRESS
else if(WSAGetLastError() == WSAEWOULDBLOCK)
{
// in progress
llarp::LogDebug("connect in progress");
@ -273,7 +274,9 @@ namespace llarp
int err = WSAGetLastError();
FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM, nullptr, err, LANG_NEUTRAL,
ebuf, 1024, nullptr);
llarp::LogError("error connecting: ", ebuf);
int l = strlen(ebuf);
ebuf[l-2] = '\0'; // remove line break
llarp::LogError("error connecting: ", ebuf, " [", err, "]");
_conn->error(_conn);
}
}
@ -288,7 +291,9 @@ namespace llarp
int err = WSAGetLastError();
FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM, nullptr, err, LANG_NEUTRAL,
ebuf, 1024, nullptr);
llarp::LogError("failed to accept on ", fd, ":", ebuf);
int l = strlen(ebuf);
ebuf[l-2] = '\0'; // remove line break
llarp::LogError("failed to accept on ", fd, ":", ebuf, " [", err, "]");
return -1;
}
// build handler

@ -0,0 +1,124 @@
// WARNING: for the love of all that is good and holy
// please DO NOT convert this file to UTF-8, much less
// UTF-16 - the UNIX cross-rc does not understand UTF-16,
// and UTF-8 chews up the copyright symbols.
// -rick
//
// Microsoft Visual C++ generated resource script.
//
#include "resource.h"
#include <winresrc.h>
/////////////////////////////////////////////////////////////////////////////
// English (United States) resources
#define STRINGIZER(version) #version
#ifdef LLARP_RELEASE_MOTTO
#define VERSION_STRING(version, codename, revision) \
STRINGIZER(version) "-release [" STRINGIZER(codename) "] (rev-" STRINGIZER(revision) ")"
#else
#define VERSION_STRING(version, revision) \
STRINGIZER(version) STRINGIZER(revision)
#endif
#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)
#ifdef _WIN32
LANGUAGE 1033,1
#pragma code_page(1252)
#endif //_WIN32
#ifdef APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
// TEXTINCLUDE
//
1 TEXTINCLUDE
BEGIN
"resource.h\0"
END
2 TEXTINCLUDE
BEGIN
"\0"
END
3 TEXTINCLUDE
BEGIN
"\r\n"
"\0"
END
#endif // APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
// Version
//
VS_VERSION_INFO VERSIONINFO
FILEVERSION 0,4,0,0
PRODUCTVERSION 0,4,0,0
FILEFLAGSMASK 0x17L
#ifdef _DEBUG
FILEFLAGS 0x3L
#else
FILEFLAGS 0x2L
#endif
FILEOS 0x40004L
FILETYPE 0x1L
FILESUBTYPE 0x0L
BEGIN
BLOCK "StringFileInfo"
BEGIN
BLOCK "040904b0"
BEGIN
VALUE "Comments", "libabyss JSON-RPC daemon demo"
VALUE "CompanyName", "Loki Foundation"
VALUE "FileDescription", "LokiNET for Microsoft® Windows® NT™"
#ifdef LLARP_RELEASE_MOTTO
VALUE "FileVersion", VERSION_STRING(0.4.0, RELEASE_MOTTO, GIT_REV)
#else
VALUE "FileVersion", VERSION_STRING(0.4.0-dev-, GIT_REV)
#endif
VALUE "InternalName", "llarpd"
VALUE "LegalCopyright", "Copyright ©2018-2019 Jeff Becker, Rick V for the Loki Foundation. All rights reserved. This software is provided under the terms of the zlib-libpng licence; see the file LICENSE for details."
VALUE "OriginalFilename", "abyss-main.exe"
VALUE "ProductName", "LokiNET for Windows"
#ifdef LLARP_RELEASE_MOTTO
VALUE "ProductVersion", VERSION_STRING(0.4.0, RELEASE_MOTTO, GIT_REV)
#else
VALUE "ProductVersion", VERSION_STRING(0.4.0-dev-, GIT_REV)
#endif
END
END
BLOCK "VarFileInfo"
BEGIN
VALUE "Translation", 0x409, 1200
END
END
/////////////////////////////////////////////////////////////////////////////
//
// RT_MANIFEST
//
1 RT_MANIFEST "app.xml"
#endif // English (United States) resources
/////////////////////////////////////////////////////////////////////////////
#ifndef APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
// Generated from the TEXTINCLUDE 3 resource.
//
/////////////////////////////////////////////////////////////////////////////
#endif // not APSTUDIO_INVOKED

@ -0,0 +1,124 @@
// WARNING: for the love of all that is good and holy
// please DO NOT convert this file to UTF-8, much less
// UTF-16 - the UNIX cross-rc does not understand UTF-16,
// and UTF-8 chews up the copyright symbols.
// -rick
//
// Microsoft Visual C++ generated resource script.
//
#include "resource.h"
#include <winresrc.h>
/////////////////////////////////////////////////////////////////////////////
// English (United States) resources
#define STRINGIZER(version) #version
#ifdef LLARP_RELEASE_MOTTO
#define VERSION_STRING(version, codename, revision) \
STRINGIZER(version) "-release [" STRINGIZER(codename) "] (rev-" STRINGIZER(revision) ")"
#else
#define VERSION_STRING(version, revision) \
STRINGIZER(version) STRINGIZER(revision)
#endif
#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)
#ifdef _WIN32
LANGUAGE 1033,1
#pragma code_page(1252)
#endif //_WIN32
#ifdef APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
// TEXTINCLUDE
//
1 TEXTINCLUDE
BEGIN
"resource.h\0"
END
2 TEXTINCLUDE
BEGIN
"\0"
END
3 TEXTINCLUDE
BEGIN
"\r\n"
"\0"
END
#endif // APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
// Version
//
VS_VERSION_INFO VERSIONINFO
FILEVERSION 0,4,0,0
PRODUCTVERSION 0,4,0,0
FILEFLAGSMASK 0x17L
#ifdef _DEBUG
FILEFLAGS 0x3L
#else
FILEFLAGS 0x2L
#endif
FILEOS 0x40004L
FILETYPE 0x1L
FILESUBTYPE 0x0L
BEGIN
BLOCK "StringFileInfo"
BEGIN
BLOCK "040904b0"
BEGIN
VALUE "Comments", "LokiNET test suite"
VALUE "CompanyName", "Loki Foundation"
VALUE "FileDescription", "LokiNET for Microsoft® Windows® NT™"
#ifdef LLARP_RELEASE_MOTTO
VALUE "FileVersion", VERSION_STRING(0.4.0, RELEASE_MOTTO, GIT_REV)
#else
VALUE "FileVersion", VERSION_STRING(0.4.0-dev-, GIT_REV)
#endif
VALUE "InternalName", "llarpd"
VALUE "LegalCopyright", "Copyright ©2018-2019 Jeff Becker, Rick V for the Loki Foundation. All rights reserved. This software is provided under the terms of the zlib-libpng licence; see the file LICENSE for details."
VALUE "OriginalFilename", "llarpd.exe"
VALUE "ProductName", "LokiNET for Windows"
#ifdef LLARP_RELEASE_MOTTO
VALUE "ProductVersion", VERSION_STRING(0.4.0, RELEASE_MOTTO, GIT_REV)
#else
VALUE "ProductVersion", VERSION_STRING(0.4.0-dev-, GIT_REV)
#endif
END
END
BLOCK "VarFileInfo"
BEGIN
VALUE "Translation", 0x409, 1200
END
END
/////////////////////////////////////////////////////////////////////////////
//
// RT_MANIFEST
//
1 RT_MANIFEST "app.xml"
#endif // English (United States) resources
/////////////////////////////////////////////////////////////////////////////
#ifndef APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
// Generated from the TEXTINCLUDE 3 resource.
//
/////////////////////////////////////////////////////////////////////////////
#endif // not APSTUDIO_INVOKED

@ -83,7 +83,7 @@ BEGIN
VALUE "FileVersion", VERSION_STRING(0.4.0-dev-, GIT_REV)
#endif
VALUE "InternalName", "llarpd"
VALUE "LegalCopyright", "Copyright ©2018 Jeff Becker, Rick V for the Loki Foundation. All rights reserved. This software is provided under the terms of the zlib-libpng licence; see the file LICENSE for details."
VALUE "LegalCopyright", "Copyright ©2018-2019 Jeff Becker, Rick V for the Loki Foundation. All rights reserved. This software is provided under the terms of the zlib-libpng licence; see the file LICENSE for details."
VALUE "OriginalFilename", "llarpd.exe"
VALUE "ProductName", "LokiNET for Windows"
#ifdef LLARP_RELEASE_MOTTO

@ -29,12 +29,10 @@
#include <sys/stat.h>
// this is probably big enough to get
// the lesser of 96 sockets or whatever
// the lesser of 4096 sockets or whatever
// the system allows
// this used to be 4096, but i think
// that took ages to process
#ifndef FD_SETSIZE
#define FD_SETSIZE 96
#define FD_SETSIZE 4096
#endif
#include <io.h>

@ -251,17 +251,64 @@ TEST_F(TestCryptoTypesSecret, secret_key_from_file_happy_bencode)
// - file not writeable
// - happy path
#ifdef _WIN32
BOOL IsRunAsAdmin()
{
BOOL fIsRunAsAdmin = FALSE;
DWORD dwError = ERROR_SUCCESS;
PSID pAdministratorsGroup = NULL;
// Allocate and initialize a SID of the administrators group.
SID_IDENTIFIER_AUTHORITY NtAuthority = SECURITY_NT_AUTHORITY;
if (!AllocateAndInitializeSid(
&NtAuthority,
2,
SECURITY_BUILTIN_DOMAIN_RID,
DOMAIN_ALIAS_RID_ADMINS,
0, 0, 0, 0, 0, 0,
&pAdministratorsGroup))
{
dwError = GetLastError();
goto Cleanup;
}
// Determine whether the SID of administrators group is enabled in
// the primary access token of the process.
if (!CheckTokenMembership(NULL, pAdministratorsGroup, &fIsRunAsAdmin))
{
dwError = GetLastError();
goto Cleanup;
}
Cleanup:
// Centralized cleanup for all allocated resources.
if (pAdministratorsGroup)
{
FreeSid(pAdministratorsGroup);
pAdministratorsGroup = NULL;
}
// Throw the error if something failed in the function.
if (ERROR_SUCCESS != dwError)
{
throw dwError;
}
return fIsRunAsAdmin;
}
#endif
TEST_F(TestCryptoTypesSecret, secret_key_to_missing_file)
{
// Verify writing to an unwritable file fails.
// Assume we're not running as root, so can't write to /
// Assume we're not running as root, so can't write to [C:]/
// if we are root just skip this test
// TODO(despair): check elevation status, return if running
// as someone who can write to C:/
// (normal users cannot write to C:/)
#ifndef _WIN32
if(getuid() == 0)
return;
#else
if(IsRunAsAdmin())
return;
#endif
filename = "/" + filename;
p = filename;

@ -3,7 +3,7 @@ Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 15
VisualStudioVersion = 15.0.28307.102
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "lokivpn", "lokivpn\lokivpn.csproj", "{1CDEE73C-29C5-4781-BD74-1EEAC6F75A14}"
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "lokivpn", "lokivpn.csproj", "{1CDEE73C-29C5-4781-BD74-1EEAC6F75A14}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution

Loading…
Cancel
Save