如何切换此代理以使用代理身份验证? [英] How do I switch this Proxy to use Proxy-Authentication?

查看:122
本文介绍了如何切换此代理以使用代理身份验证?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I'm trying to modify my simple Twisted web proxy to use "Proxy-Authentication" (username/password) instead of the current IP based authentication. Problem is, I'm new to Twisted and don't even know where to start.

这是我的工厂班级.

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

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

Any idea what I need to do to make this work? Thanks for your help!

推荐答案

前一阵子,在Twisted邮件列表上也出现了类似的问题:

A similar question came up on the Twisted mailing list a while ago:

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

就像我在那儿提到的那样,您可能需要子类化某些twisted.proxy类,以便它们理解Proxy-Authenticate和Proxy-Authorization标头.

As I mentioned there, you probably need to subclass some of the twisted.proxy classes so that they understand the Proxy-Authenticate and Proxy-Authorization headers.

这篇关于如何切换此代理以使用代理身份验证?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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