示例#1
0
		my_node.send_presentation_request((target_ip, target_port))
	elif command == 'ping':
		""" Send ping request """
		my_node = Node()
		target_ip = sys.argv[2]
		target_port = int(sys.argv[3])
		if my_node.ping(('', target_ip, target_port)) == 0:
			print("Online")
		else:
			print("Offline")
	elif command == 'get':
		""" Get topic """
		my_node = Node()
		my_node.get_topic(sys.argv[2])
		""" Run node and wait for response """
		my_node.run()
	elif command == 'add':
		if sys.argv[2] == 'contact':
			""" Add contact """
			my_node = Node()
			my_node.register_contact(sys.argv[3], sys.argv[4], sys.argv[5])
		if sys.argv[2] == 'topic':
			""" Add contact """
			my_node = Node()
			my_node.add_topic(topic_id=sys.argv[3], data=sys.argv[4])
			my_node.run()
	elif command == 'init':
		""" Pass full path to a kbuckets.json file """
		my_node = Node()
		my_node.run(sys.argv[2])
	elif command == 'specific':