Skip to content

Cookbook

Mikhail Savochkin edited this page Jan 19, 2017 · 1 revision

Here is a list of commands you can use with subutai-p2p:

p2p help will display list of commands available to use and p2p help <command> will give more details explanation about each command.

Before you perform any actions with p2p you should start it in daemon mode by running p2p daemon command. You can provide -rpc argument, which accepts port number to listen to and -save argument with path to a save-file to save information about networks you run. If file doesn't exists it will be created. Otherwise - daemon will read this file and restore every network from this file.

Create/destroy p2p connection

To create p2p network you should use start command with a list of arguments that allow you to configure your network. There is a lot of arguments available, but bare minimum is:

p2p start -ip dhcp -hash test-hash

This will let p2p to connect and join test-hash network, which doesn't use any encryption. Note, that this network should exists, otherwise p2p will not be able to retrieve IP address and will gently notify about it after 10 attempts. p2p start will return non-zero exit code in this case (and in other problematic cases too). If you want to create a completely new network - you should manually specify IP address for -ip argument. Other clients, that connect after yours can use dhcp, because system already knows which IP subnet is used for test-hash hash.

Other useful argument is a -key - you can add some encryption to your network traffic by providing an AES-key. Also:

  • -dev <NAME> will create TAP-interface with provided name
  • -dht <HOST:PORT> will use specified DHT server
  • -fwd flag will force p2p to disable discovery of nearby hosts and will use proxy to pass traffic. This will make your connection much slower in a case when proxy is overloaded.
  • -mac <HW_ADDR> - created TAP-interface will have provided hardware address
  • -port <PORT> - p2p will listen to this port for incoming connections
  • -ports <MIN-MAX> - p2p will use specified range of ports for communication
  • -ttl <KEYTIME> - specified AES-key will be used before specified timestamp. Note, that this is not Time-To-Live!

To stop p2p connection you should use p2p stop -hash <HASH> command with a hash of network you wish to stop. If you have multiple networks you want to stop - you should run this command multiple times for each hash. This will also remove network entry from save file and network will not be restored after daemon restart.

Modifying network behaviour

You can use set command to modify particular network. You should specify hash of target network by providing hash argument. For example, if you want to set log level for network test-hash you should run the following command: p2p -set -hash test-hash -log DEBUG Available log levels if TRACE, DEBUG, INFO, WARNING, ERROR

Also, set can be used to update crypto-key (for example, you may want to add some new AES-key, that will be used after current key become obsolete): p2p set -hash test-hash -key MYNEWAESKEY -ttl TIMESTAMP This will add provided key to a queue of keys.

Getting information about network

There is a set of commands available, that can be used to know status of p2p networks.

p2p show displays overall information about network or about particular network/peer:

  • p2p show will display information about active networks: TAP Interface MAC address, IP of TAP interface and hash
  • p2p show -hash <HASH> will display information about specified network in a form of table with information about peers: Peer ID, IP, Endpoint IP and MAC address
  • p2p show -check <IP> will display integration status with particular peer. Also it will return zero exit code if peer was integrated into network (it is known to our p2p client) or non-zero exit code if it's not

p2p status is another useful command that display status of all peers know to p2p client with parser-friendly information structure. Much like p2p show -hash <HASH>, but with some additional details, like latest error from peer communication

p2p debug also will show information about known peers as well as some internal information, that might be useful to p2p developers. If you run into any troubles - execute p2p debug and send it to developers as well as p2p version command output