    Copyright (C) 2020  Salahuddin <salahuddin@member.fsf.org>

    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <https://www.gnu.org/licenses/>.

INSTALL
--------
Install gnutls and gnutls-dev packages

Debian/Ubuntu:
$ apt-get install libgnutls28-dev gnutls-bin

$ cd scripts
# optional: change certificate options in config directory
$ ./gen_self-signed_cert.sh
$ ./deploy_ca_cert.sh # required for client

compile server and client
$ make

UNINSTALL
----------
$ cd scripts
$ ./remove_ca_cert.sh
$ make clean


Server:
-------
copy server program with necessary certificates to a server with public IP.

execute server with a secrect pass so that client with valid pass will able to start the connection
$ cd build
$ ./mirror-server PASSWORD

Server will listen on port 5555 and 5556 by default.
5555 - for external users
5556 - for client program

You may change default PORTs in src/common/common.h


Client:
-------
$ cd build
$ ./mirror-client PUBLIC_IP_OR_DOMAIN 5556 PASSWORD

It will use gnutls for connection.


Test
-----
HTTP 80 is set by default for LOCAL_SERVER_PORT in src/common/common.h

1. start server
2. start client
3. user will able to browse http://PUBLIC_IP_OR_DOMAIN:5555/

if you want to use HTTPS, configure apache SSL part with proxy pass.

Example: nextcloud
-------------------------
SSLProxyEngine On
SSLProxyVerify none
SSLProxyCheckPeerCN off
SSLProxyCheckPeerName off

SetEnv proxy-nokeepalive 1
ProxyPass /nextcloud/ http://127.0.0.1:5555/nextcloud/ max=1
ProxyPassReverse /nextcloud/ http://127.0.0.1:5555/nextcloud/ max=1
SetEnv proxy-nokeepalive 1
-------------------------

SSH Test
---------
You may change LOCAL_SERVER_PORT to you local SSH port in src/common/common.h
1. start server
2. start client
3. now you can ssh USER@PUBLIC_IP_OR_DOMAIN -p 5555
