MCPcopy Create free account
hub / github.com/ElementsProject/elements / Accept

Method Accept

src/i2p.cpp:145–171  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

143}
144
145bool Session::Accept(Connection& conn)
146{
147 try {
148 while (!*m_interrupt) {
149 Sock::Event occurred;
150 if (!conn.sock->Wait(MAX_WAIT_FOR_IO, Sock::RECV, &occurred)) {
151 throw std::runtime_error("wait on socket failed");
152 }
153
154 if ((occurred & Sock::RECV) == 0) {
155 // Timeout, no incoming connections within MAX_WAIT_FOR_IO.
156 continue;
157 }
158
159 const std::string& peer_dest =
160 conn.sock->RecvUntilTerminator('\n', MAX_WAIT_FOR_IO, *m_interrupt, MAX_MSG_SIZE);
161
162 conn.peer = CService(DestB64ToAddr(peer_dest), I2P_SAM31_PORT);
163
164 return true;
165 }
166 } catch (const std::runtime_error& e) {
167 Log("Error accepting: %s", e.what());
168 CheckControlSock();
169 }
170 return false;
171}
172
173bool Session::Connect(const CService& to, Connection& conn, bool& proxy_error)
174{

Callers 2

AcceptConnectionMethod · 0.45

Calls 5

DestB64ToAddrFunction · 0.85
LogFunction · 0.85
RecvUntilTerminatorMethod · 0.80
CServiceClass · 0.70
WaitMethod · 0.45

Tested by

no test coverage detected