Logo Peer-to-peer VPN

Github Gist

On this page I will present a small (40 lines) Python script that allows VpnCloud to store and load beacons using Github Gists.

The Python script is very simple and has the following requirements:


  1. Register a Github account if you don't have one

  2. Go to the Github token management and create a new access token. When prompted for the permissions, give it just the "Gists" permission. Save the token (e.g. 0123456789abcdef0123456789abcdef) that is displayed somewhere (e.g. a text editor), you will need it later.

  3. Got to the Gists page and create a new gist. You will have to give it a name and even give a filename and some contents for that file. However, all this information does not matter. Just press the "Create secret gist" button. You will be redirected to a new page. Take a look at the URL in the address bar: The last part is your gist id (e.g. 0123456789abcdef0123456789abcdef). Save that id, you will need it later.

  4. Download the Python script and copy it to a location of your choice. For this howto I will go with the path /home/user/bin/gist-beacon.py.

  5. Edit the script with your editor of choice:

    • Change the NODE variable on top to a name of your node that is unique within your VPN.
    • Change the GIST_ID variable to the gist id that you saved.
    • Change the AUTH_TOKEN variable to the token you saved.
    • Make sure to keep the double quotes around the values and to not change anything else.
    • Save the file and close the editor.
  6. Make the script executable:

    $> chmod +x /home/user/bin/gist-beacon.py

The steps 4-6 have to be repeated for every node. Make sure to use the same gist id for all nodes. If you wish, you can generate different tokens for each node or use the same token for all.

Storing and Loading Beacons

Add the following lines to your VpnCloud network config file:

  store: "|/home/user/bin/gist-beacon.py store $beacon"
  load: "|/home/user/bin/gist-beacon.py load"

The nodes will now automatically exchange beacons using the gist you created.


If you want, you can open the gist from time to time and remove old beacons from nodes that do no longer exist:

  1. Go to the Gists page and open your gist.
  2. Click on the "edit" button on the top.
  3. Remove all old beacons by clicking on the trash bin icon next to the node name.
  4. Click on the "update secret gist" button.