Commit graph

24 commits

Author SHA1 Message Date
74341e83d4 Use atomic_bool for auto-updating "flag" 2024-01-11 18:45:14 +09:00
972ec73e88 Refactor addr logprint via template specialization 2023-06-26 14:01:42 +09:00
4abd9fddcb Conditionally use UDPC_atostr internally
Previous implementation used UDPC_atostr() frequently. This commit
changes the implementation to only call UDPC_atostr() if the log level
of the code logging to output will cause the log to be output.
2023-06-22 12:39:11 +09:00
2495396d76 Fix potential memory corruption bug
UDPC_atostr(...) uses a uint32_t as an offset into a buffer inside the
UDPC Context such that there can be at most 32 different addr-strings.
The call is thread-safe, up to a point (at most 32 concurrent calls will
return correct strings). The problem was that the offset was not being
reset to 0 and was always being incremented by 40. Should the offset
overflow, the offset into the buffer will be "mis-aligned" such that the
32nd offset into the buffer can possibly overwrite memory past the
buffer's end if the addr string is long enough.

The fix is to use a mutex instead of an atomic uint32_t to lock a
code-block that will always prevent overflow (using modulus operator).

I think the speed-loss is negligable (using a lock instead of an atomic
uint32_t) since it isn't expected for programs using UDPC to use
UDPC_atostr(...) very frequently.
2023-06-21 13:23:26 +09:00
2a39267b38 Add/fix more documentation 2020-04-28 19:38:07 +09:00
31ca4ddc44 Impl create id with hostname
Previously, ids could only be created with an ip address. Now they can
be made with a hostname, which will be looked up by UDPC.

Also fix client still requesting connections even if
accept-new-connections flag is false.
2020-04-26 18:52:06 +09:00
cf6ff5a040 Change how UDPC_PacketInfo handles it's data
The "data" member variable in UDPC_PacketInfo is now handled as a
pointer to dynamic data, instead of an array with a fixed size. Every
time a UDPC_PacketInfo is received from the context,
UDPC_free_PacketInfo() must be called on it to avoid a memory leak.
2020-04-15 19:56:15 +09:00
e01a1ccd94 Fix compilation fail on no libsodium 2020-03-06 13:03:47 +09:00
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
b41639c568 Set pointers to const where possible in API 2020-01-10 20:28:08 +09:00
f588d409c9 Truncate "UDPConnection" to "UDPC" 2020-01-09 16:57:01 +09:00
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
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
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
1a39039065 Fix received packet storing unnecessary header
Added rtt (uint16_t) to UDPC_PacketInfo.
2019-12-27 13:35:28 +09:00
dbdade3b00 Impl disc. request (untested), del make_unique 2019-12-17 20:05:56 +09:00
7c444cb460 Impl auth-policy for handling with(out) auth 2019-12-09 21:27:58 +09:00
d94b44e4de More documentation, fix constants to be #define'd 2019-12-06 20:49:30 +09:00
240ed9821f Add set peer_pk, sk/pk, start/stop threaded update
Note, this code is UNTESTED.
2019-11-19 20:55:20 +09:00
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
f2b4672318 Add way to specify sleep time for threaded update 2019-11-13 14:06:48 +09:00
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
d86b7e4e1d Fix use of addr/socket types 2019-11-11 13:37:51 +09:00
00c1be07dc Replace c_impl, remove rust_binding, with cpp_impl 2019-11-11 13:08:36 +09:00
Renamed from cpp_impl/src/UDPC_Defines.hpp (Browse further)