| 143 | } |
| 144 | |
| 145 | bool 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 | |
| 173 | bool Session::Connect(const CService& to, Connection& conn, bool& proxy_error) |
| 174 | { |
no test coverage detected