1

現在の IP ベースの認証の代わりに「プロキシ認証」(ユーザー名/パスワード) を使用するように、単純な Twisted Web プロキシを変更しようとしています。問題は、私は 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

これを機能させるために何をする必要があるか考えていますか? ご協力いただきありがとうございます!

4

1 に答える 1

1

同様の質問が少し前にTwistedメーリングリストに出てきました:

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

そこで述べたように、Proxy-AuthenticateヘッダーとProxy-Authorizationヘッダーを理解できるように、twisted.proxyクラスのいくつかをサブクラス化する必要があります。

于 2009-09-22T21:20:05.360 に答える