Prepair for 1.0.3
This commit is contained in:
parent
62e9db453e
commit
ec825cc0ad
@ -1,5 +1,9 @@
|
|||||||
|
#!/usr/bin/env python
|
||||||
|
# PyLCG - Linear Congruential Generator for IP Sharding - Developed by acidvegas ib Python (https://github.com/acidvegas/pylcg)
|
||||||
|
# pylcg/__init__.py
|
||||||
|
|
||||||
from .core import LCG, IPRange, ip_stream
|
from .core import LCG, IPRange, ip_stream
|
||||||
|
|
||||||
__version__ = "1.0.3"
|
__version__ = "1.0.3"
|
||||||
__author__ = "acidvegas"
|
__author__ = "acidvegas"
|
||||||
__all__ = ["LCG", "IPRange", "ip_stream"]
|
__all__ = ["LCG", "IPRange", "ip_stream"]
|
||||||
|
10
pylcg/cli.py
10
pylcg/cli.py
@ -1,6 +1,12 @@
|
|||||||
|
#!/usr/bin/env python
|
||||||
|
# PyLCG - Linear Congruential Generator for IP Sharding - Developed by acidvegas ib Python (https://github.com/acidvegas/pylcg)
|
||||||
|
# pylcg/cli.py
|
||||||
|
|
||||||
import argparse
|
import argparse
|
||||||
|
|
||||||
from .core import ip_stream
|
from .core import ip_stream
|
||||||
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
parser = argparse.ArgumentParser(description='Ultra-fast random IP address generator with optional sharding')
|
parser = argparse.ArgumentParser(description='Ultra-fast random IP address generator with optional sharding')
|
||||||
parser.add_argument('cidr', help='Target IP range in CIDR format')
|
parser.add_argument('cidr', help='Target IP range in CIDR format')
|
||||||
@ -26,5 +32,7 @@ def main():
|
|||||||
for ip in ip_stream(args.cidr, args.shard_num, args.total_shards, args.seed, args.state):
|
for ip in ip_stream(args.cidr, args.shard_num, args.total_shards, args.seed, args.state):
|
||||||
print(ip)
|
print(ip)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
main()
|
main()
|
@ -1,6 +1,11 @@
|
|||||||
|
#!/usr/bin/env python
|
||||||
|
# PyLCG - Linear Congruential Generator for IP Sharding - Developed by acidvegas ib Python (https://github.com/acidvegas/pylcg)
|
||||||
|
# pylcg/core.py
|
||||||
|
|
||||||
import ipaddress
|
import ipaddress
|
||||||
import random
|
import random
|
||||||
|
|
||||||
|
|
||||||
class LCG:
|
class LCG:
|
||||||
'''Linear Congruential Generator for deterministic random number generation'''
|
'''Linear Congruential Generator for deterministic random number generation'''
|
||||||
|
|
||||||
|
@ -1,6 +1,11 @@
|
|||||||
|
#!/usr/bin/env python
|
||||||
|
# PyLCG - Linear Congruential Generator for IP Sharding - Developed by acidvegas ib Python (https://github.com/acidvegas/pylcg)
|
||||||
|
# pylcg/state.py
|
||||||
|
|
||||||
import os
|
import os
|
||||||
import tempfile
|
import tempfile
|
||||||
|
|
||||||
|
|
||||||
def save_state(seed: int, cidr: str, shard: int, total: int, lcg_current: int):
|
def save_state(seed: int, cidr: str, shard: int, total: int, lcg_current: int):
|
||||||
'''
|
'''
|
||||||
Save LCG state to temp file
|
Save LCG state to temp file
|
||||||
@ -12,9 +17,8 @@ def save_state(seed: int, cidr: str, shard: int, total: int, lcg_current: int):
|
|||||||
:param lcg_current: Current LCG state
|
:param lcg_current: Current LCG state
|
||||||
'''
|
'''
|
||||||
|
|
||||||
file_name = f'pylcg_{seed}_{cidr.replace("/", "_")}_{shard}_{total}.state'
|
file_name = f'pylcg_{seed}_{cidr.replace("/", "_")}_{shard}_{total}.state'
|
||||||
|
|
||||||
state_file = os.path.join(tempfile.gettempdir(), file_name)
|
state_file = os.path.join(tempfile.gettempdir(), file_name)
|
||||||
|
|
||||||
with open(state_file, 'w') as f:
|
with open(state_file, 'w') as f:
|
||||||
f.write(str(lcg_current))
|
f.write(str(lcg_current))
|
||||||
|
Loading…
Reference in New Issue
Block a user