Commit graph

175 commits

Author SHA1 Message Date
Stephen Seo 136c8b21a5 Fix verification message when using libsodium
Previous implementation had the client send only epoch-time-in-seconds
to be signed by the server. Now the client sends random data and
epoch-time to be signed by the server.
2020-01-15 16:31:38 +09:00
Stephen Seo 83392fc916 Fix doxygen documentation 2020-01-13 19:22:08 +09:00
Stephen Seo b41639c568 Set pointers to const where possible in API 2020-01-10 20:28:08 +09:00
Stephen Seo f588d409c9 Truncate "UDPConnection" to "UDPC" 2020-01-09 16:57:01 +09:00
Stephen Seo 40c4c9b2ba Fix potential non-null-terminated string bug 2020-01-09 16:45:57 +09:00
Stephen Seo 4d68715efb Add more documentation, some fixes 2020-01-08 20:50:56 +09:00
Stephen Seo 4c48dbb0cf Replace TSLQueue with std::deque where possible
Also added std::mutex for each new std::deque. cSendPkts is left as a
TSLQueue because it needs to support fast removal from the middle of the
data structure (mainly because the queued packets per ConnectionData has
an imposed limit of packets to hold).
2020-01-08 19:55:12 +09:00
Stephen Seo e66e6c7b74 Minor fix to keysSet atomic_bool 2020-01-05 16:05:22 +09:00
Stephen Seo e644cd86b1 Minor fixes 2020-01-05 15:39:25 +09:00
Stephen Seo 88ba670ce9 Fix usage of atomic_bool "keysSet" 2020-01-05 15:31:37 +09:00
Stephen Seo 1ecf9bff4f Minor refactoring/fix of use of atomic_bool 2020-01-05 15:12:13 +09:00
Stephen Seo 5c8480e5bc Refactor locking mutex during update 2020-01-05 15:05:23 +09:00
Stephen Seo 7996bd5c36 Client on connect fail now returns FAIL_CONNECT
Previously, returned event was DISCONNECT. FAIL_CONNECT is a new event
enum value.
2020-01-05 14:49:37 +09:00
Stephen Seo 3ade637205 Client now regenerates verif-time on con attempt 2020-01-05 14:42:57 +09:00
Stephen Seo 42fde9a2d0 Implement publickey whitelist (using libsodium)
Renamed "mutex" to "conMapMutex" since it is mainly used to lock access
to the connection map.

Removed UDPC_client_initiate_connection_pk() as publickey whitelisting
replaces its functionality.
2020-01-02 20:54:32 +09:00
Stephen Seo 26e8b95d94 Add verification of verification time server-side
Verification string is no longer a string but seconds since epoch.
2020-01-02 16:33:17 +09:00
Stephen Seo db2c3fed97 Change: libsodium verification now on full packet 2020-01-02 13:12:40 +09:00
Stephen Seo 89bdc7e9ca Fix copying over data of received packet 2019-12-30 14:16:05 +09:00
Stephen Seo 1a39039065 Fix received packet storing unnecessary header
Added rtt (uint16_t) to UDPC_PacketInfo.
2019-12-27 13:35:28 +09:00
Stephen Seo fdd57bc538 Minor additions/fixes to doxygen-style docs 2019-12-22 22:50:50 +09:00
Stephen Seo 1af44db109 Minor refactorings
UDPC_update now locks the mutex to keep it thread-safe.
2019-12-19 11:39:34 +09:00
Stephen Seo ffcc30bc64 Minor fixes 2019-12-18 14:34:53 +09:00
Stephen Seo 4b36d05ccc Minor fixes, improvements
When UDPC_ConnectionId is initialized, all of its bytes are now zeroed
out.
2019-12-18 14:20:29 +09:00
Stephen Seo 5ec344b733 Add way to get connection queued size
Requires locking the mutex for access to conMap.
2019-12-18 13:47:46 +09:00
Stephen Seo 62ac6e779f Bug fixes
Fixed not setting output int to 0 to specify zero connections when
returning connection IDs.
2019-12-17 20:58:44 +09:00
Stephen Seo dbdade3b00 Impl disc. request (untested), del make_unique 2019-12-17 20:05:56 +09:00
Stephen Seo a4efd98890 Replace "poor man's optional" with std::unique_ptr 2019-12-17 19:12:54 +09:00
Stephen Seo aa59777f99 Fix create_id_easy not parsing ipv4 addr correctly 2019-12-17 12:52:10 +09:00
Stephen Seo ece17e1aca Drop support from C++17 to C++11
std::optional replaced with Entry in TSLQueue (which is basically a poor
man's optional).
2019-12-11 20:00:48 +09:00
Stephen Seo 7c444cb460 Impl auth-policy for handling with(out) auth 2019-12-09 21:27:58 +09:00
Stephen Seo d94b44e4de More documentation, fix constants to be #define'd 2019-12-06 20:49:30 +09:00
Stephen Seo 6742e06596 More work on Doxygen style documentation 2019-12-04 13:08:30 +09:00
Stephen Seo feb859d745 Begin doxygen-style documentation WIP 2019-11-27 20:26:40 +09:00
Stephen Seo 69256839ac Minor fixes/refactorings 2019-11-27 20:12:57 +09:00
Stephen Seo 04fa5ca017 Add is_valid_context(), fixes/refactorings 2019-11-27 19:47:51 +09:00
Stephen Seo 8d1dbead20 Add set_libsodium_key_easy(), fixes/refactorings 2019-11-27 19:41:38 +09:00
Stephen Seo 6b14d86822 Fixes for setting pub/sec keys
Added more to NetworkTest to test new changes.
2019-11-21 15:15:05 +09:00
Stephen Seo c24273ea65 Add unset_libsodium_keys()
Still untested
2019-11-21 12:23:40 +09:00
Stephen Seo 240ed9821f Add set peer_pk, sk/pk, start/stop threaded update
Note, this code is UNTESTED.
2019-11-19 20:55:20 +09:00
Stephen Seo 4cfe35ecd1 libsodium support is now optional
Packet struture has been changed to support UDPC without libsodium
sending packets to UDPC with libsodium.
2019-11-18 17:37:03 +09:00
Stephen Seo f2b4672318 Add way to specify sleep time for threaded update 2019-11-13 14:06:48 +09:00
Stephen Seo f9e1bca4c1 Add UDPC_create_id_easy
UDPC_create_id_easy will detect if the input addr string is link local
or not, and will create the ipv6 address based on it.
2019-11-13 12:15:12 +09:00
Stephen Seo 90b36e3061 Convert NetworkTest to C from C++ 2019-11-13 11:47:53 +09:00
Stephen Seo 7b5cf3b6f8 Add events, refactorings
Added event system to lessen the use of the main mutex and instead use
thread safe data structures (TSLQueue). Also can enable and check events
during execution (connect, disconnect, good mode, bad mode).

Fixes and refactorings.
2019-11-11 16:08:51 +09:00
Stephen Seo d86b7e4e1d Fix use of addr/socket types 2019-11-11 13:37:51 +09:00
Stephen Seo 00c1be07dc Replace c_impl, remove rust_binding, with cpp_impl 2019-11-11 13:08:36 +09:00
Stephen Seo 1eed614ded Add buildgen rust binding 2019-04-17 15:15:53 +09:00
Stephen Seo a33004a4c9 Add function to drop connection to specific addr
Also added minor note about ctx->idMap
2019-04-17 15:15:19 +09:00
Stephen Seo 537fef9e8a Fix prepare_pkt function 2019-03-12 14:28:28 +09:00
Stephen Seo bf3f3c334e Fix server ignoring first packet from client 2019-03-12 14:11:22 +09:00
Stephen Seo 78db1a58c7 Add HashMap keyed by id for quick id lookups 2019-03-12 13:49:14 +09:00
Stephen Seo 05ece7c626 Fix UDPC destruct order when using thread 2019-03-07 12:16:03 +09:00
Stephen Seo c82fd10470 Fix mutex lock not being unlocked 2019-03-07 12:10:53 +09:00
Stephen Seo 1c24cc9311 Change isThreaded flag to be separate int 2019-03-07 12:01:21 +09:00
Stephen Seo 50f105ecfb Add get/set protocol id capability 2019-03-07 11:57:06 +09:00
Stephen Seo 44d1be6a23 Minor doc fix 2019-03-06 21:51:09 +09:00
Stephen Seo 1e5175d0d1 Fix const error strings 2019-03-06 21:50:13 +09:00
Stephen Seo 767e96e227 Add more documentation 2019-03-06 20:34:24 +09:00
Stephen Seo fe13c407ba Add more documentation 2019-03-06 20:31:23 +09:00
Stephen Seo 97cbe37545 Add get/set accept-new-connections fn
Fix some functions not using mutex when threaded update is enabled.
2019-03-06 20:13:38 +09:00
Stephen Seo 2bd2e868b2 Change UDPConnection to set listen address
Add some documentation, fix NetworkTest with new change.
2019-03-06 19:53:15 +09:00
Stephen Seo 71fd812137 Minor fix to NetworkTest 2019-03-06 13:49:56 +09:00
Stephen Seo 4be79ace7c Fix received callback, minor change to NetworkTest 2019-03-06 13:39:54 +09:00
Stephen Seo aab8cfe407 Fix threaded update 2019-03-05 12:56:05 +09:00
Stephen Seo 0ff6bd13a7 Change NetworkTest to exit after disconnect 2019-03-05 12:11:57 +09:00
Stephen Seo 6597b552a7 Fix memory leaks 2019-03-05 12:07:03 +09:00
Stephen Seo 96bc9caf92 More fixes to UDPConnection 2019-03-04 19:28:05 +09:00
Stephen Seo d35f081585 Fix new connections not being created 2019-03-04 19:17:55 +09:00
Stephen Seo f8950fa08e Fix endianness of addr, minor fixes 2019-03-04 19:05:07 +09:00
Stephen Seo 9134079b8d More fixes 2019-03-04 18:17:28 +09:00
Stephen Seo aa094224bc Fix NetworkTest 2019-03-04 17:56:40 +09:00
Stephen Seo ec9c3399bf Fixes to NetworkTest 2019-03-04 17:48:32 +09:00
Stephen Seo da9bd55e06 Add check for no pkt received (non-blocking) 2019-03-04 15:27:01 +09:00
Stephen Seo d38c7ac105 Add NetworkTest executable
To be used to debug UDPConnection.
2019-03-04 15:20:22 +09:00
Stephen Seo 89afc58bc7 Add UDPC_strtoa 2019-03-04 15:05:21 +09:00
Stephen Seo 4776a2f202 More impl of UDPConnection
Add client initiate connection.
2019-03-04 15:04:16 +09:00
Stephen Seo 0f1e9c9aed Use locks on check_events for threaded case 2019-03-04 11:40:34 +09:00
Stephen Seo 3b4ae6e7dd Add resendPktQueue to struct in UDPConnection
Resending packets now put in higher priority queue in ConnectionData; if
queued both regular packet and resending packet, resending packets are
sent first.
2019-03-04 11:32:44 +09:00
Stephen Seo d6f5653048 Fixes/improvements to UDPConnection, still WIP
Need to implement threaded update properly.
2019-02-21 15:40:30 +09:00
Stephen Seo 29e3940c14 Add push_..._realloc to Deque 2019-02-21 12:34:35 +09:00
Stephen Seo 69edca40f8 Impl add to send-queue and recv callbacks, WIP
Still not finished, need to set up the thread to send queued packets and
receive packets safely.

Also need to add to Deque (see TODO comment).
2019-02-20 15:13:57 +09:00
Stephen Seo 629abf6d8e Fix error log message 2019-02-19 13:31:26 +09:00
Stephen Seo 4e9929d7ba Fix handling of timed out packets 2019-02-19 13:28:16 +09:00
Stephen Seo 4ac65ab6de More impl of UDPConnection
Still WIP but almost finished
2019-02-18 16:32:50 +09:00
Stephen Seo 84791a5399 Update UDPConnection to use updated HashMap 2019-02-18 12:31:42 +09:00
Stephen Seo 40f4df0fba Update unit tests for HashMap, fixes 2019-02-18 12:24:34 +09:00
Stephen Seo 2f794beede Change HashMap to use llists, testing required 2019-02-18 12:13:49 +09:00
Stephen Seo bb301d84e9 WIP change to linked list buckets instead of deque 2019-02-16 19:00:45 +09:00
Stephen Seo 6476617b1b Minor fix to unit test for HashMap 2019-02-15 17:00:10 +09:00
Stephen Seo d0ab9edb20 Minor fix to HashMap_itercall(), add to unit test 2019-02-15 14:43:16 +09:00
Stephen Seo 44dd293a4b Add itercall() to HashMap, more work on UDPC 2019-02-15 13:52:38 +09:00
Stephen Seo f1a13cde5c Fixes to Unit Test, attempt to improve hash use 2019-02-13 17:49:24 +09:00
Stephen Seo 1bab7694cf Add unit tests for HashMap, fix HashMap 2019-02-13 14:45:29 +09:00
Stephen Seo e995c877c4 Add a few fns, fix docs to HashMap 2019-02-13 13:38:36 +09:00
Stephen Seo c335b280c9 Allow duplicate keys in HashMap 2019-02-12 17:40:52 +09:00
Stephen Seo 6801cc9744 Revert "Change formatting in HashMap.c"
This reverts commit 1dba20ba0d.
2019-02-12 17:39:07 +09:00
Stephen Seo 1dba20ba0d Change formatting in HashMap.c 2019-02-12 17:37:58 +09:00
Stephen Seo 49f46e7ce4 Change HashMap_insert to replace existing same key 2019-02-11 11:39:09 +09:00
Stephen Seo 3faae3025e Add support for zero-size unitSize in HashMap 2019-02-11 11:33:35 +09:00
Stephen Seo 164a35fbd7 Add HashMap realloc/clear, fixes 2019-02-11 11:23:08 +09:00