gpt4 book ai didi

python - 如何将此代理切换为使用代理身份验证?

转载 作者:太空宇宙 更新时间:2023-11-03 19:39:23 24 4
gpt4 key购买 nike

我正在尝试修改我的简单 Twisted Web 代理以使用“代理身份验证”(用户名/密码)而不是当前基于 IP 的身份验证。问题是,我是 Twisted 新手,甚至不知道从哪里开始。

这是我的工厂类。

class ProxyFactory(http.HTTPFactory):
def __init__(self, ip, internal_ips):
http.HTTPFactory.__init__(self)
self.ip = ip
self.protocol = proxy.Proxy
self.INTERNAL_IPS = internal_ips


def buildProtocol(self, addr):
print addr
# IP based authentication -- need to switch this to use standard Proxy password authentication
if addr.host not in self.INTERNAL_IPS:
return None
#p = protocol.ServerFactory.buildProtocol(self, addr)
p = self.protocol()
p.factory = self
# timeOut needs to be on the Protocol instance cause
# TimeoutMixin expects it there
p.timeOut = self.timeOut
return p

知道我需要做什么才能完成这项工作吗?感谢您的帮助!

最佳答案

不久前 Twisted 邮件列表上出现了类似的问题:

http://www.mail-archive.com/twisted-python@twistedmatrix.com/msg01080.html

正如我在那里提到的,您可能需要对一些 twins.proxy 类进行子类化,以便它们理解 Proxy-Authenticate 和 Proxy-Authorization header 。

关于python - 如何将此代理切换为使用代理身份验证?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1336882/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com