#3237: CIDR  in INTERNAL_IPS
---------------------------------------------+------------------------------
Reporter:  Jeremy Dunck <[EMAIL PROTECTED]>  |        Owner:  adrian
Type: enhancement | Status: new Priority: normal | Milestone: Component: Core framework | Version: Severity: normal | Resolution: Keywords: | ---------------------------------------------+------------------------------
Comment (by Jeremy Dunck <[EMAIL PROTECTED]>):

code, un-hosed:
{{{
class CIDR_LIST(list):
    def __init__(self, cidrs):
        self.cidrs = []
        try:
            #http://cheeseshop.python.org/pypi/IPv4_Utils/0.35
            import ipv4
            for cidr in cidrs:
                self.cidrs.append(ipv4.CIDR(cidr))
        except ImportError:
            pass
    def __contains__(self, ip):
        import ipv4
        try:
            for cidr in self.cidrs:
                if ipv4.CIDR(ip) in cidr:
                    return True
        except:
            pass
        return False

INTERNAL_IPS = CIDR_LIST([
    '127.0.0.1',
    '10.0.0.0/24'
    ])
}}}

--
Ticket URL: <http://code.djangoproject.com/ticket/3237#comment:>
Django <http://code.djangoproject.org/>
The web framework for perfectionists with deadlines.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Django 
updates" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-updates?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to