Advertisement
Guest User

Untitled

a guest
Feb 21st, 2019
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.79 KB | None | 0 0
  1. import sys
  2.  
  3.  
  4. def print_help():
  5. help_msg = '''
  6. This is test tool for qa,
  7. Usage: main.py <ip_type> ip1 ip2
  8. Example: main.py ipv4 192.168.0.1 127.0.0.1
  9. '''
  10. print(help_msg)
  11.  
  12.  
  13. def handle_ipv4(ips):
  14. print("I am here")
  15. parsed_ips = []
  16. for ip in ips:
  17. parsed_ips.append(ip.replace('.', ''))
  18.  
  19. parsed_ips.sort()
  20. print(parsed_ips)
  21.  
  22. with open('blocked_ips', 'wb') as f:
  23. for ip in parsed_ips:
  24. # f.write(int(ip).to_bytes(1))
  25. print(int(ip).to_bytes(1, byteorder='big'))
  26.  
  27. def handle_ipv6(ips):
  28. pass
  29.  
  30.  
  31. if len(sys.argv) < 3:
  32. print_help()
  33. exit(0)
  34.  
  35.  
  36. if sys.argv[1] == "inet4":
  37. handle_ipv4(sys.argv[2:])
  38. elif sys.argv[1] == "inet6":
  39. handle_ipv6(sys.argv[2:])
  40. else:
  41. print_help()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement