简单代理需要另一个带有扭曲的代理 [英] Simple proxy requiring another proxy with twisted

查看:42
本文介绍了简单代理需要另一个带有扭曲的代理的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我遇到了这个使用 Twisted 的简单代理示例:

I came across this simple proxy example that uses Twisted:

# Copyright (c) Twisted Matrix Laboratories.
# See LICENSE for details.

from twisted.internet import reactor
from twisted.web import proxy, server

site = server.Site(proxy.ReverseProxyResource('yahoo.com', 80, ''))
reactor.listenTCP(8080, site)
reactor.run()

问题是我的电脑需要使用代理本身来访问网络,所以我想知道是否有办法指定这些代理设置?

The issue is that my computer needs to use a proxy itself to access the web, so I was wondering if there is a way to specify those proxy settings?

推荐答案

并非如此.至少,使用 Twisted 实现这一点并不容易.

Not really. At least, there's not an easy way to do it with Twisted.

ReverseProxyResource 委托给 ReverseProxyRequest 执行 直接 TCP 连接到指定主机(在本例中为 yahoo.com).

ReverseProxyResource delegates to ReverseProxyRequest which does a direct TCP connection to the specified host (in this case, yahoo.com).

您可以可能通过调整ReverseProxyRequest 来使用twisted.web.client.ProxyAgent 来拼凑一些东西.可以说,Twisted 本身应该提供一种通过代理参数化 ReverseProxyResource 的方法.

You could probably cobble something together by adapting ReverseProxyRequest to use twisted.web.client.ProxyAgent. Arguably, Twisted itself should provide a way to parametrize ReverseProxyResource by agent.

这篇关于简单代理需要另一个带有扭曲的代理的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆