Merge remote-tracking branch 'upstream/dev' into multithreaded-cryptography

pull/850/head
jeff 5 years ago
commit 32ed821763

6
.gitignore vendored

@ -60,3 +60,9 @@ GTAGS
GRTAGS
GPATH
version.txt
lokinet-bootstrap.exe
regdbhelper.dll
# xcode
xcuserdata/

@ -59,7 +59,20 @@ matrix:
- name: "address sanitizer"
os: osx
osx_image: xcode10.2
env: BUILD_TYPE=Debug ASAN=ON PATH="/usr/local/opt/ccache/libexec:$PATH" CC=/usr/local/opt/llvm/bin/clang CXX=/usr/local/opt/llvm/bin/clang++
env: BUILD_TYPE=Debug XSAN=address PATH="/usr/local/opt/ccache/libexec:$PATH" CC=/usr/local/opt/llvm/bin/clang CXX=/usr/local/opt/llvm/bin/clang++
- name: "thread sanitizer"
os: osx
osx_image: xcode10.2
env: BUILD_TYPE=Debug XSAN=thread PATH="/usr/local/opt/ccache/libexec:$PATH" CC=/usr/local/opt/llvm/bin/clang CXX=/usr/local/opt/llvm/bin/clang++
- name: "undefined sanitizer"
os: osx
osx_image: xcode10.2
env: BUILD_TYPE=Debug XSAN=undefined PATH="/usr/local/opt/ccache/libexec:$PATH" CC=/usr/local/opt/llvm/bin/clang CXX=/usr/local/opt/llvm/bin/clang++
- name: "memory sanitizer"
os: linux
dist: xenial
compiler: clang
env: BUILD_TYPE=Debug XSAN=memory
- name: "native windows debug"
os: windows
env: BUILD_TYPE=Debug

@ -16,11 +16,12 @@ option(AMD_RYZEN_HACK "hack for AMD Ryzen FPU bug (support FMA3 and FMA4 in FPU,
option(NATIVE_BUILD "optimise for host system and FPU, may not be portable" )
option(EMBEDDED_CFG "optimise for older hardware or embedded systems")
if (NOT MSVC)
option(STATIC_LINK "link statically against dependencies" OFF)
option(STATIC_LINK_RUNTIME "link statically against compiler runtime, standard library and pthreads")
endif()
option(NON_PC_TARGET "non-pc target build: iphone, andriod, embedded non-i386 SBC, etc" )
option(SHADOW "use shadow testing framework. linux only" )
option(ASAN "use address sanitiser, if your system has it" )
option(XSAN "use sanitiser, if your system has it" )
option(JEMALLOC "use jemalloc. Not required on BSD" )
option(DEBIAN "build for debian" )
option(TESTNET "testnet build" )
@ -35,6 +36,10 @@ include(cmake/add_import_library.cmake)
include(cmake/add_log_tag.cmake)
include(cmake/libatomic.cmake)
if (STATIC_LINK AND STATIC_LINK_RUNTIME)
message(FATAL "Cannot set both STATIC_LINK and STATIC_LINK_RUNTIME")
endif()
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/cmake")
# Basic definitions
@ -82,10 +87,10 @@ if(NOT DEBIAN AND NOT MSVC_VERSION)
set(DEBUG_FLAGS -O0 -g3)
endif()
if(ASAN)
set(DEBUG_FLAGS ${DEBUG_FLAGS} -fsanitize=address -fno-omit-frame-pointer)
if(XSAN)
set(DEBUG_FLAGS ${DEBUG_FLAGS} "-fsanitize=${XSAN}" -fno-omit-frame-pointer)
set(OPTIMIZE_FLAGS "-O0")
endif(ASAN)
endif(XSAN)
if(CMAKE_BUILD_TYPE MATCHES "[Dd][Ee][Bb][Uu][Gg]")
set(OPTIMIZE_FLAGS "")
@ -179,6 +184,7 @@ set(CMAKE_THREAD_PREFER_PTHREAD TRUE)
set(THREADS_PREFER_PTHREAD_FLAG TRUE)
find_package(Threads REQUIRED)
include(cmake/static_link_runtime.cmake)
include(cmake/static_link.cmake)
if(USE_NETNS)

@ -65,8 +65,10 @@ TOOLCHAIN ?=
AVX2 ?= OFF
# non x86 target
NON_PC_TARGET ?= OFF
# statically link
# statically link everything
STATIC_LINK ?= OFF
# statically link dependencies
STATIC ?= OFF
# enable network namespace isolation
NETNS ?= OFF
# enable shell hooks callbacks
@ -77,11 +79,13 @@ CROSS ?= OFF
SHARED_LIB ?= OFF
# enable generating coverage
COVERAGE ?= OFF
COVERAGE_OUTDIR ?= "$(TMPDIR)/lokinet-coverage"
# enable ASAN
ASAN ?= OFF
# tracy profiler
TRACY_ROOT ?=
# enable sanitizer
XSAN ?= False
# cmake generator type
CMAKE_GEN ?= Unix Makefiles
@ -109,9 +113,9 @@ else
CONFIG_CMD = $(shell /bin/echo -n "cd '$(BUILD_ROOT)' && " ; /bin/echo -n "cmake -G'$(CMAKE_GEN)' -DCMAKE_CROSSCOMPILING=$(CROSS) -DSTATIC_LINK_RUNTIME=$(STATIC_LINK) -DUSE_SHELLHOOKS=$(SHELL_HOOKS) -DUSE_NETNS=$(NETNS) -DUSE_AVX2=$(AVX2) -DNON_PC_TARGET=$(NON_PC_TARGET) -DWITH_SHARED=$(SHARED_LIB) -DTRACY_ROOT=$(TRACY_ROOT) -DCMAKE_EXPORT_COMPILE_COMMANDS=ON '$(REPO)'")
CONFIG_CMD_WINDOWS = $(shell /bin/echo -n "cd '$(BUILD_ROOT)' && " ; /bin/echo -n "cmake -G'$(CMAKE_GEN)' -DCMAKE_CROSSCOMPILING=ON -DSTATIC_LINK_RUNTIME=$(STATIC_LINK) -DUSE_SHELLHOOKS=$(SHELL_HOOKS) -DUSE_NETNS=$(NETNS) -DUSE_AVX2=$(AVX2) -DNON_PC_TARGET=$(NON_PC_TARGET) -DWITH_SHARED=$(SHARED_LIB) -DCMAKE_EXPORT_COMPILE_COMMANDS=ON '$(REPO)'")
ANALYZE_CONFIG_CMD = $(shell /bin/echo -n "cd '$(BUILD_ROOT)' && " ; /bin/echo -n "$(SCAN_BUILD) cmake -G'$(CMAKE_GEN)' -DCMAKE_CROSSCOMPILING=$(CROSS) -DSTATIC_LINK_RUNTIME=$(STATIC_LINK) -DUSE_NETNS=$(NETNS) -DUSE_AVX2=$(AVX2) -DNON_PC_TARGET=$(NON_PC_TARGET) -DWITH_SHARED=$(SHARED_LIB) -DASAN=$(ASAN) -DCMAKE_EXPORT_COMPILE_COMMANDS=ON '$(REPO)'")
ANALYZE_CONFIG_CMD = $(shell /bin/echo -n "cd '$(BUILD_ROOT)' && " ; /bin/echo -n "$(SCAN_BUILD) cmake -G'$(CMAKE_GEN)' -DCMAKE_CROSSCOMPILING=$(CROSS) -DSTATIC_LINK_RUNTIME=$(STATIC_LINK) -DUSE_NETNS=$(NETNS) -DUSE_AVX2=$(AVX2) -DNON_PC_TARGET=$(NON_PC_TARGET) -DWITH_SHARED=$(SHARED_LIB) -DXSAN=$(XSAN) -DCMAKE_EXPORT_COMPILE_COMMANDS=ON '$(REPO)'")
COVERAGE_CONFIG_CMD = $(shell /bin/echo -n "cd '$(BUILD_ROOT)' && " ; /bin/echo -n "cmake -G'$(CMAKE_GEN)' -DCMAKE_CROSSCOMPILING=$(CROSS) -DSTATIC_LINK_RUNTIME=$(STATIC_LINK) -DUSE_NETNS=$(NETNS) -DUSE_AVX2=$(AVX2) -DNON_PC_TARGET=$(NON_PC_TARGET) -DWITH_SHARED=$(SHARED_LIB) -DWITH_COVERAGE=yes -DASAN=$(ASAN) -DCMAKE_EXPORT_COMPILE_COMMANDS=ON '$(REPO)'")
COVERAGE_CONFIG_CMD = $(shell /bin/echo -n "cd '$(BUILD_ROOT)' && " ; /bin/echo -n "cmake -G'$(CMAKE_GEN)' -DCMAKE_CROSSCOMPILING=$(CROSS) -DSTATIC_LINK_RUNTIME=$(STATIC_LINK) -DUSE_NETNS=$(NETNS) -DUSE_AVX2=$(AVX2) -DNON_PC_TARGET=$(NON_PC_TARGET) -DWITH_SHARED=$(SHARED_LIB) -DWITH_COVERAGE=yes -DXSAN=$(XSAN) -DCMAKE_EXPORT_COMPILE_COMMANDS=ON '$(REPO)'")
endif
TARGETS = $(REPO)/lokinet
@ -141,7 +145,7 @@ debug-configure:
release-configure: clean
mkdir -p '$(BUILD_ROOT)'
$(CONFIG_CMD) -DCMAKE_BUILD_TYPE=Release -DRELEASE_MOTTO="$(shell cat motto.txt)" -DCMAKE_C_FLAGS='$(CFLAGS)' -DCMAKE_CXX_FLAGS='$(CXXFLAGS)'
$(CONFIG_CMD) -DCMAKE_BUILD_TYPE=Release -DSTATIC_LINK=ON -DRELEASE_MOTTO="$(shell cat motto.txt)" -DCMAKE_C_FLAGS='$(CFLAGS)' -DCMAKE_CXX_FLAGS='$(CXXFLAGS)'
debug: debug-configure
$(MAKE) -C $(BUILD_ROOT)

@ -1,11 +1,4 @@
if(NOT STATIC_LINK_RUNTIME)
return()
endif()
# not supported on Solaris - system libraries are not available as archives
# LTO is supported only for native builds
if(SOLARIS)
link_libraries( -static-libstdc++ -static-libgcc )
if(NOT STATIC_LINK)
return()
endif()
@ -16,25 +9,15 @@ else()
endif()
if (CMAKE_CXX_COMPILER_ID MATCHES "Clang")
if(APPLE)
link_libraries( -flto)
else()
link_libraries( -static -static-libstdc++ -pthread -flto )
endif()
link_libraries( -flto)
return()
endif()
if(NOT CMAKE_CROSSCOMPILING)
# this is messing with release builds
add_compile_options(-U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=0)
set(CMAKE_AR "gcc-ar")
set(CMAKE_C_ARCHIVE_CREATE "<CMAKE_AR> qcs <TARGET> <LINK_FLAGS> <OBJECTS>")
set(CMAKE_C_ARCHIVE_FINISH "true")
set(CMAKE_CXX_ARCHIVE_CREATE "<CMAKE_AR> qcs <TARGET> <LINK_FLAGS> <OBJECTS>")
set(CMAKE_CXX_ARCHIVE_FINISH "true")
link_libraries( -flto -static-libstdc++ -static-libgcc -static -Wl,--whole-archive -lpthread -Wl,--no-whole-archive )
else()
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -static-libstdc++ -static-libgcc -static -Wl,--whole-archive -lpthread -Wl,--no-whole-archive" )
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS}")
link_libraries( -flto )
endif()

@ -0,0 +1,40 @@
if(NOT STATIC_LINK_RUNTIME)
return()
endif()
# not supported on Solaris - system libraries are not available as archives
# LTO is supported only for native builds
if(SOLARIS)
link_libraries( -static-libstdc++ -static-libgcc )
return()
endif()
if(NOT CMAKE_CROSSCOMPILING)
add_compile_options(-static -flto)
else()
add_compile_options(-static)
endif()
if (CMAKE_CXX_COMPILER_ID MATCHES "Clang")
if(APPLE)
link_libraries( -flto)
else()
link_libraries( -static -static-libstdc++ -pthread -flto )
endif()
return()
endif()
if(NOT CMAKE_CROSSCOMPILING)
# this is messing with release builds
add_compile_options(-U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=0)
set(CMAKE_AR "gcc-ar")
set(CMAKE_C_ARCHIVE_CREATE "<CMAKE_AR> qcs <TARGET> <LINK_FLAGS> <OBJECTS>")
set(CMAKE_C_ARCHIVE_FINISH "true")
set(CMAKE_CXX_ARCHIVE_CREATE "<CMAKE_AR> qcs <TARGET> <LINK_FLAGS> <OBJECTS>")
set(CMAKE_CXX_ARCHIVE_FINISH "true")
link_libraries( -flto -static-libstdc++ -static-libgcc -static -Wl,--whole-archive -lpthread -Wl,--no-whole-archive )
else()
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -static-libstdc++ -static-libgcc -static -Wl,--whole-archive -lpthread -Wl,--no-whole-archive" )
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS}")
endif()

@ -8,7 +8,7 @@ include(CheckLibraryExists)
add_definitions(-DUNIX)
add_definitions(-DPOSIX)
if (STATIC_LINK_RUNTIME)
if (STATIC_LINK_RUNTIME OR STATIC_LINK)
set(LIBUV_USE_STATIC ON)
endif()

@ -20,7 +20,7 @@ if(NOT MSVC_VERSION)
# GNU ld sees fit to merge *all* the .ident sections in object files
# to .r[o]data section one after the other!
add_compile_options(-fno-ident -Wa,-mbig-obj)
link_libraries( -lshlwapi -ldbghelp )
link_libraries( -lws2_32 -liphlpapi -lshlwapi -ldbghelp )
add_definitions(-DWINVER=0x0500 -D_WIN32_WINNT=0x0500)
# Wait a minute, if we're not Microsoft C++, nor a Clang paired with Microsoft C++,
# then the only possible option has to be GNU or a GNU-linked Clang!

@ -1,4 +0,0 @@
*.o
mbedtls/
*.a
*.exe

@ -1,17 +0,0 @@
Copyright (c)2018-2019 Rick V. All rights reserved.
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages
arising from the use of this software.
Permission is granted to anyone to use this software for any purpose,
including commercial applications, and to alter it and redistribute it
freely, subject to the following restrictions:
1. The origin of this software must not be misrepresented; you must not
claim that you wrote the original software. If you use this software
in a product, an acknowledgment in the product documentation would be
appreciated but is not required.
2. Altered source versions must be plainly marked as such, and must not be
misrepresented as being the original software.
3. This notice may not be removed or altered from any source distribution.

@ -1,71 +0,0 @@
# makefile for windows bootstrap
# requires mbedtls to be installed somewhere, for both native and windows targets
# requires wget to be installed for ca bundle download
# to build:
# $ [g]make prepare;[g]make lokinet-bootstrap
# set this beforehand if you use clang
CC ?= i686-w64-mingw32-gcc
NATIVE_CC ?= cc
# set these for the native system
INCLUDE ?=
LIBS ?=
# set these for 32-bit windows if cross-compiling
WINNT_INCLUDE ?=
WINNT_LIBS ?=
ifdef LTO
LTO_FLAG = -flto
LTO_LDFLAG = -flto -march=nocona -mfpmath=sse -Ofast
endif
.PHONY: download prepare all default
# windows target only
.c.o:
$(CC) $(WINNT_INCLUDE) -Iinclude $(LTO_FLAG) -Ofast -march=nocona -mfpmath=sse $< -c
zpipe: zpipe.c miniz.c
$(NATIVE_CC) $(INCLUDE) -Iinclude $(LIBS) $^ -s -static -o $@
base64enc: base64enc.c
$(NATIVE_CC) $(INCLUDE) -Iinclude $(LIBS) $^ -s -static -o $@ -lmbedx509 -lmbedtls -lmbedcrypto
download:
wget -O ./cacert.pem https://curl.haxx.se/ca/cacert.pem
# I *think* this only work with GNU sed...
prepare: zpipe base64enc download
./zpipe < cacert.pem > data.enc
./base64enc < data.enc > out.bin
sed -ie "s/.\{76\}/&\n/g" out.bin
sed -i 's/.*/\"&\"/g' out.bin
sed -i '61,2268d' bootstrap.c
echo ';' >> out.bin
sed -i '60r out.bin' bootstrap.c
prepare-testnet: zpipe base64enc download
./zpipe < cacert.pem > data.enc
./base64enc < data.enc > out.bin
sed -ie "s/.\{76\}/&\n/g" out.bin
sed -i 's/.*/\"&\"/g' out.bin
sed -i '58,2144d' testnet.c
echo ';' >> out.bin
sed -i '57r out.bin' testnet.c
lokinet-bootstrap: bootstrap.o miniz.o
$(CC) $(WINNT_LIBS) -s -static $^ -o $@.exe $(LTO_LDFLAG) -lmbedx509 -lmbedtls -lmbedcrypto -lws2_32
lokinet-bootstrap-testnet: testnet.o miniz.o
$(CC) $(WINNT_LIBS) -s -static $^ -o $@.exe $(LTO_LDFLAG) -lmbedx509 -lmbedtls -lmbedcrypto -lws2_32
clean:
-@rm lokinet*.exe
-@rm base64enc
-@rm zpipe
-@rm cacert.pem
-@rm data.enc
-@rm out.*
-@rm *.o

@ -1,35 +0,0 @@
# LokiNET bootstrap for Windows
This is a tiny executable that does the same thing as the `lokinet-bootstrap` shell script for Linux, specifically for the purpose of bypassing broken or outdated versions of Schannel that do not support current versions of TLS.
# Building
## requirements
- mbedtls 2.13.0 or later, for both host and windows
- wget for host (to download Netscape CA bundle from cURL website)
- Also included is a patch that can be applied to the mbedtls source to enable features like AES-NI in protected mode, plus some networking fixes for win32
native build:
$ export INCLUDE=/mingw32/include LIBS=/mingw32/lib # or a different path
$ export CC=cc # change these if you use clang
$ export NATIVE_CC=$CC
$ export WINNT_INCLUDE=$INCLUDE WINNT_LIBS=$LIBS
$ make prepare;make lokinet-bootstrap
cross-compile build (If you have *GNU* sed, you can also update the certificate trust store with `make prepare`):
$ export INCLUDE=/usr/local/include LIBS=/usr/local/lib # or a different path
$ export CC=i686-w64-mingw32-gcc # change these if you use clang, make sure these are in your system $PATH!
$ export NATIVE_CC=cc
$ export WINNT_INCLUDE=/path/to/win32/headers WINNT_LIBS=/path/to/win32/libs
$ make lokinet-bootstrap
# Usage
C:\>lokinet-bootstrap [uri] [local download path]
this is also included in the lokinet installer package.
-rick

@ -1,64 +0,0 @@
/*
* Copyright (c)2018-2019 Rick V. All rights reserved.
*
* This software is provided 'as-is', without any express or implied
* warranty. In no event will the authors be held liable for any damages
* arising from the use of this software.
*
* Permission is granted to anyone to use this software for any purpose,
* including commercial applications, and to alter it and redistribute it
* freely, subject to the following restrictions:
*
* 1. The origin of this software must not be misrepresented; you must not
* claim that you wrote the original software. If you use this software
* in a product, an acknowledgment in the product documentation would be
* appreciated but is not required.
* 2. Altered source versions must be plainly marked as such, and must not be
* misrepresented as being the original software.
* 3. This notice may not be removed or altered from any source distribution.
*/
/* this is a tiny build-time utility that base64 encodes up to 512K
* of text/binary data from stdin. (On UNIX, we'd use GNU's [g]base64(1)
* to encode the stream. Can't guarantee that a windows user will have cygwin
* installed, so we bootstrap these at build-time instead.)
*
* here, it is used to encode the compressed zlib-stream of the
* Netscape root certificate trust store on behalf of the lokinet
* for NT bootstrap stubs.
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "sysconf.h"
#ifdef HAVE_SETMODE
# define SET_BINARY_MODE(handle) setmode(handle, O_BINARY)
#else
# define SET_BINARY_MODE(handle) ((void)0)
#endif
#include <mbedtls/base64.h>
#include <mbedtls/error.h>
main(argc, argv)
char** argv;
{
int size,r, inl;
unsigned char in[524288];
unsigned char out[1048576];
unsigned char err[1024];
memset(&in, 0, 524288);
memset(&out, 0, 1048576);
SET_BINARY_MODE(0);
/* Read up to 512K of data from stdin */
inl = fread(in, 1, 524288, stdin);
r = mbedtls_base64_encode(out, 1048576, &size, in, inl);
if (r)
{
mbedtls_strerror(r, err, 1024);
printf("error: %s\n", err);
return r;
}
fprintf(stdout, "%s", out);
return 0;
}

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

@ -1,95 +0,0 @@
/**
* sysconf.h -- system-dependent macros and settings
*
* Copyright (C) 2002-2004 Cosmin Truta.
* Permission to use and distribute freely.
* No warranty.
**/
#ifndef SYSCONF_H
#define SYSCONF_H
/*****************************************************************************/
/* Platform identifiers */
/* Detect Unix. */
#if defined(unix) || defined(__linux__) || defined(BSD) || defined(__CYGWIN__)
/* Add more systems here. */
# ifndef UNIX
# define UNIX
# endif
#endif
/* Detect MS-DOS. */
#if defined(__MSDOS__)
# ifndef MSDOS
# define MSDOS
# endif
#endif
/* TO DO: Detect OS/2. */
/* Detect Windows. */
#if defined(_WIN32) || defined(__WIN32__)
# ifndef WIN32
# define WIN32
# endif
#endif
#if defined(_WIN64)
# ifndef WIN64
# define WIN64
# endif
#endif
#if defined(_WINDOWS) || defined(WIN32) || defined(WIN64)
# ifndef WINDOWS
# define WINDOWS
# endif
#endif
/* Enable POSIX-friendly symbols on Microsoft (Visual) C. */
#ifdef _MSC_VER
# define _POSIX_
#endif
/*****************************************************************************/
/* Library access */
#if defined(UNIX)
# include <unistd.h>
#endif
#if defined(_POSIX_VERSION)
# include <fcntl.h>
# ifndef HAVE_ISATTY
# define HAVE_ISATTY
# endif
#endif
#if defined(MSDOS) || defined(OS2) || defined(WINDOWS) || defined(__CYGWIN__)
/* Add more systems here, e.g. MacOS 9 and earlier. */
# include <fcntl.h>
# include <io.h>
# ifndef HAVE_ISATTY
# define HAVE_ISATTY
# endif
# ifndef HAVE_SETMODE
# define HAVE_SETMODE
# endif
#endif
/* Standard I/O handles. */
#define STDIN 0
#define STDOUT 1
#define STDERR 2
/* Provide a placeholder for O_BINARY, if it doesn't exist. */
#ifndef O_BINARY
# define O_BINARY 0
#endif
#endif /* SYSCONF_H */

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

@ -1,209 +0,0 @@
/* zpipe.c: example of proper use of zlib's inflate() and deflate()
Not copyrighted -- provided to the public domain
Version 1.4 11 December 2005 Mark Adler */
/* Version history:
1.0 30 Oct 2004 First version
1.1 8 Nov 2004 Add void casting for unused return values
Use switch statement for inflate() return values
1.2 9 Nov 2004 Add assertions to document zlib guarantees
1.3 6 Apr 2005 Remove incorrect assertion in inf()
1.4 11 Dec 2005 Add hack to avoid MSDOS end-of-line conversions
Avoid some compiler warnings for input and output buffers
*/
#include <stdio.h>
#include <string.h>
#include <assert.h>
#include "miniz.h"
#if defined(MSDOS) || defined(OS2) || defined(WIN32) || defined(__CYGWIN__)
# include <fcntl.h>
# include <io.h>
# define SET_BINARY_MODE(file) setmode(fileno(file), O_BINARY)
#else
# define SET_BINARY_MODE(file)
#endif
#define CHUNK 16384
/* Compress from file source to file dest until EOF on source.
def() returns Z_OK on success, Z_MEM_ERROR if memory could not be
allocated for processing, Z_STREAM_ERROR if an invalid compression
level is supplied, Z_VERSION_ERROR if the version of zlib.h and the
version of the library linked do not match, or Z_ERRNO if there is
an error reading or writing the files. */
int def(FILE *source, FILE *dest, int level)
{
int ret, flush;
unsigned have;
z_stream strm;
unsigned char in[CHUNK];unsigned char out[CHUNK];
/* allocate deflate state */
strm.zalloc = Z_NULL;
strm.zfree = Z_NULL;
strm.opaque = Z_NULL;
ret = deflateInit(&strm, level);
if (ret != Z_OK)
return ret;
/* compress until end of file */
do {
strm.avail_in = fread(in, 1, CHUNK, source);
if (ferror(source)) {
(void)deflateEnd(&strm);
return Z_ERRNO;
}
flush = feof(source) ? Z_FINISH : Z_NO_FLUSH;
strm.next_in = in;
/* run deflate() on input until output buffer not full, finish
compression if all of source has been read in */
do {
strm.avail_out = CHUNK;
strm.next_out = out;
ret = deflate(&strm, flush); /* no bad return value */
assert(ret != Z_STREAM_ERROR); /* state not clobbered */
have = CHUNK - strm.avail_out;
if (fwrite(out, 1, have, dest) != have || ferror(dest)) {
(void)deflateEnd(&strm);
return Z_ERRNO;
}
} while (strm.avail_out == 0);
assert(strm.avail_in == 0); /* all input will be used */
/* done when last data in file processed */
} while (flush != Z_FINISH);
assert(ret == Z_STREAM_END); /* stream will be complete */
/* clean up and return */
(void)deflateEnd(&strm);
return Z_OK;
}
/* Decompress from file source to file dest until stream ends or EOF.
inf() returns Z_OK on success, Z_MEM_ERROR if memory could not be
allocated for processing, Z_DATA_ERROR if the deflate data is
invalid or incomplete, Z_VERSION_ERROR if the version of zlib.h and
the version of the library linked do not match, or Z_ERRNO if there
is an error reading or writing the files. */
int inf(FILE *source, FILE *dest)
{
int ret;
unsigned have;
z_stream strm;
unsigned char in[CHUNK];
unsigned char out[CHUNK];
/* allocate inflate state */
strm.zalloc = Z_NULL;
strm.zfree = Z_NULL;
strm.opaque = Z_NULL;
strm.avail_in = 0;
strm.next_in = Z_NULL;
ret = inflateInit(&strm);
if (ret != Z_OK)
return ret;
/* decompress until deflate stream ends or end of file */
do {
strm.avail_in = fread(in, 1, CHUNK, source);
if (ferror(source)) {
(void)inflateEnd(&strm);
return Z_ERRNO;
}
if (strm.avail_in == 0)
break;
strm.next_in = in;
/* run inflate() on input until output buffer not full */
do {
strm.avail_out = CHUNK;
strm.next_out = out;
ret = inflate(&strm, Z_NO_FLUSH);
assert(ret != Z_STREAM_ERROR); /* state not clobbered */
switch (ret) {
case Z_NEED_DICT:
ret = Z_DATA_ERROR; /* and fall through */
case Z_DATA_ERROR:
case Z_MEM_ERROR:
(void)inflateEnd(&strm);
return ret;
}
have = CHUNK - strm.avail_out;
if (fwrite(out, 1, have, dest) != have || ferror(dest)) {
(void)inflateEnd(&strm);
return Z_ERRNO;
}
} while (strm.avail_out == 0);
/* done when inflate() says it's done */
} while (ret != Z_STREAM_END);
/* clean up and return */
(void)inflateEnd(&strm);
return ret == Z_STREAM_END ? Z_OK : Z_DATA_ERROR;
}
/* report a zlib or i/o error */
void zerr(int ret)
{
fputs("zpipe: ", stderr);
switch (ret) {
case Z_ERRNO:
if (ferror(stdin))
fputs("error reading stdin\n", stderr);
if (ferror(stdout))
fputs("error writing stdout\n", stderr);
break;
case Z_STREAM_ERROR:
fputs("invalid compression level\n", stderr);
break;
case Z_DATA_ERROR:
fputs("invalid or incomplete deflate data\n", stderr);
break;
case Z_MEM_ERROR:
fputs("out of memory\n", stderr);
break;
case Z_VERSION_ERROR:
fputs("zlib version mismatch!\n", stderr);
}
}
/* compress or decompress from stdin to stdout */
int main(int argc, char **argv)
{
int ret;
/* avoid end-of-line conversions */
SET_BINARY_MODE(stdin);
SET_BINARY_MODE(stdout);
/* do compression if no arguments */
/* Warning: Not compatible with plain libz, dial it back down to
* 9 if this is required, uber-level is 10
* since we have everything crammed in miniz, we don't depend on
* libz at all.
*/
if (argc == 1) {
ret = def(stdin, stdout, MZ_UBER_COMPRESSION);
if (ret != Z_OK)
zerr(ret);
return ret;
}
/* do decompression if -d specified */
else if (argc == 2 && strcmp(argv[1], "-d") == 0) {
ret = inf(stdin, stdout);
if (ret != Z_OK)
zerr(ret);
return ret;
}
/* otherwise, report usage */
else {
fputs("zpipe usage: zpipe [-d] < source > dest\n", stderr);
return 1;
}
}

@ -1,17 +0,0 @@
# TUN/TAP driver v9 for Windows
in order to set up tunnels on Windows, you will need
to instal this driver.
* v9.9.2.3 is for Windows 2000/XP/2003 (NDIS 5.0-based)
* v9.21.2 is for Windows Vista/7/8.1 and 10 (NDIS 6.0, forward-compatible with NDIS 10.0)
to instal, extract the corresponding version of the driver for your
platform and run `%ARCH%/install_tap.cmd` in an elevated shell
to remove *ALL* virtual tunnel adapters, run `%ARCH%/del_tap.cmd` in an elevated shell. Use the
Device Manager snap-in to remove individual adapter instances.
Both are signed by OpenVPN Inc, and are available for 32- and 64-bit archs.
-despair86

@ -2,6 +2,7 @@
#include <llarp.h>
#include <util/fs.hpp>
#include <util/logging/logger.hpp>
#include <util/logging/ostream_logger.hpp>
#include <csignal>
@ -138,6 +139,7 @@ main(int argc, char *argv[])
("g,generate", "generate client config", cxxopts::value<bool>())
("r,router", "generate router config", cxxopts::value<bool>())
("f,force", "overwrite", cxxopts::value<bool>())
("c,colour", "colour output", cxxopts::value<bool>()->default_value("true"))
("d,debug", "debug mode - UNENCRYPTED TRAFFIC", cxxopts::value<bool>())
("config","path to configuration file", cxxopts::value<std::string>());
@ -160,6 +162,12 @@ main(int argc, char *argv[])
llarp::LogDebug("debug logging activated");
}
if(!result["colour"].as< bool >())
{
llarp::LogContext::Instance().logStream =
std::make_unique< llarp::OStreamLogStream >(false, std::cerr);
}
if(result.count("help"))
{
std::cout << options.help() << std::endl;

@ -55,6 +55,7 @@ main(int argc, char* argv[])
options.add_options()
("v,verbose", "Verbose", cxxopts::value<bool>())
("c,colour", "colour output", cxxopts::value<bool>()->default_value("true"))
("h,help", "help", cxxopts::value<bool>())
("j,json", "output in json", cxxopts::value<bool>())
("dump", "dump rc file", cxxopts::value<std::vector<std::string> >(), "FILE");
@ -70,7 +71,8 @@ main(int argc, char* argv[])
{
SetLogLevel(llarp::eLogDebug);
llarp::LogContext::Instance().logStream =
std::make_unique< llarp::OStreamLogStream >(std::cerr);
std::make_unique< llarp::OStreamLogStream >(
result["colour"].as< bool >(), std::cerr);
llarp::LogDebug("debug logging activated");
}

@ -1,9 +0,0 @@
*.o
mbedtls/
*.a
*.dll
*.so
*.exe
cacert.pem
*.enc
*.bin*

@ -1,17 +0,0 @@
Copyright (c)2018-2019 Rick V. All rights reserved.
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages
arising from the use of this software.
Permission is granted to anyone to use this software for any purpose,
including commercial applications, and to alter it and redistribute it
freely, subject to the following restrictions:
1. The origin of this software must not be misrepresented; you must not
claim that you wrote the original software. If you use this software
in a product, an acknowledgment in the product documentation would be
appreciated but is not required.
2. Altered source versions must be plainly marked as such, and must not be
misrepresented as being the original software.
3. This notice may not be removed or altered from any source distribution.

@ -1,62 +0,0 @@
# makefile for libhttp
# requires mbedtls to be installed somewhere, for both host and target systems
# requires wget to be installed for ca bundle download
# to build:
# make prepare; make libhttp
# set this beforehand if you use clang
# make sure to preset CFLAGS if you use non-ix86 platform
# or non-GNU-compat C compilation system
# Uncomment these if you're on a 32-bit Linux?
# CC = cc
# CFLAGS = -Ofast -march=nocona -mfpmath=sse
# path to mbedtls headers/libs and system libs
# if you have local copies of libs in this folder,
# try LIBS=-L. (other stuff here)
#
# -lsocket -lnsl on Sun
# -lws2_32 on windows nt
#INCLUDE :=
#LIBS :=
.PHONY: download prepare all default
.c.o:
$(CC) $(INCLUDE) -fPIC -Iinclude $(CFLAGS) $< -c
zpipe: zpipe.c miniz.c
$(CC) $(INCLUDE) -Iinclude $(CFLAGS) $^ -s -static -o $@
base64enc: base64enc.c
$(CC) $(INCLUDE) -Iinclude $(CFLAGS) $^ -s -static -o $@ -lmbedx509 -lmbedtls -lmbedcrypto $(LIBS)
download:
wget -O ./cacert.pem https://curl.haxx.se/ca/cacert.pem
# I *think* this only work with GNU sed...
prepare: zpipe base64enc download
./zpipe < cacert.pem > data.enc
./base64enc < data.enc > out.bin
sed -ie "s/.\{76\}/&\n/g" out.bin
sed -i 's/.*/\"&\"/g' out.bin
sed -i '38,2228d' cacerts.c
echo ';' >> out.bin
sed -i '37r out.bin' cacerts.c
libhttp.dll: cacerts.o miniz.o libhttp.o uri.o internal.o
$(CC) -fPIC $(CFLAGS) $^ -s -shared -o $@ -static -lmbedx509 -lmbedtls -lmbedcrypto $(LIBS)
libhttp.so: cacerts.o miniz.o libhttp.o uri.o internal.o
$(CC) $^ -fPIC $(CFLAGS) -shared -o $@ $(LIBS) -lmbedx509 -lmbedtls -lmbedcrypto $(SYS_LIBS)
clean:
-@rm base64enc
-@rm zpipe
-@rm cacert.pem
-@rm data.enc
-@rm out.*
-@rm *.o
-@rm *.so
-@rm *.dll

@ -1,26 +0,0 @@
# liblokiweb (libhttp)
## Building
### requirements
- mbedtls 2.13.0 or later, for both host and target (if cross-compiling)
- wget for host (to download Netscape root certificate store from cURL website)
- Also included is a patch that can be applied to the mbedtls source to enable features like AES-NI in protected mode, plus some networking fixes for win32, see `../contrib/lokinet-bootstrap-winnt/mbedtls-win32.patch`
build:
$ make prepare; make libhttp.[so|dll]
## Useful build-time variables
- INCLUDE: path to mbedtls headers
- LIBS: path to mbedtls libraries
- SYS_LIBS: system-specific link libraries (`-lsocket -lnsl` on Sun systems, `-lws2_32` [or `-lwsock32` if IPv6 is disabled] on Windows)
## Usage
- include libhttp.h in your source
- link against libhttp.[so|dll]
-rick

@ -1,64 +0,0 @@
/*
* Copyright (c)2018-2019 Rick V. All rights reserved.
*
* This software is provided 'as-is', without any express or implied
* warranty. In no event will the authors be held liable for any damages
* arising from the use of this software.
*
* Permission is granted to anyone to use this software for any purpose,
* including commercial applications, and to alter it and redistribute it
* freely, subject to the following restrictions:
*
* 1. The origin of this software must not be misrepresented; you must not
* claim that you wrote the original software. If you use this software
* in a product, an acknowledgment in the product documentation would be
* appreciated but is not required.
* 2. Altered source versions must be plainly marked as such, and must not be
* misrepresented as being the original software.
* 3. This notice may not be removed or altered from any source distribution.
*/
/* this is a tiny build-time utility that base64 encodes up to 512K
* of text/binary data from stdin. (On UNIX, we'd use GNU's [g]base64(1)
* to encode the stream. Can't guarantee that a windows user will have cygwin
* installed, so we bootstrap these at build-time instead.)
*
* here, it is used to encode the compressed zlib-stream of the
* Netscape root certificate trust store on behalf of the lokinet
* for NT bootstrap stubs.
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "sysconf.h"
#ifdef HAVE_SETMODE
# define SET_BINARY_MODE(handle) setmode(handle, O_BINARY)
#else
# define SET_BINARY_MODE(handle) ((void)0)
#endif
#include <mbedtls/base64.h>
#include <mbedtls/error.h>
main(argc, argv)
char** argv;
{
int size,r, inl;
unsigned char in[524288];
unsigned char out[1048576];
unsigned char err[1024];
memset(&in, 0, 524288);
memset(&out, 0, 1048576);
SET_BINARY_MODE(0);
/* Read up to 512K of data from stdin */
inl = fread(in, 1, 524288, stdin);
r = mbedtls_base64_encode(out, 1048576, &size, in, inl);
if (r)
{
mbedtls_strerror(r, err, 1024);
printf("error: %s\n", err);
return r;
}
fprintf(stdout, "%s", out);
return 0;
}

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

@ -1,95 +0,0 @@
/**
* sysconf.h -- system-dependent macros and settings
*
* Copyright (C) 2002-2004 Cosmin Truta.
* Permission to use and distribute freely.
* No warranty.
**/
#ifndef SYSCONF_H
#define SYSCONF_H
/*****************************************************************************/
/* Platform identifiers */
/* Detect Unix. */
#if defined(unix) || defined(__linux__) || defined(BSD) || defined(__CYGWIN__)
/* Add more systems here. */
# ifndef UNIX
# define UNIX
# endif
#endif
/* Detect MS-DOS. */
#if defined(__MSDOS__)
# ifndef MSDOS
# define MSDOS
# endif
#endif
/* TO DO: Detect OS/2. */
/* Detect Windows. */
#if defined(_WIN32) || defined(__WIN32__)
# ifndef WIN32
# define WIN32
# endif
#endif
#if defined(_WIN64)
# ifndef WIN64
# define WIN64
# endif
#endif
#if defined(_WINDOWS) || defined(WIN32) || defined(WIN64)
# ifndef WINDOWS
# define WINDOWS
# endif
#endif
/* Enable POSIX-friendly symbols on Microsoft (Visual) C. */
#ifdef _MSC_VER
# define _POSIX_
#endif
/*****************************************************************************/
/* Library access */
#if defined(UNIX)
# include <unistd.h>
#endif
#if defined(_POSIX_VERSION)
# include <fcntl.h>
# ifndef HAVE_ISATTY
# define HAVE_ISATTY
# endif
#endif
#if defined(MSDOS) || defined(OS2) || defined(WINDOWS) || defined(__CYGWIN__)
/* Add more systems here, e.g. MacOS 9 and earlier. */
# include <fcntl.h>
# include <io.h>
# ifndef HAVE_ISATTY
# define HAVE_ISATTY
# endif
# ifndef HAVE_SETMODE
# define HAVE_SETMODE
# endif
#endif
/* Standard I/O handles. */
#define STDIN 0
#define STDOUT 1
#define STDERR 2
/* Provide a placeholder for O_BINARY, if it doesn't exist. */
#ifndef O_BINARY
# define O_BINARY 0
#endif
#endif /* SYSCONF_H */

@ -1,39 +0,0 @@
/*
* Copyright (c)2018-2019 Rick V. All rights reserved.
*
* This software is provided 'as-is', without any express or implied
* warranty. In no event will the authors be held liable for any damages
* arising from the use of this software.
*
* Permission is granted to anyone to use this software for any purpose,
* including commercial applications, and to alter it and redistribute it
* freely, subject to the following restrictions:
*
* 1. The origin of this software must not be misrepresented; you must not
* claim that you wrote the original software. If you use this software
* in a product, an acknowledgment in the product documentation would be
* appreciated but is not required.
* 2. Altered source versions must be plainly marked as such, and must not be
* misrepresented as being the original software.
* 3. This notice may not be removed or altered from any source distribution.
*------------------------------------------------------------------------------
* internal utility functions for libhttp
*/
#include <stdio.h>
#include <stdlib.h>
#include <stdbool.h>
#include <string.h>
#include "internal.h"
void *memncat(a, an, b, bn, s)
const void *a, *b;
size_t an, bn, s;
{
char *p = malloc(s * (an + bn));
memset(p, '\0', s * (an + bn));
memcpy(p, a, an*s);
memcpy(p + an*s, b, bn*s);
return p;
}

@ -1,84 +0,0 @@
/*
* Copyright (c)2018-2019 Rick V. All rights reserved.
*
* This software is provided 'as-is', without any express or implied
* warranty. In no event will the authors be held liable for any damages
* arising from the use of this software.
*
* Permission is granted to anyone to use this software for any purpose,
* including commercial applications, and to alter it and redistribute it
* freely, subject to the following restrictions:
*
* 1. The origin of this software must not be misrepresented; you must not
* claim that you wrote the original software. If you use this software
* in a product, an acknowledgment in the product documentation would be
* appreciated but is not required.
* 2. Altered source versions must be plainly marked as such, and must not be
* misrepresented as being the original software.
* 3. This notice may not be removed or altered from any source distribution.
*------------------------------------------------------------------------------
* this file contains internal definitions of libhttp data structures
* internal.h and libhttp.h are mutually exclusive as they define the same
* data structures, library clients must use libhttp.h
*
*/
#ifndef INTERNAL_H
#define INTERNAL_H
/* PolarSSL */
#include <mbedtls/ssl.h>
#include <mbedtls/entropy.h>
#include <mbedtls/ctr_drbg.h>
#include <mbedtls/net_sockets.h>
#include <mbedtls/error.h>
#include <mbedtls/certs.h>
#include <mbedtls/base64.h>
/* function declarations */
void free_parsed_url();
parse_url();
void *memncat();
typedef struct url_parser_url
{
char *protocol;
char *host;
int port;
char *path;
char *query_string;
int host_exists;
char *host_ip;
} url_t;
typedef struct
{
char *ua; /* platform-specific user-agent string */
char *request_uri; /* last uri requested, the response corresponds to this link */
struct responseBody
{
/* the raw_data and headers point to the same place */
/* the content is an offset into the raw_data */
union
{
char* raw_data;
char* headers;
};
char* content;
};
/* not a public field */
struct
{
mbedtls_net_context server_fd;
mbedtls_entropy_context entropy;
mbedtls_ctr_drbg_context ctr_drbg;
mbedtls_ssl_context ssl;
mbedtls_ssl_config conf;
mbedtls_x509_crt cacert;
bool TLSInit;
char seed[64];
} tls_state;
} http_state;
#endif

@ -1,301 +0,0 @@
/*
* Copyright (c)2018-2019 Rick V. All rights reserved.
*
* This software is provided 'as-is', without any express or implied
* warranty. In no event will the authors be held liable for any damages
* arising from the use of this software.
*
* Permission is granted to anyone to use this software for any purpose,
* including commercial applications, and to alter it and redistribute it
* freely, subject to the following restrictions:
*
* 1. The origin of this software must not be misrepresented; you must not
* claim that you wrote the original software. If you use this software
* in a product, an acknowledgment in the product documentation would be
* appreciated but is not required.
* 2. Altered source versions must be plainly marked as such, and must not be
* misrepresented as being the original software.
* 3. This notice may not be removed or altered from any source distribution.
*------------------------------------------------------------------------------
* libhttp, a really small HTTP 0-3 client library with TLS
*
* HTTPS only; why the hell would you serve semi-sensitive data over an
* unencrypted channel? In fact, the polarssl integration is intended to
* bypass limitations in the native TLS stack (no TLS 1.1+ on some older
* platforms, lack of high-encryption ciphersuites other than ARC4 or
* Triple-DES, etc)
* -rick
*/
#include <stdio.h>
#include <stdlib.h>
#include <stdbool.h>
#ifdef _WIN32
#include <windows.h>
#include <wincrypt.h>
#endif
#include "miniz.h"
#include "internal.h"
/* only decompress rootcerts once */
unsigned char* ca_certs = NULL;
/* netscape ca bundle */
const unsigned char *ca_cert_store_encoded;
/* imageboard ref just because */
static char userAgent[] = "NetRunner_Micro/0.1 PolarSSL/2.16.0;U;";
static void destroy_persistent_data()
{
free(ca_certs);
ca_certs = NULL;
}
static bool generateSeed(client)
http_state *client;
{
#ifdef _WIN32
HCRYPTPROV hprovider;
/* On Windows NT 4.0 or later, use CryptoAPI to grab 64 bytes of random data */
hprovider = 0;
CryptAcquireContext(&hprovider, NULL, NULL, PROV_RSA_FULL, CRYPT_VERIFYCONTEXT | CRYPT_SILENT);
CryptGenRandom(hprovider, 64, (BYTE*)&client->tls_state.seed);
CryptReleaseContext(hprovider, 0);
#endif
client->tls_state.seed[63] = '\0'; /* null-terminate for safety */
return true;
}
static bool initTLS(client)
http_state *client;
{
int inf_status,r;
size_t out;
unsigned long inf_len;
unsigned char* tmp;
char str[512];
mbedtls_net_init(&client->tls_state.server_fd);
mbedtls_ssl_init(&client->tls_state.ssl);
mbedtls_ssl_config_init(&client->tls_state.conf);
mbedtls_x509_crt_init(&client->tls_state.cacert);
mbedtls_entropy_init(&client->tls_state.entropy);
mbedtls_ctr_drbg_init(&client->tls_state.ctr_drbg);
/* only decompress once */
if (!ca_certs)
{
tmp = malloc(524288);
r = strlen(ca_cert_store_encoded) - 1;
r = mbedtls_base64_decode(tmp, 524288, &out, ca_cert_store_encoded, r);
if (r)
{
mbedtls_strerror(r, (char*)tmp, 524288);
printf("decoding failed: %s\n", tmp);
free(tmp);
return false;
}
/* inflate ca certs, they are still compressed */
ca_certs = malloc(524288);
inf_len = 524288;
inf_status = uncompress(ca_certs, &inf_len, tmp, out);
if (inf_status != Z_OK)
{
printf("decompression failed: %s\n", mz_error(inf_status));
free(tmp);
return false;
}
free(tmp);
}
if (!generateSeed())
return false;
if (mbedtls_ctr_drbg_seed(&client->tls_state.ctr_drbg, mbedtls_entropy_func, &client->tls_state.entropy, (const unsigned char*)client->tls_state.seed, 64)) {
return false;
}
r = mbedtls_x509_crt_parse(&client->tls_state.cacert, ca_certs, inf_len+1);
if (r < 0) {
mbedtls_strerror(r, str, 512);
printf("parse ca cert store failed\n ! mbedtls_x509_crt_parse returned: %s\n\n", str);
return false;
}
client->tls_state.TLSInit = true;
return true;
}
/* if false, library may be in an inconsistent state,
* call terminate_client()
*/
bool init_client(client)
http_state* client;
{
if (!ca_certs)
atexit(destroy_persistent_data);
if (!client)
client = calloc(1, sizeof(http_state));
initTLS(client);
return client->tls_state.TLSInit;
}
static void ua_string(client)
http_state *client;
{
/* fill in user-agent string */
#ifdef _WIN32
DWORD version, major, minor, build;
version = GetVersion();
major = (DWORD)(LOBYTE(LOWORD(version)));
minor = (DWORD)(HIBYTE(LOWORD(version)));
if (version < 0x80000000)
build = (DWORD)(HIWORD(version));
client->ua = malloc(512);
snprintf(client->ua, 512, "%sWindows NT %d.%d", userAgent, major, minor);
#endif
}
download_https_resource(client, uri)
http_state *client;
char *uri;
{
int r, len;
char buf[1024], port[8];
char *rq, *resp;
unsigned flags;
url_t *parsed_uri;
rq = malloc(4096);
/* this string gets readjusted each time we make a request */
client->request_uri = realloc(NULL, strlen(uri)+1);
parsed_uri = malloc(sizeof(url_t));
memset(parsed_uri, 0, sizeof(url_t));
r = parse_url(uri, false, parsed_uri);
if (r)
{
printf("Invalid URI pathspec\n");
return -1;
}
if (!client->tls_state.TLSInit)
{
printf("Failed to initialise polarssl\n");
return -1;
}
/* get host name, set port if blank */
if (!strcmp("https", parsed_uri->protocol) && !parsed_uri->port)
parsed_uri->port = 443;
printf("connecting to %s on port %d...",parsed_uri->host, parsed_uri->port);
sprintf(port, "%d", parsed_uri->port);
r = mbedtls_net_connect(&client->tls_state.server_fd, parsed_uri->host, port, MBEDTLS_NET_PROTO_TCP);
if (r)
{
printf("error - failed to connect to server: %d\n", r);
goto exit;
}
r = mbedtls_ssl_config_defaults(&client->tls_state.conf, MBEDTLS_SSL_IS_CLIENT, MBEDTLS_SSL_TRANSPORT_STREAM, MBEDTLS_SSL_PRESET_DEFAULT);
if (r)
{
printf("error - failed to set TLS options: %d\n", r);
goto exit;
}
mbedtls_ssl_conf_authmode(&client->tls_state.conf, MBEDTLS_SSL_VERIFY_REQUIRED);
mbedtls_ssl_conf_ca_chain(&client->tls_state.conf, &client->tls_state.cacert, NULL);
mbedtls_ssl_conf_rng(&client->tls_state.conf, mbedtls_ctr_drbg_random, &client->tls_state.ctr_drbg);
r = mbedtls_ssl_setup(&client->tls_state.ssl, &client->tls_state.conf);
if (r)
{
printf("error - failed to setup TLS session: %d\n", r);
goto exit;
}
r = mbedtls_ssl_set_hostname(&client->tls_state.ssl, parsed_uri->host);
if (r)
{
printf("error - failed to perform SNI: %d\n", r);
goto exit;
}
mbedtls_ssl_set_bio(&client->tls_state.ssl, &client->tls_state.server_fd, mbedtls_net_send, mbedtls_net_recv, NULL);
while ((r = mbedtls_ssl_handshake(&client->tls_state.ssl)) != 0)
{
if (r != MBEDTLS_ERR_SSL_WANT_READ && r != MBEDTLS_ERR_SSL_WANT_WRITE)
{
printf(" failed\n ! mbedtls_ssl_handshake returned -0x%x\n\n", -r);
goto exit;
}
}
if ((flags = mbedtls_ssl_get_verify_result(&client->tls_state.ssl)) != 0)
{
char vrfy_buf[512];
printf(" failed\n");
mbedtls_x509_crt_verify_info(vrfy_buf, sizeof(vrfy_buf), " ! ", flags);
printf("%s\n", vrfy_buf);
goto exit;
}
printf("\nDownloading %s...", &parsed_uri->path[1]);
snprintf(rq, 512, "GET %s HTTP/1.0\r\nHost: %s\r\nUser-Agent: %s\r\n\r\n", parsed_uri->path, parsed_uri->host, client->ua);
while ((r = mbedtls_ssl_write(&client->tls_state.ssl, (unsigned char*)rq, strlen(rq))) <= 0)
{
if (r != MBEDTLS_ERR_SSL_WANT_READ && r != MBEDTLS_ERR_SSL_WANT_WRITE)
{
printf("failed! error %d\n\n", r);
goto exit;
}
}
memset(rq, 0, 4096);
len = 0;
do {
r = mbedtls_ssl_read(&client->tls_state.ssl, (unsigned char*)buf, 1024);
if (r <= 0)
break;
else
{
rq = memncat(rq, len, buf, r, sizeof(char));
len += r;
}
} while (r);
printf("%d bytes downloaded to core.\n", len);
mbedtls_ssl_close_notify(&client->tls_state.ssl);
if (!strstr(rq, "200 OK"))
{
printf("An error occurred.\n");
printf("Server response:\n%s", rq);
goto exit;
}
/* Response body is in buf after processing */
resp = strstr(rq, "Content-Length");
r = strcspn(resp, "0123456789");
memcpy(buf, &resp[r], 4);
buf[3] = '\0';
r = atoi(buf);
resp = strstr(rq, "\r\n\r\n");
memcpy(buf, &resp[4], r);
r = 0;
exit:
free(rq);
free_parsed_url(parsed_uri);
return r;
}
void terminate_client(client)
http_state *client;
{
mbedtls_ssl_close_notify(&client->tls_state.ssl);
mbedtls_net_free(&client->tls_state.server_fd);
mbedtls_x509_crt_free(&client->tls_state.cacert);
mbedtls_ssl_free(&client->tls_state.ssl);
mbedtls_ssl_config_free(&client->tls_state.conf);
mbedtls_ctr_drbg_free(&client->tls_state.ctr_drbg);
mbedtls_entropy_free(&client->tls_state.entropy);
free(client->ua);
}

@ -1,59 +0,0 @@
/*
* Copyright (c)2018-2019 Rick V. All rights reserved.
*
* This software is provided 'as-is', without any express or implied
* warranty. In no event will the authors be held liable for any damages
* arising from the use of this software.
*
* Permission is granted to anyone to use this software for any purpose,
* including commercial applications, and to alter it and redistribute it
* freely, subject to the following restrictions:
*
* 1. The origin of this software must not be misrepresented; you must not
* claim that you wrote the original software. If you use this software
* in a product, an acknowledgment in the product documentation would be
* appreciated but is not required.
* 2. Altered source versions must be plainly marked as such, and must not be
* misrepresented as being the original software.
* 3. This notice may not be removed or altered from any source distribution.
*------------------------------------------------------------------------------
* libhttp, a really small HTTP 0-3 client library with TLS
* public API header
* do not include this file in any of the libhttp sources itself
*
* HTTPS only; why the hell would you serve semi-sensitive data over an
* unencrypted channel? In fact, the polarssl integration is intended to
* bypass limitations in the native TLS stack (no TLS 1.1+ on some older
* platforms, lack of high-encryption ciphersuites other than ARC4 or
* Triple-DES, etc)
* -rick
*/
#ifndef LIBHTTP_H
#define LIBHTTP_H
/* http client object */
typedef struct
{
char *ua; /* platform-specific user-agent string */
char *request_uri; /* last uri requested, the response corresponds to this link */
struct responseBody
{
/* the raw_data and headers point to the same place */
/* the content is an offset into the raw_data */
union
{
char* raw_data;
char* headers;
};
char* content;
};
/* anonymous field, do not poke */
void *reserved;
} http_state;
/* libhttp public API */
bool init_client(http_state*);
int download_https_resource(http_state*, char*);
void terminate_client(http_state*);
#endif

File diff suppressed because it is too large Load Diff

@ -1,138 +0,0 @@
/*
* Copyright (c)2018-2019 Rick V. All rights reserved.
*
* This software is provided 'as-is', without any express or implied
* warranty. In no event will the authors be held liable for any damages
* arising from the use of this software.
*
* Permission is granted to anyone to use this software for any purpose,
* including commercial applications, and to alter it and redistribute it
* freely, subject to the following restrictions:
*
* 1. The origin of this software must not be misrepresented; you must not
* claim that you wrote the original software. If you use this software
* in a product, an acknowledgment in the product documentation would be
* appreciated but is not required.
* 2. Altered source versions must be plainly marked as such, and must not be
* misrepresented as being the original software.
* 3. This notice may not be removed or altered from any source distribution.
*------------------------------------------------------------------------------
* uri parsing functions
*/
#include <stdio.h>
#include <stdlib.h>
#include <stdbool.h>
#include <assert.h>
#include "internal.h"
#ifdef _WIN32
#include <windows.h>
#include <wincrypt.h>
#else
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <netdb.h>
#endif
void free_parsed_url(url_parsed)
url_t *url_parsed;
{
if (url_parsed->protocol)
free(url_parsed->protocol);
if (url_parsed->host)
free(url_parsed->host);
if (url_parsed->path)
free(url_parsed->path);
if (url_parsed->query_string)
free(url_parsed->query_string);
free(url_parsed);
}
parse_url(url, verify_host, parsed_url)
char *url;
bool verify_host;
url_t *parsed_url;
{
char *local_url, *token, *token_host, *host_port, *host_ip, *token_ptr;
char *host_token_ptr, *path = NULL;
/* Copy our string */
local_url = strdup(url);
token = strtok_r(local_url, ":", &token_ptr);
parsed_url->protocol = strdup(token);
/* Host:Port */
token = strtok_r(NULL, "/", &token_ptr);
if (token)
host_port = strdup(token);
else
host_port = (char *) calloc(1, sizeof(char));
token_host = strtok_r(host_port, ":", &host_token_ptr);
parsed_url->host_ip = NULL;
if (token_host) {
parsed_url->host = strdup(token_host);
if (verify_host) {
struct hostent *host;
host = gethostbyname(parsed_url->host);
if (host != NULL) {
parsed_url->host_ip = inet_ntoa(* (struct in_addr *) host->h_addr);
parsed_url->host_exists = 1;
} else {
parsed_url->host_exists = 0;
}
} else {
parsed_url->host_exists = -1;
}
} else {
parsed_url->host_exists = -1;
parsed_url->host = NULL;
}
/* Port */
token_host = strtok_r(NULL, ":", &host_token_ptr);
if (token_host)
parsed_url->port = atoi(token_host);
else
parsed_url->port = 0;
token_host = strtok_r(NULL, ":", &host_token_ptr);
assert(token_host == NULL);
token = strtok_r(NULL, "?", &token_ptr);
parsed_url->path = NULL;
if (token) {
path = (char *) realloc(path, sizeof(char) * (strlen(token) + 2));
memset(path, 0, sizeof(char) * (strlen(token)+2));
strcpy(path, "/");
strcat(path, token);
parsed_url->path = strdup(path);
free(path);
} else {
parsed_url->path = (char *) malloc(sizeof(char) * 2);
strcpy(parsed_url->path, "/");
}
token = strtok_r(NULL, "?", &token_ptr);
if (token) {
parsed_url->query_string = (char *) malloc(sizeof(char) * (strlen(token) + 1));
strncpy(parsed_url->query_string, token, strlen(token));
} else {
parsed_url->query_string = NULL;
}
token = strtok_r(NULL, "?", &token_ptr);
assert(token == NULL);
free(local_url);
free(host_port);
return 0;
}

@ -1,209 +0,0 @@
/* zpipe.c: example of proper use of zlib's inflate() and deflate()
Not copyrighted -- provided to the public domain
Version 1.4 11 December 2005 Mark Adler */
/* Version history:
1.0 30 Oct 2004 First version
1.1 8 Nov 2004 Add void casting for unused return values
Use switch statement for inflate() return values
1.2 9 Nov 2004 Add assertions to document zlib guarantees
1.3 6 Apr 2005 Remove incorrect assertion in inf()
1.4 11 Dec 2005 Add hack to avoid MSDOS end-of-line conversions
Avoid some compiler warnings for input and output buffers
*/
#include <stdio.h>
#include <string.h>
#include <assert.h>
#include "miniz.h"
#if defined(MSDOS) || defined(OS2) || defined(WIN32) || defined(__CYGWIN__)
# include <fcntl.h>
# include <io.h>
# define SET_BINARY_MODE(file) setmode(fileno(file), O_BINARY)
#else
# define SET_BINARY_MODE(file)
#endif
#define CHUNK 16384
/* Compress from file source to file dest until EOF on source.
def() returns Z_OK on success, Z_MEM_ERROR if memory could not be
allocated for processing, Z_STREAM_ERROR if an invalid compression
level is supplied, Z_VERSION_ERROR if the version of zlib.h and the
version of the library linked do not match, or Z_ERRNO if there is
an error reading or writing the files. */
int def(FILE *source, FILE *dest, int level)
{
int ret, flush;
unsigned have;
z_stream strm;
unsigned char in[CHUNK];unsigned char out[CHUNK];
/* allocate deflate state */
strm.zalloc = Z_NULL;
strm.zfree = Z_NULL;
strm.opaque = Z_NULL;
ret = deflateInit(&strm, level);
if (ret != Z_OK)
return ret;
/* compress until end of file */
do {
strm.avail_in = fread(in, 1, CHUNK, source);
if (ferror(source)) {
(void)deflateEnd(&strm);
return Z_ERRNO;
}
flush = feof(source) ? Z_FINISH : Z_NO_FLUSH;
strm.next_in = in;
/* run deflate() on input until output buffer not full, finish
compression if all of source has been read in */
do {
strm.avail_out = CHUNK;
strm.next_out = out;
ret = deflate(&strm, flush); /* no bad return value */
assert(ret != Z_STREAM_ERROR); /* state not clobbered */
have = CHUNK - strm.avail_out;
if (fwrite(out, 1, have, dest) != have || ferror(dest)) {
(void)deflateEnd(&strm);
return Z_ERRNO;
}
} while (strm.avail_out == 0);
assert(strm.avail_in == 0); /* all input will be used */
/* done when last data in file processed */
} while (flush != Z_FINISH);
assert(ret == Z_STREAM_END); /* stream will be complete */
/* clean up and return */
(void)deflateEnd(&strm);
return Z_OK;
}
/* Decompress from file source to file dest until stream ends or EOF.
inf() returns Z_OK on success, Z_MEM_ERROR if memory could not be
allocated for processing, Z_DATA_ERROR if the deflate data is
invalid or incomplete, Z_VERSION_ERROR if the version of zlib.h and
the version of the library linked do not match, or Z_ERRNO if there
is an error reading or writing the files. */
int inf(FILE *source, FILE *dest)
{
int ret;
unsigned have;
z_stream strm;
unsigned char in[CHUNK];
unsigned char out[CHUNK];
/* allocate inflate state */
strm.zalloc = Z_NULL;
strm.zfree = Z_NULL;
strm.opaque = Z_NULL;
strm.avail_in = 0;
strm.next_in = Z_NULL;
ret = inflateInit(&strm);
if (ret != Z_OK)
return ret;
/* decompress until deflate stream ends or end of file */
do {
strm.avail_in = fread(in, 1, CHUNK, source);
if (ferror(source)) {
(void)inflateEnd(&strm);
return Z_ERRNO;
}
if (strm.avail_in == 0)
break;
strm.next_in = in;
/* run inflate() on input until output buffer not full */
do {
strm.avail_out = CHUNK;
strm.next_out = out;
ret = inflate(&strm, Z_NO_FLUSH);
assert(ret != Z_STREAM_ERROR); /* state not clobbered */
switch (ret) {
case Z_NEED_DICT:
ret = Z_DATA_ERROR; /* and fall through */
case Z_DATA_ERROR:
case Z_MEM_ERROR:
(void)inflateEnd(&strm);
return ret;
}
have = CHUNK - strm.avail_out;
if (fwrite(out, 1, have, dest) != have || ferror(dest)) {
(void)inflateEnd(&strm);
return Z_ERRNO;
}
} while (strm.avail_out == 0);
/* done when inflate() says it's done */
} while (ret != Z_STREAM_END);
/* clean up and return */
(void)inflateEnd(&strm);
return ret == Z_STREAM_END ? Z_OK : Z_DATA_ERROR;
}
/* report a zlib or i/o error */
void zerr(int ret)
{
fputs("zpipe: ", stderr);
switch (ret) {
case Z_ERRNO:
if (ferror(stdin))
fputs("error reading stdin\n", stderr);
if (ferror(stdout))
fputs("error writing stdout\n", stderr);
break;
case Z_STREAM_ERROR:
fputs("invalid compression level\n", stderr);
break;
case Z_DATA_ERROR:
fputs("invalid or incomplete deflate data\n", stderr);
break;
case Z_MEM_ERROR:
fputs("out of memory\n", stderr);
break;
case Z_VERSION_ERROR:
fputs("zlib version mismatch!\n", stderr);
}
}
/* compress or decompress from stdin to stdout */
int main(int argc, char **argv)
{
int ret;
/* avoid end-of-line conversions */
SET_BINARY_MODE(stdin);
SET_BINARY_MODE(stdout);
/* do compression if no arguments */
/* Warning: Not compatible with plain libz, dial it back down to
* 9 if this is required, uber-level is 10
* since we have everything crammed in miniz, we don't depend on
* libz at all.
*/
if (argc == 1) {
ret = def(stdin, stdout, MZ_UBER_COMPRESSION);
if (ret != Z_OK)
zerr(ret);
return ret;
}
/* do decompression if -d specified */
else if (argc == 2 && strcmp(argv[1], "-d") == 0) {
ret = inf(stdin, stdout);
if (ret != Z_OK)
zerr(ret);
return ret;
}
/* otherwise, report usage */
else {
fputs("zpipe usage: zpipe [-d] < source > dest\n", stderr);
return 1;
}
}

@ -227,9 +227,9 @@ namespace llarp
idx = v.find_first_of(delimiter);
if(idx != std::string::npos)
{
std::string val = v.substr(0, idx);
absl::StripAsciiWhitespace(&val);
parsed_opts.emplace(std::move(val));
std::string data = v.substr(0, idx);
absl::StripAsciiWhitespace(&data);
parsed_opts.emplace(std::move(data));
v = v.substr(idx + 1);
}
else

@ -2,7 +2,7 @@
#define LLARP_VERSION_HPP
#if defined(_WIN32) && defined(RC_INVOKED)
#define LLARP_VERSION 0, 5, 1, 0
#define LLARP_VERSION 0, 5, 2, 0
#else
#ifndef LLARP_VERSION_MAJ
@ -14,7 +14,7 @@
#endif
#ifndef LLARP_VERSION_PATCH
#define LLARP_VERSION_PATCH "1"
#define LLARP_VERSION_PATCH "2"
#endif
#ifndef LLARP_VERSION_NUM

@ -92,6 +92,7 @@ namespace llarp
}
else
{
Lock lock(&m_AuthedLinksMutex);
auto range = m_AuthedLinks.equal_range(itr->second);
session = range.first->second;
}

@ -865,9 +865,16 @@ namespace llarp
auto* mask = (sockaddr_in*)i->ifa_netmask;
nuint32_t ifaddr{addr->sin_addr.s_addr};
nuint32_t ifmask{mask->sin_addr.s_addr};
currentRanges.emplace_back(
IPRange{net::IPPacket::ExpandV4(xntohl(ifaddr)),
net::IPPacket::ExpandV4(xntohl(ifmask))});
#ifdef _WIN32
// do not delete, otherwise GCC will do horrible things to this lambda
LogDebug("found ", ifaddr, " with mask ", ifmask);
#endif
if(addr->sin_addr.s_addr)
// skip unconfig'd adapters (windows passes these through the unix-y
// wrapper)
currentRanges.emplace_back(
IPRange{net::IPPacket::ExpandV4(xntohl(ifaddr)),
net::IPPacket::ExpandV4(xntohl(ifmask))});
}
});
// try 10.x.0.0/16

@ -113,13 +113,13 @@ namespace llarp
virtual const SecretKey&
GetTunnelEncryptionSecretKey() const;
void
virtual void
HandlePathBuilt(Path_ptr p) override;
void
virtual void
HandlePathBuildTimeout(Path_ptr p) override;
void
virtual void
HandlePathBuildFailed(Path_ptr p) override;
};

@ -434,6 +434,16 @@ namespace llarp
itr->second.lastUsed = Now();
}
void
Endpoint::MarkConvoTagActive(const ConvoTag& tag)
{
auto itr = Sessions().find(tag);
if(itr != Sessions().end())
{
itr->second.lastUsed = Now();
}
}
bool
Endpoint::LoadKeyFile()
{
@ -1063,7 +1073,10 @@ namespace llarp
util::Lock lock(&m_state->m_SendQueueMutex);
// send outbound traffic
for(const auto& item : m_state->m_SendQueue)
{
item.second->SendRoutingMessage(*item.first, router);
MarkConvoTagActive(item.first->T.T);
}
m_state->m_SendQueue.clear();
router->PumpLL();
}

@ -322,6 +322,9 @@ namespace llarp
void
RemoveConvoTag(const ConvoTag& remote) override;
void
MarkConvoTagActive(const ConvoTag& remote) override;
void
PutReplyIntroFor(const ConvoTag& remote,
const Introduction& intro) override;

@ -96,6 +96,7 @@ namespace llarp
itr->second->Tick(now);
if(itr->second->Pump(now))
{
LogInfo("marking session as dead T=", itr->first);
itr->second->Stop();
deadSessions.emplace(std::move(*itr));
itr = remoteSessions.erase(itr);
@ -115,6 +116,7 @@ namespace llarp
{
if(itr->second.IsExpired(now))
{
LogInfo("Expire session T=", itr->first);
itr = sessions.erase(itr);
}
else

@ -29,6 +29,9 @@ namespace llarp
PutCachedSessionKeyFor(const ConvoTag& remote,
const SharedSecret& secret) = 0;
virtual void
MarkConvoTagActive(const ConvoTag& tag) = 0;
virtual void
RemoveConvoTag(const ConvoTag& remote) = 0;

@ -44,8 +44,6 @@ namespace llarp
if(MarkCurrentIntroBad(Now()))
{
SwapIntros();
LogInfo(Name(), " switched intros to ", remoteIntro.router, " via ",
remoteIntro.pathID);
}
UpdateIntroSet(true);
}
@ -53,13 +51,13 @@ namespace llarp
}
OutboundContext::OutboundContext(const IntroSet& introset, Endpoint* parent)
: path::Builder(parent->Router(), 3, path::default_len)
: path::Builder(parent->Router(), 4, path::default_len)
, SendContext(introset.A, {}, this, parent)
, currentIntroSet(introset)
{
updatingIntroSet = false;
for(const auto intro : introset.I)
for(const auto& intro : introset.I)
{
if(intro.expiresAt > m_NextIntro.expiresAt)
m_NextIntro = intro;
@ -75,6 +73,7 @@ namespace llarp
{
if(remoteIntro != m_NextIntro)
{
LogInfo(Name(), " swap intro to use ", RouterID(m_NextIntro.router));
remoteIntro = m_NextIntro;
m_DataHandler->PutIntroFor(currentConvoTag, remoteIntro);
ShiftIntroduction(false);
@ -114,7 +113,10 @@ namespace llarp
BuildOneAlignedTo(m_NextIntro.router);
}
else
{
++m_LookupFails;
LogWarn(Name(), " failed to look up introset, fails=", m_LookupFails);
}
return true;
}
@ -125,6 +127,32 @@ namespace llarp
&& GetPathByRouter(remoteIntro.router) != nullptr;
}
void
OutboundContext::ShiftIntroRouter(const RouterID r)
{
const auto now = Now();
Introduction selectedIntro;
for(const auto& intro : currentIntroSet.I)
{
if(intro.expiresAt > selectedIntro.expiresAt && intro.router != r)
{
selectedIntro = intro;
}
}
if(selectedIntro.router.IsZero() || selectedIntro.ExpiresSoon(now))
return;
LogWarn(Name(), " shfiting intro off of ", r, " to ",
RouterID(selectedIntro.router));
m_NextIntro = selectedIntro;
}
void
OutboundContext::HandlePathBuildTimeout(path::Path_ptr p)
{
ShiftIntroRouter(p->Endpoint());
path::Builder::HandlePathBuildTimeout(p);
}
void
OutboundContext::HandlePathBuilt(path::Path_ptr p)
{
@ -138,6 +166,10 @@ namespace llarp
// we now have a path to the next intro, swap intros
if(p->Endpoint() == m_NextIntro.router)
SwapIntros();
else
{
LogInfo(Name(), " built to non aligned router: ", p->Endpoint());
}
}
void
@ -241,6 +273,7 @@ namespace llarp
// we are probably dead af
if(m_LookupFails > 16 || m_BuildFails > 10)
return true;
// check for expiration
if(remoteIntro.ExpiresSoon(now))
{
@ -259,6 +292,10 @@ namespace llarp
else
++itr;
}
if(currentIntroSet.HasExpiredIntros(now))
{
UpdateIntroSet(true);
}
// send control message if we look too quiet
if(lastGoodSend)
{
@ -275,7 +312,6 @@ namespace llarp
tmp.Randomize();
llarp_buffer_t buf(tmp.data(), tmp.size());
AsyncEncryptAndSendTo(buf, eProtocolControl);
return !m_DataHandler->HasConvoTag(currentConvoTag);
}
}
}
@ -293,9 +329,10 @@ namespace llarp
{
if(m_NextIntro.router.IsZero() || prev.count(m_NextIntro.router))
{
if(!ShiftIntroduction(false))
return false;
ShiftIntroduction(false);
}
if(m_NextIntro.router.IsZero())
return false;
std::set< RouterID > exclude = prev;
exclude.insert(m_NextIntro.router);
for(const auto& snode : m_Endpoint->SnodeBlacklist())
@ -322,10 +359,7 @@ namespace llarp
{
if(markedBad)
return false;
const bool should =
(!(path::Builder::BuildCooldownHit(now)
|| path::Builder::NumInStatus(path::ePathBuilding) >= numPaths))
&& path::Builder::ShouldBuildMore(now);
const bool should = path::Builder::BuildCooldownHit(now);
if(!ReadyToSend())
{
@ -343,9 +377,15 @@ namespace llarp
bool
OutboundContext::MarkCurrentIntroBad(llarp_time_t now)
{
return MarkIntroBad(remoteIntro, now);
}
bool
OutboundContext::MarkIntroBad(const Introduction& intro, llarp_time_t now)
{
// insert bad intro
m_BadIntros[remoteIntro] = now;
m_BadIntros[intro] = now;
// try shifting intro without rebuild
if(ShiftIntroduction(false))
{

@ -6,6 +6,7 @@
#include <util/status.hpp>
#include <unordered_map>
#include <unordered_set>
namespace llarp
{
@ -52,10 +53,17 @@ namespace llarp
bool
ShiftIntroduction(bool rebuild = true) override;
/// shift the intro off the current router it is using
void
ShiftIntroRouter(const RouterID remote);
/// mark the current remote intro as bad
bool
MarkCurrentIntroBad(llarp_time_t now) override;
bool
MarkIntroBad(const Introduction& marked, llarp_time_t now);
/// return true if we are ready to send
bool
ReadyToSend() const;
@ -85,6 +93,9 @@ namespace llarp
void
HandlePathBuilt(path::Path_ptr path) override;
void
HandlePathBuildTimeout(path::Path_ptr path) override;
bool
SelectHop(llarp_nodedb* db, const std::set< RouterID >& prev,
RouterContact& cur, size_t hop, path::PathRole roles) override;

@ -20,7 +20,6 @@ namespace llarp
, m_Endpoint(ep)
{
createdAt = ep->Now();
currentConvoTag.Zero();
}
bool
@ -47,11 +46,9 @@ namespace llarp
{
lastGoodSend = r->Now();
flushpaths.emplace(item.second);
m_Endpoint->MarkConvoTagActive(item.first->T.T);
}
else
LogError(m_Endpoint->Name(), " failed to send frame on path");
}
m_SendQueue.clear();
}
// flush the select path's upstream

@ -18,9 +18,8 @@ namespace llarp
bool
Session::IsExpired(llarp_time_t now, llarp_time_t lifetime) const
{
if(now <= lastUsed)
return intro.IsExpired(now);
return now - lastUsed > lifetime || intro.IsExpired(now);
return now > lastUsed
&& (now - lastUsed > lifetime || intro.IsExpired(now));
}
} // namespace service

@ -19,7 +19,7 @@ namespace llarp
#define _LOGSTREAM_INIT
#else
using Stream_t = OStreamLogStream;
#define _LOGSTREAM_INIT std::cout
#define _LOGSTREAM_INIT true, std::cout
#endif
#endif

@ -3,7 +3,8 @@
namespace llarp
{
OStreamLogStream::OStreamLogStream(std::ostream& out) : m_Out(out)
OStreamLogStream::OStreamLogStream(bool withColours, std::ostream& out)
: m_withColours(withColours), m_Out(out)
{
}
@ -12,22 +13,25 @@ namespace llarp
const char* fname, int lineno,
const std::string& nodename) const
{
switch(lvl)
if(m_withColours)
{
case eLogNone:
break;
case eLogDebug:
ss << (char)27 << "[0m";
break;
case eLogInfo:
ss << (char)27 << "[1m";
break;
case eLogWarn:
ss << (char)27 << "[1;33m";
break;
case eLogError:
ss << (char)27 << "[1;31m";
break;
switch(lvl)
{
case eLogNone:
break;
case eLogDebug:
ss << (char)27 << "[0m";
break;
case eLogInfo:
ss << (char)27 << "[1m";
break;
case eLogWarn:
ss << (char)27 << "[1;33m";
break;
case eLogError:
ss << (char)27 << "[1;31m";
break;
}
}
ss << "[" << LogLevelToString(lvl) << "] ";
ss << "[" << nodename << "]"
@ -38,7 +42,9 @@ namespace llarp
void
OStreamLogStream::PostLog(std::stringstream& ss) const
{
ss << (char)27 << "[0;0m" << std::endl;
if(m_withColours)
ss << (char)27 << "[0;0m";
ss << std::endl;
}
void

@ -8,7 +8,7 @@ namespace llarp
{
struct OStreamLogStream : public ILogStream
{
OStreamLogStream(std::ostream& out);
OStreamLogStream(bool withColours, std::ostream& out);
~OStreamLogStream() override = default;
@ -27,6 +27,7 @@ namespace llarp
}
private:
bool m_withColours;
std::ostream& m_Out;
};
} // namespace llarp

@ -8,7 +8,7 @@ static short old_attrs;
namespace llarp
{
Win32LogStream::Win32LogStream(std::ostream& out)
: OStreamLogStream(out), m_Out(out)
: OStreamLogStream(true, out), m_Out(out)
{
// Attempt to use ANSI escapes directly
// if the modern console is active.

@ -81,18 +81,18 @@ BEGIN
VALUE "CompanyName", "Loki Foundation"
VALUE "FileDescription", "LokiNET for Microsoft® Windows® NT™"
#ifdef LLARP_RELEASE_MOTTO
VALUE "FileVersion", VERSION_STRING(0.5.1, RELEASE_MOTTO, GIT_REV)
VALUE "FileVersion", VERSION_STRING(0.5.2, RELEASE_MOTTO, GIT_REV)
#else
VALUE "FileVersion", VERSION_STRING(0.5.1-dev-, GIT_REV)
VALUE "FileVersion", VERSION_STRING(0.5.2-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.5.1, RELEASE_MOTTO, GIT_REV)
VALUE "ProductVersion", VERSION_STRING(0.5.2, RELEASE_MOTTO, GIT_REV)
#else
VALUE "ProductVersion", VERSION_STRING(0.5.1-dev-, GIT_REV)
VALUE "ProductVersion", VERSION_STRING(0.5.2-dev-, GIT_REV)
#endif
END
END

@ -81,18 +81,18 @@ BEGIN
VALUE "CompanyName", "Loki Foundation"
VALUE "FileDescription", "LokiNET daemon for Microsoft® Windows® NT™"
#ifdef LLARP_RELEASE_MOTTO
VALUE "FileVersion", VERSION_STRING(0.5.0, RELEASE_MOTTO, GIT_REV)
VALUE "FileVersion", VERSION_STRING(0.5.2, RELEASE_MOTTO, GIT_REV)
#else
VALUE "FileVersion", VERSION_STRING(0.5.0-dev-, GIT_REV)
VALUE "FileVersion", VERSION_STRING(0.5.2-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.5.0, RELEASE_MOTTO, GIT_REV)
VALUE "ProductVersion", VERSION_STRING(0.5.2, RELEASE_MOTTO, GIT_REV)
#else
VALUE "ProductVersion", VERSION_STRING(0.5.0-dev-, GIT_REV)
VALUE "ProductVersion", VERSION_STRING(0.5.2-dev-, GIT_REV)
#endif
END
END

Binary file not shown.

Binary file not shown.

@ -1 +1 @@
bedrock edition
and boom goes the dynamite

@ -81,12 +81,12 @@ BEGIN
VALUE "CompanyName", "Loki Foundation"
VALUE "FileDescription", "LokiNET for Microsoft® Windows® NT™"
#ifdef LLARP_RELEASE_MOTTO
VALUE "FileVersion", VERSION_STRING(0.5.0, RELEASE_MOTTO, GIT_REV)
VALUE "FileVersion", VERSION_STRING(0.5.2, RELEASE_MOTTO, GIT_REV)
#else
#ifdef __GNUC__
VALUE "FileVersion", VERSION_STRING(0.5.0-dev-, GIT_REV)
VALUE "FileVersion", VERSION_STRING(0.5.2-dev-, GIT_REV)
#else
VALUE "FileVersion", "0.5.0-dev"
VALUE "FileVersion", "0.5.2-dev"
#endif
#endif
VALUE "InternalName", "llarpd"
@ -94,12 +94,12 @@ BEGIN
VALUE "OriginalFilename", "llarpd.exe"
VALUE "ProductName", "LokiNET for Windows"
#ifdef LLARP_RELEASE_MOTTO
VALUE "ProductVersion", VERSION_STRING(0.5.0, RELEASE_MOTTO, GIT_REV)
VALUE "ProductVersion", VERSION_STRING(0.5.2, RELEASE_MOTTO, GIT_REV)
#else
#ifdef __GNUC__
VALUE "ProductVersion", VERSION_STRING(0.5.0-dev-, GIT_REV)
VALUE "ProductVersion", VERSION_STRING(0.5.2-dev-, GIT_REV)
#else
VALUE "ProductVersion", "0.5.0-dev"
VALUE "ProductVersion", "0.5.2-dev"
#endif
#endif
END

@ -0,0 +1,29 @@
//
// WindowsManager.swift
// lokinet
//
// Copyright © 2019 Loki. All rights reserved.
//
import AppKit
import Foundation
struct WindowsManager {
static func getVC<T: NSViewController>(withIdentifier identifier: String,
ofType: T.Type?,
storyboard: String = "Main",
bundle: Bundle? = nil) -> T? {
let storyboard = NSStoryboard(name: storyboard, bundle: bundle)
guard let vc: T = storyboard.instantiateController(withIdentifier: identifier) as? T else {
let alert = NSAlert()
alert.alertStyle = .critical
alert.messageText = "Error initiating the viewcontroller"
alert.runModal()
return nil
}
return vc
}
}

@ -0,0 +1,641 @@
// !$*UTF8*$!
{
archiveVersion = 1;
classes = {
};
objectVersion = 51;
objects = {
/* Begin PBXBuildFile section */
7B28BD1A232EA8B40073B955 /* DNSManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7B28BD19232EA8B40073B955 /* DNSManager.swift */; };
7B28BD1C232EB6EF0073B955 /* LokinetRunner.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7B28BD1B232EB6EF0073B955 /* LokinetRunner.swift */; };
7BA4FB642340D5940098E20A /* Preferences.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7BA4FB632340D5940098E20A /* Preferences.swift */; };
7BA4FB662340DA820098E20A /* StatusMenuExt.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7BA4FB652340DA820098E20A /* StatusMenuExt.swift */; };
7BA4FB6C2340F2270098E20A /* WindowsManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7BA4FB6B2340F2270098E20A /* WindowsManager.swift */; };
7BA4FB7023411FF60098E20A /* PrefsViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7BA4FB6E23411FF60098E20A /* PrefsViewController.swift */; };
7BA4FB7323412D700098E20A /* Interfaces.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7BA4FB7223412D700098E20A /* Interfaces.swift */; };
7BED5B7A232D78D900DF603F /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7BED5B79232D78D900DF603F /* AppDelegate.swift */; };
7BED5B7E232D78DB00DF603F /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 7BED5B7D232D78DB00DF603F /* Assets.xcassets */; };
7BED5B81232D78DB00DF603F /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 7BED5B7F232D78DB00DF603F /* Main.storyboard */; };
7BED5B8D232D78DB00DF603F /* lokinetTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7BED5B8C232D78DB00DF603F /* lokinetTests.swift */; };
7BED5B98232D78DB00DF603F /* lokinetUITests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7BED5B97232D78DB00DF603F /* lokinetUITests.swift */; };
7BED5BA6232E7E6600DF603F /* LokinetLog.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7BED5BA5232E7E6600DF603F /* LokinetLog.swift */; };
7BED5BA8232E831B00DF603F /* StreamReader.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7BED5BA7232E831B00DF603F /* StreamReader.swift */; };
/* End PBXBuildFile section */
/* Begin PBXContainerItemProxy section */
7BED5B89232D78DB00DF603F /* PBXContainerItemProxy */ = {
isa = PBXContainerItemProxy;
containerPortal = 7BED5B6E232D78D900DF603F /* Project object */;
proxyType = 1;
remoteGlobalIDString = 7BED5B75232D78D900DF603F;
remoteInfo = lokinet;
};
7BED5B94232D78DB00DF603F /* PBXContainerItemProxy */ = {
isa = PBXContainerItemProxy;
containerPortal = 7BED5B6E232D78D900DF603F /* Project object */;
proxyType = 1;
remoteGlobalIDString = 7BED5B75232D78D900DF603F;
remoteInfo = lokinet;
};
/* End PBXContainerItemProxy section */
/* Begin PBXFileReference section */
7B28BD19232EA8B40073B955 /* DNSManager.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DNSManager.swift; sourceTree = "<group>"; };
7B28BD1B232EB6EF0073B955 /* LokinetRunner.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LokinetRunner.swift; sourceTree = "<group>"; };
7BA4FB632340D5940098E20A /* Preferences.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Preferences.swift; sourceTree = "<group>"; };
7BA4FB652340DA820098E20A /* StatusMenuExt.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = StatusMenuExt.swift; sourceTree = "<group>"; };
7BA4FB6B2340F2270098E20A /* WindowsManager.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = WindowsManager.swift; sourceTree = "<group>"; };
7BA4FB6E23411FF60098E20A /* PrefsViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PrefsViewController.swift; sourceTree = "<group>"; };
7BA4FB7223412D700098E20A /* Interfaces.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Interfaces.swift; sourceTree = "<group>"; };
7BED5B76232D78D900DF603F /* lokinet.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = lokinet.app; sourceTree = BUILT_PRODUCTS_DIR; };
7BED5B79232D78D900DF603F /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = "<group>"; };
7BED5B7D232D78DB00DF603F /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = "<group>"; };
7BED5B80232D78DB00DF603F /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = "<group>"; };
7BED5B82232D78DB00DF603F /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
7BED5B83232D78DB00DF603F /* lokinet.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = lokinet.entitlements; sourceTree = "<group>"; };
7BED5B88232D78DB00DF603F /* lokinetTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = lokinetTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; };
7BED5B8C232D78DB00DF603F /* lokinetTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = lokinetTests.swift; sourceTree = "<group>"; };
7BED5B8E232D78DB00DF603F /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
7BED5B93232D78DB00DF603F /* lokinetUITests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = lokinetUITests.xctest; sourceTree = BUILT_PRODUCTS_DIR; };
7BED5B97232D78DB00DF603F /* lokinetUITests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = lokinetUITests.swift; sourceTree = "<group>"; };
7BED5B99232D78DB00DF603F /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
7BED5BA5232E7E6600DF603F /* LokinetLog.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LokinetLog.swift; sourceTree = "<group>"; };
7BED5BA7232E831B00DF603F /* StreamReader.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = StreamReader.swift; sourceTree = "<group>"; };
/* End PBXFileReference section */
/* Begin PBXFrameworksBuildPhase section */
7BED5B73232D78D900DF603F /* Frameworks */ = {
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
);
runOnlyForDeploymentPostprocessing = 0;
};
7BED5B85232D78DB00DF603F /* Frameworks */ = {
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
);
runOnlyForDeploymentPostprocessing = 0;
};
7BED5B90232D78DB00DF603F /* Frameworks */ = {
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
);
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXFrameworksBuildPhase section */
/* Begin PBXGroup section */
7BED5B6D232D78D900DF603F = {
isa = PBXGroup;
children = (
7BA4FB6B2340F2270098E20A /* WindowsManager.swift */,
7BED5B78232D78D900DF603F /* lokinet */,
7BED5B8B232D78DB00DF603F /* lokinetTests */,
7BED5B96232D78DB00DF603F /* lokinetUITests */,
7BED5B77232D78D900DF603F /* Products */,
7BED5BA9232E993E00DF603F /* Frameworks */,
);
sourceTree = "<group>";
};
7BED5B77232D78D900DF603F /* Products */ = {
isa = PBXGroup;
children = (
7BED5B76232D78D900DF603F /* lokinet.app */,
7BED5B88232D78DB00DF603F /* lokinetTests.xctest */,
7BED5B93232D78DB00DF603F /* lokinetUITests.xctest */,
);
name = Products;
sourceTree = "<group>";
};
7BED5B78232D78D900DF603F /* lokinet */ = {
isa = PBXGroup;
children = (
7BED5B79232D78D900DF603F /* AppDelegate.swift */,
7BA4FB652340DA820098E20A /* StatusMenuExt.swift */,
7BA4FB632340D5940098E20A /* Preferences.swift */,
7BA4FB6E23411FF60098E20A /* PrefsViewController.swift */,
7BED5B7D232D78DB00DF603F /* Assets.xcassets */,
7BED5B7F232D78DB00DF603F /* Main.storyboard */,
7BED5B82232D78DB00DF603F /* Info.plist */,
7BED5B83232D78DB00DF603F /* lokinet.entitlements */,
7BED5BA5232E7E6600DF603F /* LokinetLog.swift */,
7B28BD19232EA8B40073B955 /* DNSManager.swift */,
7BED5BA7232E831B00DF603F /* StreamReader.swift */,
7B28BD1B232EB6EF0073B955 /* LokinetRunner.swift */,
7BA4FB7223412D700098E20A /* Interfaces.swift */,
);
path = lokinet;
sourceTree = "<group>";
};
7BED5B8B232D78DB00DF603F /* lokinetTests */ = {
isa = PBXGroup;
children = (
7BED5B8C232D78DB00DF603F /* lokinetTests.swift */,
7BED5B8E232D78DB00DF603F /* Info.plist */,
);
path = lokinetTests;
sourceTree = "<group>";
};
7BED5B96232D78DB00DF603F /* lokinetUITests */ = {
isa = PBXGroup;
children = (
7BED5B97232D78DB00DF603F /* lokinetUITests.swift */,
7BED5B99232D78DB00DF603F /* Info.plist */,
);
path = lokinetUITests;
sourceTree = "<group>";
};
7BED5BA9232E993E00DF603F /* Frameworks */ = {
isa = PBXGroup;
children = (
);
name = Frameworks;
sourceTree = "<group>";
};
/* End PBXGroup section */
/* Begin PBXNativeTarget section */
7BED5B75232D78D900DF603F /* lokinet */ = {
isa = PBXNativeTarget;
buildConfigurationList = 7BED5B9C232D78DB00DF603F /* Build configuration list for PBXNativeTarget "lokinet" */;
buildPhases = (
7BED5B72232D78D900DF603F /* Sources */,
7BED5B73232D78D900DF603F /* Frameworks */,
7BED5B74232D78D900DF603F /* Resources */,
);
buildRules = (
);
dependencies = (
);
name = lokinet;
productName = lokinet;
productReference = 7BED5B76232D78D900DF603F /* lokinet.app */;
productType = "com.apple.product-type.application";
};
7BED5B87232D78DB00DF603F /* lokinetTests */ = {
isa = PBXNativeTarget;
buildConfigurationList = 7BED5B9F232D78DB00DF603F /* Build configuration list for PBXNativeTarget "lokinetTests" */;
buildPhases = (
7BED5B84232D78DB00DF603F /* Sources */,
7BED5B85232D78DB00DF603F /* Frameworks */,
7BED5B86232D78DB00DF603F /* Resources */,
);
buildRules = (
);
dependencies = (
7BED5B8A232D78DB00DF603F /* PBXTargetDependency */,
);
name = lokinetTests;
productName = lokinetTests;
productReference = 7BED5B88232D78DB00DF603F /* lokinetTests.xctest */;
productType = "com.apple.product-type.bundle.unit-test";
};
7BED5B92232D78DB00DF603F /* lokinetUITests */ = {
isa = PBXNativeTarget;
buildConfigurationList = 7BED5BA2232D78DB00DF603F /* Build configuration list for PBXNativeTarget "lokinetUITests" */;
buildPhases = (
7BED5B8F232D78DB00DF603F /* Sources */,
7BED5B90232D78DB00DF603F /* Frameworks */,
7BED5B91232D78DB00DF603F /* Resources */,
);
buildRules = (
);
dependencies = (
7BED5B95232D78DB00DF603F /* PBXTargetDependency */,
);
name = lokinetUITests;
productName = lokinetUITests;
productReference = 7BED5B93232D78DB00DF603F /* lokinetUITests.xctest */;
productType = "com.apple.product-type.bundle.ui-testing";
};
/* End PBXNativeTarget section */
/* Begin PBXProject section */
7BED5B6E232D78D900DF603F /* Project object */ = {
isa = PBXProject;
attributes = {
LastSwiftUpdateCheck = 1020;
LastUpgradeCheck = 1020;
ORGANIZATIONNAME = Loki;
TargetAttributes = {
7BED5B75232D78D900DF603F = {
CreatedOnToolsVersion = 10.2.1;
SystemCapabilities = {
com.apple.ApplicationGroups.Mac = {
enabled = 0;
};
com.apple.NetworkExtensions = {
enabled = 0;
};
com.apple.Sandbox = {
enabled = 0;
};
};
};
7BED5B87232D78DB00DF603F = {
CreatedOnToolsVersion = 10.2.1;
TestTargetID = 7BED5B75232D78D900DF603F;
};
7BED5B92232D78DB00DF603F = {
CreatedOnToolsVersion = 10.2.1;
TestTargetID = 7BED5B75232D78D900DF603F;
};
};
};
buildConfigurationList = 7BED5B71232D78D900DF603F /* Build configuration list for PBXProject "lokinet" */;
compatibilityVersion = "Xcode 10.0";
developmentRegion = en;
hasScannedForEncodings = 0;
knownRegions = (
en,
Base,
);
mainGroup = 7BED5B6D232D78D900DF603F;
productRefGroup = 7BED5B77232D78D900DF603F /* Products */;
projectDirPath = "";
projectRoot = "";
targets = (
7BED5B75232D78D900DF603F /* lokinet */,
7BED5B87232D78DB00DF603F /* lokinetTests */,
7BED5B92232D78DB00DF603F /* lokinetUITests */,
);
};
/* End PBXProject section */
/* Begin PBXResourcesBuildPhase section */
7BED5B74232D78D900DF603F /* Resources */ = {
isa = PBXResourcesBuildPhase;
buildActionMask = 2147483647;
files = (
7BED5B7E232D78DB00DF603F /* Assets.xcassets in Resources */,
7BED5B81232D78DB00DF603F /* Main.storyboard in Resources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
7BED5B86232D78DB00DF603F /* Resources */ = {
isa = PBXResourcesBuildPhase;
buildActionMask = 2147483647;
files = (
);
runOnlyForDeploymentPostprocessing = 0;
};
7BED5B91232D78DB00DF603F /* Resources */ = {
isa = PBXResourcesBuildPhase;
buildActionMask = 2147483647;
files = (
);
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXResourcesBuildPhase section */
/* Begin PBXSourcesBuildPhase section */
7BED5B72232D78D900DF603F /* Sources */ = {
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
7BED5BA8232E831B00DF603F /* StreamReader.swift in Sources */,
7BA4FB7023411FF60098E20A /* PrefsViewController.swift in Sources */,
7BED5BA6232E7E6600DF603F /* LokinetLog.swift in Sources */,
7BA4FB662340DA820098E20A /* StatusMenuExt.swift in Sources */,
7B28BD1A232EA8B40073B955 /* DNSManager.swift in Sources */,
7B28BD1C232EB6EF0073B955 /* LokinetRunner.swift in Sources */,
7BA4FB6C2340F2270098E20A /* WindowsManager.swift in Sources */,
7BA4FB7323412D700098E20A /* Interfaces.swift in Sources */,
7BA4FB642340D5940098E20A /* Preferences.swift in Sources */,
7BED5B7A232D78D900DF603F /* AppDelegate.swift in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
7BED5B84232D78DB00DF603F /* Sources */ = {
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
7BED5B8D232D78DB00DF603F /* lokinetTests.swift in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
7BED5B8F232D78DB00DF603F /* Sources */ = {
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
7BED5B98232D78DB00DF603F /* lokinetUITests.swift in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXSourcesBuildPhase section */
/* Begin PBXTargetDependency section */
7BED5B8A232D78DB00DF603F /* PBXTargetDependency */ = {
isa = PBXTargetDependency;
target = 7BED5B75232D78D900DF603F /* lokinet */;
targetProxy = 7BED5B89232D78DB00DF603F /* PBXContainerItemProxy */;
};
7BED5B95232D78DB00DF603F /* PBXTargetDependency */ = {
isa = PBXTargetDependency;
target = 7BED5B75232D78D900DF603F /* lokinet */;
targetProxy = 7BED5B94232D78DB00DF603F /* PBXContainerItemProxy */;
};
/* End PBXTargetDependency section */
/* Begin PBXVariantGroup section */
7BED5B7F232D78DB00DF603F /* Main.storyboard */ = {
isa = PBXVariantGroup;
children = (
7BED5B80232D78DB00DF603F /* Base */,
);
name = Main.storyboard;
sourceTree = "<group>";
};
/* End PBXVariantGroup section */
/* Begin XCBuildConfiguration section */
7BED5B9A232D78DB00DF603F /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
CLANG_ANALYZER_NONNULL = YES;
CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE;
CLANG_CXX_LANGUAGE_STANDARD = "gnu++14";
CLANG_CXX_LIBRARY = "libc++";
CLANG_ENABLE_MODULES = YES;
CLANG_ENABLE_OBJC_ARC = YES;
CLANG_ENABLE_OBJC_WEAK = YES;
CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
CLANG_WARN_BOOL_CONVERSION = YES;
CLANG_WARN_COMMA = YES;
CLANG_WARN_CONSTANT_CONVERSION = YES;
CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
CLANG_WARN_DOCUMENTATION_COMMENTS = YES;
CLANG_WARN_EMPTY_BODY = YES;
CLANG_WARN_ENUM_CONVERSION = YES;
CLANG_WARN_INFINITE_RECURSION = YES;
CLANG_WARN_INT_CONVERSION = YES;
CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
CLANG_WARN_STRICT_PROTOTYPES = YES;
CLANG_WARN_SUSPICIOUS_MOVE = YES;
CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE;
CLANG_WARN_UNREACHABLE_CODE = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
CODE_SIGN_IDENTITY = "-";
COPY_PHASE_STRIP = NO;
DEBUG_INFORMATION_FORMAT = dwarf;
DEVELOPMENT_TEAM = 23TKR8Q2XE;
ENABLE_HARDENED_RUNTIME = YES;
ENABLE_STRICT_OBJC_MSGSEND = YES;
ENABLE_TESTABILITY = YES;
GCC_C_LANGUAGE_STANDARD = gnu11;
GCC_DYNAMIC_NO_PIC = NO;
GCC_NO_COMMON_BLOCKS = YES;
GCC_OPTIMIZATION_LEVEL = 0;
GCC_PREPROCESSOR_DEFINITIONS = (
"DEBUG=1",
"$(inherited)",
);
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
GCC_WARN_UNDECLARED_SELECTOR = YES;
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
MACOSX_DEPLOYMENT_TARGET = 10.14;
MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE;
MTL_FAST_MATH = YES;
ONLY_ACTIVE_ARCH = YES;
SDKROOT = macosx;
SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG;
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
};
name = Debug;
};
7BED5B9B232D78DB00DF603F /* Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
CLANG_ANALYZER_NONNULL = YES;
CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE;
CLANG_CXX_LANGUAGE_STANDARD = "gnu++14";
CLANG_CXX_LIBRARY = "libc++";
CLANG_ENABLE_MODULES = YES;
CLANG_ENABLE_OBJC_ARC = YES;
CLANG_ENABLE_OBJC_WEAK = YES;
CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
CLANG_WARN_BOOL_CONVERSION = YES;
CLANG_WARN_COMMA = YES;
CLANG_WARN_CONSTANT_CONVERSION = YES;
CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
CLANG_WARN_DOCUMENTATION_COMMENTS = YES;
CLANG_WARN_EMPTY_BODY = YES;
CLANG_WARN_ENUM_CONVERSION = YES;
CLANG_WARN_INFINITE_RECURSION = YES;
CLANG_WARN_INT_CONVERSION = YES;
CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
CLANG_WARN_STRICT_PROTOTYPES = YES;
CLANG_WARN_SUSPICIOUS_MOVE = YES;
CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE;
CLANG_WARN_UNREACHABLE_CODE = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
CODE_SIGN_IDENTITY = "-";
COPY_PHASE_STRIP = NO;
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
DEVELOPMENT_TEAM = 23TKR8Q2XE;
ENABLE_HARDENED_RUNTIME = YES;
ENABLE_NS_ASSERTIONS = NO;
ENABLE_STRICT_OBJC_MSGSEND = YES;
GCC_C_LANGUAGE_STANDARD = gnu11;
GCC_NO_COMMON_BLOCKS = YES;
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
GCC_WARN_UNDECLARED_SELECTOR = YES;
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
MACOSX_DEPLOYMENT_TARGET = 10.14;
MTL_ENABLE_DEBUG_INFO = NO;
MTL_FAST_MATH = YES;
SDKROOT = macosx;
SWIFT_COMPILATION_MODE = wholemodule;
SWIFT_OPTIMIZATION_LEVEL = "-O";
};
name = Release;
};
7BED5B9D232D78DB00DF603F /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CODE_SIGN_ENTITLEMENTS = lokinet/lokinet.entitlements;
CODE_SIGN_IDENTITY = "Mac Developer";
CODE_SIGN_STYLE = Automatic;
COMBINE_HIDPI_IMAGES = YES;
DEVELOPMENT_TEAM = 23TKR8Q2XE;
ENABLE_HARDENED_RUNTIME = YES;
INFOPLIST_FILE = lokinet/Info.plist;
LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)",
"@executable_path/../Frameworks",
);
MACOSX_DEPLOYMENT_TARGET = 10.14;
PRODUCT_BUNDLE_IDENTIFIER = loki.lokinet;
PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE_SPECIFIER = "";
SWIFT_VERSION = 5.0;
};
name = Debug;
};
7BED5B9E232D78DB00DF603F /* Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CODE_SIGN_ENTITLEMENTS = lokinet/lokinet.entitlements;
CODE_SIGN_IDENTITY = "Mac Developer";
CODE_SIGN_STYLE = Automatic;
COMBINE_HIDPI_IMAGES = YES;
DEVELOPMENT_TEAM = 23TKR8Q2XE;
ENABLE_HARDENED_RUNTIME = YES;
INFOPLIST_FILE = lokinet/Info.plist;
LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)",
"@executable_path/../Frameworks",
);
MACOSX_DEPLOYMENT_TARGET = 10.14;
PRODUCT_BUNDLE_IDENTIFIER = loki.lokinet;
PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE_SPECIFIER = "";
SWIFT_VERSION = 5.0;
};
name = Release;
};
7BED5BA0232D78DB00DF603F /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES;
BUNDLE_LOADER = "$(TEST_HOST)";
CODE_SIGN_STYLE = Automatic;
COMBINE_HIDPI_IMAGES = YES;
INFOPLIST_FILE = lokinetTests/Info.plist;
LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)",
"@executable_path/../Frameworks",
"@loader_path/../Frameworks",
);
PRODUCT_BUNDLE_IDENTIFIER = loki.lokinetTests;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 5.0;
TEST_HOST = "$(BUILT_PRODUCTS_DIR)/lokinet.app/Contents/MacOS/lokinet";
};
name = Debug;
};
7BED5BA1232D78DB00DF603F /* Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES;
BUNDLE_LOADER = "$(TEST_HOST)";
CODE_SIGN_STYLE = Automatic;
COMBINE_HIDPI_IMAGES = YES;
INFOPLIST_FILE = lokinetTests/Info.plist;
LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)",
"@executable_path/../Frameworks",
"@loader_path/../Frameworks",
);
PRODUCT_BUNDLE_IDENTIFIER = loki.lokinetTests;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 5.0;
TEST_HOST = "$(BUILT_PRODUCTS_DIR)/lokinet.app/Contents/MacOS/lokinet";
};
name = Release;
};
7BED5BA3232D78DB00DF603F /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES;
CODE_SIGN_STYLE = Automatic;
COMBINE_HIDPI_IMAGES = YES;
INFOPLIST_FILE = lokinetUITests/Info.plist;
LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)",
"@executable_path/../Frameworks",
"@loader_path/../Frameworks",
);
PRODUCT_BUNDLE_IDENTIFIER = loki.lokinetUITests;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 5.0;
TEST_TARGET_NAME = lokinet;
};
name = Debug;
};
7BED5BA4232D78DB00DF603F /* Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES;
CODE_SIGN_STYLE = Automatic;
COMBINE_HIDPI_IMAGES = YES;
INFOPLIST_FILE = lokinetUITests/Info.plist;
LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)",
"@executable_path/../Frameworks",
"@loader_path/../Frameworks",
);
PRODUCT_BUNDLE_IDENTIFIER = loki.lokinetUITests;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 5.0;
TEST_TARGET_NAME = lokinet;
};
name = Release;
};
/* End XCBuildConfiguration section */
/* Begin XCConfigurationList section */
7BED5B71232D78D900DF603F /* Build configuration list for PBXProject "lokinet" */ = {
isa = XCConfigurationList;
buildConfigurations = (
7BED5B9A232D78DB00DF603F /* Debug */,
7BED5B9B232D78DB00DF603F /* Release */,
);
defaultConfigurationIsVisible = 0;
defaultConfigurationName = Release;
};
7BED5B9C232D78DB00DF603F /* Build configuration list for PBXNativeTarget "lokinet" */ = {
isa = XCConfigurationList;
buildConfigurations = (
7BED5B9D232D78DB00DF603F /* Debug */,
7BED5B9E232D78DB00DF603F /* Release */,
);
defaultConfigurationIsVisible = 0;
defaultConfigurationName = Release;
};
7BED5B9F232D78DB00DF603F /* Build configuration list for PBXNativeTarget "lokinetTests" */ = {
isa = XCConfigurationList;
buildConfigurations = (
7BED5BA0232D78DB00DF603F /* Debug */,
7BED5BA1232D78DB00DF603F /* Release */,
);
defaultConfigurationIsVisible = 0;
defaultConfigurationName = Release;
};
7BED5BA2232D78DB00DF603F /* Build configuration list for PBXNativeTarget "lokinetUITests" */ = {
isa = XCConfigurationList;
buildConfigurations = (
7BED5BA3232D78DB00DF603F /* Debug */,
7BED5BA4232D78DB00DF603F /* Release */,
);
defaultConfigurationIsVisible = 0;
defaultConfigurationName = Release;
};
/* End XCConfigurationList section */
};
rootObject = 7BED5B6E232D78D900DF603F /* Project object */;
}

@ -0,0 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<Workspace
version = "1.0">
<FileRef
location = "self:">
</FileRef>
</Workspace>

@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>IDEDidComputeMac32BitWarning</key>
<true/>
</dict>
</plist>

@ -0,0 +1,112 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "1020"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
buildImplicitDependencies = "YES">
<BuildActionEntries>
<BuildActionEntry
buildForTesting = "YES"
buildForRunning = "YES"
buildForProfiling = "YES"
buildForArchiving = "YES"
buildForAnalyzing = "YES">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "7BED5B75232D78D900DF603F"
BuildableName = "lokinet.app"
BlueprintName = "lokinet"
ReferencedContainer = "container:lokinet.xcodeproj">
</BuildableReference>
</BuildActionEntry>
</BuildActionEntries>
</BuildAction>
<TestAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
shouldUseLaunchSchemeArgsEnv = "YES">
<Testables>
<TestableReference
skipped = "NO">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "7BED5B87232D78DB00DF603F"
BuildableName = "lokinetTests.xctest"
BlueprintName = "lokinetTests"
ReferencedContainer = "container:lokinet.xcodeproj">
</BuildableReference>
</TestableReference>
<TestableReference
skipped = "NO">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "7BED5B92232D78DB00DF603F"
BuildableName = "lokinetUITests.xctest"
BlueprintName = "lokinetUITests"
ReferencedContainer = "container:lokinet.xcodeproj">
</BuildableReference>
</TestableReference>
</Testables>
<MacroExpansion>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "7BED5B75232D78D900DF603F"
BuildableName = "lokinet.app"
BlueprintName = "lokinet"
ReferencedContainer = "container:lokinet.xcodeproj">
</BuildableReference>
</MacroExpansion>
<AdditionalOptions>
</AdditionalOptions>
</TestAction>
<LaunchAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
debugAsWhichUser = "root"
launchStyle = "0"
useCustomWorkingDirectory = "NO"
ignoresPersistentStateOnLaunch = "NO"
debugDocumentVersioning = "YES"
debugServiceExtension = "internal"
allowLocationSimulation = "YES">
<BuildableProductRunnable
runnableDebuggingMode = "0">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "7BED5B75232D78D900DF603F"
BuildableName = "lokinet.app"
BlueprintName = "lokinet"
ReferencedContainer = "container:lokinet.xcodeproj">
</BuildableReference>
</BuildableProductRunnable>
<AdditionalOptions>
</AdditionalOptions>
</LaunchAction>
<ProfileAction
buildConfiguration = "Release"
shouldUseLaunchSchemeArgsEnv = "YES"
savedToolIdentifier = ""
useCustomWorkingDirectory = "NO"
debugDocumentVersioning = "YES">
<BuildableProductRunnable
runnableDebuggingMode = "0">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "7BED5B75232D78D900DF603F"
BuildableName = "lokinet.app"
BlueprintName = "lokinet"
ReferencedContainer = "container:lokinet.xcodeproj">
</BuildableReference>
</BuildableProductRunnable>
</ProfileAction>
<AnalyzeAction
buildConfiguration = "Debug">
</AnalyzeAction>
<ArchiveAction
buildConfiguration = "Release"
revealArchiveInOrganizer = "YES">
</ArchiveAction>
</Scheme>

@ -0,0 +1,155 @@
//
// AppDelegate.swift
// lokinet
//
// Copyright © 2019 Loki. All rights reserved.
//
import Cocoa
let LOG_WINDOW_CONTROLLER: NSWindowController = NSWindowController(window: nil)
@NSApplicationMain
class AppDelegate: NSObject, NSApplicationDelegate {
var lokinet: LokinetRunner? = nil
var appender: Appendable? = nil
var statusBarItem: NSStatusItem = NSStatusBar.system.statusItem(withLength: NSStatusItem.variableLength)
func applicationWillFinishLaunching(_ notification: Notification) {
if (!Preferences.firstRunDone) {
Preferences.firstRunDone = true
Preferences.restore()
}
}
func applicationDidFinishLaunching(_ aNotification: Notification) {
guard let statusButton = statusBarItem.button else { return }
statusButton.title = "LokiNet"
let statusMenu: NSMenu = NSMenu()
statusMenu.autoenablesItems = false
statusMenu.addItem(withTitle: "LokiNet", action: nil, keyEquivalent: "")
let runItem: NSMenuItem = {
let item = NSMenuItem(
title: "Run",
action: #selector(runLokinet),
keyEquivalent: "r"
)
item.target = self
return item
}()
let stopItem: NSMenuItem = {
let item = NSMenuItem(
title: "Stop",
action: #selector(stopLokinet),
keyEquivalent: "s"
)
item.isEnabled = false
item.target = self
return item
}()
let showWindowItem: NSMenuItem = {
let item = NSMenuItem(
title: "Show Window",
action: #selector(showWindow),
keyEquivalent: "w"
)
item.target = self
return item
}()
let quitApplicationItem: NSMenuItem = {
let item = NSMenuItem(
title: "Quit",
action: #selector(terminate),
keyEquivalent: "q")
item.target = self
return item
}()
statusMenu.addItems(
.separator(),
runItem,
stopItem,
.separator(),
showWindowItem,
.separator(),
quitApplicationItem
)
statusBarItem.menu = statusMenu
}
func applicationWillTerminate(_ aNotification: Notification) {
lokinet?.stop()
}
}
extension AppDelegate {
@objc
func showWindow(sender: NSMenuItem) {
if let vc = WindowsManager.getVC(withIdentifier: "LokinetLogController", ofType: LokinetLogController.self) {
appender = vc.log
let window: NSWindow = {
let w = NSWindow(contentViewController: vc)
w.styleMask.remove(.fullScreen)
w.styleMask.remove(.resizable)
w.styleMask.remove(.miniaturizable)
w.level = .floating
return w
}()
lokinet?.logAppender = vc.log
if LOG_WINDOW_CONTROLLER.window == nil {
LOG_WINDOW_CONTROLLER.window = window
}
LOG_WINDOW_CONTROLLER.showWindow(window)
}
}
@objc
func runLokinet(sender: NSMenuItem) {
if lokinet == nil {
lokinet = LokinetRunner(interface: Preferences.interfaceName, path: Preferences.lokinetPath)
lokinet?.logAppender = appender
lokinet?.start()
}
sender.isEnabled = false;
if let menu = statusBarItem.menu, let stop = menu.item(withTitle: "Stop") {
stop.isEnabled = true
}
}
@objc
func stopLokinet(_ sender: NSMenuItem) {
lokinet?.stop()
lokinet = nil
sender.isEnabled = false;
if let menu = statusBarItem.menu, let start = menu.item(withTitle: "Run") {
start.isEnabled = true
}
}
@objc
func terminate(_ sender: NSMenuItem) {
NSApp.terminate(sender)
}
}

@ -0,0 +1,58 @@
{
"images" : [
{
"idiom" : "mac",
"size" : "16x16",
"scale" : "1x"
},
{
"idiom" : "mac",
"size" : "16x16",
"scale" : "2x"
},
{
"idiom" : "mac",
"size" : "32x32",
"scale" : "1x"
},
{
"idiom" : "mac",
"size" : "32x32",
"scale" : "2x"
},
{
"idiom" : "mac",
"size" : "128x128",
"scale" : "1x"
},
{
"idiom" : "mac",
"size" : "128x128",
"scale" : "2x"
},
{
"idiom" : "mac",
"size" : "256x256",
"scale" : "1x"
},
{
"idiom" : "mac",
"size" : "256x256",
"scale" : "2x"
},
{
"idiom" : "mac",
"size" : "512x512",
"scale" : "1x"
},
{
"idiom" : "mac",
"size" : "512x512",
"scale" : "2x"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}

@ -0,0 +1,6 @@
{
"info" : {
"version" : 1,
"author" : "xcode"
}
}

@ -0,0 +1,238 @@
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.Cocoa.Storyboard.XIB" version="3.0" toolsVersion="14490.70" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES">
<dependencies>
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="14490.70"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
<scenes>
<!--Application-->
<scene sceneID="JPo-4y-FX3">
<objects>
<application id="hnw-xV-0zn" sceneMemberID="viewController">
<menu key="mainMenu" title="Main Menu" systemMenu="main" id="AYu-sK-qS6">
<items>
<menuItem title="lokinet" id="1Xt-HY-uBw">
<modifierMask key="keyEquivalentModifierMask"/>
<menu key="submenu" title="lokinet" systemMenu="apple" id="uQy-DD-JDr">
<items>
<menuItem title="About lokinet" id="5kV-Vb-QxS">
<modifierMask key="keyEquivalentModifierMask"/>
<connections>
<action selector="orderFrontStandardAboutPanel:" target="Ady-hI-5gd" id="Exp-CZ-Vem"/>
</connections>
</menuItem>
<menuItem isSeparatorItem="YES" id="VOq-y0-SEH"/>
<menuItem title="Preferences…" keyEquivalent="," id="BOF-NM-1cW">
<connections>
<segue destination="I5t-b2-LMF" kind="show" id="DG8-M4-AZh"/>
</connections>
</menuItem>
<menuItem isSeparatorItem="YES" id="wFC-TO-SCJ"/>
<menuItem title="Services" id="NMo-om-nkz">
<modifierMask key="keyEquivalentModifierMask"/>
<menu key="submenu" title="Services" systemMenu="services" id="hz9-B4-Xy5"/>
</menuItem>
<menuItem isSeparatorItem="YES" id="4je-JR-u6R"/>
<menuItem title="Hide lokinet" keyEquivalent="h" id="Olw-nP-bQN">
<connections>
<action selector="hide:" target="Ady-hI-5gd" id="PnN-Uc-m68"/>
</connections>
</menuItem>
<menuItem title="Hide Others" keyEquivalent="h" id="Vdr-fp-XzO">
<modifierMask key="keyEquivalentModifierMask" option="YES" command="YES"/>
<connections>
<action selector="hideOtherApplications:" target="Ady-hI-5gd" id="VT4-aY-XCT"/>
</connections>
</menuItem>
<menuItem title="Show All" id="Kd2-mp-pUS">
<modifierMask key="keyEquivalentModifierMask"/>
<connections>
<action selector="unhideAllApplications:" target="Ady-hI-5gd" id="Dhg-Le-xox"/>
</connections>
</menuItem>
<menuItem isSeparatorItem="YES" id="kCx-OE-vgT"/>
<menuItem title="Quit lokinet" keyEquivalent="q" id="4sb-4s-VLi">
<connections>
<action selector="terminate:" target="Ady-hI-5gd" id="Te7-pn-YzF"/>
</connections>
</menuItem>
</items>
</menu>
</menuItem>
<menuItem title="View" id="H8h-7b-M4v">
<modifierMask key="keyEquivalentModifierMask"/>
<menu key="submenu" title="View" id="HyV-fh-RgO">
<items>
<menuItem title="Enter Full Screen" keyEquivalent="f" id="4J7-dP-txa">
<modifierMask key="keyEquivalentModifierMask" control="YES" command="YES"/>
<connections>
<action selector="toggleFullScreen:" target="Ady-hI-5gd" id="dU3-MA-1Rq"/>
</connections>
</menuItem>
</items>
</menu>
</menuItem>
<menuItem title="Window" id="aUF-d1-5bR">
<modifierMask key="keyEquivalentModifierMask"/>
<menu key="submenu" title="Window" systemMenu="window" id="Td7-aD-5lo">
<items>
<menuItem title="Minimize" keyEquivalent="m" id="OY7-WF-poV">
<connections>
<action selector="performMiniaturize:" target="Ady-hI-5gd" id="VwT-WD-YPe"/>
</connections>
</menuItem>
<menuItem title="Zoom" id="R4o-n2-Eq4">
<modifierMask key="keyEquivalentModifierMask"/>
<connections>
<action selector="performZoom:" target="Ady-hI-5gd" id="DIl-cC-cCs"/>
</connections>
</menuItem>
<menuItem isSeparatorItem="YES" id="eu3-7i-yIM"/>
<menuItem title="Bring All to Front" id="LE2-aR-0XJ">
<modifierMask key="keyEquivalentModifierMask"/>
<connections>
<action selector="arrangeInFront:" target="Ady-hI-5gd" id="DRN-fu-gQh"/>
</connections>
</menuItem>
</items>
</menu>
</menuItem>
<menuItem title="Help" id="wpr-3q-Mcd">
<modifierMask key="keyEquivalentModifierMask"/>
<menu key="submenu" title="Help" systemMenu="help" id="F2S-fz-NVQ">
<items>
<menuItem title="lokinet Help" keyEquivalent="?" id="FKE-Sm-Kum">
<connections>
<action selector="showHelp:" target="Ady-hI-5gd" id="y7X-2Q-9no"/>
</connections>
</menuItem>
</items>
</menu>
</menuItem>
</items>
</menu>
<connections>
<outlet property="delegate" destination="Voe-Tx-rLC" id="PrD-fu-P6m"/>
</connections>
</application>
<customObject id="Voe-Tx-rLC" customClass="AppDelegate" customModule="lokinet" customModuleProvider="target"/>
<customObject id="YLy-65-1bz" customClass="NSFontManager"/>
<customObject id="Ady-hI-5gd" userLabel="First Responder" customClass="NSResponder" sceneMemberID="firstResponder"/>
</objects>
<point key="canvasLocation" x="123" y="-201"/>
</scene>
<!--lokinet-->
<scene sceneID="KyO-ZK-znh">
<objects>
<viewController title="lokinet" storyboardIdentifier="LokinetLogController" id="Bom-14-aTM" customClass="LokinetLogController" customModule="lokinet" sceneMemberID="viewController">
<view key="view" id="vMu-xc-OqT">
<rect key="frame" x="0.0" y="0.0" width="450" height="300"/>
<autoresizingMask key="autoresizingMask"/>
<subviews>
<scrollView fixedFrame="YES" borderType="none" horizontalLineScroll="10" horizontalPageScroll="10" verticalLineScroll="10" verticalPageScroll="10" hasHorizontalScroller="NO" translatesAutoresizingMaskIntoConstraints="NO" id="pjx-TF-AEF">
<rect key="frame" x="0.0" y="0.0" width="450" height="300"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<clipView key="contentView" ambiguous="YES" drawsBackground="NO" copiesOnScroll="NO" id="LWK-yZ-W61">
<rect key="frame" x="0.0" y="0.0" width="450" height="300"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<textView ambiguous="YES" editable="NO" importsGraphics="NO" richText="NO" verticallyResizable="YES" id="Iv9-j0-Ji1" customClass="LokinetLog" customModule="lokinet" customModuleProvider="target">
<rect key="frame" x="0.0" y="0.0" width="450" height="300"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<color key="textColor" name="textBackgroundColor" catalog="System" colorSpace="catalog"/>
<color key="backgroundColor" name="systemGrayColor" catalog="System" colorSpace="catalog"/>
<size key="minSize" width="450" height="300"/>
<size key="maxSize" width="498" height="10000000"/>
<color key="insertionPointColor" name="textColor" catalog="System" colorSpace="catalog"/>
</textView>
</subviews>
</clipView>
<scroller key="horizontalScroller" hidden="YES" wantsLayer="YES" verticalHuggingPriority="750" horizontal="YES" id="2H0-hl-PSz">
<rect key="frame" x="-100" y="-100" width="240" height="16"/>
<autoresizingMask key="autoresizingMask"/>
</scroller>
<scroller key="verticalScroller" wantsLayer="YES" verticalHuggingPriority="750" horizontal="NO" id="0vF-TP-EGb">
<rect key="frame" x="434" y="0.0" width="16" height="300"/>
<autoresizingMask key="autoresizingMask"/>
</scroller>
</scrollView>
</subviews>
</view>
</viewController>
<customObject id="4KZ-DK-tjg" userLabel="First Responder" customClass="NSResponder" sceneMemberID="firstResponder"/>
</objects>
</scene>
<!--Preferences-->
<scene sceneID="DWQ-D6-m8l">
<objects>
<viewController title="Preferences" id="I5t-b2-LMF" customClass="PrefsViewController" customModule="lokinet" sceneMemberID="viewController">
<view key="view" id="KZz-Tr-Jig">
<rect key="frame" x="0.0" y="0.0" width="450" height="300"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<box fixedFrame="YES" title="Options" translatesAutoresizingMaskIntoConstraints="NO" id="Mbe-YJ-q14">
<rect key="frame" x="-3" y="-4" width="456" height="304"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<view key="contentView" id="tbu-Pf-Pbq">
<rect key="frame" x="3" y="3" width="450" height="286"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<box verticalHuggingPriority="750" fixedFrame="YES" boxType="separator" translatesAutoresizingMaskIntoConstraints="NO" id="keI-0V-OFa">
<rect key="frame" x="0.0" y="226" width="450" height="5"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" flexibleMinY="YES"/>
</box>
<textField horizontalHuggingPriority="251" verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="NuC-QX-tDB">
<rect key="frame" x="18" y="269" width="414" height="17"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" flexibleMinY="YES"/>
<textFieldCell key="cell" lineBreakMode="clipping" title="Lokinet Path" id="J0z-ru-wAJ">
<font key="font" metaFont="system"/>
<color key="textColor" name="labelColor" catalog="System" colorSpace="catalog"/>
<color key="backgroundColor" name="textBackgroundColor" catalog="System" colorSpace="catalog"/>
</textFieldCell>
</textField>
<textField horizontalHuggingPriority="251" verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="Faq-SR-HLK">
<rect key="frame" x="18" y="201" width="414" height="17"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" flexibleMinY="YES"/>
<textFieldCell key="cell" lineBreakMode="clipping" title="Network Interface" id="EAM-Cf-Ujw">
<font key="font" metaFont="system"/>
<color key="textColor" name="labelColor" catalog="System" colorSpace="catalog"/>
<color key="backgroundColor" name="textBackgroundColor" catalog="System" colorSpace="catalog"/>
</textFieldCell>
</textField>
<comboBox identifier="lokinetInterface" verticalHuggingPriority="750" fixedFrame="YES" tag="2" translatesAutoresizingMaskIntoConstraints="NO" id="S5U-xg-7pX">
<rect key="frame" x="20" y="169" width="413" height="26"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" flexibleMinY="YES"/>
<comboBoxCell key="cell" scrollable="YES" lineBreakMode="clipping" selectable="YES" editable="YES" sendsActionOnEndEditing="YES" borderStyle="bezel" drawsBackground="YES" numberOfVisibleItems="7" id="f1D-GI-o0g">
<font key="font" metaFont="system"/>
<color key="textColor" name="controlTextColor" catalog="System" colorSpace="catalog"/>
<color key="backgroundColor" name="textBackgroundColor" catalog="System" colorSpace="catalog"/>
</comboBoxCell>
<connections>
<action selector="comboAction:" target="I5t-b2-LMF" id="Bji-8L-xCR"/>
</connections>
</comboBox>
<textField verticalHuggingPriority="750" fixedFrame="YES" tag="1" translatesAutoresizingMaskIntoConstraints="NO" id="esl-Vn-YX2">
<rect key="frame" x="20" y="239" width="410" height="22"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES"/>
<textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" selectable="YES" editable="YES" sendsActionOnEndEditing="YES" borderStyle="bezel" drawsBackground="YES" id="WCQ-qF-r0o">
<font key="font" metaFont="system"/>
<color key="textColor" name="controlTextColor" catalog="System" colorSpace="catalog"/>
<color key="backgroundColor" name="textBackgroundColor" catalog="System" colorSpace="catalog"/>
</textFieldCell>
</textField>
</subviews>
</view>
</box>
</subviews>
</view>
<connections>
<outlet property="interfaceEntry" destination="S5U-xg-7pX" id="OaG-RT-28K"/>
<outlet property="pathEntry" destination="WCQ-qF-r0o" id="aVf-iB-WbW"/>
</connections>
</viewController>
<customObject id="ncN-3l-Dyn" userLabel="First Responder" customClass="NSResponder" sceneMemberID="firstResponder"/>
</objects>
<point key="canvasLocation" x="845" y="227"/>
</scene>
</scenes>
</document>

@ -0,0 +1,79 @@
//
// DNSManager.swift
// lokinet
//
// Copyright © 2019 Loki. All rights reserved.
//
import Foundation
func split(str: String?) -> [String] {
let res = str?.components(separatedBy: NSCharacterSet.whitespacesAndNewlines) ?? []
return res.filter({!$0.isEmpty})
}
class DNSManager {
static let netSetup = URL(fileURLWithPath: "/usr/sbin/networksetup")
let interface: String
var oldDNSSettings: [String] = []
func getOldSettings() -> [String] {
let netprocess = Process()
netprocess.executableURL = DNSManager.netSetup
netprocess.arguments = ["-getdnsservers", interface]
do {
let pipe = Pipe()
netprocess.standardOutput = pipe
try netprocess.run()
let data = pipe.fileHandleForReading.readDataToEndOfFile()
let asStr = String(data: data, encoding: .ascii)
if asStr?.contains("There aren't any DNS Servers") ?? true {
return []
} else {
return split(str: asStr).filter({$0 != "127.0.0.1"})
}
} catch {
return []
}
}
func setNewSettings() throws {
self.oldDNSSettings = getOldSettings()
print("Overriding DNS Settings of \(self.oldDNSSettings)")
let netprocess = Process()
netprocess.executableURL = DNSManager.netSetup
netprocess.arguments = ["-setdnsservers", self.interface, "127.0.0.1"]
try netprocess.run()
}
func restoreOldSettings() {
let netprocess = Process()
netprocess.executableURL = DNSManager.netSetup
netprocess.arguments = ["-setdnsservers", self.interface]
if oldDNSSettings.isEmpty {
// networkmsetup uses "networksetup -setdnsservers <interface> Empty" to reset
netprocess.arguments?.append("Empty")
} else {
netprocess.arguments?.append(contentsOf: oldDNSSettings)
}
do {
try netprocess.run()
print("Resetting DNS Settings to \(self.oldDNSSettings)")
} catch {
// do nothing
}
}
init(interface: String) {
self.interface = interface
}
}

@ -0,0 +1,34 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleDevelopmentRegion</key>
<string>$(DEVELOPMENT_LANGUAGE)</string>
<key>CFBundleExecutable</key>
<string>$(EXECUTABLE_NAME)</string>
<key>CFBundleIconFile</key>
<string></string>
<key>CFBundleIdentifier</key>
<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>
<string>$(PRODUCT_NAME)</string>
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleShortVersionString</key>
<string>1.0</string>
<key>CFBundleVersion</key>
<string>1</string>
<key>LSApplicationCategoryType</key>
<string>public.app-category.productivity</string>
<key>LSMinimumSystemVersion</key>
<string>$(MACOSX_DEPLOYMENT_TARGET)</string>
<key>NSHumanReadableCopyright</key>
<string>Copyright © 2019 Loki. All rights reserved.</string>
<key>NSMainStoryboardFile</key>
<string>Main</string>
<key>NSPrincipalClass</key>
<string>NSApplication</string>
</dict>
</plist>

@ -0,0 +1,37 @@
//
// LokinetLog.swift
// lokinet
//
// Copyright © 2019 Loki. All rights reserved.
//
import AppKit
class LokinetLogController : NSViewController {
override func viewDidLoad() {
super.viewDidLoad()
}
var log: LokinetLog {
get {
// this is walking down the UI stack.
// TODO: work out a better way of doing this
let scroll = self.view.subviews[0] as! NSScrollView
let clip = scroll.subviews[0] as! NSClipView
let log = clip.subviews[0] as! LokinetLog
return log
}
}
}
protocol Appendable {
func append(string: String)
}
final class LokinetLog : NSTextView, Appendable {
func append(string: String) {
self.textStorage?.append(NSAttributedString(string: string + "\n"))
self.scrollToEndOfDocument(nil)
}
}

@ -0,0 +1,60 @@
//
// LokinetRunner.swift
// lokinet
//
// Copyright © 2019 Loki. All rights reserved.
//
import Foundation
import Cocoa
class LokinetRunner {
let dnsManager: DNSManager
let lokinetPath: URL
var process = Process()
var logAppender: Appendable? = nil
init(interface: String, path: String) {
self.lokinetPath = URL(fileURLWithPath: path)
self.dnsManager = DNSManager(interface: interface)
}
func start() {
process.executableURL = self.lokinetPath
process.arguments = ["--colour=false"]
let outputPipe = Pipe()
process.standardOutput = outputPipe
process.standardError = outputPipe
do {
try self.dnsManager.setNewSettings()
try process.run()
} catch {
NSApp.presentError(error)
}
guard let reader = StreamReader(fh: outputPipe.fileHandleForReading) else {
let err = NSError(domain: "lokinet", code: 0, userInfo: ["msg": "Failed to read from filehandle"])
NSApp.presentError(err)
return
}
DispatchQueue.global(qos: .background).async {
for line in reader {
print(line)
DispatchQueue.main.async {
self.logAppender?.append(string: line)
}
}
}
}
func stop() {
if process.isRunning {
process.terminate()
process.waitUntilExit()
}
dnsManager.restoreOldSettings()
}
}

@ -0,0 +1,73 @@
//
// StreamReader.swift
// lokinet
//
// Copyright © 2019 Loki. All rights reserved.
//
import Foundation
final class StreamReader {
let encoding : String.Encoding
let chunkSize : Int
var fileHandle : FileHandle!
var buffer : Data
let delimData : Data
var atEof : Bool = false
init?(fh: FileHandle, delimiter: String = "\n", encoding : String.Encoding = .utf8, chunkSize : Int = 4096) {
self.chunkSize = chunkSize
self.encoding = encoding
self.fileHandle = fh
guard let delimData = delimiter.data(using: encoding) else {
return nil
}
self.delimData = delimData
self.buffer = Data(capacity: chunkSize)
}
/// Return next line, or nil on EOF.
func nextLine() -> String? {
precondition(fileHandle != nil, "Attempt to read from closed file")
if atEof {
return nil
}
// Read data chunks from file until a line delimiter is found:
while !atEof {
if let range = buffer.range(of: delimData) {
// Convert complete line (excluding the delimiter) to a string:
let line = String(data: buffer.subdata(in: 0..<range.lowerBound), encoding: encoding)
// Remove line (and the delimiter) from the buffer:
buffer.removeSubrange(0..<range.upperBound)
return line
}
let tmpData = fileHandle.readData(ofLength: chunkSize)
if tmpData.count > 0 {
buffer.append(tmpData)
} else {
// EOF or read error.
atEof = true
if buffer.count > 0 {
// Buffer contains last line in file (not terminated by delimiter).
let line = String(data: buffer as Data, encoding: encoding)
buffer.count = 0
return line
}
}
}
return nil
}
}
extension StreamReader : Sequence {
func makeIterator() -> AnyIterator<String> {
return AnyIterator {
return self.nextLine()
}
}
}

@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>com.apple.security.application-groups</key>
<array/>
</dict>
</plist>

@ -0,0 +1,22 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleDevelopmentRegion</key>
<string>$(DEVELOPMENT_LANGUAGE)</string>
<key>CFBundleExecutable</key>
<string>$(EXECUTABLE_NAME)</string>
<key>CFBundleIdentifier</key>
<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>
<string>$(PRODUCT_NAME)</string>
<key>CFBundlePackageType</key>
<string>BNDL</string>
<key>CFBundleShortVersionString</key>
<string>1.0</string>
<key>CFBundleVersion</key>
<string>1</string>
</dict>
</plist>

@ -0,0 +1,33 @@
//
// lokinetTests.swift
// lokinetTests
//
// Copyright © 2019 Loki. All rights reserved.
//
import XCTest
@testable import lokinet
class lokinetTests: XCTestCase {
override func setUp() {
// Put setup code here. This method is called before the invocation of each test method in the class.
}
override func tearDown() {
// Put teardown code here. This method is called after the invocation of each test method in the class.
}
func testExample() {
// This is an example of a functional test case.
// Use XCTAssert and related functions to verify your tests produce the correct results.
}
func testPerformanceExample() {
// This is an example of a performance test case.
self.measure {
// Put the code you want to measure the time of here.
}
}
}

@ -0,0 +1,22 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleDevelopmentRegion</key>
<string>$(DEVELOPMENT_LANGUAGE)</string>
<key>CFBundleExecutable</key>
<string>$(EXECUTABLE_NAME)</string>
<key>CFBundleIdentifier</key>
<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>
<string>$(PRODUCT_NAME)</string>
<key>CFBundlePackageType</key>
<string>BNDL</string>
<key>CFBundleShortVersionString</key>
<string>1.0</string>
<key>CFBundleVersion</key>
<string>1</string>
</dict>
</plist>

@ -0,0 +1,33 @@
//
// lokinetUITests.swift
// lokinetUITests
//
// Copyright © 2019 Loki. All rights reserved.
//
import XCTest
class lokinetUITests: XCTestCase {
override func setUp() {
// Put setup code here. This method is called before the invocation of each test method in the class.
// In UI tests it is usually best to stop immediately when a failure occurs.
continueAfterFailure = false
// UI tests must launch the application that they test. Doing this in setup will make sure it happens for each test method.
XCUIApplication().launch()
// In UI tests its important to set the initial state - such as interface orientation - required for your tests before they run. The setUp method is a good place to do this.
}
override func tearDown() {
// Put teardown code here. This method is called after the invocation of each test method in the class.
}
func testExample() {
// Use recording to get started writing UI tests.
// Use XCTAssert and related functions to verify your tests produce the correct results.
}
}

@ -37,10 +37,10 @@ using System.Runtime.InteropServices;
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("0.5.0")]
[assembly: AssemblyFileVersion("0.5.0")]
[assembly: AssemblyVersion("0.5.2")]
[assembly: AssemblyFileVersion("0.5.2")]
#if DEBUG
[assembly: AssemblyInformationalVersion("0.5.0-dev-{chash:8}")]
[assembly: AssemblyInformationalVersion("0.5.2-dev-{chash:8}")]
#else
[assembly: AssemblyInformationalVersion("0.5.0 (RELEASE_CODENAME)")]
[assembly: AssemblyInformationalVersion("0.5.2 (RELEASE_CODENAME)")]
#endif

@ -1,5 +1,5 @@
using System;
using System.Diagnostics;
using System.Diagnostics;
using System.IO;
using System.Windows.Forms;
@ -58,54 +58,54 @@ namespace network.loki.lokinet.win32.ui
VisualSettings v = new VisualSettings();
v.ShowDialog();
v.Dispose();
}
private void BtnEditCfg_Click(object sender, EventArgs e)
{
try {
Process.Start(string.Format("{0}/lokinet.ini", config_path)); }
catch
{
MessageBox.Show("No existing config found");
BtnNewCfg_Click(sender, e);
}
}
private void BtnNewCfg_Click(object sender, EventArgs e)
{
if (File.Exists(string.Format("{0}/lokinet.ini", config_path)))
{
DialogResult resp = MessageBox.Show("WARNING: This will overwrite your existing config file, Continue?", "Lokinet", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
switch(resp)
{
case DialogResult.Yes:
File.Delete(string.Format("{0}/lokinet.ini", config_path));
break;
case DialogResult.No:
return;
}
}
string lokinetExeString;
if (Program.platform == PlatformID.Win32NT)
lokinetExeString = String.Format("{0}\\lokinet.exe", Directory.GetCurrentDirectory());
else
lokinetExeString = String.Format("{0}/lokinet", Directory.GetCurrentDirectory());
Process p = new Process();
p.StartInfo.FileName = lokinetExeString;
p.StartInfo.Arguments = "-g";
p.StartInfo.CreateNoWindow = true;
p.StartInfo.UseShellExecute = false;
p.EnableRaisingEvents = true;
p.Exited += new EventHandler(msg);
p.Start();
}
private void msg(object sender, EventArgs e)
{
MessageBox.Show(string.Format("Created new config file at {0}/lokinet.ini", config_path), "Success", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
}
}
private void BtnEditCfg_Click(object sender, EventArgs e)
{
try {
Process.Start(string.Format("{0}/lokinet.ini", config_path)); }
catch
{
MessageBox.Show("No existing config found");
BtnNewCfg_Click(sender, e);
}
}
private void BtnNewCfg_Click(object sender, EventArgs e)
{
if (File.Exists(string.Format("{0}/lokinet.ini", config_path)))
{
DialogResult resp = MessageBox.Show("WARNING: This will overwrite your existing config file, Continue?", "Lokinet", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
switch(resp)
{
case DialogResult.Yes:
File.Delete(string.Format("{0}/lokinet.ini", config_path));
break;
case DialogResult.No:
return;
}
}
string lokinetExeString;
if (Program.platform == PlatformID.Win32NT)
lokinetExeString = String.Format("{0}\\lokinet.exe", Directory.GetCurrentDirectory());
else
lokinetExeString = String.Format("{0}/lokinet", Directory.GetCurrentDirectory());
Process p = new Process();
p.StartInfo.FileName = lokinetExeString;
p.StartInfo.Arguments = "-g";
p.StartInfo.CreateNoWindow = true;
p.StartInfo.UseShellExecute = false;
p.EnableRaisingEvents = true;
p.Exited += new EventHandler(msg);
p.Start();
}
private void msg(object sender, EventArgs e)
{
MessageBox.Show(string.Format("Created new config file at {0}/lokinet.ini", config_path), "Success", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
}
}
}

@ -1,4 +1,6 @@
using System;
using System.Diagnostics;
using System.IO;
using System.Net;
using System.Net.Security;
using System.Security.Cryptography.X509Certificates;
@ -22,23 +24,45 @@ namespace network.loki.lokinet.win32.ui
private string default_path;
private void button1_Click(object sender, EventArgs e)
{
ServicePointManager.ServerCertificateValidationCallback += cert_check;
ServicePointManager.SecurityProtocol = (SecurityProtocolType)48 | 0 | (SecurityProtocolType)192 | (SecurityProtocolType)768 | (SecurityProtocolType)3072;
wc = new WebClient();
// add something more unique, this is the IE 5.0 default string
wc.Headers.Add("User-Agent","Mozilla/4.0 (compatible; MSIE 5.0; Windows NT 5.0)");
try
{
{
ServicePointManager.ServerCertificateValidationCallback += cert_check;
ServicePointManager.SecurityProtocol = (SecurityProtocolType)48 | 0 | (SecurityProtocolType)192 | (SecurityProtocolType)768 | (SecurityProtocolType)3072;
wc = new WebClient();
wc.Headers.Add("User-Agent", "Mozilla/4.0 (compatible; MSIE 5.0; Windows NT 5.0)");
wc.DownloadFile(uriBox.Text, default_path);
MessageBox.Show("LokiNET node bootstrapped", "LokiNET", MessageBoxButtons.OK, MessageBoxIcon.Information);
DialogResult = DialogResult.OK;
}
catch (Exception ex)
{
MessageBox.Show(string.Format("An error occured while downloading data. {0}", ex.Message), "Error", MessageBoxButtons.OK, MessageBoxIcon.Hand);
DialogResult = DialogResult.Abort;
{
string lokinetExeString;
Process lokinet_bootstrap = new Process();
if (Program.platform == PlatformID.Win32NT)
lokinetExeString = String.Format("{0}\\lokinet-bootstrap.exe", Directory.GetCurrentDirectory());
else
lokinetExeString = String.Format("{0}/lokinet-bootstrap", Directory.GetCurrentDirectory());
lokinet_bootstrap.StartInfo.UseShellExecute = false;
lokinet_bootstrap.StartInfo.CreateNoWindow = true;
lokinet_bootstrap.StartInfo.WorkingDirectory = Directory.GetCurrentDirectory();
lokinet_bootstrap.StartInfo.FileName = lokinetExeString;
lokinet_bootstrap.StartInfo.Arguments = string.Format("--cacert rootcerts.pem -L {0} --output \"{1}\"", uriBox.Text, default_path);
lokinet_bootstrap.Start();
lokinet_bootstrap.WaitForExit();
if (lokinet_bootstrap.ExitCode == 0)
{
DialogResult = DialogResult.OK;
MessageBox.Show("LokiNET node bootstrapped", "LokiNET", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
else
{
MessageBox.Show(string.Format("An error occured while downloading data. {0}", ex.Message), "Error", MessageBoxButtons.OK, MessageBoxIcon.Hand);
DialogResult = DialogResult.Abort;
}
}
wc.Dispose();
Close();
}

@ -0,0 +1,8 @@
mbedtls*.tgz*
mbedtls-*/
curl*.tar.xz*
curl-*/
include/
lib/
*.pem
LICENSE

Binary file not shown.

@ -0,0 +1,50 @@
# Makefile for windows install pkg and helper library
CC=i686-w64-mingw32-gcc
CXX=i686-w64-mingw32-g++
CFLAGS=-Ofast -march=nocona -mfpmath=sse
LIBS=-lws2_32
LDFLAGS=-static
ifndef RELEASE
all: regdbhelper.dll lokinet-bootstrap.exe
default: all
regdbhelper.dll:
i686-w64-mingw32-gcc regdb_helper.c -o $@ -shared -Os -s
mbedtls:
wget https://tls.mbed.org/download/mbedtls-2.16.3-apache.tgz
tar xvf mbedtls-2.16.3-apache.tgz
patch -p0 -d mbedtls-2.16.3 < mbedtls-win32.patch
$(MAKE) -j4 -C mbedtls-2.16.3/library CC=$(CC) CXX=$(CXX) CFLAGS="$(CFLAGS)" LDFLAGS=$(LIBS)
mkdir -p lib; mkdir -p include
cp mbedtls-2.16.3/library/*.a lib
cp -r mbedtls-2.16.3/include/mbedtls include
curl:
wget https://curl.haxx.se/download/curl-7.66.0.tar.xz
tar xvf curl-7.66.0.tar.xz
patch -p1 < curl-win32.patch
cd curl-7.66.0; ./configure --host=i686-w64-mingw32 --target=i686-w64-mingw32 CC=$(CC) CXX=$(CXX) CFLAGS="$(CFLAGS)" LIBS=$(LIBS) --disable-shared --without-zlib --without-ssl --with-mbedtls=$(PWD) --enable-optimize --enable-http --disable-ftp --disable-file --disable-ldap --disable-ldaps --disable-rtsp --enable-proxy --disable-dict --disable-telnet --disable-tftp --disable-pop3 --disable-imap --disable-smb --disable-smtp --disable-gopher --enable-manual
$(MAKE) -j4 -C curl-7.66.0
lokinet-bootstrap.exe: mbedtls curl
cp curl-7.66.0/src/curl.exe $@
wget -O rootcerts.pem https://curl.haxx.se/ca/cacert.pem
cp ../LICENSE .;unix2dos LICENSE LICENSE
else
all: regdbhelper.dll lokinet-bootstrap.exe
regdbhelper.dll:
scp despair@10.10.10.6:loki-network/win32-setup/*.dll .
lokinet-bootstrap.exe:
scp despair@10.10.10.6:loki-network/win32-setup/*.exe .
wget -O rootcerts.pem https://curl.haxx.se/ca/cacert.pem
cp ../LICENSE .;unix2dos LICENSE LICENSE
endif
clean:
-rm -rf curl-7* include lib mbedtls-2* *.exe *.dll *.pem

@ -0,0 +1,82 @@
diff --git a/curl-7.66.0/include/curl/curl.h b/curl-patched/include/curl/curl.h
index ff0c7749..4d3fdbb5 100644
--- a/curl-7.66.0/include/curl/curl.h
+++ b/curl-patched/include/curl/curl.h
@@ -65,6 +65,7 @@
included, since they can't co-exist without problems */
#include <winsock2.h>
#include <ws2tcpip.h>
+#include <wspiapi.h>
#endif
#endif
diff --git a/curl-7.66.0/include/curl/system.h b/curl-patched/include/curl/system.h
index cd37c2bf..b96cfd8c 100644
--- a/curl-7.66.0/include/curl/system.h
+++ b/curl-patched/include/curl/system.h
@@ -411,6 +411,7 @@
# include <winsock2.h>
# include <windows.h>
# include <ws2tcpip.h>
+# include <wspiapi.h>
#endif
/* CURL_PULL_SYS_TYPES_H is defined above when inclusion of header file */
diff --git a/curl-7.66.0/lib/curl_setup.h b/curl-patched/lib/curl_setup.h
index 13af8cde..a0408d5c 100644
--- a/curl-7.66.0/lib/curl_setup.h
+++ b/curl-patched/lib/curl_setup.h
@@ -255,6 +255,7 @@
# include <winsock2.h>
# ifdef HAVE_WS2TCPIP_H
# include <ws2tcpip.h>
+# include <wspiapi.h>
# endif
# else
# ifdef HAVE_WINSOCK_H
diff --git a/curl-7.66.0/lib/inet_pton.h b/curl-patched/lib/inet_pton.h
index 0209b9b7..67774fb9 100644
--- a/curl-7.66.0/lib/inet_pton.h
+++ b/curl-patched/lib/inet_pton.h
@@ -32,6 +32,7 @@ int Curl_inet_pton(int, const char *, void *);
#elif defined(HAVE_WS2TCPIP_H)
/* inet_pton() exists in Vista or later */
#include <ws2tcpip.h>
+#include <wspiapi.h>
#endif
#define Curl_inet_pton(x,y,z) inet_pton(x,y,z)
#endif
diff --git a/curl-7.66.0/src/tool_util.c b/curl-patched/src/tool_util.c
index 9990a463..8ea37f37 100644
--- a/curl-7.66.0/src/tool_util.c
+++ b/curl-patched/src/tool_util.c
@@ -40,12 +40,7 @@ struct timeval tvnow(void)
** is typically in the range of 10 milliseconds to 16 milliseconds.
*/
struct timeval now;
-#if defined(_WIN32_WINNT) && (_WIN32_WINNT >= 0x0600) && \
- (!defined(__MINGW32__) || defined(__MINGW64_VERSION_MAJOR))
- ULONGLONG milliseconds = GetTickCount64();
-#else
DWORD milliseconds = GetTickCount();
-#endif
now.tv_sec = (long)(milliseconds / 1000);
now.tv_usec = (long)((milliseconds % 1000) * 1000);
return now;
diff --git a/curl-7.66.0/tests/server/util.c b/curl-patched/tests/server/util.c
index b0613380..00d0b0c3 100644
--- a/curl-7.66.0/tests/server/util.c
+++ b/curl-patched/tests/server/util.c
@@ -415,12 +415,7 @@ static struct timeval tvnow(void)
** is typically in the range of 10 milliseconds to 16 milliseconds.
*/
struct timeval now;
-#if defined(_WIN32_WINNT) && (_WIN32_WINNT >= 0x0600) && \
- (!defined(__MINGW32__) || defined(__MINGW64_VERSION_MAJOR))
- ULONGLONG milliseconds = GetTickCount64();
-#else
DWORD milliseconds = GetTickCount();
-#endif
now.tv_sec = (long)(milliseconds / 1000);
now.tv_usec = (long)((milliseconds % 1000) * 1000);
return now;

Binary file not shown.

Binary file not shown.

@ -1,10 +1,10 @@
; Script generated by the Inno Script Studio Wizard.
; SEE THE DOCUMENTATION FOR DETAILS ON CREATING INNO SETUP SCRIPT FILES!
#define MyAppName "loki-network"
#define MyAppVersion "0.5.0"
#define MyAppName "Lokinet"
#define MyAppVersion "0.5.2"
#define MyAppPublisher "Loki Project"
#define MyAppURL "https://loki.network"
#define MyAppURL "https://lokinet.org"
#define MyAppExeName "lokinetui.exe"
; change this to avoid compiler errors -despair
#ifndef DevPath
@ -37,20 +37,20 @@ AllowNoIcons=yes
LicenseFile={#DevPath}LICENSE
OutputDir={#DevPath}win32-setup
OutputBaseFilename=lokinet-win32
Compression=lzma
Compression=lzma2/ultra64
SolidCompression=yes
VersionInfoVersion=0.5.0
VersionInfoVersion=0.5.2
VersionInfoCompany=Loki Project
VersionInfoDescription=LokiNET for Microsoft® Windows® NT™
#ifndef RELEASE
VersionInfoTextVersion=0.5.0-dev-{#VCSRev}
VersionInfoProductTextVersion=0.5.0-dev-{#VCSRev}
VersionInfoTextVersion=0.5.2-dev-{#VCSRev}
VersionInfoProductTextVersion=0.5.2-dev-{#VCSRev}
#else
VersionInfoTextVersion=0.5.0
VersionInfoProductTextVersion=0.5.0 ({#Codename})
VersionInfoTextVersion=0.5.2
VersionInfoProductTextVersion=0.5.2 ({#Codename})
#endif
VersionInfoProductName=LokiNET
VersionInfoProductVersion=0.5.0
VersionInfoProductVersion=0.5.2
InternalCompressLevel=ultra64
MinVersion=0,5.0
ArchitecturesInstallIn64BitMode=x64
@ -68,14 +68,14 @@ Name: "quicklaunchicon"; Description: "{cm:CreateQuickLaunchIcon}"; GroupDescrip
#ifdef SINGLE_ARCH
Source: "{#DevPath}build\lokinet.exe"; DestDir: "{app}"; Flags: ignoreversion
Source: "{#DevPath}build\liblokinet-shared.dll"; DestDir: "{app}"; Flags: ignoreversion
Source: "dbghelp64.dll"; DestName: "dbghelp.dll"; DestDir: "{app}"; Flags: ignoreversion
Source: "{tmp}\dbghelp64.dll"; DestName: "dbghelp.dll"; DestDir: "{app}"; Flags: ignoreversion external
#else
Source: "{#DevPath}build\lokinet.exe"; DestDir: "{app}"; Flags: ignoreversion 32bit; Check: not IsWin64
Source: "{#DevPath}build\liblokinet-shared.dll"; DestDir: "{app}"; Flags: ignoreversion 32bit; Check: not IsWin64
Source: "dbghelp32.dll"; DestName: "dbghelp.dll"; DestDir: "{app}"; Flags: ignoreversion; Check: not IsWin64
Source: "{tmp}\dbghelp32.dll"; DestName: "dbghelp.dll"; DestDir: "{app}"; Flags: ignoreversion external; Check: not IsWin64
Source: "{#DevPath}build64\lokinet.exe"; DestDir: "{app}"; Flags: ignoreversion 64bit; Check: IsWin64
Source: "{#DevPath}build64\liblokinet-shared.dll"; DestDir: "{app}"; Flags: ignoreversion 64bit; Check: IsWin64
Source: "dbghelp64.dll"; DestDir: "{app}"; DestName: "dbghelp.dll"; Flags: ignoreversion; Check: IsWin64
Source: "{tmp}\dbghelp64.dll"; DestDir: "{app}"; DestName: "dbghelp.dll"; Flags: ignoreversion external; Check: IsWin64
#endif
; UI has landed!
#ifndef RELEASE
@ -90,11 +90,12 @@ Source: "{#DevPath}ui-win32\bin\release\lokinetui.pdb"; DestDir: "{app}"; Flags:
; eh, might as well ship the 32-bit port of everything else
Source: "{#DevPath}build\testAll.exe"; DestDir: "{app}"; Flags: ignoreversion
Source: "{#DevPath}build\lokinet-rcutil.exe"; DestDir: "{app}"; Flags: ignoreversion
Source: "{#DevPath}LICENSE"; DestDir: "{app}"; Flags: ignoreversion
Source: "LICENSE"; DestDir: "{app}"; Flags: ignoreversion
Source: "lokinet-bootstrap.exe"; DestDir: "{app}"; Flags: ignoreversion
Source: "rootcerts.pem"; DestDir: "{app}"; Flags: ignoreversion
; delet this after finishing setup, we only need it to extract the drivers
; and download an initial RC. The UI has its own bootstrap built-in!
Source: "{#DevPath}lokinet-bootstrap.exe"; DestDir: "{tmp}"; Flags: deleteafterinstall
Source: "{#DevPath}win32-setup\7z.exe"; DestDir: "{tmp}"; Flags: deleteafterinstall
Source: "{tmp}\7z.exe"; DestDir: "{tmp}"; Flags: deleteafterinstall external
; if nonexistent, then inet6 was already installed
Source: "{tmp}\inet6.7z"; DestDir: "{app}"; Flags: ignoreversion external deleteafterinstall skipifsourcedoesntexist; MinVersion: 0,5.0; OnlyBelowVersion: 0,5.1
; Copy the correct tuntap driver for the selected platform
@ -103,6 +104,10 @@ Source: "{tmp}\tuntapv9_n6.7z"; DestDir: "{app}"; Flags: ignoreversion external
; NOTE: Don't use "Flags: ignoreversion" on any shared system files
Source: "regdbhelper.dll"; Flags: dontcopy
; build only if we have the 32-bit bins as well
; (i.e. *not* a Travis CI build, travis isn't expected to have these around)
#ifndef SINGLE_ARCH
Source: "C:\Windows\Fonts\iosevka-term-bold.ttf"; DestDir: "{fonts}"; FontInstall: "Iosevka Term Bold"; Flags: onlyifdoesntexist uninsneveruninstall
Source: "C:\Windows\Fonts\iosevka-term-bolditalic.ttf"; DestDir: "{fonts}"; FontInstall: "Iosevka Term Bold Italic"; Flags: onlyifdoesntexist uninsneveruninstall
Source: "C:\Windows\Fonts\iosevka-term-boldoblique.ttf"; DestDir: "{fonts}"; FontInstall: "Iosevka Term Bold Oblique"; Flags: onlyifdoesntexist uninsneveruninstall
@ -124,6 +129,7 @@ Source: "C:\Windows\Fonts\iosevka-term-regular.ttf"; DestDir: "{fonts}"; FontIns
Source: "C:\Windows\Fonts\iosevka-term-thin.ttf"; DestDir: "{fonts}"; FontInstall: "Iosevka Term Thin"; Flags: onlyifdoesntexist uninsneveruninstall
Source: "C:\Windows\Fonts\iosevka-term-thinitalic.ttf"; DestDir: "{fonts}"; FontInstall: "Iosevka Term Thin Italic"; Flags: onlyifdoesntexist uninsneveruninstall
Source: "C:\Windows\Fonts\iosevka-term-thinoblique.ttf"; DestDir: "{fonts}"; FontInstall: "Iosevka Term Thin Oblique"; Flags: onlyifdoesntexist uninsneveruninstall
#endif
[UninstallDelete]
Type: filesandordirs; Name: "{app}\tap-windows*"
@ -192,15 +198,18 @@ begin
begin
// current versions of windows :-)
// (Arguably, one could pull this from any of the forks.)
idpAddFile('https://github.com/despair86/loki-network/raw/master/contrib/tuntapv9-ndis/tap-windows-9.21.2.7z', ExpandConstant('{tmp}\tuntapv9_n6.7z'));
idpAddFile('https://snowlight.net/loki/win32-dist/tap-windows-9.21.2.7z', ExpandConstant('{tmp}\tuntapv9_n6.7z'));
end;
// Windows 2000 only, we need to install inet6 separately
if (FileExists(ExpandConstant('{sys}\drivers\tcpip6.sys')) = false) and (Version.Major = 5) and (Version.Minor = 0) then
begin
idpAddFile('http://www.rvx86.net/files/inet6.7z', ExpandConstant('{tmp}\inet6.7z'));
end;
idpDownloadAfter(wpReady);
end;
idpAddFile('http://www.rvx86.net/files/7z.exe', ExpandConstant('{tmp}\7z.exe'));
idpAddFile('http://www.rvx86.net/files/dbghelp32.dll', ExpandConstant('{tmp}\dbghelp32.dll'));
idpAddFile('http://www.rvx86.net/files/dbghelp64.dll', ExpandConstant('{tmp}\dbghelp64.dll'));
idpDownloadAfter(wpReady);
end;
[Icons]
@ -217,7 +226,7 @@ Filename: "{app}\{#MyAppExeName}"; Flags: nowait postinstall skipifsilent; Descr
Filename: "{tmp}\7z.exe"; Parameters: "x tuntapv9.7z"; WorkingDir: "{app}"; Flags: runascurrentuser waituntilterminated skipifdoesntexist; Description: "extract TUN/TAP-v9 driver"; StatusMsg: "Extracting driver..."; OnlyBelowVersion: 0, 6.0
Filename: "{tmp}\7z.exe"; Parameters: "x tuntapv9_n6.7z"; WorkingDir: "{app}"; Flags: runascurrentuser waituntilterminated skipifdoesntexist; Description: "extract TUN/TAP-v9 driver"; StatusMsg: "Extracting driver..."; MinVersion: 0, 6.0
Filename: "{tmp}\7z.exe"; Parameters: "x inet6.7z"; WorkingDir: "{app}"; Flags: skipifdoesntexist runascurrentuser waituntilterminated skipifdoesntexist; Description: "extract inet6 driver"; StatusMsg: "Extracting IPv6 driver..."; MinVersion: 0, 5.0; OnlyBelowVersion: 0, 5.1
Filename: "{tmp}\lokinet-bootstrap.exe"; Parameters:"https://seed.lokinet.org/bootstrap.signed {userappdata}\.lokinet\bootstrap.signed"; WorkingDir: "{app}"; Flags: runascurrentuser waituntilterminated; Description: "bootstrap dht"; StatusMsg: "Downloading initial RC..."
Filename: "{app}\lokinet-bootstrap.exe"; Parameters:"-L https://seed.lokinet.org/bootstrap.signed --cacert rootcerts.pem -o ""{userappdata}\.lokinet\bootstrap.signed"""; WorkingDir: "{app}"; Flags: runascurrentuser waituntilterminated; Description: "bootstrap dht"; StatusMsg: "Downloading initial RC..."
; then ask to install drivers
Filename: "{app}\tap-windows-9.9.2\install.bat"; WorkingDir: "{app}\tap-windows-9.9.2\"; Flags: runascurrentuser waituntilterminated skipifdoesntexist; Description: "Install TUN/TAP-v9 driver"; StatusMsg: "Installing driver..."; OnlyBelowVersion: 0, 6.0; Check: not IsTapInstalled
Filename: "{app}\tap-windows-9.21.2\install.bat"; WorkingDir: "{app}\tap-windows-9.21.2\"; Flags: runascurrentuser waituntilterminated skipifdoesntexist; Description: "Install TUN/TAP-v9 driver"; StatusMsg: "Installing driver..."; MinVersion: 0, 6.0; Check: not IsTapInstalled

@ -1,6 +1,6 @@
diff -ruN polarssl-master/include/mbedtls/aesni.h polarssl/include/mbedtls/aesni.h
--- polarssl-master/include/mbedtls/aesni.h 2018-03-16 11:25:12.000000000 -0500
+++ polarssl/include/mbedtls/aesni.h 2018-04-17 15:47:59.320514100 -0500
diff -ruN include/mbedtls/aesni.h include/mbedtls/aesni.h
--- include/mbedtls/aesni.h 2018-03-16 11:25:12.000000000 -0500
+++ include/mbedtls/aesni.h 2018-04-17 15:47:59.320514100 -0500
@@ -26,17 +26,16 @@
#include "aes.h"
@ -33,9 +33,9 @@ diff -ruN polarssl-master/include/mbedtls/aesni.h polarssl/include/mbedtls/aesni
-#endif /* MBEDTLS_HAVE_X86_64 */
-
#endif /* MBEDTLS_AESNI_H */
diff -ruN polarssl-master/include/mbedtls/bn_mul.h polarssl/include/mbedtls/bn_mul.h
--- polarssl-master/include/mbedtls/bn_mul.h 2018-03-16 11:25:12.000000000 -0500
+++ polarssl/include/mbedtls/bn_mul.h 2018-04-17 15:42:09.045117300 -0500
diff -ruN include/mbedtls/bn_mul.h include/mbedtls/bn_mul.h
--- include/mbedtls/bn_mul.h 2018-03-16 11:25:12.000000000 -0500
+++ include/mbedtls/bn_mul.h 2018-04-17 15:42:09.045117300 -0500
@@ -754,7 +754,9 @@
#if defined(MBEDTLS_HAVE_SSE2)
@ -47,9 +47,9 @@ diff -ruN polarssl-master/include/mbedtls/bn_mul.h polarssl/include/mbedtls/bn_m
#define MULADDC_HUIT \
EMIT 0x0F EMIT 0x6E EMIT 0xC9 \
EMIT 0x0F EMIT 0x6E EMIT 0xC3 \
diff -ruN polarssl-master/include/mbedtls/config.h polarssl/include/mbedtls/config.h
--- polarssl-master/include/mbedtls/config.h 2018-03-16 11:25:12.000000000 -0500
+++ polarssl/include/mbedtls/config.h 2018-04-17 17:27:18.350938700 -0500
diff -ruN include/mbedtls/config.h include/mbedtls/config.h
--- include/mbedtls/config.h 2018-03-16 11:25:12.000000000 -0500
+++ include/mbedtls/config.h 2018-04-17 17:27:18.350938700 -0500
@@ -91,7 +91,7 @@
*
* Uncomment if the CPU supports SSE2 (IA-32 specific).
@ -86,9 +86,9 @@ diff -ruN polarssl-master/include/mbedtls/config.h polarssl/include/mbedtls/conf
/**
* \def MBEDTLS_HMAC_DRBG_C
diff -ruN polarssl-master/library/aes.c polarssl/library/aes.c
--- polarssl-master/library/aes.c 2018-03-16 11:25:12.000000000 -0500
+++ polarssl/library/aes.c 2018-04-17 16:51:37.098413400 -0500
diff -ruN library/aes.c library/aes.c
--- library/aes.c 2018-03-16 11:25:12.000000000 -0500
+++ library/aes.c 2018-04-17 16:51:37.098413400 -0500
@@ -514,7 +514,7 @@
#endif
ctx->rk = RK = ctx->buf;
@ -107,18 +107,18 @@ diff -ruN polarssl-master/library/aes.c polarssl/library/aes.c
if( mbedtls_aesni_has_support( MBEDTLS_AESNI_AES ) )
{
mbedtls_aesni_inverse_key( (unsigned char *) ctx->rk,
@@ -850,7 +850,7 @@
const unsigned char input[16],
unsigned char output[16] )
{
@@ -1016,7 +1016,7 @@
AES_VALIDATE_RET( mode == MBEDTLS_AES_ENCRYPT ||
mode == MBEDTLS_AES_DECRYPT );
-#if defined(MBEDTLS_AESNI_C) && defined(MBEDTLS_HAVE_X86_64)
+#if defined(MBEDTLS_AESNI_C)
if( mbedtls_aesni_has_support( MBEDTLS_AESNI_AES ) )
return( mbedtls_aesni_crypt_ecb( ctx, mode, input, output ) );
#endif
diff -ruN polarssl-master/library/aesni.c polarssl/library/aesni.c
--- polarssl-master/library/aesni.c 2018-03-16 11:25:12.000000000 -0500
+++ polarssl/library/aesni.c 2018-04-17 16:09:26.050605000 -0500
diff -ruN library/aesni.c library/aesni.c
--- library/aesni.c 2018-03-16 11:25:12.000000000 -0500
+++ library/aesni.c 2018-04-17 16:09:26.050605000 -0500
@@ -30,7 +30,16 @@
#include MBEDTLS_CONFIG_FILE
#endif
@ -153,9 +153,9 @@ diff -ruN polarssl-master/library/aesni.c polarssl/library/aesni.c
-#endif /* MBEDTLS_HAVE_X86_64 */
-
#endif /* MBEDTLS_AESNI_C */
diff -ruN polarssl-master/library/entropy_poll.c polarssl/library/entropy_poll.c
--- polarssl-master/library/entropy_poll.c 2018-03-16 11:25:12.000000000 -0500
+++ polarssl/library/entropy_poll.c 2018-04-17 15:52:13.013004200 -0500
diff -ruN library/entropy_poll.c library/entropy_poll.c
--- library/entropy_poll.c 2018-03-16 11:25:12.000000000 -0500
+++ library/entropy_poll.c 2018-04-17 15:52:13.013004200 -0500
@@ -56,6 +56,12 @@
#include <windows.h>
#include <wincrypt.h>
@ -169,9 +169,9 @@ diff -ruN polarssl-master/library/entropy_poll.c polarssl/library/entropy_poll.c
int mbedtls_platform_entropy_poll( void *data, unsigned char *output, size_t len,
size_t *olen )
{
diff -ruN polarssl-master/library/gcm.c polarssl/library/gcm.c
--- polarssl-master/library/gcm.c 2018-03-16 11:25:12.000000000 -0500
+++ polarssl/library/gcm.c 2018-04-17 16:53:18.630262400 -0500
diff -ruN library/gcm.c library/gcm.c
--- library/gcm.c 2018-03-16 11:25:12.000000000 -0500
+++ library/gcm.c 2018-04-17 16:53:18.630262400 -0500
@@ -126,7 +126,7 @@
ctx->HL[8] = vl;
ctx->HH[8] = vh;
@ -190,9 +190,9 @@ diff -ruN polarssl-master/library/gcm.c polarssl/library/gcm.c
if( mbedtls_aesni_has_support( MBEDTLS_AESNI_CLMUL ) ) {
unsigned char h[16];
diff -ruN polarssl-master/library/net_sockets.c polarssl/library/net_sockets.c
--- polarssl-master/library/net_sockets.c 2018-03-16 11:25:12.000000000 -0500
+++ polarssl/library/net_sockets.c 2018-04-17 15:50:08.118440600 -0500
diff -ruN library/net_sockets.c library/net_sockets.c
--- library/net_sockets.c 2018-03-16 11:25:12.000000000 -0500
+++ library/net_sockets.c 2018-04-17 15:50:08.118440600 -0500
@@ -51,7 +51,8 @@
/* Enables getaddrinfo() & Co */
#define _WIN32_WINNT 0x0501

Binary file not shown.
Loading…
Cancel
Save