i2p: avoid using Sock::Get() for checking for a valid socket

Peeking at the underlying socket file descriptor of `Sock` and checkig
if it is `INVALID_SOCKET` is bad encapsulation and stands in the way of
testing/mocking/fuzzing.

Instead use an empty unique_ptr to denote that there is no valid socket.
This commit is contained in:
Vasil Dimov
2021-05-25 15:01:53 +02:00
parent 083316c4fe
commit 5ac1a51ee5
2 changed files with 5 additions and 6 deletions

View File

@@ -261,6 +261,7 @@ private:
* ("SESSION CREATE"). With the established session id we later open
* other connections to the SAM service to accept incoming I2P
* connections and make outgoing ones.
* If not connected then this unique_ptr will be empty.
* See https://geti2p.net/en/docs/api/samv3
*/
std::unique_ptr<Sock> m_control_sock GUARDED_BY(m_mutex);