Changeset 351

Show
Ignore:
Timestamp:
07/14/08 14:33:10 (6 months ago)
Author:
rgl
Message:

Bugfix: binaryproxy not honoring access whitelist.

This closes #23.

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • branches/0.5/daemon/orbited/binaryproxy.py

    r335 r351  
     1from config import map as config 
    12from tcp import TCPConnection, TCPConnectionFactory 
    23from twisted.internet import reactor, defer 
     
    6061        for item in self.buffer: 
    6162            self.remote_conn.send(item) 
     63        # TODO clear buffer? 
    6264     
    6365    def dataReceived(self, data): 
     
    7173            self.host = host 
    7274            self.port = int(port) 
     75            # TODO DRY this with ProxyConnection. 
     76            if (self.host, self.port) not in config['[access]']: 
     77                log.warn('unauthorized', data) 
     78                raise (Exception("Unauthorized"), "(host, port) pair not authorized for proxying") 
    7379            log.access(self.getClientIP(), "TCP/bin", " -> ", self.host, ":", self.port, " [ ", self.getClientIP(), " ]") 
     80            # TODO set errback (also look for errback misses in other classes)! 
    7481            self.factory.client.connect(self.host, self.port).addCallback(self.connected_remote) 
    7582            self.state = 'proxy' 
    7683        except Exception, x: 
     84            # TODO when we raise the unauthorized message, the client does not understand it. 
    7785            self.send("Invalid handhsake: " + str(x) + "(payload: %s)" % data) 
    7886            self.loseConnection() 
     
    9199        if self.remote_conn: 
    92100            self.remote_conn.transport.loseConnection() 
     101        # TODO set connected=False et al? 
    93102#        print "Proxy Connection Lost", self.id 
    94103