/*
|
* =====================================================================================
|
*
|
* Filename: tcp_proxy.cpp
|
*
|
* Description:
|
*
|
* Version: 1.0
|
* Created: 2021年05月19日 15时04分15秒
|
* Revision: none
|
* Compiler: gcc
|
*
|
* Author: Li Chao (), lichao@aiotlink.com
|
* Organization:
|
*
|
* =====================================================================================
|
*/
|
#include "tcp_proxy.h"
|
#include "tcp_connection.h"
|
|
bool TcpProxy::Request(const std::string &ip, int port, std::string &&content, ReplyCB const &cb)
|
{
|
if (content.empty()) { return false; }
|
try {
|
tcp::endpoint dest(ip::address::from_string(ip), port);
|
TcpRequest1::Create(io_, dest, std::move(content), cb);
|
LOG_TRACE() << "tcp request start " << ip << ':' << port;
|
return true;
|
} catch (std::exception &e) {
|
LOG_ERROR() << "proxy request exception: " << e.what();
|
return false;
|
}
|
}
|
|
bool TcpProxy::Publish(const std::string &ip, int port, std::string &&content)
|
{
|
return Request(ip, port, std::move(content), ReplyCB());
|
}
|