Jackarain / proxy

Implementation of http, https, socks4/socks4a, socks5 server and client proxy protocols using modern c++ (使用现代 c++ 实现 http、https、socks4/socks4a、socks5 服务端和客户端完整的代理协议。)
Boost Software License 1.0
199 stars 82 forks source link

curl use proxy #13

Open 13015517713 opened 1 year ago

13015517713 commented 1 year ago

when I use curl library to view some pages use this proxy, like

curl -x 0.0.0.0:8080 http://www.baidu.com

It will use web_server to handle the seesion. I found it will return empty page by judging m_option.docdirectory.empty(). I'm confused that why not it parse target page, resend the request to the page and return the content to client ?

rampageX commented 1 year ago

Use your network interface ip address or 127.0.0.1 as you proxy ip, not 0.0.0.0

13015517713 commented 1 year ago

Use your network interface ip address or 127.0.0.1 as you proxy ip, not 0.0.0.0

Maybe it's not the reason.

func: inline net::awaitable<void> web_server()
if (m_option.doc_directory_.empty())
{
co_await net::async_write(
    m_local_socket,
    net::buffer(fake_web_page()),
    net::transfer_all(),
    net_awaitable[ec]);
net::streambuf bufs(8192);
co_await net::async_read_until(
    m_local_socket,
    bufs,
    "\r\n\r\n",
    net_awaitable[ec]);
if (!ec)
    m_local_socket.shutdown(
        net::socket_base::shutdown_both, ec);
co_return;  
}

when recv the GET request, it dirtectly check the doc_directory and return fake page.