void forward(socket_ptr<T> from,
socket_ptr<S> to,
std::shared_ptr<AsyncEvent> connection_end,
+ const std::string tag,
yield_ctx yield) {
try {
char data[chunk_size];
*to, boost::asio::buffer(data, len), yield);
}
} catch (std::exception &e) {
- LOGD(MODULE_DEBUGPROXY, "Stopped forwarding sockets: %s", e.what());
+ LOGD(MODULE_DEBUGPROXY, "%s: Stopped forwarding sockets: %s",
+ tag.c_str(), e.what());
connection_end->set();
}
}
#include <memory>
+#include <cstdio>
#include <boost/bind.hpp>
#include <boost/asio/deadline_timer.hpp>
{
LOGD(MODULE_DEBUGPROXY, "(%p) Two-way forwarding started", this);
auto connection_lost_event = std::make_shared<AsyncEvent>(this->io());
+ char tag[100];
+
+ std::sprintf(tag, "(%p) local -> port", this);
boost::asio::spawn(
this->io(),
boost::bind(&forward<local::stream_protocol, ip::tcp>,
this->local_socket, this->port_socket,
- connection_lost_event, _1));
+ connection_lost_event, tag, _1));
+ std::sprintf(tag, "(%p) port -> local", this);
boost::asio::spawn(
this->io(),
boost::bind(&forward<ip::tcp, local::stream_protocol>,
this->port_socket, this->local_socket,
- connection_lost_event, _1));
+ connection_lost_event, tag, _1));
return connection_lost_event;
}