创建一个不做任何特殊事情的 SOCKS 代理
我正在尝试在 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我会研究 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
构建 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.