2009-08-26 47 views
1

我正在嘗試修改簡單的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 

任何想法,我需要做什麼,使這項工作?謝謝你的幫助!

回答