add create_tunnel method to cli
This commit is contained in:
@ -58,6 +58,10 @@ Remove couple of nodes:
|
|||||||
|
|
||||||
testnet> remove d34db33f1001 3f1001d34db3
|
testnet> remove d34db33f1001 3f1001d34db3
|
||||||
|
|
||||||
|
Create I2P tunnel (options are specified exactly as `key=value` without spaces):
|
||||||
|
|
||||||
|
testnet> create_tunnel d34db33f1001 test-tunnel type=http host=127.0.0.1 port=8888 keys=test.dat
|
||||||
|
|
||||||
Stop a network and quit:
|
Stop a network and quit:
|
||||||
|
|
||||||
testnet> stop
|
testnet> stop
|
||||||
|
@ -17,7 +17,7 @@ __version__ = "0.1"
|
|||||||
|
|
||||||
history = InMemoryHistory()
|
history = InMemoryHistory()
|
||||||
TestnetCompleter = WordCompleter(['help', 'quit', 'start', 'stats', 'stop',
|
TestnetCompleter = WordCompleter(['help', 'quit', 'start', 'stats', 'stop',
|
||||||
'add', 'remove', 'inspect'])
|
'add', 'create_tunnel', 'remove', 'inspect'])
|
||||||
|
|
||||||
|
|
||||||
def start(testnet):
|
def start(testnet):
|
||||||
@ -54,6 +54,18 @@ def add(testnet, count=1, floodfill=False):
|
|||||||
|
|
||||||
print("*** Added {} nodes".format(count))
|
print("*** Added {} nodes".format(count))
|
||||||
|
|
||||||
|
def create_tunnel(testnet, cid, name, args):
|
||||||
|
"""Create tunnel. Usage: [id] [name] [option=value] ..."""
|
||||||
|
node = testnet.NODES[cid]
|
||||||
|
options = {}
|
||||||
|
for x in args:
|
||||||
|
k, v = x.split("=")
|
||||||
|
options[k] = v
|
||||||
|
|
||||||
|
node.add_tunnel(name, options)
|
||||||
|
time.sleep(1)
|
||||||
|
print("*** Tunnel created: {}".format(node.tunnel_destinations()[-1]))
|
||||||
|
|
||||||
def remove(testnet, ids):
|
def remove(testnet, ids):
|
||||||
"""Remove node(s) from testnet. Usage: remove [id] ..."""
|
"""Remove node(s) from testnet. Usage: remove [id] ..."""
|
||||||
for n in ids:
|
for n in ids:
|
||||||
@ -84,6 +96,7 @@ def print_help():
|
|||||||
stats\t{}
|
stats\t{}
|
||||||
stop\t{}
|
stop\t{}
|
||||||
add \t{}
|
add \t{}
|
||||||
|
create_tunnel \t{}
|
||||||
remove \t{}
|
remove \t{}
|
||||||
inspect \t{}
|
inspect \t{}
|
||||||
quit\tStop testnet and quit
|
quit\tStop testnet and quit
|
||||||
@ -93,6 +106,7 @@ def print_help():
|
|||||||
stats.__doc__,
|
stats.__doc__,
|
||||||
stop.__doc__,
|
stop.__doc__,
|
||||||
add.__doc__,
|
add.__doc__,
|
||||||
|
create_tunnel.__doc__,
|
||||||
remove.__doc__,
|
remove.__doc__,
|
||||||
inspect.__doc__,)
|
inspect.__doc__,)
|
||||||
)
|
)
|
||||||
@ -135,6 +149,9 @@ def main():
|
|||||||
elif command[0] == "add":
|
elif command[0] == "add":
|
||||||
args = command[1:] if len(command) > 1 else []
|
args = command[1:] if len(command) > 1 else []
|
||||||
add(testnet, *args)
|
add(testnet, *args)
|
||||||
|
elif command[0] == "create_tunnel":
|
||||||
|
if len(command) < 7: continue
|
||||||
|
create_tunnel(testnet, command[1], command[2], command[3:])
|
||||||
elif command[0] == "remove":
|
elif command[0] == "remove":
|
||||||
if len(command) < 2: continue
|
if len(command) < 2: continue
|
||||||
remove(testnet, command[1:])
|
remove(testnet, command[1:])
|
||||||
|
Reference in New Issue
Block a user