Changeset 09370c in indico


Ignore:
Timestamp:
07/27/11 15:38:57 (22 months ago)
Author:
Pedro Ferreira <jose.pedro.ferreira@…>
Branches:
master, burotel, hello-world-walkthrough, ipv6, v0.98-series, v0.98.2, v0.98.3, v0.98b1, v0.98b2, v0.99, 051b2622c51afb171a1dedb46a0df4fbb0cbd02e, 4c7d4152dff271ba5df5a8606605969cab454080
Children:
6c9393
Parents:
44d915
Message:

[IMP] Network-wide ACLs for export.py

  • Hopefully temporary;
Location:
indico
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • indico/MaKaC/RSSinterface/conference.py

    r5e7b56 r09370c  
    2828from MaKaC.common.timezoneUtils import nowutc 
    2929import MaKaC.common.info as info 
     30import struct, socket 
    3031 
    3132 
     33# TOREMOVE 
    3234def ACLfiltered(iter, requestIP, aw=None): 
    3335 
     36    def _inIPList(iplist, ip): 
     37 
     38        for rule in iplist: 
     39            if '/' in rule: 
     40                # it's a netmask (CIDR), check if ip belongs to it 
     41                # ipv4-specific, non-endian-safe check! 
     42                ipaddr = struct.unpack('L', socket.inet_aton(ip))[0] 
     43                netaddr, bits = rule.split('/') 
     44                netmask = struct.unpack('L', socket.inet_aton(netaddr))[0] & ((2L << int(bits) - 1) - 1) 
     45                if ipaddr & netmask == netmask: 
     46                    return True 
     47            else: 
     48                if ip in iplist: 
     49                    return True 
     50        return False 
     51 
    3452    acl = Config.getInstance().getExportACL().iteritems() 
    35     blIds = list(categ for (categ, iplist) in acl if (requestIP not in iplist)) 
     53    blIds = list(categ for (categ, iplist) in acl if (not _inIPList(iplist, requestIP))) 
    3654 
    3755    for conf in iter: 
  • indico/htdocs/scripts/export.py

    rfcbd84 r09370c  
    4848  minfo = info.HelperMaKaCInfo.getMaKaCInfoInstance() 
    4949 
    50   hostIP = req.get_remote_host() 
     50  hostIP = req.get_remote_ip() 
    5151  if minfo.useProxy(): 
    5252      # if we're behind a proxy, use X-Forwarded-For 
    53       xff = req.headers_in.get("X-Forwarded-For", hostIP).split(", ")[-1] 
    54       hostIP = socket.gethostbyname(xff) 
     53      hostIP = req.headers_in.get("X-Forwarded-For", hostIP).split(", ")[-1] 
    5554 
    5655  if minfo.getRoomBookingModuleActive(): 
Note: See TracChangeset for help on using the changeset viewer.