Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
333 commits
Select commit Hold shift + click to select a range
76e984c
add unit tests for `getIPConnectionProtocol()`
ProfessorTom Mar 16, 2026
4d55c51
use `getIPConnectionProtocol()` in production
ProfessorTom Mar 16, 2026
e7487c2
update comment to match method being tested
ProfessorTom Mar 17, 2026
1e2a379
make private members that we need access to in unit tests protected
ProfessorTom Mar 19, 2026
2880667
separate out code that creates and wires up a new socket
ProfessorTom Mar 19, 2026
1e3df86
dd `MosckSslSocket` o projext
ProfessorTom Mar 19, 2026
49661fa
Replace most direct clientConnection accesses with clientSocket()
ProfessorTom Mar 19, 2026
afdd01c
feat(tcpthread): add constructor accepting pre-created QSslSocket
ProfessorTom Mar 19, 2026
9db1a31
add extracted methods
ProfessorTom Mar 19, 2026
9a9764f
use bindClientSocket()
ProfessorTom Mar 19, 2026
f88a468
update debug statement
ProfessorTom Mar 19, 2026
5b75ad2
add unit tests
ProfessorTom Mar 19, 2026
c96033e
add TestUtils class to project
ProfessorTom Apr 4, 2026
d2d48aa
add helper method `debugSpy()` that prints out the content of a `QSig…
ProfessorTom Apr 4, 2026
ffb181e
add `testtils.cpp` to unit test CMake list.
ProfessorTom Apr 4, 2026
d9c6fc4
overload `operator<<` on Packet
ProfessorTom Apr 4, 2026
b1f60ea
add more `run()` characterization tests...
ProfessorTom Apr 4, 2026
e9aa466
rename `handleEncryptedConnectionOutcome()` to `handleOutgoingEncrypt…
ProfessorTom Apr 4, 2026
1d2b1fc
rename `handleOutgoingEncryptedConnection()` to `handleOutgoingSSLHan…
ProfessorTom Apr 4, 2026
c9a0289
workaround for `isEncrypted()` not being a virtual method in `QSslSoc…
ProfessorTom Apr 4, 2026
d26d1e8
provide test double override for `isSocketEncrypted()`
ProfessorTom Apr 4, 2026
8ad1c8c
Add virtual getSslErrorList helpers to TCPThread for mockable SSL err…
ProfessorTom Apr 5, 2026
84f5c06
dd getSslErrors / getSslHandshakeErrors overrides in TestTcpThreadClass
ProfessorTom Apr 5, 2026
263a42c
Extract incoming SSL handshake logic into handleIncomingSSLHandshake()
ProfessorTom Apr 5, 2026
e7d7ed1
add separator comment
ProfessorTom Apr 5, 2026
a7c08f7
add wrappers to handle number of method calls on test double.
ProfessorTom Apr 5, 2026
a7aba98
Add unit tests for handleIncomingSSLHandshake and handleOutgoingSSLHa…
ProfessorTom Apr 5, 2026
3f745cd
remove extraneous semicolon
ProfessorTom Apr 5, 2026
30d85fb
get rid of unnecessary braces and indention
ProfessorTom Apr 5, 2026
e59c166
Extract outgoing client logic into runOutgoingClient() + add characte…
ProfessorTom Apr 5, 2026
3e3bd31
Refactor: Extract buildInitialReceivedPacket() from TCPThread::run()
ProfessorTom Apr 5, 2026
d96fe69
add `setSocketDescriptor()` to `TcpThread`
ProfessorTom Apr 11, 2026
f59c46e
Refactor: Extract runIncomingConnection() for incoming/server path
ProfessorTom Apr 11, 2026
0e91378
Refactor: Extract prepareForPersistentLoop() from incoming path
ProfessorTom Apr 11, 2026
1caf4de
add `persistentLoopConnection.cpp` to project
ProfessorTom Apr 11, 2026
36e3552
add persistentConnectionLoopTests class to projext
ProfessorTom Apr 11, 2026
b22cf50
Refactor: Move persistent loop code to its own file
ProfessorTom Apr 11, 2026
e91afc5
remove unnecessary comment
ProfessorTom Apr 11, 2026
75450ab
Add comprehensive characterization tests for persistentConnectionLoop()
ProfessorTom Apr 12, 2026
ce611c1
Add first unit test for cleanupAfterPersistentConnectionLoop()
ProfessorTom Apr 12, 2026
83bdd34
DRY out debug code for printing out status spy
ProfessorTom Apr 12, 2026
81f4396
Extract cleanupAfterPersistentConnectionLoop() and add unit tests
ProfessorTom Apr 13, 2026
92d5a4e
extract and use handlePersistentIdleCase()
ProfessorTom Apr 18, 2026
117f3ae
Extract getPeerAddressAsString() and remove duplicated IPv4/IPv6 logic
ProfessorTom Apr 18, 2026
9586a93
clarify intent
ProfessorTom Apr 18, 2026
d5fa737
Extract sendCurrentPacket() and add unit tests
ProfessorTom Apr 18, 2026
137a544
Add unit test for sendCurrentPacket when no data is present
ProfessorTom Apr 19, 2026
d1a271b
Extract handleReceiveBeforeSend() and add unit tests
ProfessorTom Apr 21, 2026
b9d85ec
Extract buildReceivedPacket() and add dedicated SSL test
ProfessorTom Apr 21, 2026
8c1b3be
Refactor handleReceiveBeforeSend() + add SSL unit test
ProfessorTom Apr 21, 2026
0d5fd04
Extract handleResponseAfterSend() from persistentConnectionLoop()
ProfessorTom Apr 25, 2026
d7a8f34
make `buildRecviedPacketCallCount` variable consistent with...
ProfessorTom Apr 25, 2026
d139cfb
add shouldBreakPersistentLoop() helper and unit tests
ProfessorTom Apr 25, 2026
a341510
add resetPacketForPersistentLoop() for proper packet reuse in persist…
ProfessorTom Apr 25, 2026
3c01a23
simplify persistent connection loop logic in TCPThread
ProfessorTom Apr 25, 2026
ce5ac3d
add description comments
ProfessorTom Apr 25, 2026
932c3eb
add `basetcpthread.h` to project
ProfessorTom Apr 25, 2026
c584dff
add `basetcpthread.cpp` to project
ProfessorTom Apr 26, 2026
295401d
add `basetcpthreadtests` class files to project
ProfessorTom Apr 26, 2026
1bfe40c
feat: implement BaseTcpThread base class with core socket getters
ProfessorTom May 1, 2026
9017c14
feat: implement initial OutgoingTcpThread class
ProfessorTom May 10, 2026
118ebac
refactor: add convenience constructor to OutgoingTcpThread
ProfessorTom May 10, 2026
0e7b67d
Add `Packet::isValidForSending()` validation method + comprehensive u…
ProfessorTom May 15, 2026
8fb3fdf
Add `operator==()` and `operator!=()` to Packet + comprehensive unit …
ProfessorTom May 15, 2026
5ca32ac
Refactor OutgoingTcpThread + BaseTcpThread with comprehensive single-…
ProfessorTom May 19, 2026
76162a9
move run() to bottom of OutgoingTchThread
ProfessorTom May 20, 2026
92d911d
Refactor: Extract test helpers to TestUtils + add persistentConnectio…
ProfessorTom May 20, 2026
67e63b6
feat: Implement persistentConnectionLoop() idle handling in OutgoingT…
ProfessorTom May 20, 2026
ecfb9f9
move idle debug message out of body of `persistentConnectionLoop()`
ProfessorTom May 20, 2026
8ad68dc
feat: add incoming data processing support for persistent TCP connect…
ProfessorTom May 21, 2026
c6a020d
feat: Implement receiveBeforeSend support in persistentConnectionLoop()
ProfessorTom May 24, 2026
8f067e4
feat: Implement buildReplyPacket() + enforce uppercase hex in ASCIITo…
ProfessorTom May 24, 2026
d6177e2
feat: implement sendReplyIfNeeded() and shouldSendReply() with full t…
ProfessorTom May 25, 2026
cc25917
remove debug code
ProfessorTom May 25, 2026
5a3178e
clean up test from earlier debugging
ProfessorTom May 25, 2026
f37a643
feat: call sendReplyIfNeeded() from processIncomingData()
ProfessorTom May 25, 2026
698301f
feat(outgoingtcpthread): enable automatic replies for single-shot con…
ProfessorTom May 25, 2026
97013b2
remove unnecessary flag
ProfessorTom May 25, 2026
123365e
feat(outgoingtcpthread): add smart response support via getSmartRespo…
ProfessorTom May 26, 2026
ef3a518
feat(outgoingtcpthread): wire up smart responses in buildReplyPacket
ProfessorTom May 26, 2026
8134f07
DRY out code
ProfessorTom May 26, 2026
67182b2
Refactor OutgoingTcpThread: extract SSL and plain TCP connection hand…
ProfessorTom May 31, 2026
bc31cce
Refactor: Introduce PacketSenderQSslSocketInterface abstraction
ProfessorTom Jun 1, 2026
5cded12
Refactor: Remove getSocket(), fully migrate to PacketSenderQSslSocket…
ProfessorTom Jun 2, 2026
cd4cae6
feat(outgoingtcpthread): complete SSL support for single-shot connect…
ProfessorTom Jun 3, 2026
0030729
add override keyword
ProfessorTom Jun 3, 2026
2e41ebc
feat(outgoingtcpthread): wire up persistent flag and finalize single-…
ProfessorTom Jun 3, 2026
9d9c367
remove unused QSslSocket
ProfessorTom Jun 9, 2026
d51314a
feat: add initial skeleton for IncomingTcpThread
ProfessorTom Jun 9, 2026
29390ae
remove unused include
ProfessorTom Jun 9, 2026
b7a21b0
feat: implement buildInitialReceivedPacket() in IncomingTcpThread
ProfessorTom Jun 9, 2026
8236c42
additional test coverage
ProfessorTom Jun 9, 2026
a4bd0a2
feat: implement sendSmartReplyIfConfigured() with macro support
ProfessorTom Jun 9, 2026
ccaa1c7
feat: add SSL diagnostic packets for incoming encrypted connections
ProfessorTom Jun 10, 2026
2617e82
Refactor test doubles to use shared CallTracker utility
ProfessorTom Jun 10, 2026
8745e23
Move test utilities into dedicated utils/ subdirectory
ProfessorTom Jun 10, 2026
5a9f1ba
Implement and test performSSLHandshakeIfNeeded() in IncomingTcpThread
ProfessorTom Jun 10, 2026
9393177
Refactor: Move closeConnection() implementation to BaseTcpThread
ProfessorTom Jun 10, 2026
3cbbe2d
Implement core incoming connection handling in IncomingTcpThread
ProfessorTom Jun 10, 2026
22ef22c
feat: deprecate and replace old Connection class - introduce Deprecat…
ProfessorTom Jun 15, 2026
c436dcd
feat: implement Connection::isSecure() with unit tests
ProfessorTom Jun 15, 2026
69ff32e
feat: implement Connection::isIncoming() with tests
ProfessorTom Jun 15, 2026
3262c1c
feat: implement Connection::isPersistent() + supporting changes
ProfessorTom Jun 16, 2026
1e27a4d
refactor: rename Connection to BaseTcpConnection + move to connections/
ProfessorTom Jun 16, 2026
de5ecfc
move `basetcpconncionttests` to `tests/unit/connection` subfolder
ProfessorTom Jun 16, 2026
e893f93
refactor: introduce abstract Connection base class
ProfessorTom Jun 17, 2026
749bbd6
remove DeprecatedConnection and associated unit tests
ProfessorTom Jun 17, 2026
567d7a2
remove unnecessary reimplementation of id() in derived class (`BaseTc…
ProfessorTom Jun 18, 2026
07fcc03
code clean up
ProfessorTom Jun 18, 2026
ef6b41d
remove unused field
ProfessorTom Jun 18, 2026
6593bfe
feat: add getClassName() support to Connection hierarchy
ProfessorTom Jun 18, 2026
1c4d072
Add shutdown() method to BaseTcpThread
ProfessorTom Jun 21, 2026
596f748
Add unique ID generation to BaseTcpThread
ProfessorTom Jun 21, 2026
06e7ddf
Refactor BaseTcpConnection for better thread ownership
ProfessorTom Jun 21, 2026
39a0b84
Make send() pure virtual
ProfessorTom Jun 21, 2026
f87abd3
Ensure OutgoingTcpThread calls stop() in destructor
ProfessorTom Jun 21, 2026
e99e213
Update CMakeLists and test runner for new connection tests
ProfessorTom Jun 21, 2026
ecb1629
Enhance OutgoingTcpThreadTestDouble with Q_OBJECT and lifecycle signals
ProfessorTom Jun 21, 2026
8ea9337
Add test_send_replacesExistingThread
ProfessorTom Jun 21, 2026
1d01857
Rename buildInitialReceivedPacket() to buildReceivedPacket() in Incom…
ProfessorTom Jun 26, 2026
b76fae0
Add isInterruptionRequested() to BaseTcpThread
ProfessorTom Jun 26, 2026
438840f
mark methods with `[[nodiscard]]`
ProfessorTom Jun 26, 2026
2a06316
Implement persistentConnectionLoop() for IncomingTcpThread
ProfessorTom Jun 26, 2026
7f84126
prepare `ConnectionManager` for new implementation
ProfessorTom Jun 27, 2026
420e4f0
remove redundant `public` section marker
ProfessorTom Jun 27, 2026
efd5b1e
update comment block to reflect the current order of operations
ProfessorTom Jun 27, 2026
749d22b
Add terminateConnection() and close() to BaseTcpConnection
ProfessorTom Jun 28, 2026
3284023
fix capitalization
ProfessorTom Jun 28, 2026
1f7ee27
remove unnecessary virtual keyword
ProfessorTom Jun 28, 2026
2b41189
Add factory methods to ConnectionManager for creating connections
ProfessorTom Jun 28, 2026
80b3e73
add test that demonstrates ids for Connections in the map always go up
ProfessorTom Jun 28, 2026
a3bc48e
add test for `ConnectionManager::close()`
ProfessorTom Jun 28, 2026
f138822
add test for shutdownAll()
ProfessorTom Jun 28, 2026
401bf04
comments clean up
ProfessorTom Jun 28, 2026
50776ba
add helper methods for determining whether a vector of `QString`s sta…
ProfessorTom Jun 30, 2026
dd20266
add `persistentConnectionLoop()` call to `run()` in `IncomingTcpConne…
ProfessorTom Jun 30, 2026
66ed2ae
Add receiveData() method to Connection and BaseTcpConnection
ProfessorTom Jun 30, 2026
9a3fccc
update MockSslSocket to have default paraemters
ProfessorTom Jun 30, 2026
21cf3df
Implement receiveData() in IncomingTcpConnection
ProfessorTom Jun 30, 2026
e4b32eb
remove debugging code
ProfessorTom Jun 30, 2026
dfee0be
Add disconnected() signal to BaseTcpThread
ProfessorTom Jun 30, 2026
cae8574
remove unnecessary commented out code
ProfessorTom Jun 30, 2026
1702152
Implement setupSignalConnections() in BaseTcpConnection
ProfessorTom Jun 30, 2026
384fb52
remove unused commented out code
ProfessorTom Jun 30, 2026
10b3a03
update comment
ProfessorTom Jun 30, 2026
6fe5b9d
Add signal forwarding in ConnectionManager
ProfessorTom Jun 30, 2026
380e43a
spell filename properly
ProfessorTom Jul 5, 2026
4b0719e
move `startQTcpServer()` to `TestUtils`
ProfessorTom Jul 5, 2026
56d2151
remove unneeded field
ProfessorTom Jul 5, 2026
b918268
fix code indentation
ProfessorTom Jul 5, 2026
c72bd50
remove unnecessary, commented out code
ProfessorTom Jul 5, 2026
46357df
add pseudo state machine to `BaseTcpThread` and hence `*TcpThread` cl…
ProfessorTom Jul 5, 2026
2bae294
translate pseudo state machine to human readable text
ProfessorTom Jul 5, 2026
da86fad
add is`ThreadRunning()` method
ProfessorTom Jul 5, 2026
c0fb6e8
use `isThreadRunning()`
ProfessorTom Jul 5, 2026
ad967f2
remove debug statement
ProfessorTom Jul 5, 2026
ecdd76b
fix spelling
ProfessorTom Jul 5, 2026
5466a86
add constants for `ConnedtionStatusMessages`
ProfessorTom Jul 5, 2026
01d69cf
update `run()` logic
ProfessorTom Jul 5, 2026
53c94c2
add pseudo state machine to `Connection`
ProfessorTom Jul 5, 2026
e0770ba
clean up imports
ProfessorTom Jul 5, 2026
74bac0e
modify tests to match new behavior and avoid test artifacts
ProfessorTom Jul 5, 2026
c180b71
remove unnecessary commented out code
ProfessorTom Jul 5, 2026
b197f2d
invert `if` logic for early exit and to make code slightly easier to …
ProfessorTom Jul 5, 2026
5616075
update unit tests
ProfessorTom Jul 5, 2026
4d9b694
`operator<<` overload (though it may not be that useful because it do…
ProfessorTom Jul 5, 2026
9ecc11c
move through states in *TcpThread objects
ProfessorTom Jul 5, 2026
f719b76
remove unused import
ProfessorTom Jul 5, 2026
557cea9
clean up `#include`s
ProfessorTom Jul 5, 2026
2b1a2c7
remove unnecessary and commented out code
ProfessorTom Jul 5, 2026
048cfb8
add method for getting printable version of `Connection` state machine
ProfessorTom Jul 5, 2026
c869dbb
Refactor BaseTcpConnection to use state machine
ProfessorTom Jul 5, 2026
99e8d08
Improve ConnectionManager close() and factory methods
ProfessorTom Jul 5, 2026
a549fa2
undo overzealous `#include` clean up
ProfessorTom Jul 5, 2026
8cb14c4
use signal constants in signal emissions
ProfessorTom Jul 5, 2026
6d361d4
explicitly move thread
ProfessorTom Jul 6, 2026
f42c7db
add signal spy helper methods for unit tests
ProfessorTom Jul 6, 2026
b8c3770
update unit test and unit test doubles
ProfessorTom Jul 6, 2026
474c3df
Add initial Connection state machine tests
ProfessorTom Jul 6, 2026
38759ac
Add Connection state transition tests for send()
ProfessorTom Jul 6, 2026
a05a0e2
Add more Connection state transition tests and improve test doubles
ProfessorTom Jul 6, 2026
a8309c7
added case for incoming SSL successful changes `Socket` state to `Act…
ProfessorTom Jul 6, 2026
990ca13
feat(tests): add incoming SSL failure test and supporting mock config…
ProfessorTom Jul 6, 2026
134a138
Fix test setup for IncomingTcpThread and related tests
ProfessorTom Jul 7, 2026
c1b672f
`ConnectionManagerTests` need to run as "GUI" tests
ProfessorTom Jul 7, 2026
705ac54
Add SSL state transition tests for OutgoingTcpConnection
ProfessorTom Jul 7, 2026
86e1df3
Add state string conversion utilities in TestUtils
ProfessorTom Jul 7, 2026
8916e27
add debug message so that if we get in this situation, there is a clu…
ProfessorTom Jul 7, 2026
5588ccd
Improve BaseTcpConnection state machine
ProfessorTom Jul 7, 2026
3ad1424
Update SSL status emission in threads
ProfessorTom Jul 7, 2026
29cc9e7
Enhance test doubles with state history tracking
ProfessorTom Jul 7, 2026
a13a0ff
Update tests to use new state tracking and helpers
ProfessorTom Jul 7, 2026
1b38a65
add `*tcpconnection.cpp` to `CMakeList.txt` for main project
ProfessorTom Aug 3, 2026
867aef7
add comment explaining the choice made
ProfessorTom Aug 3, 2026
d407f5a
call the three parameter version of `setSocketDescriptor()`
ProfessorTom Aug 3, 2026
4dc4c21
remove unused line
ProfessorTom Aug 7, 2026
564a882
add `sendPacket` to `IncomingTcpThread` so we can send from the...
ProfessorTom Aug 7, 2026
aa1302e
Remove redundant dialogIsClosing() connection in PersistentConnection
ProfessorTom Aug 8, 2026
133a91c
reconfigure test runner to print a summary that includes...
ProfessorTom Aug 9, 2026
fcf0c78
Extract processReceivedPacket() and skip empty packets
ProfessorTom Aug 9, 2026
e5eeae7
`isValidForSending()` logic now lives in `BaseTcpThread` and `Outgoin…
ProfessorTom Aug 9, 2026
68efc7e
add `connectionId_` member variable to `PersistentConnection`
ProfessorTom Aug 9, 2026
1cad5aa
add `sendRequested` signal
ProfessorTom Aug 10, 2026
f8ae322
IncomingTcpConnection: implement `send()`
ProfessorTom Aug 10, 2026
f0539c2
move socket to worker thread and wire up `sendRequested`
ProfessorTom Aug 9, 2026
1dd57fe
add `ConnectionManager` to `PacketNetwork`
ProfessorTom Aug 10, 2026
79350da
become parent of `connectionManager` in constructor
ProfessorTom Aug 10, 2026
72ebae0
destroy all connections in `connectionManager` upon destruction of `P…
ProfessorTom Aug 10, 2026
34e3477
add `initWithConnection()` to `PersistentConnection`
ProfessorTom Aug 10, 2026
2d7a8b5
emit `closeConnection()` to clean up connection when...
ProfessorTom Aug 10, 2026
10d4283
PersistentConnection: auto-fill send target from first received packet
ProfessorTom Aug 10, 2026
51eeb0e
remove `const`s from parameter list in `receiveData` function prototype
ProfessorTom Aug 10, 2026
a641c4b
add a raw, non-owning `ConnectionManager` pointer to `ThreadedTcpServer`
ProfessorTom Aug 10, 2026
2c48561
update `ThreadedTCPServer` constructor function prototype
ProfessorTom Aug 10, 2026
458d43d
change `ipMode` parameter to be a `const` `QString` reference
ProfessorTom Aug 10, 2026
e4351d3
add `setupGlobalLogging()`
ProfessorTom Aug 10, 2026
457f599
add `setupPersistentWindowConnections()` to `ThreadedTCPServer`
ProfessorTom Aug 10, 2026
4ee91f2
update `init()` implementation
ProfessorTom Aug 10, 2026
0077389
update `incomingConnection()` implementation
ProfessorTom Aug 10, 2026
78d010d
remove `QList`s of `TCPThread`s
ProfessorTom Aug 10, 2026
f8cc7fd
fix cross-thread socket writes on Incoming path
ProfessorTom Aug 11, 2026
7a45501
Extract PersistentConnection window wiring into shared helper
ProfessorTom Aug 11, 2026
b924b39
move `outputTCPPacket` from `ThreadedTCPServer` to `PacketNetwork`
ProfessorTom Aug 11, 2026
e92b6a8
move `setupGlobalLogging()` from `ThreadedTCPServer` to `PacketNetwork`
ProfessorTom Aug 11, 2026
bdcf5d8
call `setupConnectionLogging()`
ProfessorTom Aug 11, 2026
91a68cd
remove unused `slot`s from `TcpThreadedServer`
ProfessorTom Aug 11, 2026
c43fae2
remove unused `signal`s from `TcpThreadServer`
ProfessorTom Aug 11, 2026
7ff3c22
remove `tcpthread.h` `#include` from `TcpThreadedServer`
ProfessorTom Aug 11, 2026
26476a0
add `persistentconnectionwiring.cpp` to `CMakeLists.txt`
ProfessorTom Aug 11, 2026
7a3a4d1
make `enqueuePacket()` public
ProfessorTom Aug 12, 2026
b978a01
remove TOOD line that has already been done
ProfessorTom Aug 12, 2026
568624d
Make `Packet::isValidForSending` and `getByteArray` `const`
ProfessorTom Aug 12, 2026
db5a94c
Fix bind-error text to use the server's port instead of `udpPort`.
ProfessorTom Aug 12, 2026
2312eb1
PacketNetwork::init: drop dead TCP server signal connects
ProfessorTom Aug 12, 2026
d139c7e
BaseTcpConnection: map idle status to Active; add `moveSocketToWorker…
ProfessorTom Aug 12, 2026
1915471
`OutgoingTcpThread`: drain send queue in persistent loop
ProfessorTom Aug 13, 2026
da2e987
Adjust persistent-loop unit test for new idle policy
ProfessorTom Aug 13, 2026
7caa3b9
OutgoingTcpConnection::send: reuse live persistent thread via queue
ProfessorTom Aug 13, 2026
1f3c5cc
Route outgoing TCP through ConnectionManager and persistent window wi…
ProfessorTom Aug 13, 2026
016b055
remove noisy debug statements
ProfessorTom Aug 13, 2026
42dd7f2
remove `TCPThread` from project
ProfessorTom Aug 13, 2026
4fb3923
replace bare `ConnectionStatusMessage` strings with constants
ProfessorTom Aug 13, 2026
05897b4
move *tcpthread.* files into a tcpthread subfolder to help organize code
ProfessorTom Aug 13, 2026
e8d14b0
move *tcpthread* test files into a `tcpThread` subfolder
ProfessorTom Aug 13, 2026
ce72670
move `*tcpthreadtestdouble` files into `tcpThread` subfolder
ProfessorTom Aug 13, 2026
be5763c
attempt to fix Debian build on GitHub
ProfessorTom Aug 13, 2026
d99ef99
fix case insensitive issue created by macOS
ProfessorTom Aug 13, 2026
3193f4e
CI: run unit tests on Debian workflow and align packaging deps
ProfessorTom Aug 15, 2026
2484c33
Fix Chinese Qt translation load on Linux; embed app .qm in unit tests
ProfessorTom Aug 15, 2026
ca12873
Fix unit tests that fail to compile on Linux/GCC
ProfessorTom Aug 15, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions .github/workflows/build-debian.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,19 @@ jobs:
- name: install_dependencies
run: |
sudo apt update
sudo apt install cmake debhelper devscripts qt6-base-dev qt6-base-dev-tools qt6-tools-dev build-essential
sudo apt install cmake debhelper devscripts qt6-base-dev qt6-base-dev-tools qt6-tools-dev build-essential qt6-translations-l10n libgl1-mesa-dev
- name: unit tests
env:
QT_QPA_PLATFORM: offscreen
run: |
cmake -S src -B build-tests \
-DCMAKE_BUILD_TYPE=Release \
-DPACKETSENDER_BUILD_TESTS=ON
cmake --build build-tests -j"$(nproc)"
ctest --test-dir build-tests --output-on-failure
- name: build
run: |
debuild --no-lintian --no-sign

- name: Collect Debian Artifacts
run: |
mkdir -p artifacts
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/debian/control
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ Source: packetsender
Section: net
Priority: optional
Maintainer: Joao Eriberto Mota Filho <eriberto@debian.org>
Build-Depends: debhelper-compat (= 12), cmake, qt6-base-dev
Build-Depends: debhelper-compat (= 12), cmake, build-essential, pkg-config, qt6-base-dev, qt6-base-dev-tools, qt6-tools-dev, qt6-tools-dev-tools, libgl1-mesa-dev, libssl-dev, qt6-translations-l10n
Standards-Version: 4.5.0
Homepage: https://packetsender.com/
Rules-Requires-Root: no
Expand Down
11 changes: 9 additions & 2 deletions .github/workflows/debian/rules
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,15 @@ export QT_SELECT = qt6
export DEB_BUILD_MAINT_OPTIONS = hardening=+all

%:
dh $@ --sourcedirectory=src
dh $@ --buildsystem=cmake --sourcedirectory=src

override_dh_auto_configure:
dh_auto_configure --buildsystem=cmake --sourcedirectory=src -- \
-DCMAKE_BUILD_TYPE=Release

override_dh_auto_install:
dh_auto_install
mv debian/packetsender/usr/bin/PacketSender debian/packetsender/usr/bin/packetsender
# CMake target is PacketSender; package expects packetsender
if [ -f debian/packetsender/usr/bin/PacketSender ]; then \
mv debian/packetsender/usr/bin/PacketSender debian/packetsender/usr/bin/packetsender; \
fi
26 changes: 25 additions & 1 deletion src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ set(
mainwindow.h
panel.h
globals.h
settingnames.h
panelgenerator.h
persistentconnection.h
persistenthttp.h
Expand Down Expand Up @@ -62,6 +63,11 @@ set(
PACKETSENDER_SRCS
about.cpp
brucethepoodle.cpp
connections/connection.cpp
connections/basetcpconnection.cpp
connections/incomingtcpconnection.cpp
connections/outgoingtcpconnection.cpp
connectionmanager.cpp
irisandmarigold.cpp
cloudui.cpp
main.cpp
Expand All @@ -79,7 +85,6 @@ set(
sendpacketbutton.cpp
settings.cpp
subnetcalc.cpp
tcpthread.cpp
threadedtcpserver.cpp
udpflooding.cpp
languagechooser.cpp
Expand All @@ -88,6 +93,14 @@ set(
association.cpp
dtlsserver.cpp
dtlsthread.cpp
packetsenderqsslsocketinterface.h
realqsslsocket.cpp
tcpThreads/basetcpthread.cpp
tcpThreads/outgoingtcpthread.cpp
tcpThreads/incomingtcpthread.cpp
fileutils.cpp
ConnectionStatusMessages.h
connections/persistentconnectionwiring.cpp
)


Expand Down Expand Up @@ -178,6 +191,17 @@ if(APPLE)
)
endif()

# ==================== UNIT TESTS (QtTest) ====================
option(PACKETSENDER_BUILD_TESTS "Build unit tests (QtTest)" OFF)

if(PACKETSENDER_BUILD_TESTS)
find_package(Qt6 REQUIRED COMPONENTS Test)

enable_testing()

add_subdirectory(tests/unit)
endif()

# -------------------
# Packaging
# -------------------
Expand Down
24 changes: 24 additions & 0 deletions src/ConnectionStatusMessages.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
//
// Created by Tomas Gallucci on 7/4/26.
//

#ifndef CONNECTIONSTATUSMESSAGES_H
#define CONNECTIONSTATUSMESSAGES_H
#include <QString>

class ConnectionStatusMessages
{
public:
static QString INCOMING_CONNECTION_ACCEPTED() { return QStringLiteral("Incoming connection accepted"); }
static QString ERROR_NO_SOCKET_AVAILABLE() { return QStringLiteral("Error: No socket available"); }
static QString ERROR_SOCKET_NOT_CONNECTED() { return QStringLiteral("Error: Socket not connected"); }
static QString SENDING_DATA() { return QStringLiteral("Sending data: "); }
static QString DISCONNECTED() { return QStringLiteral("Disconnected"); }
static QString SSL_CONNECTED() { return QStringLiteral("SSL Connected"); }
static QString SSL_HANDSHAKE_FAILED() { return QStringLiteral("SSL Handshake Failed"); }
static QString CONNECTED() { return QStringLiteral("Connected"); }
static QString COULD_NOT_CONNECT() { return QStringLiteral("Could not connect."); }
static QString CONNECTED_AND_IDLE() { return QStringLiteral("Connected and idle."); }
static QString WAITING_FOR_DATA_BEFORE_SEND() { return QStringLiteral("Waiting for data before send"); }
};
#endif //CONNECTIONSTATUSMESSAGES_H
130 changes: 130 additions & 0 deletions src/connectionmanager.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,130 @@
//
// Created by Tomas Gallucci on 3/5/26.
//

#include "connectionmanager.h"

#include "connections/incomingtcpconnection.h"

ConnectionManager::ConnectionManager(QObject *parent)
: QObject(parent)
{
}

ConnectionManager::~ConnectionManager()
{
shutdownAll(); // RAII: clean up on manager destruction
}

bool ConnectionManager::hasConnection(quint64 id)
{
return connections.find(id) != connections.end();
}

void ConnectionManager::setupConnectionSignals(Connection* conn, quint64 id)
{
if (!conn) return;

connect(conn, &Connection::dataReceived,
this, [this, id](const Packet& p) {
emit dataReceived(id, p);
});
connect(conn, &Connection::packetSent,
this, [this, id](const Packet& p) {
emit packetSent(id, p);
});

connect(conn, &Connection::stateChanged,
this, [this, id](const QString& msg) {
emit stateChanged(id, msg);
});

connect(conn, &Connection::errorOccurred,
this, [this, id](const QString& err) {
emit errorOccurred(id, err);
});

connect(conn, &Connection::disconnected,
this, [this, id]() {
if (
const auto it = connections.find(id);
it != connections.end() && it->second->isConnected())
{
// QDEBUG() << "calling close() on connection in ConnectionManager::disconnect()";
QDEBUG() << "removing connection from map in ConnectionManager::disconnect()";
it->second->close();
connections.erase(id);
emit disconnected(id);
}
});
}

std::unique_ptr<OutgoingTcpConnection> ConnectionManager::createOutgoingTcpConnectionObject()
{
return std::make_unique<OutgoingTcpConnection>(this);
}

std::unique_ptr<IncomingTcpConnection> ConnectionManager::createIncomingTcpConnectionObject()
{
return std::make_unique<IncomingTcpConnection>(this);
}

std::pair<quint64, IncomingTcpConnection*> ConnectionManager::createIncomingTcpConnection()
{
auto conn = createIncomingTcpConnectionObject();
quint64 id = nextId++;

IncomingTcpConnection* rawPtr = conn.get();
connections[id] = std::move(conn);
setupConnectionSignals(connections[id].get(), id);

return {id, rawPtr};
}

std::pair<quint64, OutgoingTcpConnection*> ConnectionManager::createOutgoingTcpConnection()
{
auto conn = createOutgoingTcpConnectionObject();

quint64 id = nextId++;

OutgoingTcpConnection* rawPtr = conn.get();
connections[id] = std::move(conn);
setupConnectionSignals(connections[id].get(), id);

return {id, rawPtr};
}

void ConnectionManager::send(quint64 id, const Packet &packet)
{
auto it = connections.find(id);
if (it != connections.end()) {
it->second->send(packet);
}
}

void ConnectionManager::close(quint64 id)
{
QMutexLocker locker(&mutex);
const auto it = connections.find(id);

if (it == connections.end()) {
QDEBUG() << "returning early from ConnectionManager::close()";
return; // early return — very clear
}

if (it->second->isConnected()) {
QDEBUG() << "calling close on thread in ConnectionManager::close()";
it->second->close();
QDEBUG() << "called close on thread in ConnectionManager::close()";
}

QDEBUG() << "about to erase thread in ConnectionManager::close()";
connections.erase(it);
QDEBUG() << "erased thread in ConnectionManager::close()";
}

void ConnectionManager::shutdownAll()
{
// Deleting unique_ptrs triggers Connection dtors → threads close/wait
connections.clear();
}
66 changes: 66 additions & 0 deletions src/connectionmanager.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
//
// Created by Tomas Gallucci on 3/5/26.
//

#ifndef CONNECTIONMANAGER_H
#define CONNECTIONMANAGER_H


#include <memory>
#include <QMutex>
#include <unordered_map>
#include <utility>

#include "packet.h"
#include "connections/connection.h"
#include "connections/incomingtcpconnection.h"
#include "connections/outgoingtcpconnection.h"

class ConnectionManager : public QObject
{
Q_OBJECT

public:
explicit ConnectionManager(QObject *parent = nullptr);
~ConnectionManager() override;

bool hasConnection(quint64 id);

// Factory methods - explicit about type for future extensibility
std::pair<quint64, IncomingTcpConnection*> createIncomingTcpConnection();
std::pair<quint64, OutgoingTcpConnection*> createOutgoingTcpConnection();

// Send data to connection by ID
void send(quint64 id, const Packet &packet);

// Close a specific connection
void close(quint64 id);

// Shut down all connections (called on app quit or server disable)
void shutdownAll();

signals:
// Forwarded with connection ID prefix
void packetSent(quint64 id, const Packet& packet);
void dataReceived(quint64 id, const Packet& packet);
void stateChanged(quint64 id, const QString& message);
void errorOccurred(quint64 id, const QString& errorString);
void disconnected(quint64 id);

protected:
std::unordered_map<quint64, std::unique_ptr<Connection>> connections;
quint64 nextId = 1;

virtual void setupConnectionSignals(Connection* conn, quint64 id);

// these methods exist so I didn't have to make the public API virtual, but we can
// still override the creation of objects in test doubles
virtual std::unique_ptr<OutgoingTcpConnection> createOutgoingTcpConnectionObject();
virtual std::unique_ptr<IncomingTcpConnection> createIncomingTcpConnectionObject();

private:
QMutex mutex; // protects thread shutdown
};


#endif //CONNECTIONMANAGER_H
Loading
Loading