GithubHelp home page GithubHelp logo

python-iptools's Introduction

===== python-iptools =====

Utitlities for dealing with ip addresses.

  A few useful functions and objects for manipulating ip addresses in python. 
  This was all inspired by a desire to be able to use CIDR address notation to 
  designate INTERNAL_IPS in a Django project's settings file.

  The IpRangeList object can be used in a django settings file to allow CIDR 
  notation and/or (start, end) ranges to be used in the INTERNAL_IPS list.

  Example:

    INTERNAL_IPS = IpRangeList(
        '127.0.0.1',
        '192.168/16',
        ('10.0.0.1', '10.0.0.19'),
    )

python-iptools's People

Watchers

 avatar

python-iptools's Issues

python3k compatibility

It has been mentioned on
[http://stackoverflow.com/questions/1942160/python-3-create-a-list-of-possible-i
p-addresses-from-a-cidr-notation/1942178#1942178
stackoverflow] that it would be non-trivial to make iptools work with python3k.

Sounds like a challenge to me. :)

Original issue reported on code.google.com by casadebender on 1 Jan 2010 at 6:14

IPv6

Is IPv6 in IPTools roadmap? Thanks!

Original issue reported on code.google.com by fran.net on 13 Nov 2011 at 9:00

long2ip does not handle range errors

What steps will reproduce the problem?
1. long2ip(-1)
2. long2ip(374297346592387463875L)
3.

What is the expected output? What do you see instead?
expected: TypeError exception "out of range"
got: 1. '255.255.255.255'  2. '10.133.122.195'

What version of the product are you using? On what operating system?
Windows XP
python 2.6.4

Please provide any additional information below.
iptools.__init__.py:229
    if _MAX_IP < l < 0: 
        raise ...
I suppose there should be:
    if _MAX_IP < l or l < 0:

Original issue reported on code.google.com by [email protected] on 16 May 2010 at 6:22

xrange incompatible with long int

As the python documentation describes, some platforms do not support long
int for xrange arguments.

Running the example code from the wiki results in "OverflowError: long int
too large to convert to int" on OS X 10.5.8 on intel mac with the default
system 2.5 python.

I have attached a patch that should work as an alternative. No claim to the
validity or accuracy of the patch.

Original issue reported on code.google.com by [email protected] on 2 Nov 2009 at 10:17

Attachments:

Migration to github and improvements

Hi,

I have various performance and class layout improvements which will massively 
benefit the project (albeit, most are backwards incompatible).

Would you have any objections to me forking this project as python-iptools2 to 
github??

Thanks

Cal

Original issue reported on code.google.com by [email protected] on 9 May 2012 at 6:48

IpRangeList method does not work for IP range tuples

What steps will reproduce the problem?
1. Using an IP range with iptools.IpRangeList
2.
3.

What is the expected output? What do you see instead?

Well, I use __iter__ so it would be the IP addresses that are in that
range. I get an exception instead. Here is the output as shown in pythons
interactive mode. Same thing happens with 2.6.

>>> INTERNAL_IPS = iptools.IpRangeList('1.2.3.4',
('192.168.1.20','192.168.1.60'), '192.168.0.12/24')
Traceback (most recent call last):
  File "<stdin>", line 1, in ?
  File
"/usr/lib/python2.4/site-packages/iptools-0.2-py2.4.egg/iptools/__init__.py",
line 490, in __init__
    self.ips = tuple(map(IpRange, args))
  File
"/usr/lib/python2.4/site-packages/iptools-0.2-py2.4.egg/iptools/__init__.py",
line 376, in __init__
    if validate_cidr(start):
  File
"/usr/lib/python2.4/site-packages/iptools-0.2-py2.4.egg/iptools/__init__.py",
line 156, in validate_cidr
    if _CIDR_RE.match(s):
TypeError: expected string or buffer

The example on the page also fails:

http://code.google.com/p/python-iptools/wiki/DjangoSettings

What version of the product are you using? On what operating system?

I'm not sure but I think you mean iptools, and that's version 0.2. I'm
using python 2.4.3 and python 2.6.1 on CentOS 5 x86.

Please provide any additional information below.

I hope thats enough. I do have a request, perhaps see if this can be part
of the standard python library? It would be nice.

Thanks!

Original issue reported on code.google.com by [email protected] on 2 Jan 2010 at 4:48

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.