Changeset 486

Show
Ignore:
Timestamp:
08/12/08 08:57:52 (5 months ago)
Author:
heyadayo
Message:

Added host-based ACL -- closes ticket 40

Location:
trunk/daemon
Files:
6 modified

Legend:

Unmodified
Added
Removed
  • trunk/daemon/orbited-debug.cfg

    r445 r486  
    1515 
    1616[access] 
    17 irc.freenode.net:6667 
    18 localhost:6667 
    19 localhost:61613 
    20 localhost:7 
     17localhost:8001-> irc.freenode.net:6667 
     18* -> irc.freenode.org:6667 
     19* -> localhost:6163 
     20* -> localhost:7 
     21localhost:8001 -> localhost:6667 
    2122 
    2223[logging] 
  • trunk/daemon/orbited.cfg

    r440 r486  
    1414 
    1515[static] 
    16 #tmp=/tmp 
    1716 
    1817[access] 
    19 irc.freenode.net:6667 
    20 localhost:61613 
     18127.0.0.1:8001 -> irc.freenode.net:6667 
     19localhost:8001 -> irc.freenode.net:6667 
     200.0.0.0:8001 -> irc.freenode.net:6667 
    2121 
    2222[logging] 
  • trunk/daemon/orbited/cometsession.py

    r481 r486  
    138138        self.protocol.connectionLost(None) 
    139139             
     140    hostHeader = property(lambda s: s.transportProtocol.hostHeader) 
    140141     
    141142class TCPConnectionResource(resource.Resource): 
     
    149150    pingInterval = 40 
    150151 
    151     def __init__(self, root, key, peer, host, **options): 
     152    def __init__(self, root, key, peer, host, hostHeader, **options): 
    152153        resource.Resource.__init__(self) 
    153154         
     
    156157        self.peer = peer 
    157158        self.host = host 
     159        self.hostHeader = hostHeader 
    158160        self.transport = None 
    159161        self.cometTransport = None 
     
    413415        print request.getClientIP(), repr(request.getClientIP()) 
    414416        # request.client and request.host should be address.IPv4Address classes 
    415         self.connections[key] = TCPConnectionResource(self, key, request.client, request.host) 
     417        hostHeader = request.headers.get('Host', '') 
     418        self.connections[key] = TCPConnectionResource(self, key, request.client, request.host, hostHeader) 
    416419        self.listeningPort.connectionMade(self.connections[key]) 
    417420        self.logger.debug('created conn: ', repr(self.connections[key])) 
  • trunk/daemon/orbited/config.py

    r417 r486  
    3535    }, 
    3636 
    37     '[access]': [ 
    38         #('irc.freenode.net', 6667), 
    39     ], 
     37    '[access]': { 
     38        #('irc.freenode.net', 6667): ['localhost:8001', '127.0.0.1:8001'], 
     39    }, 
    4040 
    4141    '[static]': { 
     
    104104            # assign each source in the proxy section to a target address and port 
    105105            if section == '[access]': 
    106                 if ':' in line: 
    107                     addr, port = line.split(':', 1) 
    108                     port = int(port) 
     106                if '->' not in line: 
     107                    raise ValueError, "line %s -- [access] lines must contain an ->" % (i+1) 
     108                source, dest = line.split('->') 
     109                source, dest = source.strip(), dest.strip() 
     110                print 'dest is', dest 
     111                print 'source is', source 
     112                if ':' in dest: 
     113                    daddr, dport = dest.split(':', 1) 
     114                    dport = int(dport) 
    109115                else: 
    110                     addr, port = target, 80 
    111                 map[section].append((addr, port)) 
     116                    daddr, dport = dest, 80 
     117                if (daddr, dport) not in map[section]: 
     118                    map[section][(daddr, dport)] = [] 
     119                map[section][(daddr, dport)].append(source) 
    112120                continue 
    113121            if section == '[listen]': 
  • trunk/daemon/orbited/proxy.py

    r481 r486  
    5151                return 
    5252            peer = self.transport.getPeer() 
    53             if (host, port) not in config.map['[access]']: 
     53            allowed = False 
     54            for source in config.map['[access]'].get((host, port), []): 
     55                if source == self.transport.hostHeader or source == '*': 
     56                    allowed = True 
     57                    break 
     58            if not allowed: 
    5459                self.logger.warn('Unauthorized connect from %r:%d to %r:%d' % (peer.host, peer.port, host, port)) 
    5560                self.transport.write("0" + str(ERRORS['Unauthorized'])) 
  • trunk/daemon/orbited/static/xsdrBridge.html

    r484 r486  
    130130    var responseIndex = 0; 
    131131    xhr.onreadystatechange = function() { 
    132         debug('onreadystatechange', xhr.readyState); 
    133         var payload = { 
    134             readyState: xhr.readyState 
     132        // NOTE: after an abort, a readystatechange will cause an error... 
     133        // TOOD: to aborts by pushing 'ABORT' instead of ifr.src= null from the 
     134        //       parent (Orbited.XSDR.abort) 
     135        try { 
     136;;;         debug('onreadystatechange', xhr.readyState); 
     137            var payload = { 
     138                readyState: xhr.readyState 
     139            } 
     140            try { 
     141                payload['status'] = xhr.status 
     142            } 
     143            catch(e) {            
     144            } 
     145            try { 
     146                var data = xhr.responseText.slice(responseIndex) 
     147                responseIndex = xhr.responseText.length; 
     148                payload['responseText'] = data; 
     149            } 
     150            catch(e) { 
     151            } 
     152;;;         debug('pushing payload', payload); 
     153            push(["readystatechange", payload]) 
     154     
     155            if (xhr.readyState == 4) { 
     156                req = null; 
     157                return doNextRequest(); 
     158            } 
    135159        } 
    136         try { 
    137             payload['status'] = xhr.status 
    138         } 
    139         catch(e) {            
    140         } 
    141         try { 
    142             var data = xhr.responseText.slice(responseIndex) 
    143             responseIndex = xhr.responseText.length; 
    144             payload['responseText'] = data; 
    145         } 
    146         catch(e) { 
    147         } 
    148         debug('pushing payload', payload) 
    149         push(["readystatechange", payload]) 
    150  
    151         if (xhr.readyState == 4) { 
    152             req = null; 
    153             return doNextRequest(); 
    154         } 
     160    catch(e) { 
     161    } 
    155162    } 
    156163    xhr.open(smethod, surl, true)