mirror of https://github.com/oxen-io/lokinet
Merge remote-tracking branch 'origin/master'
commit
8dac38fcdc
@ -1,2 +1,2 @@
|
||||
HeaderFilterRegex: 'llarp/.*'
|
||||
Checks: 'readability-else-after-return,clang-analyzer-core-*'
|
||||
Checks: 'readability-else-after-return,clang-analyzer-core-*,modernize-*'
|
||||
|
@ -1,28 +1,16 @@
|
||||
set(CMAKE_SYSTEM_NAME Windows)
|
||||
set(TOOLCHAIN_PREFIX x86_64-w64-mingw32)
|
||||
set(TOOLCHAIN_SUFFIX "")
|
||||
set(WIN64_CROSS_COMPILE ON)
|
||||
|
||||
add_definitions("-DWINNT_CROSS_COMPILE")
|
||||
|
||||
# target environment on the build host system
|
||||
# second one is for non-root installs
|
||||
set(CMAKE_FIND_ROOT_PATH /usr/${TOOLCHAIN_PREFIX} /usr/local/opt/mingw-w64/toolchain-x86_64/ /opt/mingw64 /home/$ENV{USER}/mingw32 /home/$ENV{USER}/mingw64 /home/$ENV{USER}/mingw64/${TOOLCHAIN_PREFIX} /home/$ENV{USER}/mingw32/${TOOLCHAIN_PREFIX})
|
||||
|
||||
# modify default behavior of FIND_XXX() commands
|
||||
set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
|
||||
set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
|
||||
set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
|
||||
|
||||
# cross compilers to use
|
||||
if($ENV{COMPILER} MATCHES "clang")
|
||||
set(USING_CLANG ON)
|
||||
set(CMAKE_C_COMPILER ${TOOLCHAIN_PREFIX}-clang)
|
||||
set(CMAKE_CXX_COMPILER ${TOOLCHAIN_PREFIX}-clang++)
|
||||
else()
|
||||
set(CMAKE_C_COMPILER ${TOOLCHAIN_PREFIX}-gcc${TOOLCHAIN_SUFFIX})
|
||||
set(CMAKE_CXX_COMPILER ${TOOLCHAIN_PREFIX}-g++${TOOLCHAIN_SUFFIX})
|
||||
add_compile_options("-Wa,-mbig-obj")
|
||||
endif()
|
||||
set(TOOLCHAIN_PATHS
|
||||
/usr/${TOOLCHAIN_PREFIX}
|
||||
/usr/local/opt/mingw-w64/toolchain-x86_64
|
||||
/usr/local/opt/mingw-w64/toolchain-x86_64/x86_64-w64-mingw32
|
||||
/opt/mingw64
|
||||
/home/$ENV{USER}/mingw32
|
||||
/home/$ENV{USER}/mingw64
|
||||
/home/$ENV{USER}/mingw64/${TOOLCHAIN_PREFIX}
|
||||
/home/$ENV{USER}/mingw32/${TOOLCHAIN_PREFIX})
|
||||
|
||||
set(CMAKE_RC_COMPILER ${TOOLCHAIN_PREFIX}-windres)
|
||||
set(WIN64_CROSS_COMPILE ON)
|
||||
include("${CMAKE_CURRENT_LIST_DIR}/mingw_core.cmake")
|
||||
|
@ -1,26 +1,15 @@
|
||||
set(CMAKE_SYSTEM_NAME Windows)
|
||||
set(TOOLCHAIN_PREFIX i686-w64-mingw32)
|
||||
set(TOOLCHAIN_SUFFIX "")
|
||||
set(WOW64_CROSS_COMPILE ON)
|
||||
|
||||
add_definitions("-DWINNT_CROSS_COMPILE")
|
||||
|
||||
# target environment on the build host system
|
||||
# second one is for non-root installs
|
||||
set(CMAKE_FIND_ROOT_PATH /usr/${TOOLCHAIN_PREFIX} /opt/mingw32 /home/$ENV{USER}/mingw32 /home/$ENV{USER}/mingw32/${TOOLCHAIN_PREFIX})
|
||||
|
||||
# modify default behavior of FIND_XXX() commands
|
||||
set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
|
||||
set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
|
||||
set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
|
||||
|
||||
# cross compilers to use
|
||||
if($ENV{COMPILER} MATCHES "clang")
|
||||
set(USING_CLANG ON)
|
||||
set(CMAKE_C_COMPILER ${TOOLCHAIN_PREFIX}-clang)
|
||||
set(CMAKE_CXX_COMPILER ${TOOLCHAIN_PREFIX}-clang++)
|
||||
else()
|
||||
set(CMAKE_C_COMPILER ${TOOLCHAIN_PREFIX}-gcc)
|
||||
set(CMAKE_CXX_COMPILER ${TOOLCHAIN_PREFIX}-g++)
|
||||
endif()
|
||||
set(TOOLCHAIN_PATHS
|
||||
/usr/${TOOLCHAIN_PREFIX}
|
||||
/usr/local/opt/mingw-w64/toolchain-i686
|
||||
/usr/local/opt/mingw-w64/toolchain-i686/i686-w64-mingw32
|
||||
/opt/mingw32
|
||||
/home/$ENV{USER}/mingw32
|
||||
/home/$ENV{USER}/mingw32/${TOOLCHAIN_PREFIX}
|
||||
)
|
||||
|
||||
set(CMAKE_RC_COMPILER ${TOOLCHAIN_PREFIX}-windres)
|
||||
set(WOW64_CROSS_COMPILE ON)
|
||||
include("${CMAKE_CURRENT_LIST_DIR}/mingw_core.cmake")
|
||||
|
@ -0,0 +1,24 @@
|
||||
# target environment on the build host system
|
||||
# second one is for non-root installs
|
||||
set(CMAKE_FIND_ROOT_PATH ${TOOLCHAIN_PATHS})
|
||||
|
||||
add_definitions("-DWINNT_CROSS_COMPILE")
|
||||
|
||||
# modify default behavior of FIND_XXX() commands
|
||||
set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
|
||||
set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
|
||||
set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
|
||||
set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY)
|
||||
|
||||
# cross compilers to use
|
||||
if($ENV{COMPILER} MATCHES "clang")
|
||||
set(USING_CLANG ON)
|
||||
set(CMAKE_C_COMPILER ${TOOLCHAIN_PREFIX}-clang)
|
||||
set(CMAKE_CXX_COMPILER ${TOOLCHAIN_PREFIX}-clang++)
|
||||
else()
|
||||
set(CMAKE_C_COMPILER ${TOOLCHAIN_PREFIX}-gcc${TOOLCHAIN_SUFFIX})
|
||||
set(CMAKE_CXX_COMPILER ${TOOLCHAIN_PREFIX}-g++${TOOLCHAIN_SUFFIX})
|
||||
add_compile_options("-Wa,-mbig-obj")
|
||||
endif()
|
||||
|
||||
set(CMAKE_RC_COMPILER ${TOOLCHAIN_PREFIX}-windres)
|
@ -0,0 +1 @@
|
||||
v/
|
@ -0,0 +1,266 @@
|
||||
#!/usr/bin/env python3
|
||||
import requests
|
||||
import json
|
||||
import time
|
||||
import curses
|
||||
import math
|
||||
import traceback
|
||||
|
||||
|
||||
class Monitor:
|
||||
|
||||
_speedSamples = 8
|
||||
_globalspeed = []
|
||||
|
||||
def __init__(self, url):
|
||||
self.data = dict()
|
||||
self.win = curses.initscr()
|
||||
self._url = url
|
||||
while len(self._globalspeed) < self._speedSamples:
|
||||
self._globalspeed.append((0, 0))
|
||||
|
||||
def __del__(self):
|
||||
curses.endwin()
|
||||
|
||||
def on_timer(self, event):
|
||||
"""called on timer event"""
|
||||
self.update_data()
|
||||
|
||||
def jsonrpc(self, meth, params):
|
||||
r = requests.post(
|
||||
self._url,
|
||||
headers={"Content-Type": "application/json"},
|
||||
json={
|
||||
"jsonrpc": "2.0",
|
||||
"id": "0",
|
||||
"method": "{}".format(meth),
|
||||
"params": params,
|
||||
},
|
||||
)
|
||||
return r.json()
|
||||
|
||||
def update_data(self):
|
||||
"""update data from lokinet"""
|
||||
try:
|
||||
j = self.jsonrpc("llarp.admin.dumpstate", {})
|
||||
self.data = j["result"]
|
||||
except Exception as ex:
|
||||
self.data = None
|
||||
|
||||
def _render_path(self, y, path, name):
|
||||
"""render a path at current position"""
|
||||
self.win.move(y, 1)
|
||||
self.win.addstr("({}) ".format(name))
|
||||
y += 1
|
||||
self.win.move(y, 1)
|
||||
y += 1
|
||||
self.win.addstr("me -> ")
|
||||
for hop in path["hops"]:
|
||||
self.win.addstr(" {} ->".format(hop["router"][:4]))
|
||||
self.win.addstr(" [{} ms latency]".format(path["intro"]["latency"]))
|
||||
self.win.addstr(" [{} until expire]".format(self.timeTo(path["expiresAt"])))
|
||||
if path["expiresSoon"]:
|
||||
self.win.addstr("(expiring)")
|
||||
elif path["expired"]:
|
||||
self.win.addstr("(expired)")
|
||||
return y
|
||||
|
||||
def timeTo(self, ts):
|
||||
""" return time until timestamp in seconds formatted"""
|
||||
now = time.time() * 1000
|
||||
return "{} seconds".format(int((ts - now) / 1000))
|
||||
|
||||
def speedOf(self, rate):
|
||||
"""turn int speed into string formatted"""
|
||||
units = ["B", "KB", "MB", "GB"]
|
||||
idx = 0
|
||||
while rate > 1000 and idx < len(units):
|
||||
rate /= 1000.0
|
||||
idx += 1
|
||||
return "{} {}ps".format("%.2f" % rate, units[idx])
|
||||
|
||||
def display_service(self, y, name, status):
|
||||
"""display a service at current position"""
|
||||
self.win.move(y, 1)
|
||||
self.win.addstr("service [{}]".format(name))
|
||||
build = status["buildStats"]
|
||||
ratio = build["success"] / (build["attempts"] or 1)
|
||||
y += 1
|
||||
self.win.move(y, 1)
|
||||
self.win.addstr("build success: {} %".format(int(100 * ratio)))
|
||||
y += 1
|
||||
self.win.move(y, 1)
|
||||
paths = status["paths"]
|
||||
self.win.addstr("paths: {}".format(len(paths)))
|
||||
for path in paths:
|
||||
y = self._render_path(y, path, "inbound")
|
||||
for session in status["remoteSessions"]:
|
||||
for path in session["paths"]:
|
||||
y = self._render_path(
|
||||
y, path, "[active] {}".format(session["currentConvoTag"])
|
||||
)
|
||||
for session in status["snodeSessions"]:
|
||||
for path in session["paths"]:
|
||||
y = self._render_path(y, path, "[snode]")
|
||||
return y
|
||||
|
||||
# for k in status:
|
||||
# self.win.move(y + 1, 1)
|
||||
# y += 1
|
||||
# self.win.addstr('{}: {}'.format(k, json.dumps(status[k])))
|
||||
|
||||
def display_links(self, y, data):
|
||||
self.txrate = 0
|
||||
self.rxrate = 0
|
||||
for link in data["outbound"]:
|
||||
y += 1
|
||||
self.win.move(y, 1)
|
||||
self.win.addstr("outbound sessions:")
|
||||
y = self.display_link(y, link)
|
||||
for link in data["inbound"]:
|
||||
y += 1
|
||||
self.win.move(y, 1)
|
||||
self.win.addstr("inbound sessions:")
|
||||
y = self.display_link(y, link)
|
||||
y += 2
|
||||
self.win.move(y, 1)
|
||||
self.win.addstr(
|
||||
"global speed:\t\t[{}\ttx]\t[{}\trx]".format(
|
||||
self.speedOf(self.txrate), self.speedOf(self.rxrate)
|
||||
)
|
||||
)
|
||||
|
||||
self._globalspeed.append((self.txrate, self.rxrate))
|
||||
while len(self._globalspeed) > self._speedSamples:
|
||||
self._globalspeed.pop(0)
|
||||
return self.display_speedgraph(y + 2, self._globalspeed)
|
||||
|
||||
def display_speedgraph(self, y, samps, maxsz=20):
|
||||
""" display global speed graph """
|
||||
|
||||
def scale(x, n):
|
||||
while n > 0:
|
||||
x /= 2
|
||||
n -= 1
|
||||
return int(x)
|
||||
|
||||
txmax, rxmax = 1000, 1000
|
||||
for tx, rx in samps:
|
||||
if tx > txmax:
|
||||
txmax = tx
|
||||
if rx > rxmax:
|
||||
rxmax = rx
|
||||
|
||||
rxscale = 0
|
||||
while rxmax > maxsz:
|
||||
rxscale += 1
|
||||
rxmax /= 2
|
||||
|
||||
txscale = 0
|
||||
while txmax > maxsz:
|
||||
txscale += 1
|
||||
txmax /= 2
|
||||
|
||||
def makebar(samp, max):
|
||||
bar = "#" * samp
|
||||
pad = " " * (max - samp)
|
||||
return pad, bar
|
||||
|
||||
txlabelpad = int(txmax / 2) - 1
|
||||
rxlabelpad = int(rxmax / 2) - 1
|
||||
if txlabelpad <= 0:
|
||||
txlabelpad = 1
|
||||
if rxlabelpad <= 0:
|
||||
rxlabelpad = 1
|
||||
txlabelpad = " " * txlabelpad
|
||||
rxlabelpad = " " * rxlabelpad
|
||||
y += 1
|
||||
self.win.move(y, 1)
|
||||
self.win.addstr(
|
||||
"{}tx{}{}rx{}".format(txlabelpad, txlabelpad, rxlabelpad, rxlabelpad)
|
||||
)
|
||||
for tx, rx in samps:
|
||||
y += 1
|
||||
self.win.move(y, 1)
|
||||
txpad, txbar = makebar(scale(tx, txscale), int(txmax))
|
||||
rxpad, rxbar = makebar(scale(rx, rxscale), int(rxmax))
|
||||
self.win.addstr("{}{}|{}{}".format(txpad, txbar, rxbar, rxpad))
|
||||
return y + 2
|
||||
|
||||
def display_link(self, y, link):
|
||||
y += 1
|
||||
self.win.move(y, 1)
|
||||
sessions = link["sessions"]["established"]
|
||||
for s in sessions:
|
||||
y += 1
|
||||
self.win.move(y, 1)
|
||||
self.txrate += s["tx"]
|
||||
self.rxrate += s["rx"]
|
||||
self.win.addstr(
|
||||
"{}\t[{}\ttx]\t[{}\trx]".format(
|
||||
s["remoteAddr"], self.speedOf(s["tx"]), self.speedOf(s["rx"])
|
||||
)
|
||||
)
|
||||
if s["sendBacklog"] > 0:
|
||||
self.win.addstr("[backlog {}]".format(s["sendBacklog"]))
|
||||
return y
|
||||
|
||||
def display_dht(self, y, data):
|
||||
y += 2
|
||||
self.win.move(y, 1)
|
||||
self.win.addstr("DHT:")
|
||||
y += 1
|
||||
self.win.move(y, 1)
|
||||
self.win.addstr("introset lookups")
|
||||
y = self.display_bucket(y, data["pendingIntrosetLookups"])
|
||||
y += 1
|
||||
self.win.move(y, 1)
|
||||
self.win.addstr("router lookups")
|
||||
return self.display_bucket(y, data["pendingRouterLookups"])
|
||||
|
||||
def display_bucket(self, y, data):
|
||||
txs = data["tx"]
|
||||
self.win.addstr(" ({} lookups)".format(len(txs)))
|
||||
for tx in txs:
|
||||
y += 1
|
||||
self.win.move(y, 1)
|
||||
self.win.addstr("search for {}".format(tx["tx"]["target"]))
|
||||
return y
|
||||
|
||||
def display_data(self):
|
||||
"""draw main window"""
|
||||
if self.data is not None:
|
||||
self.win.addstr(1, 1, "lokinet online")
|
||||
# print(self.data)
|
||||
services = self.data["services"] or {}
|
||||
y = 3
|
||||
try:
|
||||
y = self.display_links(y, self.data["links"])
|
||||
for k in services:
|
||||
y = self.display_service(y, k, services[k])
|
||||
y = self.display_dht(y, self.data["dht"])
|
||||
except Exception as exc:
|
||||
pass
|
||||
else:
|
||||
self.win.move(1, 1)
|
||||
self.win.addstr("lokinet offline")
|
||||
|
||||
def run(self):
|
||||
while True:
|
||||
self.win.clear()
|
||||
self.win.box()
|
||||
self.update_data()
|
||||
self.display_data()
|
||||
self.win.refresh()
|
||||
time.sleep(1)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
import sys
|
||||
|
||||
mon = Monitor(
|
||||
"http://{}/jsonrpc".format(
|
||||
len(sys.argv) > 1 and sys.argv[1] or "127.0.0.1:1190"
|
||||
)
|
||||
)
|
||||
mon.run()
|
@ -0,0 +1 @@
|
||||
requests
|
@ -1,598 +1,99 @@
|
||||
#include <buffer.hpp>
|
||||
#include <crypto/crypto.hpp>
|
||||
#include <fs.hpp>
|
||||
#include <llarp.h>
|
||||
#include <logger.hpp>
|
||||
#include <messages/dht.hpp>
|
||||
#include <net.hpp>
|
||||
#include <nodedb.hpp>
|
||||
#include <router.hpp>
|
||||
#include <router_contact.hpp>
|
||||
#include <time.hpp>
|
||||
#include <util/logger.hpp>
|
||||
#include <util/ostream_logger.hpp>
|
||||
|
||||
#include <fstream>
|
||||
#include <getopt.h>
|
||||
#include <signal.h>
|
||||
#include <absl/synchronization/mutex.h>
|
||||
#include <cxxopts.hpp>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
struct llarp_main *ctx = 0;
|
||||
|
||||
void
|
||||
handle_signal(int sig)
|
||||
{
|
||||
if(ctx)
|
||||
llarp_main_signal(ctx, sig);
|
||||
}
|
||||
|
||||
#ifndef TESTNET
|
||||
#define TESTNET 0
|
||||
#endif
|
||||
|
||||
void
|
||||
displayRC(const llarp::RouterContact &rc)
|
||||
{
|
||||
std::cout << rc.pubkey << std::endl;
|
||||
for(const auto &addr : rc.addrs)
|
||||
{
|
||||
std::cout << "AddressInfo: " << addr << std::endl;
|
||||
}
|
||||
}
|
||||
|
||||
// fwd declr
|
||||
struct check_online_request;
|
||||
|
||||
void
|
||||
HandleDHTLocate(llarp_router_lookup_job *job)
|
||||
bool
|
||||
dumpRc(const std::vector< std::string >& files, bool json)
|
||||
{
|
||||
llarp::LogInfo("DHT result: ", job->found ? "found" : "not found");
|
||||
if(job->found)
|
||||
{
|
||||
// save to nodedb?
|
||||
displayRC(job->result);
|
||||
}
|
||||
// shutdown router
|
||||
|
||||
// well because we're in the gotroutermessage, we can't sigint because we'll
|
||||
// deadlock because we're session locked
|
||||
// llarp_main_signal(ctx, SIGINT);
|
||||
|
||||
// llarp_timer_run(logic->timer, logic->thread);
|
||||
// we'll we don't want logic thread
|
||||
// but we want to switch back to the main thread
|
||||
// llarp_logic_stop();
|
||||
// still need to exit this logic thread...
|
||||
llarp_main_abort(ctx);
|
||||
}
|
||||
|
||||
int
|
||||
main(int argc, char *argv[])
|
||||
{
|
||||
// take -c to set location of daemon.ini
|
||||
// take -o to set log level
|
||||
// --generate-blank /path/to/file.signed
|
||||
// --update-ifs /path/to/file.signed
|
||||
// --key /path/to/long_term_identity.key
|
||||
// --import
|
||||
// --export
|
||||
|
||||
// --generate /path/to/file.signed
|
||||
// --update /path/to/file.signed
|
||||
// --verify /path/to/file.signed
|
||||
// printf("has [%d]options\n", argc);
|
||||
if(argc < 2)
|
||||
{
|
||||
printf(
|
||||
"please specify: \n"
|
||||
"--generate with a path to a router contact file\n"
|
||||
"--update with a path to a router contact file\n"
|
||||
"--list path to nodedb skiplist\n"
|
||||
"--import with a path to a router contact file\n"
|
||||
"--export a hex formatted public key\n"
|
||||
"--locate a hex formatted public key\n"
|
||||
"--find a base32 formatted service address\n"
|
||||
"--b32 a hex formatted public key\n"
|
||||
"--hex a base32 formatted public key\n"
|
||||
"--localInfo \n"
|
||||
"--read with a path to a router contact file\n"
|
||||
"--verify with a path to a router contact file\n"
|
||||
"\n");
|
||||
return 0;
|
||||
}
|
||||
bool haveRequiredOptions = false;
|
||||
bool genMode = false;
|
||||
bool updMode = false;
|
||||
bool listMode = false;
|
||||
bool importMode = false;
|
||||
bool exportMode = false;
|
||||
bool locateMode = false;
|
||||
bool findMode = false;
|
||||
bool localMode = false;
|
||||
bool verifyMode = false;
|
||||
bool readMode = false;
|
||||
bool toHexMode = false;
|
||||
bool toB32Mode = false;
|
||||
int c;
|
||||
char *conffname;
|
||||
char defaultConfName[] = "daemon.ini";
|
||||
conffname = defaultConfName;
|
||||
char *rcfname = nullptr;
|
||||
char *nodesdir = nullptr;
|
||||
|
||||
llarp::RouterContact rc;
|
||||
while(1)
|
||||
{
|
||||
static struct option long_options[] = {
|
||||
{"file", required_argument, 0, 'f'},
|
||||
{"config", required_argument, 0, 'c'},
|
||||
{"logLevel", required_argument, 0, 'o'},
|
||||
{"generate", required_argument, 0, 'g'},
|
||||
{"update", required_argument, 0, 'u'},
|
||||
{"list", required_argument, 0, 'l'},
|
||||
{"import", required_argument, 0, 'i'},
|
||||
{"export", required_argument, 0, 'e'},
|
||||
{"locate", required_argument, 0, 'q'},
|
||||
{"find", required_argument, 0, 'F'},
|
||||
{"localInfo", no_argument, 0, 'n'},
|
||||
{"read", required_argument, 0, 'r'},
|
||||
{"b32", required_argument, 0, 'b'},
|
||||
{"hex", required_argument, 0, 'h'},
|
||||
{"verify", required_argument, 0, 'V'},
|
||||
{0, 0, 0, 0}};
|
||||
int option_index = 0;
|
||||
c = getopt_long(argc, argv, "c:f:o:g:lu:i:e:q:F:nr:b:h:V:", long_options,
|
||||
&option_index);
|
||||
#define MIN(X, Y) (((X) < (Y)) ? (X) : (Y))
|
||||
if(c == -1)
|
||||
break;
|
||||
switch(c)
|
||||
{
|
||||
case 0:
|
||||
break;
|
||||
case 'c':
|
||||
conffname = optarg;
|
||||
break;
|
||||
case 'o':
|
||||
if(strncmp(optarg, "debug",
|
||||
MIN(strlen(optarg), static_cast< unsigned long >(5)))
|
||||
== 0)
|
||||
{
|
||||
llarp::SetLogLevel(llarp::eLogDebug);
|
||||
}
|
||||
else if(strncmp(optarg, "info",
|
||||
MIN(strlen(optarg), static_cast< unsigned long >(4)))
|
||||
== 0)
|
||||
{
|
||||
llarp::SetLogLevel(llarp::eLogInfo);
|
||||
}
|
||||
else if(strncmp(optarg, "warn",
|
||||
MIN(strlen(optarg), static_cast< unsigned long >(4)))
|
||||
== 0)
|
||||
{
|
||||
llarp::SetLogLevel(llarp::eLogWarn);
|
||||
}
|
||||
else if(strncmp(optarg, "error",
|
||||
MIN(strlen(optarg), static_cast< unsigned long >(5)))
|
||||
== 0)
|
||||
{
|
||||
llarp::SetLogLevel(llarp::eLogError);
|
||||
}
|
||||
break;
|
||||
case 'V':
|
||||
rcfname = optarg;
|
||||
haveRequiredOptions = true;
|
||||
verifyMode = true;
|
||||
break;
|
||||
case 'f':
|
||||
rcfname = optarg;
|
||||
break;
|
||||
case 'l':
|
||||
nodesdir = optarg;
|
||||
listMode = true;
|
||||
break;
|
||||
case 'i':
|
||||
// printf ("option -g with value `%s'\n", optarg);
|
||||
nodesdir = optarg;
|
||||
importMode = true;
|
||||
break;
|
||||
case 'e':
|
||||
// printf ("option -g with value `%s'\n", optarg);
|
||||
rcfname = optarg;
|
||||
exportMode = true;
|
||||
break;
|
||||
case 'q':
|
||||
// printf ("option -g with value `%s'\n", optarg);
|
||||
rcfname = optarg;
|
||||
locateMode = true;
|
||||
break;
|
||||
case 'F':
|
||||
rcfname = optarg;
|
||||
haveRequiredOptions = true;
|
||||
findMode = true;
|
||||
break;
|
||||
case 'g':
|
||||
// printf ("option -g with value `%s'\n", optarg);
|
||||
rcfname = optarg;
|
||||
genMode = true;
|
||||
break;
|
||||
case 'u':
|
||||
// printf ("option -u with value `%s'\n", optarg);
|
||||
rcfname = optarg;
|
||||
updMode = true;
|
||||
break;
|
||||
case 'n':
|
||||
localMode = true;
|
||||
break;
|
||||
case 'r':
|
||||
rcfname = optarg;
|
||||
readMode = true;
|
||||
break;
|
||||
case 'b':
|
||||
rcfname = optarg;
|
||||
haveRequiredOptions = true;
|
||||
toB32Mode = true;
|
||||
break;
|
||||
case 'h':
|
||||
rcfname = optarg;
|
||||
haveRequiredOptions = true;
|
||||
toHexMode = true;
|
||||
break;
|
||||
default:
|
||||
printf("Bad option: %c\n", c);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
#undef MIN
|
||||
if(!haveRequiredOptions)
|
||||
{
|
||||
llarp::LogError("Parameters dont all have their required parameters.\n");
|
||||
return 0;
|
||||
}
|
||||
// printf("parsed options\n");
|
||||
|
||||
if(!genMode && !updMode && !listMode && !importMode && !exportMode
|
||||
&& !locateMode && !localMode && !readMode && !findMode && !toB32Mode
|
||||
&& !toHexMode && !verifyMode)
|
||||
nlohmann::json result;
|
||||
for(const auto& file : files)
|
||||
{
|
||||
llarp::LogError(
|
||||
"I don't know what to do, no generate or update parameter\n");
|
||||
return 1;
|
||||
}
|
||||
|
||||
#ifdef LOKINET_DEBUG
|
||||
absl::SetMutexDeadlockDetectionMode(absl::OnDeadlockCycle::kAbort);
|
||||
#endif
|
||||
llarp::RouterContact rc;
|
||||
const bool ret = rc.Read(file.c_str());
|
||||
|
||||
llarp::RouterContact tmp;
|
||||
|
||||
if(verifyMode)
|
||||
{
|
||||
llarp::Crypto crypto(llarp::Crypto::sodium{});
|
||||
if(!rc.Read(rcfname))
|
||||
if(ret)
|
||||
{
|
||||
std::cout << "failed to read " << rcfname << std::endl;
|
||||
return 1;
|
||||
}
|
||||
if(!rc.Verify(&crypto))
|
||||
{
|
||||
std::cout << rcfname << " is invalid" << std::endl;
|
||||
return 1;
|
||||
}
|
||||
if(!rc.IsPublicRouter())
|
||||
{
|
||||
std::cout << rcfname << " is not a public router";
|
||||
if(rc.addrs.size() == 0)
|
||||
if(json)
|
||||
{
|
||||
std::cout << " because it has no public addresses";
|
||||
result[file] = rc.ToJson();
|
||||
}
|
||||
std::cout << std::endl;
|
||||
return 1;
|
||||
}
|
||||
|
||||
std::cout << "router identity and dht routing key: " << rc.pubkey
|
||||
<< std::endl;
|
||||
|
||||
std::cout << "router encryption key: " << rc.enckey << std::endl;
|
||||
|
||||
if(rc.HasNick())
|
||||
std::cout << "router nickname: " << rc.Nick() << std::endl;
|
||||
|
||||
std::cout << "advertised addresses: " << std::endl;
|
||||
for(const auto &addr : rc.addrs)
|
||||
{
|
||||
std::cout << addr << std::endl;
|
||||
}
|
||||
std::cout << std::endl;
|
||||
|
||||
std::cout << "advertised exits: ";
|
||||
if(rc.exits.size())
|
||||
{
|
||||
for(const auto &exit : rc.exits)
|
||||
else
|
||||
{
|
||||
std::cout << exit << std::endl;
|
||||
std::cout << "file = " << file << "\n";
|
||||
std::cout << rc << "\n\n";
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
std::cout << "none";
|
||||
std::cerr << "file = " << file << " was not a valid rc file\n";
|
||||
}
|
||||
std::cout << std::endl;
|
||||
return 0;
|
||||
}
|
||||
|
||||
ctx = llarp_main_init(conffname, !TESTNET);
|
||||
if(!ctx)
|
||||
{
|
||||
llarp::LogError("Cant set up context");
|
||||
return 1;
|
||||
}
|
||||
signal(SIGINT, handle_signal);
|
||||
if(json)
|
||||
std::cout << result << "\n";
|
||||
|
||||
// is this Neuro or Jeff's?
|
||||
// this is the only one...
|
||||
if(listMode)
|
||||
{
|
||||
llarp::Crypto crypto(llarp::Crypto::sodium{});
|
||||
auto nodedb = llarp_nodedb_new(&crypto);
|
||||
llarp_nodedb_iter itr;
|
||||
itr.visit = [](llarp_nodedb_iter *i) -> bool {
|
||||
std::cout << i->rc->pubkey << std::endl;
|
||||
return true;
|
||||
};
|
||||
if(llarp_nodedb_load_dir(nodedb, nodesdir) > 0)
|
||||
llarp_nodedb_iterate_all(nodedb, itr);
|
||||
llarp_nodedb_free(&nodedb);
|
||||
return 0;
|
||||
}
|
||||
|
||||
if(importMode)
|
||||
{
|
||||
if(rcfname == nullptr)
|
||||
{
|
||||
std::cout << "no file to import" << std::endl;
|
||||
return 1;
|
||||
}
|
||||
llarp::Crypto crypto(llarp::Crypto::sodium{});
|
||||
auto nodedb = llarp_nodedb_new(&crypto);
|
||||
if(!llarp_nodedb_ensure_dir(nodesdir))
|
||||
{
|
||||
std::cout << "failed to ensure " << nodesdir << strerror(errno)
|
||||
<< std::endl;
|
||||
return 1;
|
||||
}
|
||||
llarp_nodedb_set_dir(nodedb, nodesdir);
|
||||
if(!rc.Read(rcfname))
|
||||
{
|
||||
std::cout << "failed to read " << rcfname << " " << strerror(errno)
|
||||
<< std::endl;
|
||||
return 1;
|
||||
}
|
||||
|
||||
if(!rc.Verify(&crypto))
|
||||
{
|
||||
std::cout << rcfname << " is invalid" << std::endl;
|
||||
return 1;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
if(!llarp_nodedb_put_rc(nodedb, rc))
|
||||
{
|
||||
std::cout << "failed to store " << strerror(errno) << std::endl;
|
||||
return 1;
|
||||
}
|
||||
int
|
||||
main(int argc, char* argv[])
|
||||
{
|
||||
#ifdef LOKINET_DEBUG
|
||||
absl::SetMutexDeadlockDetectionMode(absl::OnDeadlockCycle::kAbort);
|
||||
#endif
|
||||
|
||||
std::cout << "imported " << rc.pubkey << std::endl;
|
||||
// clang-format off
|
||||
cxxopts::Options options(
|
||||
"lokinet-rcutil",
|
||||
"LokiNET is a free, open source, private, decentralized, \"market based sybil resistant\" and IP based onion routing network"
|
||||
);
|
||||
|
||||
return 0;
|
||||
}
|
||||
options.add_options()
|
||||
("v,verbose", "Verbose", cxxopts::value<bool>())
|
||||
("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");
|
||||
// clang-format on
|
||||
|
||||
if(genMode)
|
||||
try
|
||||
{
|
||||
printf("Creating [%s]\n", rcfname);
|
||||
// if we zero it out then
|
||||
// set updated timestamp
|
||||
rc.last_updated = llarp::time_now_ms();
|
||||
// load longterm identity
|
||||
llarp::Crypto crypt(llarp::Crypto::sodium{});
|
||||
|
||||
// which is in daemon.ini config: router.encryption-privkey (defaults
|
||||
// "encryption.key")
|
||||
fs::path encryption_keyfile = "encryption.key";
|
||||
llarp::SecretKey encryption;
|
||||
const auto result = options.parse(argc, argv);
|
||||
|
||||
llarp_findOrCreateEncryption(&crypt, encryption_keyfile, encryption);
|
||||
const bool json = result["json"].as< bool >();
|
||||
|
||||
rc.enckey = llarp::seckey_topublic(encryption);
|
||||
|
||||
// get identity public sig key
|
||||
fs::path ident_keyfile = "identity.key";
|
||||
llarp::SecretKey identity;
|
||||
llarp_findOrCreateIdentity(&crypt, ident_keyfile, identity);
|
||||
|
||||
rc.pubkey = llarp::seckey_topublic(identity);
|
||||
|
||||
// this causes a segfault
|
||||
if(!rc.Sign(&crypt, identity))
|
||||
if(result.count("verbose") > 0)
|
||||
{
|
||||
std::cout << "failed to sign" << std::endl;
|
||||
return 1;
|
||||
SetLogLevel(llarp::eLogDebug);
|
||||
llarp::LogContext::Instance().logStream =
|
||||
std::make_unique< llarp::OStreamLogStream >(std::cerr);
|
||||
llarp::LogDebug("debug logging activated");
|
||||
}
|
||||
// set filename
|
||||
fs::path our_rc_file = rcfname;
|
||||
// write file
|
||||
rc.Write(our_rc_file.string().c_str());
|
||||
|
||||
// llarp_rc_write(&tmp, our_rc_file.string().c_str());
|
||||
|
||||
// release memory for tmp lists
|
||||
// llarp_rc_free(&tmp);
|
||||
}
|
||||
if(updMode)
|
||||
{
|
||||
printf("rcutil.cpp - Loading [%s]\n", rcfname);
|
||||
llarp::RouterContact tmp;
|
||||
// llarp_rc_clear(&rc);
|
||||
rc.Clear();
|
||||
// FIXME: new rc api
|
||||
// llarp_rc_read(rcfname, &rc);
|
||||
|
||||
// set updated timestamp
|
||||
rc.last_updated = llarp::time_now_ms();
|
||||
// load longterm identity
|
||||
llarp::Crypto crypt(llarp::Crypto::sodium{});
|
||||
|
||||
// no longer used?
|
||||
// llarp_crypto_libsodium_init(&crypt);
|
||||
llarp::SecretKey identityKey; // FIXME: Jeff requests we use this
|
||||
fs::path ident_keyfile = "identity.key";
|
||||
llarp::SecretKey identity;
|
||||
llarp_findOrCreateIdentity(&crypt, ident_keyfile, identity);
|
||||
|
||||
// FIXME: update RC API
|
||||
// get identity public key
|
||||
// const uint8_t *pubkey = llarp::seckey_topublic(identity);
|
||||
|
||||
// FIXME: update RC API
|
||||
// llarp_rc_set_pubsigkey(&rc, pubkey);
|
||||
// // FIXME: update RC API
|
||||
// llarp_rc_sign(&crypt, identity, &rc);
|
||||
|
||||
// set filename
|
||||
fs::path our_rc_file_out = "update_debug.rc";
|
||||
// write file
|
||||
// FIXME: update RC API
|
||||
// rc.Write(our_rc_file.string().c_str());
|
||||
// llarp_rc_write(&tmp, our_rc_file_out.string().c_str());
|
||||
}
|
||||
|
||||
if(listMode)
|
||||
{
|
||||
llarp::Crypto crypto(llarp::Crypto::sodium{});
|
||||
auto nodedb = llarp_nodedb_new(&crypto);
|
||||
llarp_nodedb_iter itr;
|
||||
itr.visit = [](llarp_nodedb_iter *i) -> bool {
|
||||
std::cout << llarp::PubKey(i->rc->pubkey) << std::endl;
|
||||
return true;
|
||||
};
|
||||
if(llarp_nodedb_load_dir(nodedb, nodesdir) > 0)
|
||||
llarp_nodedb_iterate_all(nodedb, itr);
|
||||
llarp_nodedb_free(&nodedb);
|
||||
return 0;
|
||||
}
|
||||
if(exportMode)
|
||||
{
|
||||
llarp_main_loadDatabase(ctx);
|
||||
// llarp::LogInfo("Looking for string: ", rcfname);
|
||||
|
||||
llarp::PubKey binaryPK;
|
||||
llarp::HexDecode(rcfname, binaryPK.data(), binaryPK.size());
|
||||
|
||||
llarp::LogInfo("Looking for binary: ", binaryPK);
|
||||
llarp::RouterContact *rc = llarp_main_getDatabase(ctx, binaryPK.data());
|
||||
if(!rc)
|
||||
if(result.count("help") > 0)
|
||||
{
|
||||
llarp::LogError("Can't load RC from database");
|
||||
std::cout << options.help() << std::endl;
|
||||
return 0;
|
||||
}
|
||||
std::string filename(rcfname);
|
||||
filename.append(".signed");
|
||||
llarp::LogInfo("Writing out: ", filename);
|
||||
// FIXME: update RC API
|
||||
// rc.Write(our_rc_file.string().c_str());
|
||||
// llarp_rc_write(rc, filename.c_str());
|
||||
}
|
||||
if(locateMode)
|
||||
{
|
||||
llarp::LogInfo("Going online");
|
||||
llarp_main_setup(ctx);
|
||||
|
||||
llarp::PubKey binaryPK;
|
||||
llarp::HexDecode(rcfname, binaryPK.data(), binaryPK.size());
|
||||
|
||||
llarp::LogInfo("Queueing job");
|
||||
llarp_router_lookup_job *job = new llarp_router_lookup_job;
|
||||
job->iterative = true;
|
||||
job->found = false;
|
||||
job->hook = &HandleDHTLocate;
|
||||
// llarp_rc_new(&job->result);
|
||||
job->target = binaryPK; // set job's target
|
||||
|
||||
// create query DHT request
|
||||
check_online_request *request = new check_online_request;
|
||||
request->ptr = ctx;
|
||||
request->job = job;
|
||||
request->online = false;
|
||||
request->nodes = 0;
|
||||
request->first = false;
|
||||
llarp_main_queryDHT(request);
|
||||
|
||||
llarp::LogInfo("Processing");
|
||||
// run system and wait
|
||||
llarp_main_run(ctx);
|
||||
}
|
||||
if(findMode)
|
||||
{
|
||||
llarp::LogInfo("Going online");
|
||||
llarp_main_setup(ctx);
|
||||
|
||||
llarp::LogInfo("Please find ", rcfname);
|
||||
std::string str(rcfname);
|
||||
|
||||
llarp::service::Tag tag(rcfname);
|
||||
llarp::LogInfo("Tag ", tag);
|
||||
|
||||
llarp::service::Address addr;
|
||||
str = str.append(".loki");
|
||||
llarp::LogInfo("Prestring ", str);
|
||||
bool res = addr.FromString(str.c_str());
|
||||
llarp::LogInfo(res ? "Success" : "not a base32 string");
|
||||
|
||||
// Base32Decode(rcfname, addr);
|
||||
llarp::LogInfo("Addr ", addr);
|
||||
|
||||
// uint64_t txid, const llarp::service::Address& addr
|
||||
// FIXME: new API?
|
||||
// msg->M.push_back(new llarp::dht::FindIntroMessage(tag, 1));
|
||||
|
||||
// I guess we may need a router to get any replies
|
||||
llarp::LogInfo("Processing");
|
||||
// run system and wait
|
||||
llarp_main_run(ctx);
|
||||
}
|
||||
if(localMode)
|
||||
{
|
||||
// FIXME: update llarp_main_getLocalRC
|
||||
// llarp::RouterContact *rc = llarp_main_getLocalRC(ctx);
|
||||
// displayRC(rc);
|
||||
// delete it
|
||||
}
|
||||
{
|
||||
if(rc.Read(rcfname))
|
||||
displayRC(rc);
|
||||
if(result.count("dump") > 0)
|
||||
{
|
||||
if(!dumpRc(result["dump"].as< std::vector< std::string > >(), json))
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(toB32Mode)
|
||||
catch(const cxxopts::OptionParseException& ex)
|
||||
{
|
||||
llarp::LogInfo("Converting hex string ", rcfname);
|
||||
std::string str(rcfname);
|
||||
|
||||
llarp::PubKey binaryPK;
|
||||
// llarp::service::Address::FromString
|
||||
llarp::HexDecode(rcfname, binaryPK.data(), binaryPK.size());
|
||||
char tmp[(1 + 32) * 2] = {0};
|
||||
std::string b32 = llarp::Base32Encode(binaryPK, tmp);
|
||||
llarp::LogInfo("to base32 ", b32);
|
||||
std::cerr << ex.what() << std::endl;
|
||||
std::cout << options.help() << std::endl;
|
||||
return 1;
|
||||
}
|
||||
if(toHexMode)
|
||||
{
|
||||
llarp::service::Address addr;
|
||||
llarp::Base32Decode(rcfname, addr);
|
||||
llarp::LogInfo("Converting base32 string ", addr);
|
||||
|
||||
// llarp::service::Address::ToString
|
||||
char ftmp[68] = {0};
|
||||
const char *hexname =
|
||||
llarp::HexEncode< llarp::service::Address, decltype(ftmp) >(addr, ftmp);
|
||||
|
||||
llarp::LogInfo("to hex ", hexname);
|
||||
}
|
||||
// it's a unique_ptr, should clean up itself
|
||||
// llarp_main_free(ctx);
|
||||
return 0; // success
|
||||
return 0;
|
||||
}
|
||||
|
@ -0,0 +1,19 @@
|
||||
ARG LOKINET_NETID=docker
|
||||
|
||||
FROM alpine:edge as builder
|
||||
|
||||
RUN apk update && \
|
||||
apk add build-base cmake git libcap-dev libcap-static libuv-dev libuv-static curl ninja bash binutils-gold
|
||||
|
||||
WORKDIR /src/
|
||||
COPY . /src/
|
||||
|
||||
RUN make NINJA=ninja STATIC_LINK=ON BUILD_TYPE=Release
|
||||
|
||||
FROM alpine:latest
|
||||
|
||||
COPY ./docker/compose/bootstrap.ini /root/.lokinet/lokinet.ini
|
||||
COPY --from=builder /src/build/lokinet .
|
||||
|
||||
CMD ["./lokinet"]
|
||||
EXPOSE 1090/udp 1190/tcp
|
@ -0,0 +1,76 @@
|
||||
# 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
|
||||
|
||||
# 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
|
@ -0,0 +1,59 @@
|
||||
version: '3.2'
|
||||
services:
|
||||
bootstrap-router:
|
||||
build:
|
||||
context: .
|
||||
dockerfile: docker/compose/bootstrap.Dockerfile
|
||||
image: bootstrap
|
||||
cap_add:
|
||||
- NET_ADMIN
|
||||
devices:
|
||||
- "/dev/net/tun:/dev/net/tun"
|
||||
ports:
|
||||
- target: 1090
|
||||
protocol: udp
|
||||
mode: host
|
||||
- target: 1190
|
||||
protocol: tcp
|
||||
mode: host
|
||||
volumes:
|
||||
- bootstrap-dir:/root/.lokinet/
|
||||
environment:
|
||||
- LOKINET_NETID=docker
|
||||
networks:
|
||||
testing_net:
|
||||
|
||||
router:
|
||||
depends_on:
|
||||
- bootstrap-router
|
||||
build:
|
||||
context: .
|
||||
dockerfile: docker/compose/router.Dockerfile
|
||||
image: router
|
||||
devices:
|
||||
- "/dev/net/tun:/dev/net/tun"
|
||||
ports:
|
||||
- target: 1090
|
||||
protocol: udp
|
||||
mode: host
|
||||
- target: 1190
|
||||
protocol: tcp
|
||||
mode: host
|
||||
cap_add:
|
||||
- NET_ADMIN
|
||||
volumes:
|
||||
- bootstrap-dir:/bootstrap/
|
||||
environment:
|
||||
- LOKINET_NETID=docker
|
||||
networks:
|
||||
testing_net:
|
||||
|
||||
volumes:
|
||||
bootstrap-dir:
|
||||
|
||||
networks:
|
||||
testing_net:
|
||||
ipam:
|
||||
driver: default
|
||||
config:
|
||||
- subnet: 172.28.0.0/16
|
@ -0,0 +1,19 @@
|
||||
ARG LOKINET_NETID=docker
|
||||
|
||||
FROM alpine:edge as builder
|
||||
|
||||
RUN apk update && \
|
||||
apk add build-base cmake git libcap-dev libcap-static libuv-dev libuv-static curl ninja bash binutils-gold
|
||||
|
||||
WORKDIR /src/
|
||||
COPY . /src/
|
||||
|
||||
RUN make NINJA=ninja STATIC_LINK=ON BUILD_TYPE=Release
|
||||
|
||||
FROM alpine:latest
|
||||
|
||||
COPY ./docker/compose/router.ini /root/.lokinet/lokinet.ini
|
||||
COPY --from=builder /src/build/lokinet .
|
||||
|
||||
CMD ["./lokinet"]
|
||||
EXPOSE 1090/udp 1190/tcp
|
@ -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=/bootstrap/self.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
|
@ -0,0 +1,13 @@
|
||||
#include <constants/limits.hpp>
|
||||
|
||||
namespace llarp
|
||||
{
|
||||
namespace limits
|
||||
{
|
||||
/// snode limit parameters
|
||||
const LimitParameters snode = {6, 60};
|
||||
|
||||
/// client limit parameters
|
||||
const LimitParameters client = {4, 6};
|
||||
} // namespace limits
|
||||
} // namespace llarp
|
@ -0,0 +1,26 @@
|
||||
#ifndef LLARP_CONSTANTS_LIMITS_HPP
|
||||
#define LLARP_CONSTANTS_LIMITS_HPP
|
||||
#include <cstddef>
|
||||
namespace llarp
|
||||
{
|
||||
namespace limits
|
||||
{
|
||||
/// Limits are a struct that contains all hard and soft limit
|
||||
/// parameters for a given mode of operation
|
||||
struct LimitParameters
|
||||
{
|
||||
/// minimum routers needed to run
|
||||
std::size_t DefaultMinRouters;
|
||||
/// hard limit on router sessions (by pubkey)
|
||||
std::size_t DefaultMaxRouters;
|
||||
};
|
||||
|
||||
/// snode limit parameters
|
||||
const extern LimitParameters snode;
|
||||
|
||||
/// client limit parameters
|
||||
const extern LimitParameters client;
|
||||
} // namespace limits
|
||||
} // namespace llarp
|
||||
|
||||
#endif
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue