创建一个不做任何特殊事情的 SOCKS 代理

发布于 2024-08-02 04:45:54 字数 223 浏览 1 评论 0原文

我正在尝试在 C++ 中创建一个 SOCKS 代理,该代理在本地主机上作为后台进程运行。

如果用户的浏览器配置为使用代理,我希望所有 HTTP 请求都通过正常的 TCP/IP 堆栈传递。即浏览器的行为与平常完全一样。

最终,我将添加另一个层,该层将检查请求的资源是否符合特定条件,如果符合,将以不同的方式处理请求。但现在我只是想解决基本问题......如何创建一个不改变任何东西的 SOCKS 代理?

I am trying to create a SOCKS proxy in C++ that runs as a background process on localhost.

If the user's browser is configured to use the proxy, I want all HTTP requests to be passed along through the normal TCP/IP stack. i.e. The browser will behave exactly as it normally would.

Eventually I will add another layer which will check to see if the requested resource matches certain criteria, and if so will handle the request differently. But for now I'm just trying to solve the basic problem... how to create a SOCKS proxy that doesn't change anything?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

夜巴黎 2024-08-09 04:45:54

我会研究 Squid 项目,具体取决于你需要它的用途。

http://www.squid-cache.org/

GPL 许可源。

对许多美好的事物都非常友善。

雅各布

I would look into the Squid project, depending on what you need it for.

http://www.squid-cache.org/

GPL licensed source.

Insanely nice for many good things.

Jacob

骄兵必败 2024-08-09 04:45:54

构建 HTTP 代理比构建 SOCKS4/SOCKS5 容易得多,因为 HTTP 协议是人类可读的,而 SOCKS 协议则不然。 这是我几年前为体验而构建的 HTTP 代理示例。它曾经在旧浏览器上运行良好,现在由于无法处理持久连接而损坏,但它仍然是学习其工作原理的良好来源。

也许您更愿意使用现有的 HTTP 代理软件,例如 Squid。

It is far easier to build a HTTP Proxy then a SOCKS4/SOCKS5 as HTTP protocol is human readable and SOCKS protocols are not. Here is an exemple of a HTTP proxy I build for experience some years ago. It used to work fine with old browsers, now its broken as it cannot handle persistent connections, but it still is a good source to learn how it works.

Maybe you rather use a already existing HTTP proxy software like Squid.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文