如何获得原始端点?

时间:2018-01-23 17:54:55

标签: c++ boost-asio

我已将浏览器的代理设置为我在localhost上托管的应用程序

这是该程序的简短片段

boost::asio::io_service ios;
ip::tcp::acceptor acceptor(io_service_,ip::tcp::endpoint("127.0.0.1", 12345))
ip::tcp::socket socket(ios);
acceptor_.async_accept(socket,
                boost::bind(&acceptor::handle_accept,
                     this,
                     boost::asio::placeholders::error));

这是我的接受者对象。

如何将原始请求目标主机和请求端口重定向到我的应用程序?

完整代码在这里https://github.com/ArashPartow/proxy/blob/master/tcpproxy_server.cpp

1 个答案:

答案 0 :(得分:0)

You're pointing the "full code" link to a github repository from someone else. This code example accepts connections on a local port and will forward them to a remote machine. E.g. a connection on localhost to a remote webserver or a connection on your local port 8080 to a remote webserver.

On its command line, you provide the information where to listen for a connection (local) and where to connect to (remote).

I have a strong feeling you want something else: the inbound connection to tell you where to connect to (instead of a fixed remote). That's beyond this simple piece of C++ code.