Created
April 22, 2010 17:10
-
-
Save simonw/375493 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| "For generating fake IP addresses" | |
| import random | |
| def make_ip_issuer(chance_of_a_repeat = 0.0): | |
| issued_ips = [] | |
| def issue(): | |
| if issued_ips and random.uniform(0.0, 1.0) < chance_of_a_repeat: | |
| return random.choice(issued_ips) | |
| ip = '%s.%s.%s.%s' % ( | |
| random.randint(0, 255), random.randint(0, 255), | |
| random.randint(0, 255), random.randint(0, 255) | |
| ) | |
| issued_ips.append(ip) | |
| return ip | |
| return issue |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment