From 5589d9b471813d4edeaf37550803e6fe1fc83f5a Mon Sep 17 00:00:00 2001 From: Michael Date: Tue, 23 Apr 2019 21:52:13 +0100 Subject: [PATCH 01/17] Make help more useful --- daemon/main.cpp | 24 +++++++++--------------- 1 file changed, 9 insertions(+), 15 deletions(-) diff --git a/daemon/main.cpp b/daemon/main.cpp index eb67bc2e6..006af03d2 100644 --- a/daemon/main.cpp +++ b/daemon/main.cpp @@ -27,14 +27,6 @@ handle_signal(int sig) llarp_main_signal(ctx, sig); } -int -printHelp(const char *argv0, int code = 1) -{ - std::cout << "usage: " << argv0 << " [-h] [-v] [-g|-c] config.ini" - << std::endl; - return code; -} - #ifdef _WIN32 int startWinsock() @@ -117,7 +109,7 @@ main(int argc, char *argv[]) ("config","path to configuration file", cxxopts::value()); options.parse_positional("config"); - // clang-format on + // clang-format on bool genconfigOnly = false; bool asRouter = false; @@ -136,7 +128,8 @@ main(int argc, char *argv[]) if(result.count("help")) { - return printHelp(argv[0], 0); + std::cout << options.help() << std::endl; + return 0; } if(result.count("generate") > 0) @@ -154,7 +147,7 @@ main(int argc, char *argv[]) asRouter = true; } - if(result.count("config") > 0) + if(result.count("config") > 0) { auto arg = result["config"].as< std::string >(); if(!arg.empty()) @@ -163,10 +156,11 @@ main(int argc, char *argv[]) } } } - catch (const cxxopts::option_not_exists_exception& ex) + catch(const cxxopts::option_not_exists_exception &ex) { std::cerr << ex.what(); - return printHelp(argv[0]); + std::cout << options.help() << std::endl; + return 1; } if(!conffname.empty()) @@ -186,8 +180,8 @@ main(int argc, char *argv[]) // does this file exist? if(genconfigOnly) { - if(!llarp_ensure_config(conffname.c_str(), basedir.string().c_str(), overWrite, - asRouter)) + if(!llarp_ensure_config(conffname.c_str(), basedir.string().c_str(), + overWrite, asRouter)) return 1; } else From 8cf6a77c1dea4e4565866d2f10771790d1374f44 Mon Sep 17 00:00:00 2001 From: Ryan Tharp Date: Tue, 23 Apr 2019 14:50:49 -0700 Subject: [PATCH 02/17] address issue loki-project#547, remove client.ini, update ini defaults, and clean up help message --- daemon/main.cpp | 8 +-- llarp/config.cpp | 130 +++++++++++++++++------------------------------ 2 files changed, 50 insertions(+), 88 deletions(-) diff --git a/daemon/main.cpp b/daemon/main.cpp index eb67bc2e6..56c044885 100644 --- a/daemon/main.cpp +++ b/daemon/main.cpp @@ -30,7 +30,7 @@ handle_signal(int sig) int printHelp(const char *argv0, int code = 1) { - std::cout << "usage: " << argv0 << " [-h] [-v] [-g|-c] config.ini" + std::cout << "usage: " << argv0 << " [-h] [-v] [-g|-r [-f]] [config.ini]" << std::endl; return code; } @@ -106,13 +106,13 @@ main(int argc, char *argv[]) // clang-format off cxxopts::Options options( "lokinet", - "Lokinet is a private, decentralized and IP based overlay network for the internet" + "LokiNET is a free, open source, private, decentralized, "market based sybil resistant" and IP based onion routing network" ); options.add_options() ("v,verbose", "Verbose", cxxopts::value()) ("h,help", "help", cxxopts::value()) - ("g,generate", "generate config", cxxopts::value()) - ("r,router", "run as router", cxxopts::value()) + ("g,generate", "generate client config", cxxopts::value()) + ("r,router", "generate router config", cxxopts::value()) ("f,force", "overwrite", cxxopts::value()) ("config","path to configuration file", cxxopts::value()); diff --git a/llarp/config.cpp b/llarp/config.cpp index be2365982..82b665125 100644 --- a/llarp/config.cpp +++ b/llarp/config.cpp @@ -94,6 +94,7 @@ namespace llarp } // namespace llarp +/// fname should be a relative path (from CWD) or absolute path to the config file extern "C" bool llarp_ensure_config(const char *fname, const char *basedir, bool overwrite, bool asRouter) @@ -122,13 +123,13 @@ llarp_ensure_config(const char *fname, const char *basedir, bool overwrite, llarp::LogInfo("Attempting to create config file ", fname); - // abort if client.ini already exists + // abort if config already exists if(!asRouter) { - if(fs::exists(basepath + "client.ini", ec) && !overwrite) + if(fs::exists(fname, ec) && !overwrite) { llarp::LogError( - basepath, "client.ini currently exists, please use -f to overwrite"); + fname, " currently exists, please use -f to overwrite"); return true; } if(ec) @@ -179,7 +180,7 @@ llarp_generic_ensure_config(std::ofstream &f, std::string basepath) f << std::endl; f << "# uncomment following line to set router nickname to 'lokinet'" << std::endl; - f << "# nickname=lokinet" << std::endl; + f << "#nickname=lokinet" << std::endl; f << std::endl << std::endl; // logging @@ -200,21 +201,15 @@ llarp_generic_ensure_config(std::ofstream &f, std::string basepath) f << "# admin api (disabled by default)" << std::endl; f << "[api]" << std::endl; f << "enabled=false" << std::endl; - f << "# authkey=insertpubkey1here" << std::endl; - f << "# authkey=insertpubkey2here" << std::endl; - f << "# authkey=insertpubkey3here" << std::endl; + f << "#authkey=insertpubkey1here" << std::endl; + f << "#authkey=insertpubkey2here" << std::endl; + f << "#authkey=insertpubkey3here" << std::endl; f << "bind=127.0.0.1:1190" << std::endl; f << std::endl << std::endl; f << "# system settings for privileges and such" << std::endl; f << "[system]" << std::endl; -#ifdef _WIN32 - f << "# "; -#endif f << "user=" << DEFAULT_LOKINET_USER << std::endl; -#ifdef _WIN32 - f << "# "; -#endif f << "group=" << DEFAULT_LOKINET_GROUP << std::endl; f << "pidfile=" << basepath << "lokinet.pid" << std::endl; f << std::endl << std::endl; @@ -251,8 +246,9 @@ llarp_generic_ensure_config(std::ofstream &f, std::string basepath) << std::endl; f << "# if we don't have any peers we connect to this router" << std::endl; f << "add-node=" << basepath << "bootstrap.signed" << std::endl; - f << "# add another bootstrap node" << std::endl; - f << "#add-node=/path/to/alternative/self.signed" << std::endl; + // we only process one of these... + //f << "# add another bootstrap node" << std::endl; + //f << "#add-node=/path/to/alternative/self.signed" << std::endl; f << std::endl << std::endl; } @@ -268,13 +264,14 @@ llarp_ensure_router_config(std::ofstream &f, std::string basepath) f << "# network settings " << std::endl; f << "[network]" << std::endl; f << "profiles=" << basepath << "profiles.dat" << std::endl; - f << "ifaddr=10.105.0.1/16" << std::endl; - f << "ifname=lokitun0" << std::endl; + // better to let the routers auto-configure + f << "ifaddr=auto" << std::endl; + f << "ifname=auto" << std::endl; f << "enabled=true" << std::endl; f << "exit=false" << std::endl; - f << "# exit-blacklist=tcp:25" << std::endl; - f << "# exit-whitelist=tcp:*" << std::endl; - f << "# exit-whitelist=udp:*" << std::endl; + f << "#exit-blacklist=tcp:25" << std::endl; + f << "#exit-whitelist=tcp:*" << std::endl; + f << "#exit-whitelist=udp:*" << std::endl; f << std::endl; f << "# ROUTERS ONLY: publish network interfaces for handling inbound traffic" << std::endl; @@ -285,7 +282,7 @@ llarp_ensure_router_config(std::ofstream &f, std::string basepath) f << ifname << "=1090" << std::endl; else f << "# could not autodetect network interface" << std::endl - << "# eth0=1090" << std::endl; + << "#eth0=1090" << std::endl; f << std::endl; } @@ -293,39 +290,47 @@ llarp_ensure_router_config(std::ofstream &f, std::string basepath) bool llarp_ensure_client_config(std::ofstream &f, std::string basepath) { + // write snapp-example.ini const std::string snappExample_fpath = basepath + "snapp-example.ini"; - // done with fname.ini - // start client.ini - // write fname ini { - std::ofstream clientini_f(snappExample_fpath, + std::ofstream example_f(snappExample_fpath, std::ios::binary | std::ios::out); if(f.is_open()) { - clientini_f << "# this is an example configuration for a snapp" + // pick ip + std::string ip = llarp::findFreePrivateRange(); + if(ip == "") + { + llarp::LogError( + "Couldn't easily detect a private range to map lokinet onto"); + return false; + } + example_f << "# this is an example configuration for a snapp" << std::endl; - clientini_f << "[example-snapp]" << std::endl; - clientini_f << "# keyfile is the path to the private key of the snapp" + example_f << "[example-snapp]" << std::endl; + example_f << "# keyfile is the path to the private key of the snapp, your .loki is tied to this key, DON'T LOSE IT" << std::endl; - clientini_f << "keyfile=" << basepath << "example-snap-keyfile.private" + example_f << "keyfile=" << basepath << "example-snap-keyfile.private" << std::endl; - clientini_f << "# ifaddr is the ip range to allocate to this snapp" + example_f << "# ifaddr is the ip range to allocate to this snapp" << std::endl; - clientini_f << "ifaddr=10.55.0.0/16" << std::endl; - clientini_f << "# ifname is the name to try and give to the network " + example_f << "ifaddr=" << ip << std::endl; + // probably fine to leave this (and not-auto-detect it) I'm not worried about any collisions + example_f << "# ifname is the name to try and give to the network " "interface this snap owns" << std::endl; - clientini_f << "ifname=snapp-tun0" << std::endl; + example_f << "ifname=snapp-tun0" << std::endl; } else { llarp::LogError("failed to write ", snappExample_fpath); } } + // now do up fname f << std::endl << std::endl; f << "# snapps configuration section" << std::endl; f << "[services]"; - f << "# uncomment next line to enable persistant snapp" << std::endl; + f << "# uncomment next line to enable a snapp" << std::endl; f << "#example-snapp=" << snappExample_fpath << std::endl; f << std::endl << std::endl; @@ -339,57 +344,14 @@ llarp_ensure_client_config(std::ofstream &f, std::string basepath) f << "# uncomment next line to use router with pubkey as an exit node" << std::endl; f << "#exit-node=pubkey" << std::endl; - // pick ip - std::string ip = llarp::findFreePrivateRange(); - /* - struct privatesInUse ifsInUse = llarp_getPrivateIfs(); - std::string ip = ""; - if(!ifsInUse.ten) - { - ip = "10.10.0.1/24"; - } - else if(!ifsInUse.oneSeven) - { - ip = "172.16.10.1/24"; - } - else if(!ifsInUse.oneNine) - { - ip = "192.168.10.1/24"; - } - else - { - llarp::LogError( - "Couldn't easily detect a private range to map lokinet onto"); - return false; - } - */ - if(ip == "") - { - llarp::LogError( - "Couldn't easily detect a private range to map lokinet onto"); - return false; - } - llarp::LogDebug("Detected " + ip - + " is available for use, configuring as such"); - // clientini_f << "ifaddr=" << ip << std::endl; - // pick interface name - std::string ifName = llarp::findFreeLokiTunIfName(); - if(ifName == "") - { - llarp::LogError("Could not find any free lokitun interface names"); - return false; - } - /* - clientini_f << "ifname=lokinum" << std::to_string(num) << std::endl; - // prefetch-tags=test - // enable netns? - - llarp::LogInfo("Generated hidden service client as " + basepath - + "client.ini"); - */ - f << "ifname=" << ifName << std::endl; - f << "ifaddr=" << ip << std::endl; + // better to set them to auto then to hard code them now + // operating environment may change over time and this will help adapt + f << "ifname=auto" << std::endl; + f << "ifaddr=auto" << std::endl; + + // should this also be auto? or not declared? + // probably auto in case they want to set up a hidden service f << "enabled=true" << std::endl; return true; } From b36b378583c34a6f0e18449b3e366191637929c9 Mon Sep 17 00:00:00 2001 From: Ryan Tharp Date: Tue, 23 Apr 2019 14:57:01 -0700 Subject: [PATCH 03/17] issue 547 make format --- daemon/main.cpp | 10 +++++----- llarp/config.cpp | 34 ++++++++++++++++++---------------- 2 files changed, 23 insertions(+), 21 deletions(-) diff --git a/daemon/main.cpp b/daemon/main.cpp index 56c044885..66495e51a 100644 --- a/daemon/main.cpp +++ b/daemon/main.cpp @@ -117,7 +117,7 @@ main(int argc, char *argv[]) ("config","path to configuration file", cxxopts::value()); options.parse_positional("config"); - // clang-format on + // clang-format on bool genconfigOnly = false; bool asRouter = false; @@ -154,7 +154,7 @@ main(int argc, char *argv[]) asRouter = true; } - if(result.count("config") > 0) + if(result.count("config") > 0) { auto arg = result["config"].as< std::string >(); if(!arg.empty()) @@ -163,7 +163,7 @@ main(int argc, char *argv[]) } } } - catch (const cxxopts::option_not_exists_exception& ex) + catch(const cxxopts::option_not_exists_exception &ex) { std::cerr << ex.what(); return printHelp(argv[0]); @@ -186,8 +186,8 @@ main(int argc, char *argv[]) // does this file exist? if(genconfigOnly) { - if(!llarp_ensure_config(conffname.c_str(), basedir.string().c_str(), overWrite, - asRouter)) + if(!llarp_ensure_config(conffname.c_str(), basedir.string().c_str(), + overWrite, asRouter)) return 1; } else diff --git a/llarp/config.cpp b/llarp/config.cpp index 82b665125..623d7d06b 100644 --- a/llarp/config.cpp +++ b/llarp/config.cpp @@ -94,7 +94,8 @@ namespace llarp } // namespace llarp -/// fname should be a relative path (from CWD) or absolute path to the config file +/// fname should be a relative path (from CWD) or absolute path to the config +/// file extern "C" bool llarp_ensure_config(const char *fname, const char *basedir, bool overwrite, bool asRouter) @@ -128,8 +129,7 @@ llarp_ensure_config(const char *fname, const char *basedir, bool overwrite, { if(fs::exists(fname, ec) && !overwrite) { - llarp::LogError( - fname, " currently exists, please use -f to overwrite"); + llarp::LogError(fname, " currently exists, please use -f to overwrite"); return true; } if(ec) @@ -247,8 +247,8 @@ llarp_generic_ensure_config(std::ofstream &f, std::string basepath) f << "# if we don't have any peers we connect to this router" << std::endl; f << "add-node=" << basepath << "bootstrap.signed" << std::endl; // we only process one of these... - //f << "# add another bootstrap node" << std::endl; - //f << "#add-node=/path/to/alternative/self.signed" << std::endl; + // f << "# add another bootstrap node" << std::endl; + // f << "#add-node=/path/to/alternative/self.signed" << std::endl; f << std::endl << std::endl; } @@ -294,7 +294,7 @@ llarp_ensure_client_config(std::ofstream &f, std::string basepath) const std::string snappExample_fpath = basepath + "snapp-example.ini"; { std::ofstream example_f(snappExample_fpath, - std::ios::binary | std::ios::out); + std::ios::binary | std::ios::out); if(f.is_open()) { // pick ip @@ -302,23 +302,25 @@ llarp_ensure_client_config(std::ofstream &f, std::string basepath) if(ip == "") { llarp::LogError( - "Couldn't easily detect a private range to map lokinet onto"); + "Couldn't easily detect a private range to map lokinet onto"); return false; } example_f << "# this is an example configuration for a snapp" - << std::endl; + << std::endl; example_f << "[example-snapp]" << std::endl; - example_f << "# keyfile is the path to the private key of the snapp, your .loki is tied to this key, DON'T LOSE IT" - << std::endl; + example_f << "# keyfile is the path to the private key of the snapp, " + "your .loki is tied to this key, DON'T LOSE IT" + << std::endl; example_f << "keyfile=" << basepath << "example-snap-keyfile.private" - << std::endl; + << std::endl; example_f << "# ifaddr is the ip range to allocate to this snapp" - << std::endl; + << std::endl; example_f << "ifaddr=" << ip << std::endl; - // probably fine to leave this (and not-auto-detect it) I'm not worried about any collisions + // probably fine to leave this (and not-auto-detect it) I'm not worried + // about any collisions example_f << "# ifname is the name to try and give to the network " - "interface this snap owns" - << std::endl; + "interface this snap owns" + << std::endl; example_f << "ifname=snapp-tun0" << std::endl; } else @@ -349,7 +351,7 @@ llarp_ensure_client_config(std::ofstream &f, std::string basepath) // operating environment may change over time and this will help adapt f << "ifname=auto" << std::endl; f << "ifaddr=auto" << std::endl; - + // should this also be auto? or not declared? // probably auto in case they want to set up a hidden service f << "enabled=true" << std::endl; From 58be0229e689fe08197c2cb74a5441c3869c0839 Mon Sep 17 00:00:00 2001 From: Ryan Tharp Date: Tue, 23 Apr 2019 15:10:31 -0700 Subject: [PATCH 04/17] fix issue #550 kqueue crash --- llarp/ev/ev_kqueue.cpp | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/llarp/ev/ev_kqueue.cpp b/llarp/ev/ev_kqueue.cpp index f5959a3d2..c0b2cb612 100644 --- a/llarp/ev/ev_kqueue.cpp +++ b/llarp/ev/ev_kqueue.cpp @@ -371,18 +371,19 @@ llarp_kqueue_loop::tick(int ms) llarp::ev_io* ev = static_cast< llarp::ev_io* >(events[idx].udata); if(ev) { - if(events[idx].filter & EVFILT_READ) + // it'll crash if we flip these + if(events[idx].filter & EVFILT_WRITE) { IO([&]() -> ssize_t { - return ev->read( - readbuf, std::min(sizeof(readbuf), size_t(events[idx].data))); + ev->flush_write_buffers(events[idx].data); + return 0; }); } - if(events[idx].filter & EVFILT_WRITE) + if(events[idx].filter & EVFILT_READ) { IO([&]() -> ssize_t { - ev->flush_write_buffers(events[idx].data); - return 0; + return ev->read( + readbuf, std::min(sizeof(readbuf), size_t(events[idx].data))); }); } } From 1344095a06e122285e45a77b1ee027c85b0e7383 Mon Sep 17 00:00:00 2001 From: Ryan Tharp Date: Tue, 23 Apr 2019 15:18:41 -0700 Subject: [PATCH 05/17] MacOS scripts to create package installer --- osx-setup/distribution.xml | 29 +++++++++++++++++++++++++++++ osx-setup/make-release.sh | 16 ++++++++++++++++ osx-setup/resources/conclusion.html | 3 +++ osx-setup/resources/license.html | 23 +++++++++++++++++++++++ osx-setup/resources/welcome.html | 7 +++++++ osx-setup/scripts/postinstall | 27 +++++++++++++++++++++++++++ osx-setup/scripts/preinstall | 8 ++++++++ 7 files changed, 113 insertions(+) create mode 100644 osx-setup/distribution.xml create mode 100755 osx-setup/make-release.sh create mode 100644 osx-setup/resources/conclusion.html create mode 100644 osx-setup/resources/license.html create mode 100644 osx-setup/resources/welcome.html create mode 100755 osx-setup/scripts/postinstall create mode 100755 osx-setup/scripts/preinstall diff --git a/osx-setup/distribution.xml b/osx-setup/distribution.xml new file mode 100644 index 000000000..608a7bf18 --- /dev/null +++ b/osx-setup/distribution.xml @@ -0,0 +1,29 @@ + + + LokiNET + network.loki + + + + + + + + lokinet.pkg + + + + + + + + + diff --git a/osx-setup/make-release.sh b/osx-setup/make-release.sh new file mode 100755 index 000000000..9f3be2252 --- /dev/null +++ b/osx-setup/make-release.sh @@ -0,0 +1,16 @@ +#!/bin/sh +VERSION=$1 + +echo "Copying latest build" +mkdir -p osx-pkg/usr/local/bin +cp ../lokinet osx-pkg/usr/local/bin +# just incase they want to switch networks later +cp ../lokinet-bootstrap osx-pkg/usr/local/bin + +echo "Building package $VERSION" +mkdir -p pkg1 +rm pkg1/lokinet.pkg +pkgbuild --root osx-pkg --scripts scripts --identifier network.loki.lokinet --version $VERSION pkg1/lokinet.pkg +rm lokinet-v0.4.pkg +productbuild --distribution distribution.xml --resources resources --package-path pkg1 --version $VERSION lokinet-v$VERSION.pkg + diff --git a/osx-setup/resources/conclusion.html b/osx-setup/resources/conclusion.html new file mode 100644 index 000000000..c40e75277 --- /dev/null +++ b/osx-setup/resources/conclusion.html @@ -0,0 +1,3 @@ +IRC or Discord is likely the best place for help with LokiNET + +IRC: #llarp on irc.freenode.org diff --git a/osx-setup/resources/license.html b/osx-setup/resources/license.html new file mode 100644 index 000000000..c0b098c8c --- /dev/null +++ b/osx-setup/resources/license.html @@ -0,0 +1,23 @@ +LokiNET is the reference implementation of LLARP (Low Latency Anonymous +Routing Protocol) and is licensed under ZLIB license, however the protocol +specifications are placed into the public domian using the CC0 License. + +Copyright (c) 2018-2019 The Loki Project +Copyright (c) 2018-2019 Jeff Becker +Windows NT port and portions Copyright (c) 2018-2019 Rick V. + +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. diff --git a/osx-setup/resources/welcome.html b/osx-setup/resources/welcome.html new file mode 100644 index 000000000..86efea88f --- /dev/null +++ b/osx-setup/resources/welcome.html @@ -0,0 +1,7 @@ +Hi, welcome to LokiNET public alpha! + +LokiNET is a private, decentralized and Market based, Sybil resistant overlay network for the internet. + +This package contains the reference implementation of LLARP. + +This software is in a very early stage where there's much work to be done. diff --git a/osx-setup/scripts/postinstall b/osx-setup/scripts/postinstall new file mode 100755 index 000000000..f56f360cc --- /dev/null +++ b/osx-setup/scripts/postinstall @@ -0,0 +1,27 @@ +#!/bin/sh +echo "Running postinstall" > /tmp/lokinet_postinstall.log + +RED='\033[0;31m' +GREEN='\033[0;32m' +NC='\033[0m' # No Color + +rm $HOME/.lokinet/*.signed >> /tmp/lokinet_postinstall.log +rm $HOME/.lokinet/*.key >> /tmp/lokinet_postinstall.log +rm $HOME/.lokinet/*.private >> /tmp/lokinet_postinstall.log +rm -fr $HOME/.lokinet/netdb >> /tmp/lokinet_postinstall.log + +url="https://i2p.rocks/i2procks.signed" +echo "downloading $url" >> /tmp/lokinet_postinstall.log +echo "to $HOME/.lokinet/bootstrap.signed" >> /tmp/lokinet_postinstall.log + +# use temp file to not overrwrite existing bootstrap file on fail +tmp=/tmp/bootstrap.tmp + +# MacOS does not have wget without homebrew but does have curl +# Rick also had indicated most BSDs have curl too +curl "$url" > "$tmp" && \ + (mv "$tmp" "$HOME/.lokinet/bootstrap.signed" && echo "${GREEN}lokinet successfully bootstrapped${NC}" >> /tmp/lokinet_postinstall.log) \ + || echo "${RED}failed to download bootstrap from $url${NC}" >> /tmp/lokinet_postinstall.log +rm -f "$tmp" + +exit 0 # all good diff --git a/osx-setup/scripts/preinstall b/osx-setup/scripts/preinstall new file mode 100755 index 000000000..c7f98c71d --- /dev/null +++ b/osx-setup/scripts/preinstall @@ -0,0 +1,8 @@ +#!/bin/sh +echo "Running preinstall" > /tmp/lokinet_preinstall.log +if [ ! -d "$HOME/.lokinet" ] +then + mkdir $HOME/.lokinet >> /tmp/lokinet_preinstall.log +fi +find $HOME/.lokinet >> /tmp/lokinet_preinstall.log +exit 0 # all good From 8220df002e52cce043bb3f83d5916366084d3428 Mon Sep 17 00:00:00 2001 From: Ryan Tharp Date: Tue, 23 Apr 2019 15:27:13 -0700 Subject: [PATCH 06/17] update description --- osx-setup/distribution.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osx-setup/distribution.xml b/osx-setup/distribution.xml index 608a7bf18..81c67e70c 100644 --- a/osx-setup/distribution.xml +++ b/osx-setup/distribution.xml @@ -22,7 +22,7 @@ id="network.loki.lokinet" visible="false" title="LokiNET" - description="Anonymous network layer onion router" + description="LokiNET is a free, open source, private, decentralized, "market based sybil resistant" and IP based onion routing network" start_selected="true"> From db25a9107ce740d6f660c8230ad9ef7255ac2244 Mon Sep 17 00:00:00 2001 From: Ryan Tharp Date: Tue, 23 Apr 2019 16:15:42 -0700 Subject: [PATCH 07/17] format / fix syntax error --- daemon/main.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/daemon/main.cpp b/daemon/main.cpp index 55a5f4609..a03084949 100644 --- a/daemon/main.cpp +++ b/daemon/main.cpp @@ -98,7 +98,7 @@ main(int argc, char *argv[]) // clang-format off cxxopts::Options options( "lokinet", - "LokiNET is a free, open source, private, decentralized, "market based sybil resistant" and IP based onion routing network" + "LokiNET is a free, open source, private, decentralized, \"market based sybil resistant\" and IP based onion routing network" ); options.add_options() ("v,verbose", "Verbose", cxxopts::value()) From 11f091f38fa149d9be228790a5f1f1093238ba47 Mon Sep 17 00:00:00 2001 From: Ryan Tharp Date: Tue, 23 Apr 2019 16:19:01 -0700 Subject: [PATCH 08/17] fix syntax error --- osx-setup/distribution.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osx-setup/distribution.xml b/osx-setup/distribution.xml index 81c67e70c..4b16a7591 100644 --- a/osx-setup/distribution.xml +++ b/osx-setup/distribution.xml @@ -22,7 +22,7 @@ id="network.loki.lokinet" visible="false" title="LokiNET" - description="LokiNET is a free, open source, private, decentralized, "market based sybil resistant" and IP based onion routing network" + description='LokiNET is a free, open source, private, decentralized, \"market based sybil resistant\" and IP based onion routing network' start_selected="true"> From ecec0628f0e7844b6ddee1e3f67429f2b594358d Mon Sep 17 00:00:00 2001 From: Ryan Tharp Date: Tue, 23 Apr 2019 17:03:42 -0700 Subject: [PATCH 09/17] fix generate router config --- daemon/main.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/daemon/main.cpp b/daemon/main.cpp index 66495e51a..61e9a7486 100644 --- a/daemon/main.cpp +++ b/daemon/main.cpp @@ -152,6 +152,9 @@ main(int argc, char *argv[]) if(result.count("router") > 0) { asRouter = true; + // we should generate and exit (docker needs this, so we don't write a + // config each time on startup) + genconfigOnly = true; } if(result.count("config") > 0) From 563407c0a804737fc2156c327048abf89d95eebd Mon Sep 17 00:00:00 2001 From: Ryan Tharp Date: Tue, 23 Apr 2019 17:28:16 -0700 Subject: [PATCH 10/17] can't have these enabled like this apparently, breaks validation --- llarp/config.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/llarp/config.cpp b/llarp/config.cpp index 623d7d06b..1fdff9a53 100644 --- a/llarp/config.cpp +++ b/llarp/config.cpp @@ -265,8 +265,8 @@ llarp_ensure_router_config(std::ofstream &f, std::string basepath) f << "[network]" << std::endl; f << "profiles=" << basepath << "profiles.dat" << std::endl; // better to let the routers auto-configure - f << "ifaddr=auto" << std::endl; - f << "ifname=auto" << std::endl; + // f << "ifaddr=auto" << std::endl; + // f << "ifname=auto" << std::endl; f << "enabled=true" << std::endl; f << "exit=false" << std::endl; f << "#exit-blacklist=tcp:25" << std::endl; @@ -349,8 +349,8 @@ llarp_ensure_client_config(std::ofstream &f, std::string basepath) // better to set them to auto then to hard code them now // operating environment may change over time and this will help adapt - f << "ifname=auto" << std::endl; - f << "ifaddr=auto" << std::endl; + // f << "ifname=auto" << std::endl; + // f << "ifaddr=auto" << std::endl; // should this also be auto? or not declared? // probably auto in case they want to set up a hidden service From 89837d5528a7f58c413d6f201bf42fb05345eee6 Mon Sep 17 00:00:00 2001 From: Ryan Tharp Date: Tue, 23 Apr 2019 17:40:44 -0700 Subject: [PATCH 11/17] handle relative config paths better --- daemon/main.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/daemon/main.cpp b/daemon/main.cpp index 61e9a7486..e0cc23b6f 100644 --- a/daemon/main.cpp +++ b/daemon/main.cpp @@ -72,8 +72,9 @@ resolvePath(std::string conffname) char *resolvedPath = realpath(exp_result.we_wordv[0], NULL); if(!resolvedPath) { - llarp::LogWarn("Can't resolve path: ", exp_result.we_wordv[0]); - return ""; + // relative paths don't need to be resolved + // llarp::LogWarn("Can't resolve path: ", exp_result.we_wordv[0]); + return conffname; } return resolvedPath; #else @@ -106,7 +107,7 @@ main(int argc, char *argv[]) // clang-format off cxxopts::Options options( "lokinet", - "LokiNET is a free, open source, private, decentralized, "market based sybil resistant" and IP based onion routing network" + "LokiNET is a free, open source, private, decentralized, \"market based sybil resistant\" and IP based onion routing network" ); options.add_options() ("v,verbose", "Verbose", cxxopts::value()) From 60f7916cb6d71b2708b8c39a23cd4d87d5fc63b0 Mon Sep 17 00:00:00 2001 From: Ryan Tharp Date: Wed, 24 Apr 2019 02:10:21 +0000 Subject: [PATCH 12/17] got router working in docker --- docker/router.Dockerfile | 13 +++---- lokinet-docker.ini | 82 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 87 insertions(+), 8 deletions(-) create mode 100644 lokinet-docker.ini diff --git a/docker/router.Dockerfile b/docker/router.Dockerfile index 1104d6e81..403942a18 100644 --- a/docker/router.Dockerfile +++ b/docker/router.Dockerfile @@ -6,13 +6,10 @@ RUN apt update && \ WORKDIR /src/ COPY . /src/ -# 12p/24l cores takes 8gb -ARG BIG_AND_FAST="false" - -RUN if [ "false$BIG_AND_FAST" = "false" ] ; then make ; else make NINJA=ninja ; fi -RUN find . -name lokinet -RUN ./lokinet -g -f -RUN ./lokinet-bootstrap http://206.81.100.174/n-st-1.signed +RUN make NINJA=ninja +#RUN ./lokinet -r -f +COPY lokinet-docker.ini /root/.lokinet/lokinet.ini +RUN ./lokinet-bootstrap CMD ["./lokinet"] -EXPOSE 1090/udp +EXPOSE 1090/udp 1190/tcp diff --git a/lokinet-docker.ini b/lokinet-docker.ini new file mode 100644 index 000000000..c55480eec --- /dev/null +++ b/lokinet-docker.ini @@ -0,0 +1,82 @@ +# this configuration was auto generated with 'sane' defaults +# change these values as desired + + +[router] +# number of crypto worker threads +threads=4 +# path to store signed RC +contact-file=/root/.lokinet/self.signed +# path to store transport private key +transport-privkey=/root/.lokinet/transport.private +# path to store identity signing key +ident-privkey=/root/.lokinet/identity.private +# encryption key for onion routing +encryption-privkey=/root/.lokinet/encryption.private + +# uncomment following line to set router nickname to 'lokinet' +#nickname=lokinet + + +[logging] +level=info +# uncomment for logging to file +#type=file +#file=/path/to/logfile +# uncomment for syslog logging +#type=syslog + +[metrics] +json-metrics-path=/root/.lokinet/metrics.json + +# admin api (disabled by default) +[api] +enabled=true +#authkey=insertpubkey1here +#authkey=insertpubkey2here +#authkey=insertpubkey3here +bind=127.0.0.1:1190 + +# system settings for privileges and such +[system] +user=lokinet +group=lokinet +pidfile=/root/.lokinet/lokinet.pid + +# dns provider configuration section +[dns] +# resolver +upstream=1.1.1.1 +bind=127.3.2.1:53 + +# network database settings block +[netdb] +# directory for network database skiplist storage +dir=/netdb + +# bootstrap settings +[bootstrap] +# add a bootstrap node's signed identity to the list of nodes we want to bootstrap from +# if we don't have any peers we connect to this router +add-node=/root/.lokinet/bootstrap.signed + +# lokid settings (disabled by default) +[lokid] +enabled=false +jsonrpc=127.0.0.1:22023 +#service-node-seed=/path/to/servicenode/seed + +# network settings +[network] +profiles=/root/.lokinet/profiles.dat +enabled=true +exit=false +#exit-blacklist=tcp:25 +#exit-whitelist=tcp:* +#exit-whitelist=udp:* +ifaddr=10.200.0.1/8 +ifname=loki-docker0 + +# ROUTERS ONLY: publish network interfaces for handling inbound traffic +[bind] +eth0=1090 From d60199fd4326377b481da7161d8c80696190deb9 Mon Sep 17 00:00:00 2001 From: Ryan Tharp Date: Wed, 24 Apr 2019 00:55:14 -0700 Subject: [PATCH 13/17] Add MacOS instructions, update other minor things, re-order sections now that we have binaries remove -r -g as that's hybrid (router and client) --- readme.md | 129 +++++++++++++++++++++++++++++++++--------------------- 1 file changed, 79 insertions(+), 50 deletions(-) diff --git a/readme.md b/readme.md index fdc21cd05..16c5f07b7 100644 --- a/readme.md +++ b/readme.md @@ -10,6 +10,50 @@ You can view documentation on how to get started [here](https://loki-project.git ![build status](https://gitlab.com/lokiproject/loki-network/badges/master/pipeline.svg "build status") +## Usage + +see the [documentation](https://loki-project.github.io/loki-docs/Lokinet/LokinetOverview/) on how to get started. + +## Running on Linux/UNIX/BSD (Except MacOS) + +**DO NOT RUN AS ROOT**, run as normal user. This requires the binary to have the proper setcaps set by `make install` on the binary. + +to run as client: + + $ lokinet -g + $ lokinet-bootstrap + $ lokinet + +to run as relay: + + $ lokinet -r + $ lokinet-bootstrap + $ lokinet + +## Running on MacOS + +**YOU HAVE TO RUN AS ROOT**, run using sudo. Elevated privileges are needed to create the virtual tunnel interface. + +to run as client: + + $ lokinet -g + $ lokinet-bootstrap + $ sudo lokinet + +to run as relay: + + $ lokinet -r + $ lokinet-bootstrap + $ sudo lokinet + + +## Running on Windows + +**DO NOT RUN AS ELEVATED USER**, run as normal user. + +to run as client, run the `run-lokinet.bat` batch file as your normal user. + + ## Building Build requirements: @@ -33,6 +77,41 @@ install: $ sudo make install +### MacOS + +build: + make sure you have cmake and xcode command line tools installed + + $ git clone https://github.com/loki-project/loki-network + $ cd loki-network + $ make -j8 + +install: + + $ sudo make install + +### Windows + +build (where `$ARCH` is your platform - `i686` or `x86_64`): + + $ pacman -Sy base-devel mingw-w64-$ARCH-toolchain git libtool autoconf mingw-w64-$ARCH-cmake + $ git clone https://github.com/loki-project/loki-network.git + $ cd loki-network + $ mkdir -p build; cd build + $ cmake .. -DCMAKE_BUILD_TYPE=[Debug|Release] -DSTATIC_LINK_RUNTIME=ON -DCMAKE_C_COMPILER=gcc -DCMAKE_CXX_COMPILER=g++ -G 'Unix Makefiles' + +install (elevated) to `$PROGRAMFILES/lokinet` or `$ProgramFiles(x86)/lokinet`: + + $ make install + +if cross-compiling, install mingw-w64 from your distro's package manager, or [build from source](https://sourceforge.net/p/mingw-w64/wiki2/Cross%20Win32%20and%20Win64%20compiler/), then: + + $ mkdir -p build; cd build + $ export COMPILER=clang # if using clang for windows + $ cmake .. -DCMAKE_BUILD_TYPE=[Debug|Release] -DSTATIC_LINK_RUNTIME=ON -DCMAKE_CROSSCOMPILING=ON -DCMAKE_TOOLCHAIN_FILE=../contrib/cross/mingw[32].cmake + +this will create a static binary that can be installed anywhere, with no other dependency other than libc (minimum v6.1) + ### Solaris 2.10+ NOTE: Oracle Solaris users need to download/compile the TAP driver from http://www.whiteboard.ne.jp/~admin2/tuntap/ @@ -84,53 +163,3 @@ build: install (root): # gmake install - -### Windows - -build (where `$ARCH` is your platform - `i686` or `x86_64`): - - $ pacman -Sy base-devel mingw-w64-$ARCH-toolchain git libtool autoconf mingw-w64-$ARCH-cmake - $ git clone https://github.com/loki-project/loki-network.git - $ cd loki-network - $ mkdir -p build; cd build - $ cmake .. -DCMAKE_BUILD_TYPE=[Debug|Release] -DSTATIC_LINK_RUNTIME=ON -DCMAKE_C_COMPILER=gcc -DCMAKE_CXX_COMPILER=g++ -G 'Unix Makefiles' - -install (elevated) to `$PROGRAMFILES/lokinet` or `$ProgramFiles(x86)/lokinet`: - - $ make install - -if cross-compiling, install mingw-w64 from your distro's package manager, or [build from source](https://sourceforge.net/p/mingw-w64/wiki2/Cross%20Win32%20and%20Win64%20compiler/), then: - - $ mkdir -p build; cd build - $ export COMPILER=clang # if using clang for windows - $ cmake .. -DCMAKE_BUILD_TYPE=[Debug|Release] -DSTATIC_LINK_RUNTIME=ON -DCMAKE_CROSSCOMPILING=ON -DCMAKE_TOOLCHAIN_FILE=../contrib/cross/mingw[32].cmake - -this will create a static binary that can be installed anywhere, with no other dependency other than libc (minimum v6.1) - -## Running on Linux/UNIX/BSD - -**DO NOT RUN AS ROOT**, run as normal user. - -to run as client: - - $ lokinet -g - $ lokinet-bootstrap - $ lokinet - -to run as relay: - - $ lokinet -r -g - $ lokinet-bootstrap - $ lokinet - - -## Running on Windows - -**DO NOT RUN AS ELEVATED USER**, run as normal user. - -to run as client, run the `run-lokinet.bat` batch file as your normal user. - - -## Usage - -see the [documentation](https://loki-project.github.io/loki-docs/Lokinet/LokinetOverview/) on how to get started. From 6444337a7e73cb63352fe49cf6bd2274ba102b7d Mon Sep 17 00:00:00 2001 From: Ryan Tharp Date: Wed, 24 Apr 2019 00:58:01 -0700 Subject: [PATCH 14/17] add https://lokidocs.com/Lokinet/Guides/PublicTestingGuide/#1-lokinet-installation link --- readme.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/readme.md b/readme.md index 16c5f07b7..4544fc5f5 100644 --- a/readme.md +++ b/readme.md @@ -14,6 +14,8 @@ You can view documentation on how to get started [here](https://loki-project.git see the [documentation](https://loki-project.github.io/loki-docs/Lokinet/LokinetOverview/) on how to get started. +Also read the [Public Testing Guide](https://lokidocs.com/Lokinet/Guides/PublicTestingGuide/#1-lokinet-installation) for installation and other helpful information. + ## Running on Linux/UNIX/BSD (Except MacOS) **DO NOT RUN AS ROOT**, run as normal user. This requires the binary to have the proper setcaps set by `make install` on the binary. From d81930c61a00b4ed7582431e5d7a1320f9eae8f8 Mon Sep 17 00:00:00 2001 From: Ryan Tharp Date: Wed, 24 Apr 2019 01:07:32 -0700 Subject: [PATCH 15/17] update BSD --- readme.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/readme.md b/readme.md index 4544fc5f5..8d683240d 100644 --- a/readme.md +++ b/readme.md @@ -16,7 +16,7 @@ see the [documentation](https://loki-project.github.io/loki-docs/Lokinet/Lokinet Also read the [Public Testing Guide](https://lokidocs.com/Lokinet/Guides/PublicTestingGuide/#1-lokinet-installation) for installation and other helpful information. -## Running on Linux/UNIX/BSD (Except MacOS) +## Running on Linux **DO NOT RUN AS ROOT**, run as normal user. This requires the binary to have the proper setcaps set by `make install` on the binary. @@ -32,7 +32,7 @@ to run as relay: $ lokinet-bootstrap $ lokinet -## Running on MacOS +## Running on MacOS/UNIX/BSD **YOU HAVE TO RUN AS ROOT**, run using sudo. Elevated privileges are needed to create the virtual tunnel interface. From 50def753454726cef1f4d7f83e4897764d47a1dd Mon Sep 17 00:00:00 2001 From: Ryan Tharp Date: Wed, 24 Apr 2019 01:17:28 -0700 Subject: [PATCH 16/17] Explain MacOS installer --- readme.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/readme.md b/readme.md index 8d683240d..e626678f5 100644 --- a/readme.md +++ b/readme.md @@ -36,6 +36,8 @@ to run as relay: **YOU HAVE TO RUN AS ROOT**, run using sudo. Elevated privileges are needed to create the virtual tunnel interface. +The MacOS installer places the normal binaries (`lokinet` and `lokinet-bootstrap`) in `/usr/local/bin` which should be in your path, so you can easily use the binaries from your terminal. The installer also nukes your previous config and keys and sets up a fresh config and downloads the latest bootstrap seed. + to run as client: $ lokinet -g From 4143472a171cd74a37076e234195b7d1ecc086d4 Mon Sep 17 00:00:00 2001 From: Michael Date: Thu, 25 Apr 2019 00:27:31 +0100 Subject: [PATCH 17/17] Add cmake module to target a library as 'system', and fix a few warnings --- CMakeLists.txt | 10 +++++---- cmake/target_link_libraries_system.cmake | 9 ++++++++ crypto/include/libntrup/ntru.h | 2 +- libabyss/include/abyss/client.hpp | 4 ++-- libabyss/include/abyss/http.hpp | 4 ++-- libabyss/include/abyss/server.hpp | 4 ++-- libabyss/main.cpp | 5 ++--- llarp/CMakeLists.txt | 11 +++++++--- llarp/crypto/types.hpp | 8 +++++-- llarp/dht/bucket.hpp | 4 +++- llarp/dht/kademlia.hpp | 6 +++-- llarp/dht/message.cpp | 4 +++- llarp/dht/message.hpp | 4 +++- llarp/dht/tx.hpp | 4 +++- llarp/dns/rectypes.hpp | 28 ++++++++++++++++++------ llarp/dns/serialize.cpp | 2 ++ llarp/dns/serialize.hpp | 2 +- llarp/dns/server.hpp | 2 +- llarp/ev/ev.hpp | 14 +++++++----- llarp/ev/ev_kqueue.hpp | 8 +++++-- llarp/exit/session.hpp | 8 ++++--- llarp/handlers/null.hpp | 4 +++- llarp/link/session.hpp | 4 +++- llarp/messages/path_confirm.hpp | 6 +++-- llarp/messages/path_latency.hpp | 2 +- llarp/net/net_addr.hpp | 2 +- llarp/path/path.hpp | 4 +++- llarp/profiling.hpp | 6 +++-- llarp/routing/message.hpp | 4 +++- llarp/service/info.hpp | 2 +- llarp/service/lookup.hpp | 4 +++- llarp/service/sendcontext.hpp | 2 +- llarp/util/bencode.hpp | 4 +++- llarp/util/buffer.cpp | 2 +- llarp/util/file_logger.hpp | 8 ++++--- llarp/util/json.hpp | 2 +- llarp/util/logger_syslog.hpp | 4 +++- llarp/util/logstream.hpp | 4 +++- llarp/util/ostream_logger.hpp | 4 +++- 39 files changed, 145 insertions(+), 66 deletions(-) create mode 100644 cmake/target_link_libraries_system.cmake diff --git a/CMakeLists.txt b/CMakeLists.txt index 6e190c707..ac5e69de4 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -21,6 +21,8 @@ option(WITH_SHARED "build shared library") option(WITH_COVERAGE "generate coverage data") option(WARNINGS_AS_ERRORS "treat all warnings as errors. turn off for development, on for release" OFF) +include(cmake/target_link_libraries_system.cmake) + # Basic definitions get_filename_component(CORE_INCLUDE include ABSOLUTE) get_filename_component(ABYSS_INCLUDE "${CMAKE_CURRENT_LIST_DIR}/${ABYSS}/include" ABSOLUTE) @@ -86,7 +88,7 @@ endif(WIN32 AND NOT STATIC_LINK_RUNTIME) add_subdirectory(vendor/cxxopts) add_subdirectory(vendor/nlohmann) -include_directories(vendor/cxxopts/include) +include_directories(SYSTEM vendor/cxxopts/include) # still need the headers unconditionally set(ABSEIL_DIR vendor/abseil-cpp) @@ -372,7 +374,7 @@ set(ABYSS_SRC add_library(${ABYSS_LIB} STATIC ${ABYSS_SRC}) add_subdirectory(${ABSEIL_DIR}) -include_directories(${ABSEIL_DIR}) +include_directories(SYSTEM ${ABSEIL_DIR}) add_subdirectory(crypto) add_subdirectory(libutp) @@ -396,7 +398,7 @@ target_include_directories(${ABYSS_EXE} PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/${AB # for freebsd if(${CMAKE_SYSTEM_NAME} MATCHES "FreeBSD") - target_include_directories(${ABYSS_LIB} PUBLIC /usr/local/include) + target_include_directories(${ABYSS_LIB} SYSTEM PUBLIC /usr/local/include) endif(${CMAKE_SYSTEM_NAME} MATCHES "FreeBSD") add_log_tag(${ABYSS_EXE}) add_log_tag(${ABYSS_LIB}) @@ -419,7 +421,7 @@ else() add_executable(${EXE} ${EXE_SRC}) elseif(NOT MSVC_VERSION) add_executable(${EXE} ${EXE_SRC} llarp/win32/version.rc) - else() + else() add_executable(${EXE} ${EXE_SRC}) endif(NOT WIN32) diff --git a/cmake/target_link_libraries_system.cmake b/cmake/target_link_libraries_system.cmake new file mode 100644 index 000000000..761b7c767 --- /dev/null +++ b/cmake/target_link_libraries_system.cmake @@ -0,0 +1,9 @@ +# This adds a dependency as a "system" dep - e.g -isystem +function(target_link_libraries_system target) + set(libs ${ARGN}) + foreach(lib ${libs}) + get_target_property(lib_include_dirs ${lib} INTERFACE_INCLUDE_DIRECTORIES) + target_include_directories(${target} SYSTEM PUBLIC ${lib_include_dirs}) + target_link_libraries(${target} ${lib}) + endforeach(lib) +endfunction() diff --git a/crypto/include/libntrup/ntru.h b/crypto/include/libntrup/ntru.h index 12d12f7ad..390f06f0a 100644 --- a/crypto/include/libntrup/ntru.h +++ b/crypto/include/libntrup/ntru.h @@ -34,4 +34,4 @@ extern "C" #ifdef __cplusplus } #endif -#endif \ No newline at end of file +#endif diff --git a/libabyss/include/abyss/client.hpp b/libabyss/include/abyss/client.hpp index 09bcf1079..e1b97a349 100644 --- a/libabyss/include/abyss/client.hpp +++ b/libabyss/include/abyss/client.hpp @@ -1,5 +1,5 @@ -#ifndef __ABYSS_CLIENT_HPP__ -#define __ABYSS_CLIENT_HPP__ +#ifndef ABYSS_CLIENT_HPP +#define ABYSS_CLIENT_HPP #include #include diff --git a/libabyss/include/abyss/http.hpp b/libabyss/include/abyss/http.hpp index 0ac3abfb5..fe386c3d4 100644 --- a/libabyss/include/abyss/http.hpp +++ b/libabyss/include/abyss/http.hpp @@ -1,5 +1,5 @@ -#ifndef __ABYSS_HTTP_HPP__ -#define __ABYSS_HTTP_HPP__ +#ifndef ABYSS_HTTP_HPP +#define ABYSS_HTTP_HPP #include #include diff --git a/libabyss/include/abyss/server.hpp b/libabyss/include/abyss/server.hpp index a45910fff..af83ee829 100644 --- a/libabyss/include/abyss/server.hpp +++ b/libabyss/include/abyss/server.hpp @@ -1,5 +1,5 @@ -#ifndef __ABYSS_SERVER_HPP__ -#define __ABYSS_SERVER_HPP__ +#ifndef ABYSS_SERVER_HPP +#define ABYSS_SERVER_HPP #include #include diff --git a/libabyss/main.cpp b/libabyss/main.cpp index cc7232418..67c1aa1e7 100644 --- a/libabyss/main.cpp +++ b/libabyss/main.cpp @@ -50,8 +50,7 @@ struct DemoCall : public abyss::http::IRPCClientHandler } void - PopulateReqHeaders(ABSL_ATTRIBUTE_UNUSED - abyss::http::Headers_t& hdr) override + PopulateReqHeaders(ABSL_ATTRIBUTE_UNUSED abyss::http::Headers_t& hdr) override { } @@ -85,7 +84,7 @@ struct DemoClient : public abyss::http::JSONRPC QueueRPC("test", nlohmann::json::object(), std::bind(&DemoClient::NewConn, this, std::placeholders::_1)); Flush(); - }; + } }; struct DemoServer : public abyss::httpd::BaseReqHandler diff --git a/llarp/CMakeLists.txt b/llarp/CMakeLists.txt index 6b61f7e19..34dfb7c48 100644 --- a/llarp/CMakeLists.txt +++ b/llarp/CMakeLists.txt @@ -46,12 +46,11 @@ set(LIB_UTIL_SRC add_library(${UTIL_LIB} STATIC ${LIB_UTIL_SRC}) target_include_directories(${UTIL_LIB} PUBLIC ${CMAKE_CURRENT_SOURCE_DIR} ${PROJECT_SOURCE_DIR}/include) -target_link_libraries(${UTIL_LIB} PUBLIC absl::synchronization absl::hash) -target_link_libraries(${UTIL_LIB} PUBLIC nlohmann_json::nlohmann_json) +target_link_libraries_system(${UTIL_LIB} absl::synchronization absl::hash nlohmann_json::nlohmann_json) # cut back on fluff if (NOT WIN32) - target_link_libraries(${UTIL_LIB} PUBLIC absl::optional absl::variant absl::strings cppbackport) + target_link_libraries_system(${UTIL_LIB} absl::optional absl::variant absl::strings cppbackport) endif(NOT WIN32) if(${CMAKE_SYSTEM_NAME} MATCHES "Linux") @@ -259,6 +258,12 @@ if(WITH_SHARED) add_log_tag(${SHARED_LIB}) endif() +if (WARNINGS_AS_ERRORS) + set(WARN_FLAGS -Wall -Wextra -Wextra-semi -Werror) + target_compile_options(${UTIL_LIB} PUBLIC ${WARN_FLAGS}) + target_compile_options(${PLATFORM_LIB} PUBLIC ${WARN_FLAGS}) + target_compile_options(${STATIC_LIB} PUBLIC ${WARN_FLAGS}) +endif() add_log_tag(${UTIL_LIB}) add_log_tag(${PLATFORM_LIB}) add_log_tag(${STATIC_LIB}) diff --git a/llarp/crypto/types.hpp b/llarp/crypto/types.hpp index 4933d9210..d9045bdbe 100644 --- a/llarp/crypto/types.hpp +++ b/llarp/crypto/types.hpp @@ -78,7 +78,9 @@ namespace llarp struct SecretKey final : public AlignedBuffer< SECKEYSIZE > { - SecretKey() : AlignedBuffer< SECKEYSIZE >(){}; + SecretKey() : AlignedBuffer< SECKEYSIZE >() + { + } explicit SecretKey(const SecretKey &k) : AlignedBuffer< SECKEYSIZE >(k) { @@ -127,7 +129,9 @@ namespace llarp /// IdentitySecret is a secret key from a service node secret seed struct IdentitySecret final : public AlignedBuffer< 32 > { - IdentitySecret() : AlignedBuffer< 32 >(){}; + IdentitySecret() : AlignedBuffer< 32 >() + { + } friend std::ostream & operator<<(std::ostream &out, const IdentitySecret &) diff --git a/llarp/dht/bucket.hpp b/llarp/dht/bucket.hpp index 4451fbd87..d796bc480 100644 --- a/llarp/dht/bucket.hpp +++ b/llarp/dht/bucket.hpp @@ -19,7 +19,9 @@ namespace llarp using BucketStorage_t = std::map< Key_t, Val_t, XorMetric >; using Random_t = std::function< uint64_t() >; - Bucket(const Key_t& us, Random_t r) : nodes(XorMetric(us)), random(r){}; + Bucket(const Key_t& us, Random_t r) : nodes(XorMetric(us)), random(r) + { + } util::StatusObject ExtractStatus() const diff --git a/llarp/dht/kademlia.hpp b/llarp/dht/kademlia.hpp index 8d234fb89..9e99594eb 100644 --- a/llarp/dht/kademlia.hpp +++ b/llarp/dht/kademlia.hpp @@ -11,13 +11,15 @@ namespace llarp { const Key_t& us; - XorMetric(const Key_t& ourKey) : us(ourKey){}; + XorMetric(const Key_t& ourKey) : us(ourKey) + { + } bool operator()(const Key_t& left, const Key_t& right) const { return (us ^ left) < (us ^ right); - }; + } }; } // namespace dht } // namespace llarp diff --git a/llarp/dht/message.cpp b/llarp/dht/message.cpp index 90711b797..f71186079 100644 --- a/llarp/dht/message.cpp +++ b/llarp/dht/message.cpp @@ -101,7 +101,9 @@ namespace llarp { ListDecoder(const Key_t &from, std::vector< std::unique_ptr< IMessage > > &list) - : From(from), l(list){}; + : From(from), l(list) + { + } bool relayed = false; const Key_t &From; diff --git a/llarp/dht/message.hpp b/llarp/dht/message.hpp index b02616113..9e0d385ba 100644 --- a/llarp/dht/message.hpp +++ b/llarp/dht/message.hpp @@ -16,7 +16,9 @@ namespace llarp struct IMessage : public IBEncodeMessage { - virtual ~IMessage(){}; + virtual ~IMessage() + { + } /// construct IMessage(const Key_t& from) : From(from) diff --git a/llarp/dht/tx.hpp b/llarp/dht/tx.hpp index e3581c209..3f13a8d27 100644 --- a/llarp/dht/tx.hpp +++ b/llarp/dht/tx.hpp @@ -29,7 +29,9 @@ namespace llarp { } - virtual ~TX(){}; + virtual ~TX() + { + } void OnFound(const Key_t& askedPeer, const V& value); diff --git a/llarp/dns/rectypes.hpp b/llarp/dns/rectypes.hpp index 411536c7a..a56b4f89d 100644 --- a/llarp/dns/rectypes.hpp +++ b/llarp/dns/rectypes.hpp @@ -28,7 +28,9 @@ namespace llarp { huint32_t ipaddr; - virtual ~type_1a(){}; + virtual ~type_1a() + { + } type_1a(); bool @@ -42,7 +44,9 @@ namespace llarp { std::string ns; - virtual ~type_2ns(){}; + virtual ~type_2ns() + { + } type_2ns(); bool @@ -62,7 +66,9 @@ namespace llarp uint32_t expire; uint32_t minimum; - virtual ~type_6soa(){}; + virtual ~type_6soa() + { + } type_6soa(); bool @@ -76,7 +82,9 @@ namespace llarp { std::string cname; - virtual ~type_5cname(){}; + virtual ~type_5cname() + { + } type_5cname(); bool @@ -90,7 +98,9 @@ namespace llarp { std::string revname; - virtual ~type_12ptr(){}; + virtual ~type_12ptr() + { + } type_12ptr(); bool @@ -105,7 +115,9 @@ namespace llarp std::string mx; uint16_t priority; - virtual ~type_15mx(){}; + virtual ~type_15mx() + { + } type_15mx(); bool @@ -119,7 +131,9 @@ namespace llarp { std::string txt; - virtual ~type_16txt(){}; + virtual ~type_16txt() + { + } type_16txt(); bool diff --git a/llarp/dns/serialize.cpp b/llarp/dns/serialize.cpp index 7f13b394c..0fbab55b8 100644 --- a/llarp/dns/serialize.cpp +++ b/llarp/dns/serialize.cpp @@ -5,6 +5,8 @@ namespace llarp { namespace dns { + Serialize::~Serialize(){}; + bool EncodeRData(llarp_buffer_t* buf, const std::vector< byte_t >& v) { diff --git a/llarp/dns/serialize.hpp b/llarp/dns/serialize.hpp index b0d380bd7..564ca049c 100644 --- a/llarp/dns/serialize.hpp +++ b/llarp/dns/serialize.hpp @@ -12,7 +12,7 @@ namespace llarp /// base type for serializable dns entities struct Serialize { - virtual ~Serialize() = default; + virtual ~Serialize() = 0; /// encode entity to buffer virtual bool diff --git a/llarp/dns/server.hpp b/llarp/dns/server.hpp index 0bc40302f..7cddfa100 100644 --- a/llarp/dns/server.hpp +++ b/llarp/dns/server.hpp @@ -15,7 +15,7 @@ namespace llarp /// handler of dns query hooking struct IQueryHandler { - virtual ~IQueryHandler(){}; + virtual ~IQueryHandler(){} /// return true if we should hook this message virtual bool diff --git a/llarp/ev/ev.hpp b/llarp/ev/ev.hpp index 4566d2c04..65fa3c391 100644 --- a/llarp/ev/ev.hpp +++ b/llarp/ev/ev.hpp @@ -383,14 +383,14 @@ namespace llarp __attribute__((unused)) size_t sz) { return -1; - }; + } /// return false if we want to deregister and remove ourselves virtual bool tick() { return true; - }; + } /// used for tun interface and tcp conn virtual ssize_t @@ -423,7 +423,9 @@ namespace llarp } virtual void - before_flush_write(){}; + before_flush_write() + { + } /// called in event loop when fd is ready for writing /// requeues anything not written @@ -505,7 +507,7 @@ namespace llarp virtual ~posix_ev_io() { close(fd); - }; + } }; #endif @@ -755,7 +757,9 @@ struct llarp_ev_loop virtual bool add_ev(llarp::ev_io* ev, bool write) = 0; - virtual ~llarp_ev_loop(){}; + virtual ~llarp_ev_loop() + { + } std::list< std::unique_ptr< llarp::ev_io > > handlers; diff --git a/llarp/ev/ev_kqueue.hpp b/llarp/ev/ev_kqueue.hpp index 913858be1..02b2135cb 100644 --- a/llarp/ev/ev_kqueue.hpp +++ b/llarp/ev/ev_kqueue.hpp @@ -22,7 +22,9 @@ namespace llarp { llarp_udp_io* udp; - udp_listener(int fd, llarp_udp_io* u) : ev_io(fd), udp(u){}; + udp_listener(int fd, llarp_udp_io* u) : ev_io(fd), udp(u) + { + } ~udp_listener() { @@ -45,7 +47,9 @@ namespace llarp tun(llarp_tun_io* tio, llarp_ev_loop_ptr l) : ev_io(-1, new LossyWriteQueue_t("kqueue_tun_write", l, l)) , t(tio) - , tunif(tuntap_init()){}; + , tunif(tuntap_init()) + { + } int sendto(__attribute__((unused)) const sockaddr* to, diff --git a/llarp/exit/session.hpp b/llarp/exit/session.hpp index 0f2bedbbd..10d07ddec 100644 --- a/llarp/exit/session.hpp +++ b/llarp/exit/session.hpp @@ -145,9 +145,11 @@ namespace llarp ExitSession(const llarp::RouterID& snodeRouter, std::function< bool(const llarp_buffer_t&) > writepkt, AbstractRouter* r, size_t numpaths, size_t hoplen) - : BaseSession(snodeRouter, writepkt, r, numpaths, hoplen){}; + : BaseSession(snodeRouter, writepkt, r, numpaths, hoplen) + { + } - ~ExitSession(){}; + ~ExitSession() = default; std::string Name() const override; @@ -169,7 +171,7 @@ namespace llarp AbstractRouter* r, size_t numpaths, size_t hoplen, bool useRouterSNodeKey = false); - ~SNodeSession(){}; + ~SNodeSession() = default; std::string Name() const override; diff --git a/llarp/handlers/null.hpp b/llarp/handlers/null.hpp index 009847614..9e6dea957 100644 --- a/llarp/handlers/null.hpp +++ b/llarp/handlers/null.hpp @@ -11,7 +11,9 @@ namespace llarp { NullEndpoint(const std::string &name, AbstractRouter *r, llarp::service::Context *parent) - : llarp::service::Endpoint(name, r, parent){}; + : llarp::service::Endpoint(name, r, parent) + { + } bool HandleWriteIPPacket(const llarp_buffer_t &, diff --git a/llarp/link/session.hpp b/llarp/link/session.hpp index 04b269726..9faee2207 100644 --- a/llarp/link/session.hpp +++ b/llarp/link/session.hpp @@ -15,7 +15,9 @@ namespace llarp struct ILinkLayer; struct ILinkSession { - virtual ~ILinkSession(){}; + virtual ~ILinkSession() + { + } /// hook for utp for when we have established a connection virtual void diff --git a/llarp/messages/path_confirm.hpp b/llarp/messages/path_confirm.hpp index 3c80873f4..b1ba46ca1 100644 --- a/llarp/messages/path_confirm.hpp +++ b/llarp/messages/path_confirm.hpp @@ -13,7 +13,9 @@ namespace llarp uint64_t pathCreated; PathConfirmMessage(); PathConfirmMessage(uint64_t lifetime); - ~PathConfirmMessage(){}; + ~PathConfirmMessage() + { + } bool BEncode(llarp_buffer_t* buf) const override; @@ -29,7 +31,7 @@ namespace llarp { pathLifetime = 0; pathCreated = 0; - }; + } }; } // namespace routing } // namespace llarp diff --git a/llarp/messages/path_latency.hpp b/llarp/messages/path_latency.hpp index 21cb3d48a..4e1617244 100644 --- a/llarp/messages/path_latency.hpp +++ b/llarp/messages/path_latency.hpp @@ -24,7 +24,7 @@ namespace llarp { T = 0; L = 0; - }; + } bool HandleMessage(IMessageHandler* h, AbstractRouter* r) const override; diff --git a/llarp/net/net_addr.hpp b/llarp/net/net_addr.hpp index d891d340b..b6745393c 100644 --- a/llarp/net/net_addr.hpp +++ b/llarp/net/net_addr.hpp @@ -131,7 +131,7 @@ namespace llarp in_addr_t addr = this->addr4()->s_addr; uint32_t byte = ntohl(addr); return byte; - }; + } bool isTenPrivate(uint32_t byte); diff --git a/llarp/path/path.hpp b/llarp/path/path.hpp index 52dfa0eba..1adb03434 100644 --- a/llarp/path/path.hpp +++ b/llarp/path/path.hpp @@ -113,7 +113,9 @@ namespace llarp struct IHopHandler { - virtual ~IHopHandler(){}; + virtual ~IHopHandler() + { + } virtual bool Expired(llarp_time_t now) const = 0; diff --git a/llarp/profiling.hpp b/llarp/profiling.hpp index 2c41bb6fa..d8c1b37f3 100644 --- a/llarp/profiling.hpp +++ b/llarp/profiling.hpp @@ -21,9 +21,11 @@ namespace llarp llarp_time_t lastUpdated = 0; llarp_time_t lastDecay = 0; - RouterProfile() : IBEncodeMessage(){}; + RouterProfile() : IBEncodeMessage() + { + } - ~RouterProfile(){}; + ~RouterProfile() = default; bool BEncode(llarp_buffer_t* buf) const override; diff --git a/llarp/routing/message.hpp b/llarp/routing/message.hpp index c5fe40aa2..42d5c345a 100644 --- a/llarp/routing/message.hpp +++ b/llarp/routing/message.hpp @@ -21,7 +21,9 @@ namespace llarp { } - virtual ~IMessage(){}; + virtual ~IMessage() + { + } virtual bool HandleMessage(IMessageHandler* h, AbstractRouter* r) const = 0; diff --git a/llarp/service/info.hpp b/llarp/service/info.hpp index b88bb6da4..0cfb5d942 100644 --- a/llarp/service/info.hpp +++ b/llarp/service/info.hpp @@ -98,7 +98,7 @@ namespace llarp version = other.version; UpdateAddr(); return *this; - }; + } bool operator<(const ServiceInfo& other) const diff --git a/llarp/service/lookup.hpp b/llarp/service/lookup.hpp index e0738fc21..1dfa10513 100644 --- a/llarp/service/lookup.hpp +++ b/llarp/service/lookup.hpp @@ -23,7 +23,9 @@ namespace llarp struct IServiceLookup { IServiceLookup() = delete; - virtual ~IServiceLookup(){}; + virtual ~IServiceLookup() + { + } /// handle lookup result virtual bool diff --git a/llarp/service/sendcontext.hpp b/llarp/service/sendcontext.hpp index 73dfca717..e9c435443 100644 --- a/llarp/service/sendcontext.hpp +++ b/llarp/service/sendcontext.hpp @@ -47,7 +47,7 @@ namespace llarp { (void)rebuild; return true; - }; + } virtual void UpdateIntroSet(bool randomizePath = false) = 0; diff --git a/llarp/util/bencode.hpp b/llarp/util/bencode.hpp index abe74895d..91343ddce 100644 --- a/llarp/util/bencode.hpp +++ b/llarp/util/bencode.hpp @@ -227,7 +227,9 @@ namespace llarp /// bencode serializable message struct IBEncodeMessage { - virtual ~IBEncodeMessage(){}; + virtual ~IBEncodeMessage() + { + } IBEncodeMessage(uint64_t v = LLARP_PROTO_VERSION) { diff --git a/llarp/util/buffer.cpp b/llarp/util/buffer.cpp index a95a17ae1..3e22c5a06 100644 --- a/llarp/util/buffer.cpp +++ b/llarp/util/buffer.cpp @@ -27,7 +27,7 @@ llarp_buffer_t::writef(const char* fmt, ...) va_end(args); if(written <= 0) return false; - if(sz < written) + if(sz < static_cast< size_t >(written)) return false; cur += written; return true; diff --git a/llarp/util/file_logger.hpp b/llarp/util/file_logger.hpp index fd9a4a338..743193e17 100644 --- a/llarp/util/file_logger.hpp +++ b/llarp/util/file_logger.hpp @@ -7,7 +7,7 @@ namespace llarp { - /// fluhsable file based log stream + /// flushable file based log stream struct FileLogStream : public ILogStream { FileLogStream(llarp_threadpool* disk, FILE* f, llarp_time_t flushInterval); @@ -25,7 +25,9 @@ namespace llarp Tick(llarp_time_t now) override; void - PostLog(std::stringstream&) const override{}; + PostLog(std::stringstream&) const override + { + } private: struct FlushEvent @@ -58,4 +60,4 @@ namespace llarp }; } // namespace llarp -#endif \ No newline at end of file +#endif diff --git a/llarp/util/json.hpp b/llarp/util/json.hpp index ec915e7cb..470bf9519 100644 --- a/llarp/util/json.hpp +++ b/llarp/util/json.hpp @@ -14,7 +14,7 @@ namespace llarp { struct IParser { - virtual ~IParser(){}; + virtual ~IParser(){} /// result from feeding data to parser enum Result diff --git a/llarp/util/logger_syslog.hpp b/llarp/util/logger_syslog.hpp index 5b236cda9..2a20d9ceb 100644 --- a/llarp/util/logger_syslog.hpp +++ b/llarp/util/logger_syslog.hpp @@ -17,7 +17,9 @@ namespace llarp void PostLog(std::stringstream& ss) const override; - void Tick(llarp_time_t) override{}; + void Tick(llarp_time_t) override + { + } }; } // namespace llarp #endif diff --git a/llarp/util/logstream.hpp b/llarp/util/logstream.hpp index 1ca183fd2..f2af1d2c7 100644 --- a/llarp/util/logstream.hpp +++ b/llarp/util/logstream.hpp @@ -11,7 +11,9 @@ namespace llarp /// logger stream interface struct ILogStream { - virtual ~ILogStream(){}; + virtual ~ILogStream() + { + } virtual void PreLog(std::stringstream& out, LogLevel lvl, const char* fname, diff --git a/llarp/util/ostream_logger.hpp b/llarp/util/ostream_logger.hpp index 4937b4a52..cdf998acd 100644 --- a/llarp/util/ostream_logger.hpp +++ b/llarp/util/ostream_logger.hpp @@ -24,7 +24,9 @@ namespace llarp virtual void PostLog(std::stringstream& ss) const override; - void Tick(llarp_time_t) override{}; + void Tick(llarp_time_t) override + { + } private: std::ostream& m_Out;