| 1233 | } |
| 1234 | |
| 1235 | void SAMSocket::HandleI2PForward (std::shared_ptr<i2p::stream::Stream> stream, |
| 1236 | boost::asio::ip::tcp::endpoint ep) |
| 1237 | { |
| 1238 | if (stream) |
| 1239 | { |
| 1240 | LogPrint (eLogDebug, "SAM: Incoming forward I2P connection for session ", m_ID); |
| 1241 | auto newSocket = std::make_shared<SAMSocket>(m_Owner); |
| 1242 | newSocket->SetSocketType (SAMSocketType::eSAMSocketTypeStream); |
| 1243 | auto s = shared_from_this (); |
| 1244 | newSocket->GetSocket ().async_connect (ep, |
| 1245 | [s, newSocket, stream](const boost::system::error_code& ecode) |
| 1246 | { |
| 1247 | if (!ecode) |
| 1248 | { |
| 1249 | s->m_Owner.AddSocket (newSocket); |
| 1250 | newSocket->Receive (); |
| 1251 | newSocket->m_Stream = stream; |
| 1252 | newSocket->m_ID = s->m_ID; |
| 1253 | if (!s->m_IsSilent) |
| 1254 | { |
| 1255 | // get remote peer address |
| 1256 | auto dest = stream->GetRemoteIdentity()->ToBase64 (); |
| 1257 | memcpy (newSocket->m_StreamBuffer, dest.c_str (), dest.length ()); |
| 1258 | newSocket->m_StreamBuffer[dest.length ()] = '\n'; |
| 1259 | newSocket->HandleI2PReceive (boost::system::error_code (),dest.length () + 1); // we send identity like it has been received from stream |
| 1260 | } |
| 1261 | else |
| 1262 | newSocket->I2PReceive (); |
| 1263 | } |
| 1264 | else |
| 1265 | stream->AsyncClose (); |
| 1266 | }); |
| 1267 | } |
| 1268 | else |
| 1269 | LogPrint (eLogWarning, "SAM: I2P forward acceptor has been reset"); |
| 1270 | } |
| 1271 | |
| 1272 | void SAMSocket::HandleI2PDatagramReceive (const i2p::data::IdentityEx& from, uint16_t fromPort, uint16_t toPort, |
| 1273 | const uint8_t * buf, size_t len, const i2p::util::Mapping * options) |
nothing calls this directly
no test coverage detected