Commit Graph

269 Commits

Author SHA1 Message Date
Jason Rhinelander 519a107542
Merge pull request #53 from jagerman/allow-disabling-werror
Allow disabling -Werror via a cmake option
2021-10-14 11:43:10 -03:00
Jason Rhinelander 23c2d537a3 Maybe fix macos tests? 2021-10-14 11:10:28 -03:00
Jason Rhinelander 6a386b7d4a Crank clang to 13
Also reformat and move things around a bit.
2021-10-14 11:00:25 -03:00
Jason Rhinelander 5e9b8c0948 Update catch2 to latest 2.x upstream
Should fix build issues with newer libc.
2021-10-13 20:35:37 -03:00
Jason Rhinelander 560d38d069 Allow disabling -Werror via a cmake option 2021-10-13 19:03:18 -03:00
Jason Rhinelander 504d0d10ea
Merge pull request #52 from jagerman/convert-iterators
Make (and use) iterator approach for encoding/decoding
2021-10-13 18:17:28 -03:00
Jason Rhinelander 7695e770a7 drone: quiet/optimize image setup 2021-10-05 12:27:53 -03:00
Jason Rhinelander 0d0ed8efa9 Fix r narrowing initialization warning when uint_fast16_t is small 2021-10-05 12:21:38 -03:00
Jason Rhinelander 02a542b9c6 Simplify iterator initialization & avoid warnings 2021-10-05 12:12:16 -03:00
Jason Rhinelander 9a8adb5bfd Add methods for unpadded base64 construction
The iterator has them; this adds wrapper methods to access them when not
using the iterator directly.
2021-10-01 18:53:05 -03:00
Jason Rhinelander ee1d69f333 Add b32z/b64 invalid garbage tests
Tests the new restricted added for b32z/b64 trailing crap.
2021-10-01 18:52:30 -03:00
Jason Rhinelander 24dd7a3854 Make (and use) iterator approach for encoding/decoding
This allows for on-the-fly encoding/decoding, and also allows for
on-the-fly transcoding between types without needing intermediate string
allocations (see added test cases for examples).
2021-10-01 18:23:29 -03:00
Jason Rhinelander cd56ad8e08 Expose size calculations; stricter b32z/b64 validity checking
- Add {to,from}_{base64,base32z,hex}_size functions to calculate the
  resulting output size from a given input size.

- Use it internally

- Make b32z and b64 validity checking slightly stricter: currently we
  "accept" some b32z and b64 strings that contain an extra character
  that leave us with 5-7 trailing bits (base32z) or 6 trailing bits
  (base64).  We simply ignore the extra one if decoding, but we
  shouldn't accept it in the "is valid" calls.
2021-10-01 17:54:03 -03:00
Jason Rhinelander 6100802f82
Merge pull request #48 from majestrate/boob-operator-overload-2021-09-24
add operator() overload for defered message that sends reply
2021-09-28 01:32:58 -03:00
Jason Rhinelander 7cb7c2fd6d
Merge pull request #46 from jagerman/bt_dict_producer
Bt dict producer
2021-09-28 01:32:48 -03:00
Jeff Becker 5a41e84378
add operator() overload for defered message that sends reply 2021-09-24 16:01:31 -04:00
Jason Rhinelander 377932607c Add const 2021-09-07 16:26:45 -03:00
Jason Rhinelander cdd21a9e81 Another workaround for crapple 2021-09-07 02:00:09 -03:00
Jason Rhinelander 977bced84e Apple workaround 2021-09-07 01:16:38 -03:00
Jason Rhinelander 9e3469d968 Add allocation-free bt-list and bt-dict producer
This should allow for b-encoding with better performance and less memory
fragmentation.

Documentation and test suite show how it's used.
2021-09-07 01:12:47 -03:00
Jason Rhinelander f12a48a195 Remove ancient dead code
I don't remember why this was here.
2021-09-06 21:48:56 -03:00
Jason Rhinelander e1b1a84c4b
Merge pull request #45 from jagerman/return-final-out-it
Make {to,from}_{hex/b64/b32} return output iterator
2021-08-20 16:27:25 -03:00
Jason Rhinelander 2ac4379fa6 Make {to,from}_{hex/b64/b32} return output iterator
Changes the 3-iterator versions of to_hex, from_b32z, etc. to return the
final output iterator, which allows for much easier in-place "from"
conversion without needing a new string by doing something like:

    std::string data = /* some hex */;
    auto end = oxenmq::from_hex(data.begin(), data.end(), data.begin();
    data.erase(end, data.end());

Returning from the "to" converters is a bit less useful but doing it
anyway for consistency (and because it could still have some use, e.g.
if output is into some fixed buffer it lets you determine how much was
written).
2021-08-20 16:08:33 -03:00
Jason Rhinelander ae884d2f13 Fix backwards logic on overlapping ranges comment 2021-08-20 15:45:03 -03:00
Jason Rhinelander 45f358ab5f Remove debugging 2021-08-13 20:05:21 -03:00
Jason Rhinelander c6ae1faefa Downgrade "worker waiting for" log message to trace 2021-08-06 15:21:07 -03:00
Jason Rhinelander 719d33f1cc
Merge pull request #43 from jagerman/inproc
Add support for inproc: connections
2021-08-04 21:21:44 -03:00
Jason Rhinelander f553085558 Add support for inproc: requests
inproc support is special in zmq: in particular it completely bypasses
the auth layer, which causes problems in OxenMQ because we assume that a
message will always have auth information (set during initial connection
handshake).

This adds an "always-on" inproc listener and adds a new `connect_inproc`
method for a caller to establish a connection to it.

It also throws exceptions if you try to `listen_plain` or `listen_curve`
on an inproc address, because that won't work for the reasons detailed
above.
2021-08-04 20:15:16 -03:00
Jason Rhinelander bae71ec6a8 Another apple time fix attempt 2021-08-04 20:15:00 -03:00
Jason Rhinelander 29cd543af9
Merge pull request #44 from jagerman/apple-test-tweaks
Tweak test timers to deal with Apple's shitty thread scheduling
2021-08-04 20:02:59 -03:00
Jason Rhinelander 917c7d64c5 Apple test suite hacks
Because macOS is really slow.
2021-08-04 19:54:17 -03:00
Jason Rhinelander 4a24ac9baa Update bundled zeromq download version 2021-08-04 19:40:54 -03:00
Jason Rhinelander e1d21d3faf Tweak test timers to deal with Apple's shitty thread scheduling 2021-08-04 17:48:53 -03:00
Jason Rhinelander 1d2246cda8 Remove debug 2021-07-01 01:08:32 -03:00
Jason Rhinelander 3bb32a81ff
Merge pull request #42 from jagerman/fix-backmsg-connid
Fix return messages on SN connections
2021-07-01 01:00:19 -03:00
Jason Rhinelander 9e0d2e24f6 Add a single container version of `send_option::data_parts`
`send_option::data_parts(mycontainer)` is now a shortcut for
`send_option::data_parts(mycontainer.begin(), mycontainer.end())`.
2021-07-01 00:39:35 -03:00
Jason Rhinelander 4a6bb3f702 Fix messages coming back on an outgoing connection
The recent PR that revamped the connection IDs missed a case when
connecting to service nodes where we store the SN pubkey in peers, but
then fail to find the peer when we look it up by connection id.

This adds the required tracking to fix that case (and adds a test that
fails without the fix here).
2021-07-01 00:37:55 -03:00
Jason Rhinelander ad04c53c0e
Simplify conn index handling (#41)
The existing code was overly complicated by trying to track indices in
the `connections` vector, which complication happening because things
get removed from `connections` requiring all the internal index values
to be updated.  So we ended up with a connection ID inside the
ConnectionID object, plus a map of those connection IDs to the
`connections` index, and need a map back from indices to ConnectionIDs.

Though this seems to work usually, I recently noticed an
oxen-storage-server sending oxend requests on the wrong connection and
so I suspect there is some rare edge cases here where a failed
connection index might not be updated properly.

This PR simplifies the whole thing by making getting rid of connection
ids entirely and keeping the connections in a map (with connection ids
that never change).  This might end up being a little less efficient
than the vector, but it's unlikely to matter and the added complexity
isn't worth it.
2021-06-23 17:51:25 -03:00
Jason Rhinelander 7ba81a7d50
Merge pull request #40 from jagerman/dynamic-listen
Add support for listening on a new port after start()
2021-06-23 14:06:37 -03:00
Jason Rhinelander 45db87f712 Fix uninitialized value in post-start listen test 2021-06-23 14:04:16 -03:00
Jason Rhinelander a0642a894e Miscellaneous small test suite fixes/improvements
- Allow up to 200ms (instead of 100ms) for the things we are waiting on
to become available, to prevent occasional spurious failures.
- Add unscoped info for how long we waited.
- Avoid calling into oxenmq with the catch lock held in the "hey google"
tests (because this will deadlock if the oxenmq call invokes any
logging).
- Replace an old std::cerr logger with the updated catch2 logger.
2021-06-23 10:55:47 -03:00
Jason Rhinelander 5dd7c12219 Add support for listening after startup
This commit adds support for listening on new ports after startup.  This
will make things easier in storage server, in particular, where we want
to delay listening on public ports until we have an established
connection and initial block status update from oxend.
2021-06-23 10:51:08 -03:00
Jason Rhinelander dccbd1e8cd Loki->Oxen rebrand the README 2021-06-08 10:57:39 -03:00
Jason Rhinelander 780246858f Add `is_unsigned_integer` to bt_{dict,list}_consumer
Also adds missing consume_dict_consumer/consume_list_consumer to
bt_list_consumer to match the bt_dict_consumer interface.
2021-06-08 00:58:20 -03:00
Jason Rhinelander 0287f7834e Minor doc fix 2021-06-02 13:16:19 -03:00
Jason Rhinelander cdc6a9709c Add thread-safe timerid assignment version of add_timer()
I realized after merging the previous PR that it is difficult to
correctly pass ownership into a timer, because something like:

    TimerID x = omq.add_timer([&] { omq.cancel_timer(x); }, 5ms);

doesn't work when the timer job needs to outlive the caller.  My next
approach was:

    auto x = std::make_shared<TimerID>();
    *x = omq.add_timer([&omq, x] { omq.cancel_timer(*x); }, 5ms);

but this has two problems: first, TimerID wasn't default constructible,
and second, there is no guarantee that the assignment to *x happens
before (and is visible to) the access for the cancellation.

This commit fixes both issues: TimerID is now default constructible, and
an overload is added that takes the lvalue reference to the TimerID to
set rather than returning it (and guarantees that it will be set before
the timer is created).
2021-05-25 17:29:25 -03:00
Jason Rhinelander 3991f50547 Bump project version in dev branch (for next release) 2021-05-23 10:36:44 -03:00
Jason Rhinelander 26745299ed Add timer cancellation & timer tests
Updates `add_timer` to return a new opaque TimerID object that can later
be passed to `cancel_timer` to cancel an existing timer.

Also adds timer tests, which was omitted (except for one in the tagged
threads section), along with a new test for timer deletion.
2021-05-20 22:05:58 -03:00
Jason Rhinelander 4ef1060e3f
Merge pull request #36 from jagerman/optional-send-parts
Add support for std::optional<T> send arguments
2021-04-20 14:06:16 -03:00
Jason Rhinelander 5ccacafdb1 Add support for std::optional<T> send arguments
If the optional is set it gets applied as if you specified the `T` in
the send(...), if unset it works as if you didn't specify the argument
at all.
2021-04-20 13:54:42 -03:00