MCPcopy Create free account
hub / github.com/PurpleI2P/i2pd / SocksRequestSuccess

Method SocksRequestSuccess

libi2pd_client/SOCKS.cpp:344–373  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

342 }
343
344 void SOCKSHandler::SocksRequestSuccess()
345 {
346 boost::asio::const_buffer response(nullptr,0);
347 // TODO: this should depend on things like the command type and callbacks may change
348 switch (m_socksv)
349 {
350 case SOCKS4:
351 LogPrint(eLogInfo, "SOCKS: v4 connection success");
352 response = GenerateSOCKS4Response(SOCKS4_OK, m_4aip, m_port);
353 break;
354 case SOCKS5:
355 LogPrint(eLogInfo, "SOCKS: v5 connection success");
356 if (m_cmd == CMD_UDP && m_UDPTunnel)
357 {
358 address ad;
359 // TODO: implement ipv6
360 ad.ip = m_UDPTunnel->GetLocalEndpoint ().address ().to_v4 ().to_uint ();
361 response = GenerateSOCKS5Response(SOCKS5_OK, ADDR_IPV4, ad, m_UDPTunnel->GetLocalEndpoint ().port ());
362 }
363 else
364 {
365 auto s = i2p::client::context.GetAddressBook().ToAddress(GetOwner()->GetLocalDestination()->GetIdentHash());
366 address ad; ad.dns.FromString(s);
367 // HACK only 16 bits passed in port as SOCKS5 doesn't allow for more
368 response = GenerateSOCKS5Response(SOCKS5_OK, ADDR_DNS, ad, m_stream ? m_stream->GetRecvStreamID() : 0);
369 }
370 break;
371 }
372 boost::asio::async_write(*m_sock, response, std::bind(&SOCKSHandler::SentSocksDone, shared_from_this(), std::placeholders::_1));
373 }
374
375 void SOCKSHandler::EnterState(SOCKSHandler::state nstate, uint8_t parseleft) {
376 switch (nstate)

Callers

nothing calls this directly

Calls 5

LogPrintFunction · 0.85
ToAddressMethod · 0.80
FromStringMethod · 0.80
GetRecvStreamIDMethod · 0.80
GetLocalDestinationMethod · 0.45

Tested by

no test coverage detected