 |
Bitcoin Core
22.99.0
P2P Digital Currency
|
Go to the documentation of this file.
18 #include <unordered_map>
33 std::unique_ptr<Sock>
sock;
130 std::unordered_map<std::string, std::optional<std::string>>
keys;
142 std::string
Get(
const std::string& key)
const;
150 template <
typename... Args>
151 void Log(
const std::string& fmt,
const Args&...
args)
const;
162 const std::string& request,
163 bool check_result_ok =
true)
const;
270 #endif // BITCOIN_I2P_H
std::unordered_map< std::string, std::optional< std::string > > keys
A map of keywords from the parsed reply.
A combination of a network address (CNetAddr) and a (TCP) port.
const fs::path m_private_key_file
The name of the file where this peer's private key is stored (in binary).
void Disconnect() EXCLUSIVE_LOCKS_REQUIRED(m_mutex)
Destroy the session, closing the internally used sockets.
Session(const fs::path &private_key_file, const CService &control_host, CThreadInterrupt *interrupt)
Construct a session.
A reply from the SAM proxy.
CService peer
The peer's I2P address.
std::unique_ptr< Sock > Hello() const EXCLUSIVE_LOCKS_REQUIRED(m_mutex)
Open a new connection to the SAM proxy.
void GenerateAndSavePrivateKey(const Sock &sock) EXCLUSIVE_LOCKS_REQUIRED(m_mutex)
Generate a new destination with the SAM proxy, set m_private_key to it and save it on disk to m_priva...
std::string full
Full, unparsed reply.
const CService m_control_host
The host and port of the SAM control service.
bool Listen(Connection &conn)
Start listening for an incoming connection.
RAII helper class that manages a socket.
Reply SendRequestAndGetReply(const Sock &sock, const std::string &request, bool check_result_ok=true) const
Send request and get a reply from the SAM proxy.
std::vector< uint8_t > Binary
Binary data.
void CreateIfNotCreatedAlready() EXCLUSIVE_LOCKS_REQUIRED(m_mutex)
Create the session if not already created.
Mutex m_mutex
Mutex protecting the members that can be concurrently accessed.
Path class wrapper to block calls to the fs::path(std::string) implicit constructor and the fs::path:...
CThreadInterrupt *const m_interrupt
Cease network activity when this is signaled.
Binary MyDestination() const EXCLUSIVE_LOCKS_REQUIRED(m_mutex)
Derive own destination from m_private_key.
std::string request
Request, used for detailed error reporting.
std::string Get(const std::string &key) const
Get the value of a given key.
bool Connect(const CService &to, Connection &conn, bool &proxy_error)
Connect to an I2P peer.
std::unique_ptr< Sock > StreamAccept() EXCLUSIVE_LOCKS_REQUIRED(m_mutex)
Open a new connection to the SAM proxy and issue "STREAM ACCEPT" request using the existing session i...
void Log(const std::string &fmt, const Args &... args) const
Log a message in the BCLog::I2P category.
void DestGenerate(const Sock &sock) EXCLUSIVE_LOCKS_REQUIRED(m_mutex)
Generate a new destination with the SAM proxy and set m_private_key to it.
#define EXCLUSIVE_LOCKS_REQUIRED(...)
Filesystem operations and types.
static constexpr size_t MAX_MSG_SIZE
The maximum size of an incoming message from the I2P SAM proxy (in bytes).
An established connection with another peer.
CService me
Our I2P address.
void CheckControlSock()
Check the control socket for errors and possibly disconnect.
Binary m_private_key GUARDED_BY(m_mutex)
The private key of this peer.
bool Accept(Connection &conn)
Wait for and accept a new incoming connection.
std::unique_ptr< Sock > sock
Connected socket.
~Session()
Destroy the session, closing the internally used sockets.