Pass IPv4 via CLI argument
This commit is contained in:
1
.gitignore
vendored
Normal file
1
.gitignore
vendored
Normal file
@@ -0,0 +1 @@
|
|||||||
|
.idea
|
||||||
21
6to4_converter.py
Normal file → Executable file
21
6to4_converter.py
Normal file → Executable file
@@ -1,9 +1,18 @@
|
|||||||
#!/usr/bin/env python3
|
#!/usr/bin/env python3
|
||||||
|
|
||||||
|
import argparse
|
||||||
|
|
||||||
def get_ipv4_from_user():
|
|
||||||
user_in = input("Enter IPv4 address: ")
|
def parse_args():
|
||||||
return user_in
|
parser = argparse.ArgumentParser(description='Get 6to4 address from IPv4 address.')
|
||||||
|
parser.add_argument('-a', '--address', dest='address', action='store', help='IPv4 address', required=True)
|
||||||
|
args = parser.parse_args()
|
||||||
|
return args
|
||||||
|
|
||||||
|
|
||||||
|
def get_address():
|
||||||
|
args = parse_args()
|
||||||
|
return args.address
|
||||||
|
|
||||||
|
|
||||||
def ipv4_to_ipv6(ipv4):
|
def ipv4_to_ipv6(ipv4):
|
||||||
@@ -39,8 +48,10 @@ def ipv4_to_ipv6(ipv4):
|
|||||||
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
ipv4 = get_ipv4_from_user()
|
ipv4 = get_address()
|
||||||
output = ipv4_to_ipv6(ipv4)
|
output = ipv4_to_ipv6(ipv4)
|
||||||
print(output)
|
print(output)
|
||||||
|
|
||||||
main()
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
main()
|
||||||
|
|||||||
Reference in New Issue
Block a user