Sentinel dVPN Node on Linux
===
Contents
===
* Releases
* Objective
* Setup Instructions for Sentinel Node hosting
* OpenVPN Sentinel Node
* SOCKS5 Sentinel Node
* Helpful docker commands to interact with the Sentinel dVPN Node
* Installation of Sentinel dVPN Desktop App
* Linux
* Windows
* Mac
* Sentinel dVPN Desktop App
* On Start-Up
* Ethereum TestNet
* Ethereum MainNet
* Switching between Networks
* Tendermint TestNet
Releases
===
Check out the latest releases on the [GitHub Repo](https://github.com/sentinel-official/sentinel/releases).
Objective
===
Enable users to set up a Sentinel dVPN OpenVPN and SOCKS5 Node.
Setup Instructions for Sentinel Node hosting
===
Below are the steps involved in getting a Sentinel dVPN OpenVPN and SOCKS5 Node up and running.
0. Configuring firewall
1. Installing docker
2. Running the **Sentinel dVPN** docker image
3. Updating an existing Sentinel dVPN OpenVPN Node
## OpenVPN Sentinel Node
To run the Sentinel dVPN OpenVPN node, a user has to go through the following steps:
### Step 0 --- Configuring Firewall
---
Below are the instructions for configuring the firewall:
1. Firstly, open specific ports on the firewall, as required. Do not open all the ports.
2. UFW or Uncomplicated Firewall is installed by default on Ubuntu. If it has been uninstalled for some reason or needs an update, it can be installed with the following command:
`sudo apt-get install ufw`
3. Type the following command in the terminal to check the status of the firewall
`sudo ufw status verbose`
4. If the status of the firewall is `inactive`, then use the following command to activate it:
`sudo ufw enable`
5. For OpenVPN to work successfully, type the following command to allow the required ports through UFW
`sudo ufw allow 3000`
`sudo ufw allow 1194`
6. Refer to the following image for all the steps explained above.

### Step 1 --- Installing Docker
---
##### OS Requirements
* A 64-bit installation
* Version 3.10 or higher of the Linux kernel.
As the first step to setting Sentinel dPVN OpenVPN node on Linux, the user will need to install [Docker](https://www.docker.com/).
1. Update the apt package index:
`sudo apt-get update`
2. Install required dependencies to get the docker installation script located [here](https://get.docker.com).
`sudo apt-get install curl`
`curl -fsSL get.docker.com -o /tmp/get-docker.sh`
2. Run the downloaded script to setup & install docker
`sudo sh /tmp/get-docker.sh`
3. Add current user to the docker group to give required access
`sudo usermod -aG docker $USER`
### Step 2 --- Running the Sentinel dVPN OpenVPN Node
---
The VPN node can be set up and run in two ways:
1. Quick Run - by downloading docker image from Docker Hub.
2. DIY - by building a custom docker image from the Sentinel code repository.
#### Method #1 [Quick Run: Download Docker Image from Docker Hub]
Using existing docker image:
1. Navigate to the User's home directory.
`cd ~`
2. Create a new folder to pull the docker image and run it.
`mkdir -p $HOME/.sentinel`
3. Pull the official Sentinel docker image from Docker Hub & configure the node.
`sudo docker run -it --privileged --mount type=bind,source=$HOME/.sentinel,target=/root/.sentinel -p 3000:3000 -p 1194:1194/udp sentinelofficial/sentinel-vpn-node:0.0.8-alpha`
#### Method #2 [DIY: Build a Custom Docker Image]
Do-it-Yourself setup by building a custom docker image:
1. Navigate to the root folder or specifiy any other directory for the project and download code from the repository.
`cd ~`
2. Clone the Sentinel repository.
`git clone https://github.com/sentinel-official/sentinel.git`
3. Navigate into the cloned folder to build the docker image.
`cd ~/sentinel/vpn-node-docker`
4. Build the docker image.
`sudo docker build --file Dockerfile.prod --tag sentinel-vpn-node --force-rm --no-cache`
5. Navigate to the folder where the docker container was set up. In this case, it is the User's home directory.
`mkdir -p $HOME/.sentinel`
6. Run the image and configure the node.
`sudo docker run -it --privileged --mount type=bind,source=$HOME/.sentinel,target=/root/.sentinel -p 3000:3000 -p 1194:1194/udp sentinel-vpn-node`
### Step 3 --- Updating an existing Sentinel dVPN OpenVPN Node
===
1. Stop the running docker container.
`sudo docker stop $(sudo docker ps -aq -f ancestor=sentinelofficial/sentinel-vpn-node)`
2. Remove the older version of docker container (if present).
`sudo docker rm -f $(sudo docker ps -aq -f ancestor=sentinelofficial/sentinel-vpn-node)`
3. Remove the older version of docker image (if present).
`sudo docker rmi -f $(sudo docker images -aq -f reference=sentinelofficial/sentinel-vpn-node)`
4. Set the token value to an EMPTY STRING in the config file.
```
Config file location: $HOME/.sentinel/config.data
Example: {"token": "", "enc_method": "AES-256-CBC", "account_addr": "0x656b756e6c6335302e676c343572357232786970", "price_per_gb": 125.0}
```
After completing the above steps, follow the instructions on
[Method #1 (Quick Run: Download Docker Image from Docker Hub)](https://hackmd.io/ZsIiWsMLQ0Oq6FFmm_bDtQ?both#Method-1-Quick-Run-Download-Docker-Image-from-Docker-Hub) to get the node up and running again.
## SOCKS5 Sentinel Node
To **run** the sentinel node in SOCKS5, go through the following steps:
0. Configuring firewall
1. Installing docker
2. Running the **Sentinel dVPN** Socks Node
3. Updating an existing **Sentinel dVPN** SOCKS5 Node
### Step 0 --- Configuring Firewall
---
Below are the instructions for configuring the firewall:
1. First of all open the specific ports on the firewall. Do not open all the ports.
2. UFW or Uncomplicated Firewall is installed by default on Ubuntu. If it has been uninstalled for some reason, install it with
`apt-get install ufw`
3. Type the following command in the terminal to check the status of the firewall.
`ufw status verbose`
4. If firewall is inactive, then type the following command to activate it.
`ufw enable`
5. For SOCKS5 to work successfully, type the following command to allow the ports.
`ufw allow 3000`
`ufw allow 4200`
`ufw allow 4201`
`ufw allow 4202`
`ufw allow 4203`
### Step 1 --- Installing Docker
---
##### OS Requirements
* A 64-bit installation
* Version 3.10 or higher of the Linux kernel.
As the first step to setting Sentinel node on Linux, install [Docker](https://www.docker.com/).
1. Install required dependencies to get the docker installation script located [here](https://get.docker.com).
`sudo apt install -y curl`
`curl -fsSL get.docker.com -o /tmp/get-docker.sh`
2. Run the downloaded script to setup & install docker.
`sudo sh /tmp/get-docker.sh`
3. Add current user to the docker group to give required access.
`sudo usermod -aG docker $USER`
### Step 2 --- Running the Sentinel dVPN Socks Node
---
You can setup and run VPN node in two ways:
1. Quick Run - download docker image from Docker Hub
2. DIY - build your own docker image from the Sentinel code repository
#### Method #1 [Download Docker Image from Docker Hub]
Using existing docker image:
1. Navigate to the User's home directory
`cd ~`
2. Create a new folder to pull the docker image and run it
`mkdir -p $HOME/.sentinel`
3. Pull the official Sentinel docker image from Docker Hub & configure the node
`sudo docker run -it --privileged --mount type=bind,source=$HOME/.sentinel,target=/root/.sentinel -p 3000:3000 -p 4200:4200 -p 4201:4201 -p 4202:4202 -p 4203:4203 sentinelofficial/sentinel-socks5-node:0.0.8-alpha`
#### Method #2 [DIY: Build a Custom Docker Image]
Do-it-Yourself setup by building a custom docker image
1. Navigate to the root folder or specifiy any other directory for the project and download code from the repository.
`cd ~`
2. Clone the Sentinel repository.
`git clone https://github.com/sentinel-official/sentinel.git`
3. Navigate to the folder with code to build the docker image.
`cd ~/sentinel/socks5-node-docker`
4. Build the docker image.
`sudo docker build --file Dockerfile.dev --tag sentinel-socks-node --force-rm --no-cache`
5. Navigate to the folder where the docker container was setup. In this case it is the User's home directory.
`mkdir -p $HOME/.sentinel`
6. Run the image and configure the node.
`sudo docker run -it --privileged --mount type=bind,source=$HOME/.sentinel,target=/root/.sentinel -p 3000:3000 -p 4200:4200 -p 4201:4201 -p 4202:4202 -p 4203:4203 sentinel-socks-node`
### Step 3 --- Updating an existing Sentinel dVPN SOCKS5 Node
===
1. Pull the latest version of docker.
`sudo docker pull sentinelofficial/sentinel-socks5-node`
2. Stop the running docker container.
`sudo docker stop $(sudo docker ps -a -q --filter="ancestor=sentinelofficial/sentinel-socks5-node")`
3. Remove the older version of docker image.
`sudo docker rm $(sudo docker ps -a -q --filter="ancestor=sentinelofficial/sentinel-socks5-node")`
4. Set the token value to an EMPTY STRING in the config file
```
Config file location: $HOME/.sentinel/config.data
Example: {"token": "", "enc_method": "AES-256-CBC", "account_addr": "0x656b756e6c6335302e676c343572357232786970", "price_per_gb": 125.0}
```
After running the above commands,follow the method [#1 (Quick Run: Download Docker Image from Docker Hub)](https://hackmd.io/ZsIiWsMLQ0Oq6FFmm_bDtQ?both#Method-1-Download-Docker-Image-from-Docker-Hub1) to get the node up and running again.
Helpful docker commands to interact with the Sentinel dVPN Node
===
* List a running Sentinel dVPN Node:
```sudo docker ps```
* List both the running and stopped Sentinel dVPN Nodes:
```sudo docker ps -a```
* Stop a particular Sentinel Node:
* run ```sudo docker ps``` and copy the Container ID.
* run ```sudo docker stop ContainerID```
###### Note: stopping a dVPN Node does not remove the container
* Remove a particular Sentinel dVPN Node:
```sudo docker rm ContainerID```
###### Note: The Sentinel dVPN Node must be stopped to be removed. Alternatively, you can use the `-f` flag to forcefully remove the Node if the node can not be stopped.
* Remove all stopped Sentinel dVPN Nodes:
```sudo docker rm $(sudo docker ps -a -q)```
* Stop all the running dVPN Nodes and remove them:
```sudo docker stop $(sudo docker ps -a -q) && sudo docker rm $(sudo docker ps -a -q)```
###### Note 1: In case you previously ran any version of Sentinel client, read the wallet from keystore file in .sentinel folder and use that same address for node setup
###### Note 2: once initialization sequence is complete, press ***ctrl + p + q*** to detach from the docker container and run it in the background.
*We're enabling developer console in this version for better error and log reporting. Please use it when submitting issues in the chat group or on our github repo*
```Please enable TESTNET from topbar for using the Sentinel dVPN```
#### When swix transaction is completed, please click on SENTINEL Logo present at the start of swixer web page in Swixer Tab, to start a new swix transaction.
More specific steps depend on the user's operating system:
1. Linux
2. Mac
3. Windows
### For Mozilla Firefox users there's a caveat [ MacOS | Windows | Ubuntu ]:
Firefox users need to change proxy settings in their browser. To do that,
open firefox and navigate to ``` menu > preferences > network proxy ``` and enter the above details in the respective fields.
# Linux- Installation of Sentinel dVPN Desktop App
The latest deb package for Linux can be downloaded from:
* The Sentinel official GitHub https://github.com/sentinel-official/sentinel/releases/
* The Sentinel official Downloads Page https://sentinel.co/#downloads
1. For downloading the Sentinel dVPN Desktop App on Linux, visit either of these.
There will be two Debian packages, one will be for Linux 16.04, and another will be for Linux 18.04. This guide will cover the installation for Linux 18.04.
Github Page:

Official Downloads Page:

2. After downloading the file, locate the download path.

3. Open the terminal. Go to the path where the Deb file is saved. Before installing the Deb file, run the following command in the terminal. After executing the command, a prompt will ask for permission before continuing.
```
sudo apt install -f
```

3. Install the deb file by running the following command.
```
sudo dpkg -i Sentinel***.deb
```

4. After successful installation, type `sentinel` in the terminal. A prompt will then ask the authentication. Enter the user password and continue to open the app.

---
# Windows- Installation of Sentinel dVPN Desktop App
The latest deb package for Windows can be downloaded from:
* The Sentinel official GitHub https://github.com/sentinel-official/sentinel/releases/
* The Sentinel official Downloads Page https://sentinel.co/#downloads
Github Page:

Official Downloads Page:

1. Download the installer.
2. Once it is downloaded, run the installer (Sentinel-{version}.exe). It will be in C:\Users\{user_name}\Downloads if not specified otherwise.
3. In this version the user can launch the app without "Run As Administrator". However, a prompt will ask the user to give admin access. If a popup saying 'Windows protected your PC' appears, click on "More info" and then click on "Run anyway" to start the installation.
5. Click yes"" to allow the changes to be made on Computer.
6. From next time onwards, the user can run the app from the folder:
```C:/ > Users > {Your Username} > AppData > Local > Sentinel > Sentinel.exe```
**Note:** If AppData is hidden, click on "view" on the top bar and select "hidden items".

Moreover, the user can create a shortcut of the app and save it on their desktop for ease of use. To do that, right click on the sentinel.exe file and select "Create Shortcut". After that, copy the shortcut to Desktop for easy access.
6. In case of any issue during installation, please uninstall any previous installations of OpenVPN through the control panel and then re-install OpenVPN from the following path on the local machine and re-run the Sentinel App.
`C:// > Users > {Your Username} > AppData > Local > Sentinel > app-{version} > resources > extras > openvpn-install-2.3.18-*.exe`

7. The "keystore file" will be stored in the path mentioned below. Save this keystore as it is the only way to give/restore wallet access in any device.
`C:\Users\{Your Username}\.sentinel`

---
# Mac- Installation of Sentinel dVPN Desktop App
The latest exe package for MacOS can be downloaded from:
* The Sentinel official GitHub https://github.com/sentinel-official/sentinel/releases/
* The Sentinel official Downloads Page https://sentinel.co/#downloads
Github Page:

Official Downloads Page:

1. After download completes, run the .dmg file and drag the Sentinel app to ***Applications*** folder.
2. Go to Applications Folder and right click on the "Sentinel app". Then click on the ***Show Package Contents*** option.
3. Then go to ```Contents > MacOs``` and run Sentinel by double clicking the package.
4. Additionally,a shortcut of the app can be created by right clicking the Sentinel package and then selecting ```make alias```. Copy this alias to the Desktop for ease of use.
5. Install homebrew, in case of an error - 'Package ***brew*** is not installed' while connecting to VPN.
6. Please follow instructions from this [howtogeek tutorial](https://www.howtogeek.com/211541/homebrew-for-os-x-easily-installs-desktop-apps-and-terminal-utilities/) to install Homebrew.
---
# Sentinel dVPN Desktop App
Sentinel is an interoperable, secure network layer offering the Sentinel Service Chain exclusively for distributed & decentralized native services like - dVPN, Sentrix (dChat and dVoIP) and more.
## Part A. On StartUp

### Create a new account: Ethereum Network
**Note:** To start creating a wallet on the Ethereum Network, click on the second button
1. While accessing the Ethereum Network for the first time, choose between creating or restoring an old wallet.
2. Click on Create/Restore wallet.

3. For **creating account**, enter a password to create an anonymous user ID. For **restoring account** skip to step 7.
4. The next screen will display the user's private key and address. Kindly save it offline in a very secure place to avoid loss or theft of keys. Do not lose keys as it is the only way to unlock the wallet. The app will also mention the path of the keystore file.
5. Click on “Yes, I have copied my keys in a secured place.” and then continue to get the access to the dashboard.
**Note:** The path where the keystore file is saved will be displayed according to your system:

6. After saving the keys, click ‘go to Dashboard’ and get access to the features of Sentinel.
**Note:** Move on to Section B if not **restoring an account**.
7. For **restoring the account**, retrieve the keystore file. Locate the file using 'Select keystore file' and enter the password associated with it. Then select ‘Restore keystore file’ to access the dashboard.

**Login**
1. If the keystore is already in place, then the app will directly ask for the password.

2. After successful authenitication, the Dashboard will become accessible.
---
## Part B. Ethereum TestNet

To select the Ethereum TESTNET, first activate TESTNET through the slider located at the top of the window.
### Wallet Transfer - Receive Funds
**Note:** ‘Get free tokens’ is only available when connceted to the TESTNET. In MainNET, SENT tokens can only be received from another wallet.
1. Click on the "recieve" button on the left side of the app to view the wallet address and to access the **free** test tokens.

2. To receive funds, share the wallet address with the sender.
3. To get free tokens, click on ‘Get free tokens’ at the top. The wallet will then receive TestSENT's and TestETH's. Wait for a few seconds and then press the Refresh button for the wallet to show new balances. There is a limit to the amount of free tokens that can be availed.
### Wallet Transfer - Send Funds
1. To send funds, click on send symbol on the left side of the app.
2. Enter the reciver's address.
3. Enter the amount and select the type of token from the list- TestSENT or TestETH.
4. Set the gas limit and gas price. Set high gas for faster transaction.
5. After signing the transaction with the keystore password, click on **Send Tokens**. In case of wrong password input, the **Send Tokens** option will be unavailable.

6. On successful transaction, the user will be able to check the status through an on-screen Notification.

### Transaction History
1. To view transaction history, click on Tx History symbol on the left side of the app. Select the token to view its transaction history.

### dVPN Service
1. Select the LIST symbol on the right side of the app to view the list of dVPN nodes.

2. There are two Network options available- Public and Private.
3. For Private network, select the Private network symbol. It will then ask for an Authentication code. Enter the password and click **Connect** to access the private network.

4. By default, Public is selected. Under the Public Network, there are again two options OpenVPN and SOCKS5 (available soon).
5. **OpenVPN**
**a.** Select OpenVPN to see the list of the available nodes.
**b.** Click on a node to see the information and a **Connect** button.

**c.** Use the map on the top right corner to select a node based on it's location visually.

**d.** Or search by city name or country name in LIST view.

**e.** Click on **Connect**.

**f.** For only the first time use of the VPN service, the app will prompt an ‘Initial Payment Alert.’

**g.** After clicking **Pay**, the user will be redirected to Wallet transfer- Send tokens. The address associated with the dPVN node and amount will be set by default. Set the gas limit and password and pay the initial amount to activate the service.

**h.** After successful payment, connect to the node. The node details like IP, speed, location, upload, and download will be stated at the bottom of the app.

**i.** Check the IP on the browser and match the queried result with the IP shown on the Sentinel dVPN node.

**j.** After the use of the service, disconnect the node anytime by clicking on **Disconnect**.

**k.** Rate the node and the session quality. It is optional. Comment based on the experience while using the Sentinel dVPN Desktop App.

**l.** While connecting the node for the VPN service next time, payment of the pending amounts is mandatory. Otherwise while connecting to a node, the app will prompt the user to pay the tokens for the previous session by displaying the message on the bottom screen of the app.
**m.** To pay the due amount go to the VPN history symbol on the left side of the page.

**n.** If there is an outstanding payment, it will be reflected in SESSIONS. Click on **Pay Now** to pay the amount.

**o.** After clicking **Pay Now**, the user will be redirected to Wallet transfer- Send tokens. Set the gas limit and password and pay the pending amount to pay the due.
**Note.** Check status to copy the transaction hash. This hash can be used to view transaction info anytime.
**p.** In case of a payment issue, click on the **Already Paid** button and enter the transaction hash.

**q.** A message saying "Reported successfully" will appear on the bottom screen.
**r.** After successful payment, the dVPN services will be made available again. Previous session history will be viewable in the dVPN **History** tab.

6. **SOCKS5** (Coming Soon)
---
## Part C. Etheruem MainNet
### Wallet Transfer - Receive Funds
To select the Ethereum MainNet, first deactivate TESTNET through the slider located at the top of the window.
1. Click on the receive button on the left side of the app to view the wallet address and to access available tokens.
2. To receive funds, share the wallet address to the sender.

### Wallet Transfer - Send Funds
1. To send funds, click on SEND token symbol on the left side of the app.
2. Enter the reciver’s address.
3. Enter the amount and select the type of token from the list- TestSENT or TestETH.
4. Set the gas limit and gas price. Set high gas for faster transaction.
5. After signing the transaction with the keystore password, click on **Send Tokens**. In case of wrong password input, the **Send Tokens** option will be unavailable.

### Transaction History
1. To view transaction history, click on Tx History symbol on the left side of the app. Select the token to view its transaction history.

---
## Part D. Switching between Netwroks
### Switch Network
The app can switch between "Sentinel Tendermint Network" and the "Ethereum Network" anytime.
1. Click on the account icon on top-right of the window.

2. Select "Switch Network"
This will bring the user to the main screen, where they can choose either of the two networks.

___
## Part E. Tendermint TestNet
Click the first button to access Tendermint TestNet

### Account Creation
1. When accessing the Tendermint TestNet for the first time enter the account details.

2. The next screen will prompt the user to save the keys and the seed at a safe place.

3. After saving the keys, click on ‘Go to Sentinel Tendermint Wallet.’
### Wallet Transfer - Receive Funds
**Note:** ‘Get free tokens’ is only applicable to the TESTNET. In mainnet, you can only receive SENT tokens from another wallet.
1. Click on the **Receive** button on the left side of the app to view the wallet address and to access to free test tokens.
2. To receive funds, share the wallet address with the sender.
3. To get free tokens, click on **Get Free Tokens** at the top. TSENT's will be credited to the wallet. Wait for a few seconds for the wallet to show new balances. There is a limit to the amount of free tokens that can be availed.

4. Free test TSENTs can only be availed if the wallet balance is less than 1000.
### Wallet Transfer - Send Funds
1. To send funds, click on send symbol on the left side of the app.
2. Enter the reciver's address.
3. Enter the amount that needs to be sent.
4. After signing the transaction with the tendermint account password, click on **Send Tokens**. In case of wrong password input, the **Send Tokens** option will be unavailable.

### Transaction History
To view the transaction history, click on Tx History symbol on the left side of the app.

### dVPN Service
1. Select the VPN list in the left side of the app.
2. There are two options available- **Public** and **Private**(coming soon).
3. By default, Public is selected. Under Public, there are again two options OpenVPN and SOCKS5.
4. **OpenVPN**
**a.** Select the LIST symbol on the right side of the app to view the list of dVPN nodes.

**b.** Use the map on the top right corner to select a node based on it's location visually.

**c.** Or search by city name or country name in LIST view.

**d.** For the use of the dVPN service, the PP will be redirected to the Send Tokens page to LOCK the test TSENT tokens.

**e.** If less than 100 test TSENTs are consumed during the session, the unused tokens will be refunded back to the wallet.

**f.** Check the IP on the browser and match the queried result with the IP shown on the dVPN node.

**g.** After the use of the service, disconnect the node anytime by clicking on **Disconnect**.
**h.** After the full consumption of the locked test TSENTs, the service will automatically disconnect.
**i.** Previous session history will be viewable in the dVPN **History** tab.

5. **SOCKS5** (Coming Soon)
---