Commit graph

1300 commits

Author SHA1 Message Date
Jason Rhinelander c97971c419
Add test case for multi-sub request 2022-08-11 22:48:14 -03:00
Jason Rhinelander a60a07f6dd
Allow subscribing to multiple pubkeys at once
The PN server potentially needs to subscribe to many addresses at once;
this allows it to do so in a single request rather than needing many
separate small requests.
2022-08-11 22:48:14 -03:00
Jason Rhinelander f8900e572f
Add testnet network tests for monitoring endpoint 2022-08-11 22:48:13 -03:00
Jason Rhinelander f402017baa
Message monitoring
This PR adds endpoints to storage server that allows someone to maintain
a oxenmq connection to one or more swarm members and receive pushed
notifications through that connection when new messages are delivered.

This is authenticated: subscribing requires a signature from the mailbox
owner signed within the past 14 days, and connections have to be
refreshed at least once/hour to keep the push notifications alive.

The immediate use for this will be for more efficient push notifications
for mobile clients using the push notification server, but this
mechanism will eventually also allow clients (over lokinet) to get
messages pushed to them rather than having to frequently poll.
2022-08-11 22:45:40 -03:00
Jason Rhinelander a682570aed
Bump oxenc for bt_dict_producer fix 2022-08-11 22:42:30 -03:00
Jason Rhinelander f94f7df9dd
Merge pull request #460 from jagerman/nearest-swarm-fixes
Nearest swarm fixes, ip update fixes & optimizations
2022-08-11 22:41:14 -03:00
Jason Rhinelander b346c7f55d
Merge pull request #461 from darcys22/subkey-tag-revocation
Add subkey tag revocation
2022-08-11 22:38:17 -03:00
Sean Darcy ad9fd5d3c2 Revoking Subkeys
This adds a new endpoint to the storage server to revoke a subkey. The
storage server will keep track of previously revoked subkeys and will
now check that a message authenticated by a subkey does not use one of
these revoked subkeys.
2022-08-12 11:22:51 +10:00
Jason Rhinelander 06490d966f
Remove unused function 2022-07-28 17:18:51 -03:00
Jason Rhinelander cbfd8f1ba0
Formatting 2022-07-28 17:08:06 -03:00
Jason Rhinelander 3b7e1b43ee
Fix broken nearest-swarm logic & optimizations
The nearest-swarm logic was rather broken when handling ids in the
wrapping space (i.e. > max swarm id or < min swarm id).  This fixes the
issues, as well as optimizing it.

Issues:
- all the wrapped-around values trying to compute distances were off by
  *2*:
  - The first off-by-one was because, even though swarm ids cannot be ==
    max-u64, swarm space values (from pubkeys) *can* be, so all the
    logic trying to make it wrap at MAX_SWARM_ID was invalid.
  - The wrapping at MAX_SWARM_ID was *also* wrong because, even ignoring
    the above point, distances are % (MAX_SWARM_ID+1), not %
    (MAX_SWARM_ID).
- Because of the above, a session ID that maps to 0xff..ff in swarm
  space would compute the distance to swarm_id 0 as max-u64 and thus
  always go to the top swarm_id, even when 0xff..fe would map to
  swarm_id 0.
- Values in the space between 0 and the minimum swarm id were rounding
  to the *right* side node, while everything else rounds to the left
  edge.

All of this is due to bad logic and insufficient test cases that
unfortunately was not properly reviewed when originally added to storage
server.

This commit changes the behaviour.  This means old and new nodes *will*
slightly disagree for a couple of edge cases:
- we *do* have a swarm 0 on mainnet, so a session id that maps to
  exactly 0xff..ff will break while the network has mixed versions.
  This, however, is extremely rare (~1 in 2^64), and so is unlikely to
  matter in practice.
- Values in the [0, lowest_swarm_id) that are exactly at the midpoint
  change to now prefer the left node (highest_swarm_id) rather than the
  right (lowest_swarm_id).  This makes it consistent with the other
  cases.  On mainnet, however, this case doesn't actually exist between
  lowest_swarm_id equals 0.

This also changes the code to use a binary search, rather than linear
scan, because swarms are guaranteed to be sorted.  This also
significantly simplifies the code.  The linear scan was just
unoptimized.
2022-07-28 15:59:39 -03:00
Jason Rhinelander 6a498d7362
Fix and optimize swarm replacement
Swarm replacement had a bug in updating IPs: it would try to *preserve*
the IP from the old data when loading new swarm data.

This was completely wrong: it meant we would refuse IP changes, which
would almost certainly lead to storage server connectivity problems when
an IP changes.

This fixes it to only preserve IP/port data *if* the new data has it as
0s (which could happen if, for example, oxend is resyncing and hasn't
received proofs yet, but we got an initial data from a bootstrap node).

The code path was also rather inefficient with multiple unnecessary
vector copies, and an oversived map allocation.

There was yet another oddity where we were returning a reference to a
dummy value, rather than returning a nullptr on failure; this changes it
to be a nullable pointer instead (which also cascaded into returning an
optional swarm where that pointer was being used).
2022-07-28 15:53:20 -03:00
Jason Rhinelander 9905f6bea2
Remove debugging 2022-07-28 15:48:53 -03:00
Jason Rhinelander e06f380d3e
Bump version 2022-07-22 17:30:17 -03:00
Jason Rhinelander 86ad074cfc
Merge pull request #458 from jagerman/subkey-ttl-extension
Subkey auth for expiry extension; failable delete_msgs
2022-07-22 17:29:47 -03:00
Jason Rhinelander 1a1b143f97
Allow subkey authentication for expiry extension
Allows subkey authentication for the `expire` endpoint; if using a
subkey, expiries can be extended but not shortened (so that you can't
misuse expiry to delete messages prematurely).
2022-07-22 15:47:21 -03:00
Jason Rhinelander 93bab08f44
Fix "swarms" -> "swarm" typo in rpc docs 2022-07-22 15:47:21 -03:00
Jason Rhinelander cc57cbf77c
Formatting: use short typedefs for load_fields
The `load_fields` calls using a ton of vertical space because of the
long list of type names; this adds some short typedefs to significantly
shorten them and make the formatted code much smaller.
2022-07-22 15:47:21 -03:00
Jason Rhinelander a0976b04a7
Miscellaneous network test fixes
- test_expire was broken by expiry extensions (it assumed they wouldn't
  get updated).
- a test_ifelse test was broken by the testnet reboot
2022-07-22 15:47:21 -03:00
Jason Rhinelander 3f6a1cf396
Add failable delete_msgs
Adding `"required": true` to the delete_msgs request tells SS to return
a 404 if no swarm members found anything to delete, allowing chaining
into a sequence to only proceed if a message got deleted.
2022-07-22 15:47:20 -03:00
Jason Rhinelander a2a515d28c
Remove spdlog from up-to-date submodule check 2022-07-22 15:47:05 -03:00
Jason Rhinelander 53fee5689b
Remove now-unused spdlog submodule
spdlog comes via oxen-logging now
2022-07-22 15:22:20 -03:00
Jason Rhinelander 20d3d043ef
Merge pull request #457 from jagerman/remove-cruft
Remove cruft
2022-07-21 11:55:18 -03:00
Jason Rhinelander 2fea350b99
Remove obsolete cruft
- Removes HTTPS storage test and obsolete ping endpoint
- Removes monero signature code
- Removes now-unused "dev sink" header
- Remove pre-HF19 namespace-0 forcing
- Remove docs about pre-HF19 behaviour
2022-07-19 19:25:36 -03:00
Jason Rhinelander da050cb60b
Merge pull request #456 from jagerman/oxen-logging
Convert to oxen-logging's logger implementation
2022-07-19 13:42:36 -03:00
Jason Rhinelander 56b2928a78 Convert to oxen-logging's logger implementation
This isn't too bad because oxen-storage was already using spdlog, but
does improve things and makes us consistent with upcoming core/lokinet.
2022-07-19 13:18:43 -03:00
Jason Rhinelander d44fa2260c
Merge pull request #454 from jagerman/jemalloc
Fix missing jemalloc linking
2022-07-19 12:54:03 -03:00
Jason Rhinelander ab8bdb2a6c
Fix missing jemalloc linking
The 2.3.0 code refactor accidentally dropped linking against jemalloc,
and as a result memory usage is much higher.

This restores it.
2022-06-14 12:48:34 -03:00
Jason Rhinelander 4a84d77dfc
Merge pull request #453 from jagerman/static-build-fixes
Static build fixes
2022-06-01 22:15:29 -03:00
Jason Rhinelander 57457741e6
Set BUILD_SHARED_LIBS OFF for static submodule libs 2022-06-01 21:56:33 -03:00
Jason Rhinelander 7321143931
Fix binary path for static libs check 2022-06-01 19:19:14 -03:00
Jason Rhinelander 3d8db3a274
Merge pull request #452 from jagerman/prefer-system-libs
Prefer system libs
2022-05-30 16:36:57 -03:00
Jason Rhinelander 670d643dd0
Add oxen repo for updated cmake for bionic build 2022-05-30 15:45:59 -03:00
Jason Rhinelander ad3cf01bee
Fix VERSIONTAG generation
storage-server has a bug where the git tag is only regenerated when
cmake runs, but not when the git index changes.

Import the code to do this properly from lokinet, and rename it from
SHORT_HASH -> VERSIONTAG to be consistent.
2022-05-30 15:24:59 -03:00
Jason Rhinelander e017637351
Rework build version handling
- Allow an external OXENSS_SHORT_HASH to override the version (which
  lets us drop a patch to do this from the debs)
- Remove the build time from the version.cpp because that is a bad idea
  in general that makes builds non-reproducible.
2022-05-30 15:24:58 -03:00
Jason Rhinelander 2cac91b92f
Prefer sys libs for nlohmann/cli11/spdlog; clean up sys/submodule handling
Also add some missing oxenc::oxenc deps.

Bump oxenmq to fixed/retagged 1.2.12 that is happier with life as a
submodule.
2022-05-30 15:24:47 -03:00
Jason Rhinelander 7d065a6510
Merge pull request #451 from jagerman/big-retrieves
Big retrieves
2022-05-30 11:23:51 -03:00
Jason Rhinelander 36d367b383
Dep updates
- curl 1.83.1
- oxenmq 1.2.12
- oxenc 1.0.3
2022-05-30 11:22:33 -03:00
Jason Rhinelander edfd0ac684
Add network test for large retrieve requests 2022-05-26 23:53:43 -03:00
Jason Rhinelander b2eb1bce93
formatting 2022-05-26 22:07:14 -03:00
Jason Rhinelander 420950fb88
Add "more" to retrieve response
Lets the requester know that we hit the count/size limit before
including everything.
2022-05-26 20:15:41 -03:00
Jason Rhinelander d0f81c7b35
Add size limits to retrieve messages 2022-05-26 20:15:41 -03:00
Jason Rhinelander 13ef30b5a6
Merge branch 'v230-rc' into dev 2022-05-25 22:34:39 -03:00
Jason Rhinelander 0fc91aa855
Update static dep versions 2022-05-25 22:33:47 -03:00
Jason Rhinelander afa245d215
Bump version to 2.3.0
Release candidate, for testing.  This may or may not end up as the final
2.3.0 release.
2022-05-10 17:11:59 -03:00
Jason Rhinelander 6e840fb37b
Update static dep versions 2022-05-10 17:11:58 -03:00
Jason Rhinelander 5dc63b71ad
Merge pull request #449 from darcys22/rpc-ping-pubkey
Adds ed25519 pubkey to oxend pings
2022-05-10 17:11:05 -03:00
Sean Darcy 541ee9331d
Adds ed25519 pubkey to oxend pings
This will allow the oxend to verify the pubkey when pings are received
and reject the ping if they are wrong.

The reason this causes issues is that storage server only receives the
snode keys on startup and if oxend is restarted without restarting
storage server then it could end up running with the wrong keys.

If oxend instead rejects the pings and stops sending uptime proofs then
the operator will know that something needs attention and can restart
the storage server.
2022-05-10 17:09:26 -03:00
Jason Rhinelander 33a287a5b0
Merge pull request #448 from jagerman/namespace-part2
Batching; subkey auth; more namespace work
2022-05-10 16:35:00 -03:00
Jason Rhinelander f43c2b3b00
Allow extending expiry (up to TTL from now)
This removes the restriction on updating message expiries that only
allowed shortening, but not extending, expiries.

With this change, a client can renew its own messages indefinitely as
long as it continually re-renews within 14 days of the last renewal.
2022-05-10 16:08:21 -03:00