Storage server for Oxen Service Nodes
Go to file
Jason Rhinelander 69d3e8c380 Stats cleanup and refactor
Refactors how stats are collected:

- Keeping a rolling window of recent stats for every 10 minutes over the
past hour so that when we rotate stats, we only chop off the 1h10min-1h
counts, but always have a recent stats counter that reflects the last
~1h of requests.

- Move the stats cleanup timer into the stats class itself

- Make the all_stats class properly thread safe.  Previously *parts* of
it were thread safe but much of it wasn't, so really wasn't safe to be
used without holding the owning service_node's global lock.

- Fix various bugs in the stats values:
    - "reset_time" was never updated, but even if it had been, it was a
    steady_clock and being returned as time_since_epoch() which is a
    useless value.

    - recent_retrieve_requests wasn't being set at all in the returned
    json (instead recent_store_requests was set twice).

    - onion requests weren't being counted at all; instead every onion
    request bumped the proxy request counter

- Got rid of exposing "current period" stats: instead we now just expose
the recent request counters, which are calculated from current period +
stored historic period values, thus giving you a count for requests over
the last 1h5m (±5 minutes).

- Replace time_t with modern time types

- Don't indent/prettify json; in any case where you'd actually want it
this is much better done via tools like `jq`.
2021-06-16 18:59:06 -03:00
.github/ISSUE_TEMPLATE Update issue templates 2019-04-17 13:46:28 +10:00
.vscode check the difficulty every 10 mins 2019-06-06 17:13:17 +10:00
cmake Convert unit tests to Catch2 2021-06-16 18:59:06 -03:00
common Improve logging output 2021-06-16 18:59:06 -03:00
contrib Add direction to xchacha20 shared key 2021-04-21 21:31:39 -03:00
crypto Move parse_pubkey into oxend_key 2021-06-16 18:59:06 -03:00
httpserver Stats cleanup and refactor 2021-06-16 18:59:06 -03:00
storage Improve logging output 2021-06-16 18:59:06 -03:00
unit_test Convert unit tests to Catch2 2021-06-16 18:59:06 -03:00
utils oops 2021-06-16 18:58:53 -03:00
vendors Remove boost beast & many intertwined changes 2021-06-16 18:59:06 -03:00
.clang-format Run clang-format 2019-03-19 14:47:55 +11:00
.dockerignore docker support 2019-04-26 10:35:05 +00:00
.drone.jsonnet Build and run tests everywhere 2021-04-25 20:16:12 -03:00
.gitignore Ignore swapfiles and reject localhost binding 2019-07-25 13:12:44 +10:00
.gitmodules Add check for up-to-date submodules 2021-06-16 18:59:06 -03:00
CMakeLists.txt Add check for up-to-date submodules 2021-06-16 18:59:06 -03:00
Dockerfile Allow http in onion requests to an external server 2021-03-29 17:28:34 +11:00
LICENSE Add MIT license 2018-11-16 02:04:02 +11:00
Makefile No longer require POW for message storage 2021-03-26 12:01:47 +11:00
mock_lokid.py Always strip the 05 from start of client request pubkeys 2019-03-28 15:33:41 +11:00
README.md Add static build capability to cmake 2021-01-13 15:19:22 -04:00

loki-storage-server

Storage server for Loki Service Nodes

Requirements:

  • Boost >= 1.66 (for boost.beast)
  • OpenSSL >= 1.1.1a (for X25519 curves)
  • sodium >= 1.0.17 (for ed25119 to curve25519 conversion)

You can, however, download and build static versions these dependencies as part of the build by adding the -DBUILD_STATIC_DEPS=ON option to cmake.

Can use RelWithDebInfo instead of Release if you want to include debug symbols to provide developers with valueable core dumps from crashes. Also make sure you don't have an older (than 4.3.0) libzmq header in /usr/local/include, if so please install a new version.

git submodule update --init --recursive
mkdir build && cd build
cmake -DDISABLE_SNODE_SIGNATURE=OFF -DCMAKE_BUILD_TYPE=Release ..
cmake --build .
./loki-storage 0.0.0.0 8080

The paths for Boost and OpenSSL can be specified by exporting the variables in the terminal before running make:

export OPENSSL_ROOT_DIR = ...
export BOOST_ROOT= ...

Then using something like Postman (https://www.getpostman.com/) you can hit the API:

post data

HTTP POST http://127.0.0.1/store
body: "hello world"
headers:
- X-Loki-recipient: "mypubkey"
- X-Loki-ttl: "86400"
- X-Loki-timestamp: "1540860811000"
- X-Loki-pow-nonce: "xxxx..."

get data

HTTP GET http://127.0.0.1/retrieve
headers:
- X-Loki-recipient: "mypubkey"
- X-Loki-last-hash: "" (optional)

unit tests

mkdir build_test
cd build_test
cmake ../unit_test -DBOOST_ROOT="path to boost" -DOPENSSL_ROOT_DIR="path to openssl"
cmake --build .
./Test --log_level=all