Status page

This commit is contained in:
kexkey
2018-12-15 00:52:24 -05:00
parent 36dfc92985
commit 57f2217abb
17 changed files with 108 additions and 37 deletions

View File

@@ -12,6 +12,7 @@ RUN apk add --update --no-cache \
COPY auth.sh /etc/nginx/conf.d COPY auth.sh /etc/nginx/conf.d
COPY default-ssl.conf /etc/nginx/conf.d/default.conf COPY default-ssl.conf /etc/nginx/conf.d/default.conf
COPY statuspage.html /etc/nginx/conf.d/status
COPY entrypoint.sh entrypoint.sh COPY entrypoint.sh entrypoint.sh
COPY trace.sh /etc/nginx/conf.d COPY trace.sh /etc/nginx/conf.d
COPY tests.sh /etc/nginx/conf.d COPY tests.sh /etc/nginx/conf.d

View File

@@ -1,22 +0,0 @@
FROM nginx:1.14
RUN apt-get update \
&& apt-get install -y \
openssl \
spawn-fcgi \
fcgiwrap \
jq \
curl
COPY auth.sh /etc/nginx/conf.d
COPY default-ssl.conf /etc/nginx/conf.d/default.conf
COPY entrypoint.sh entrypoint.sh
COPY keys.properties /etc/nginx/conf.d
COPY api.properties /etc/nginx/conf.d
COPY trace.sh /etc/nginx/conf.d
COPY tests.sh /etc/nginx/conf.d
COPY ip-whitelist.conf /etc/nginx/conf.d
RUN chmod +x /etc/nginx/conf.d/auth.sh entrypoint.sh
ENTRYPOINT ["./entrypoint.sh"]

View File

@@ -7,6 +7,12 @@ server {
ssl_certificate /etc/ssl/certs/cert.pem; ssl_certificate /etc/ssl/certs/cert.pem;
ssl_certificate_key /etc/ssl/private/key.pem; ssl_certificate_key /etc/ssl/private/key.pem;
location /status {
auth_basic "status";
auth_basic_user_file conf.d/status/htpasswd;
proxy_pass http://proxy:8888;
}
location / { location / {
auth_request /auth; auth_request /auth;
proxy_pass http://proxy:8888; proxy_pass http://proxy:8888;

View File

@@ -35,26 +35,28 @@ build_docker_images() {
trace "Updating SatoshiPortal repos" trace "Updating SatoshiPortal repos"
git submodule update --recursive --remote git submodule update --recursive --remote
local archpath=$(uname -m) local bitcoin_dockerfile=Dockerfile.amd64
local clightning_dockerfile=Dockerfile local clightning_dockerfile=Dockerfile.amd64
local proxy_dockerfile=Dockerfile.amd64
# compat mode for SatoshiPortal repo # compat mode for SatoshiPortal repo
# TODO: add more mappings? # TODO: add more mappings?
if [[ $archpath == 'armv7l' ]]; then if [[ $(uname -m) == 'armv7l' ]]; then
archpath="rpi" bitcoin_dockerfile="Dockerfile.arm32v6"
clightning_dockerfile="Dockerfile-alpine" clightning_dockerfile="Dockerfile.arm32v6"
proxy_dockerfile="Dockerfile.arm32v6"
fi fi
trace "Creating cyphernodeconf image" trace "Creating cyphernodeconf image"
build_docker_image install/ cyphernode/cyphernodeconf:cyphernode-0.05 build_docker_image install/ cyphernode/cyphernodeconf:cyphernode-0.05
trace "Creating SatoshiPortal images" trace "Creating SatoshiPortal images"
build_docker_image install/SatoshiPortal/dockers/$archpath/bitcoin-core cyphernode/bitcoin:cyphernode-0.05 build_docker_image install/SatoshiPortal/dockers/bitcoin-core cyphernode/bitcoin:cyphernode-0.05 $bitcoin_dockerfile
build_docker_image install/SatoshiPortal/dockers/$archpath/LN/c-lightning cyphernode/clightning:cyphernode-0.05 $clightning_dockerfile build_docker_image install/SatoshiPortal/dockers/c-lightning cyphernode/clightning:cyphernode-0.05 $clightning_dockerfile
trace "Creating cyphernode images" trace "Creating cyphernode images"
build_docker_image api_auth_docker/ cyphernode/gatekeeper:cyphernode-0.05 build_docker_image api_auth_docker/ cyphernode/gatekeeper:cyphernode-0.05
build_docker_image proxy_docker/ cyphernode/proxy:cyphernode-0.05 build_docker_image proxy_docker/ cyphernode/proxy:cyphernode-0.05 $proxy_dockerfile
build_docker_image cron_docker/ cyphernode/proxycron:cyphernode-0.05 build_docker_image cron_docker/ cyphernode/proxycron:cyphernode-0.05
build_docker_image pycoin_docker/ cyphernode/pycoin:cyphernode-0.05 build_docker_image pycoin_docker/ cyphernode/pycoin:cyphernode-0.05
build_docker_image otsclient_docker/ cyphernode/otsclient:cyphernode-0.05 build_docker_image otsclient_docker/ cyphernode/otsclient:cyphernode-0.05
@@ -62,4 +64,3 @@ build_docker_images() {
} }
build_docker_images build_docker_images

1
dist/setup.sh vendored
View File

@@ -370,6 +370,7 @@ install_docker() {
copy_file $current_path/client.7z $GATEKEEPER_DATAPATH/client.7z 1 $SUDO_REQUIRED copy_file $current_path/client.7z $GATEKEEPER_DATAPATH/client.7z 1 $SUDO_REQUIRED
copy_file $current_path/gatekeeper/cert.pem $GATEKEEPER_DATAPATH/certs/cert.pem 1 $SUDO_REQUIRED copy_file $current_path/gatekeeper/cert.pem $GATEKEEPER_DATAPATH/certs/cert.pem 1 $SUDO_REQUIRED
copy_file $current_path/gatekeeper/key.pem $GATEKEEPER_DATAPATH/private/key.pem 1 $SUDO_REQUIRED copy_file $current_path/gatekeeper/key.pem $GATEKEEPER_DATAPATH/private/key.pem 1 $SUDO_REQUIRED
copy_file $current_path/gatekeeper/htpasswd $GATEKEEPER_DATAPATH/htpasswd 1 $SUDO_REQUIRED
fi fi
if [ ! -d $PROXY_DATAPATH ]; then if [ ! -d $PROXY_DATAPATH ]; then

View File

@@ -198,6 +198,8 @@ module.exports = class extends Generator {
// migrate here // migrate here
} }
this.props.gatekeeper_statuspw = await new Cert().passwd(this.configurationPassword);
this._assignConfigDefaults(); this._assignConfigDefaults();
for( let c of this.featureChoices ) { for( let c of this.featureChoices ) {
c.checked = this._isChecked( 'features', c.value ); c.checked = this._isChecked( 'features', c.value );

View File

@@ -113,4 +113,20 @@ module.exports = class Cert {
return path.join( this.folder, this.filename ); return path.join( this.folder, this.filename );
} }
async passwd( pw ) {
const openssl = spawn('openssl', [ "passwd", pw ], {stdio: ['ignore', 'pipe', 'ignore' ]});
const result = await new Promise( function(resolve, reject ) {
let result = '';
openssl.stdout.on('data', (data) => {
result += data.toString();
});
openssl.on('exit', (code) => {
resolve(result);
});
});
return result;
}
} }

View File

@@ -97,6 +97,6 @@ module.exports = {
}]; }];
}, },
templates: function( props ) { templates: function( props ) {
return [ 'keys.properties', 'api.properties', 'cert.pem', 'key.pem' ]; return [ 'keys.properties', 'api.properties', 'cert.pem', 'key.pem', 'htpasswd' ];
} }
}; };

View File

@@ -0,0 +1 @@
cyphernode:<%- gatekeeper_statuspw %>

View File

@@ -13,6 +13,7 @@ services:
- "<%= gatekeeper_datapath %>/private:/etc/ssl/private" - "<%= gatekeeper_datapath %>/private:/etc/ssl/private"
- "<%= gatekeeper_datapath %>/keys.properties:/etc/nginx/conf.d/keys.properties" - "<%= gatekeeper_datapath %>/keys.properties:/etc/nginx/conf.d/keys.properties"
- "<%= gatekeeper_datapath %>/api.properties:/etc/nginx/conf.d/api.properties" - "<%= gatekeeper_datapath %>/api.properties:/etc/nginx/conf.d/api.properties"
- "<%= gatekeeper_datapath %>/htpasswd:/etc/nginx/conf.d/status/htpasswd"
command: $USER command: $USER
# deploy: # deploy:

View File

@@ -17,3 +17,7 @@ docker run --rm -it -v $current_path/testfeatures.sh:/testfeatures.sh \
-v $current_path/gatekeeper/cert.pem:/cert.pem \ -v $current_path/gatekeeper/cert.pem:/cert.pem \
-v <%= proxy_datapath %>:/proxy \ -v <%= proxy_datapath %>:/proxy \
--network cyphernodenet alpine:3.8 /testfeatures.sh --network cyphernodenet alpine:3.8 /testfeatures.sh
echo "Point your favorite browser to one of the following URLs to access Cyphernode's status page:"
echo
echo

View File

@@ -26,6 +26,7 @@ RUN apk add --update --no-cache \
COPY app/data/cyphernode.sql ${HOME} COPY app/data/cyphernode.sql ${HOME}
COPY app/data/sqlmigrate* ${HOME} COPY app/data/sqlmigrate* ${HOME}
COPY app/html/statuspage.sh ${HOME}
COPY app/script/callbacks_job.sh ${HOME} COPY app/script/callbacks_job.sh ${HOME}
COPY app/script/blockchainrpc.sh ${HOME} COPY app/script/blockchainrpc.sh ${HOME}
COPY app/script/call_lightningd.sh ${HOME} COPY app/script/call_lightningd.sh ${HOME}

View File

@@ -22,6 +22,7 @@ RUN apk add --update --no-cache \
COPY app/data/cyphernode.sql ${HOME} COPY app/data/cyphernode.sql ${HOME}
COPY app/data/sqlmigrate* ${HOME} COPY app/data/sqlmigrate* ${HOME}
COPY app/html/statuspage.sh ${HOME}
COPY app/script/callbacks_job.sh ${HOME} COPY app/script/callbacks_job.sh ${HOME}
COPY app/script/blockchainrpc.sh ${HOME} COPY app/script/blockchainrpc.sh ${HOME}
COPY app/script/call_lightningd.sh ${HOME} COPY app/script/call_lightningd.sh ${HOME}

View File

@@ -221,7 +221,7 @@ serve_ots_getfile()
local hash=${1} local hash=${1}
trace "[serve_ots_getfile] hash=${hash}" trace "[serve_ots_getfile] hash=${hash}"
file_response_to_client "/otsfiles/" "${hash}.ots" binfile_response_to_client "/otsfiles/" "${hash}.ots"
returncode=$? returncode=$?
trace_rc ${returncode} trace_rc ${returncode}

View File

@@ -18,6 +18,7 @@
. ./bitcoin.sh . ./bitcoin.sh
. ./call_lightningd.sh . ./call_lightningd.sh
. ./ots.sh . ./ots.sh
. ./statuspage.sh
main() main()
{ {
@@ -243,6 +244,12 @@ main()
serve_ots_getfile $(echo "${line}" | cut -d ' ' -f2 | cut -d '/' -f3) serve_ots_getfile $(echo "${line}" | cut -d ' ' -f2 | cut -d '/' -f3)
break break
;; ;;
status)
# curl (GET) http://192.168.111.152:8080/status
status_page
break
;;
esac esac
break break
fi fi

View File

@@ -8,19 +8,47 @@ response_to_client()
local response=${1} local response=${1}
local returncode=${2} local returncode=${2}
local contenttype=${3}
[ -z "${contenttype}" ] && contenttype="application/json"
([ -z "${returncode}" ] || [ "${returncode}" -eq "0" ]) && echo -ne "HTTP/1.1 200 OK\r\n" ([ -z "${returncode}" ] || [ "${returncode}" -eq "0" ]) && echo -ne "HTTP/1.1 200 OK\r\n"
[ -n "${returncode}" ] && [ "${returncode}" -ne "0" ] && echo -ne "HTTP/1.1 400 Bad Request\r\n" [ -n "${returncode}" ] && [ "${returncode}" -ne "0" ] && echo -ne "HTTP/1.1 400 Bad Request\r\n"
echo -en "Content-Type: application/json\r\nContent-Length: ${#response}\r\n\r\n${response}" echo -en "Content-Type: ${contenttype}\r\nContent-Length: ${#response}\r\n\r\n${response}"
# Small delay needed for the data to be processed correctly by peer # Small delay needed for the data to be processed correctly by peer
sleep 0.2s sleep 0.2s
} }
file_response_to_client() htmlfile_response_to_client()
{ {
trace "Entering file_response_to_client()..." trace "Entering htmlfile_response_to_client()..."
local path=${1}
local filename=${2}
local pathfile="${path}${filename}"
local returncode
trace "[htmlfile_response_to_client] path=${path}"
trace "[htmlfile_response_to_client] filename=${filename}"
trace "[htmlfile_response_to_client] pathfile=${pathfile}"
local file_length=$(stat -c'%s' ${pathfile})
trace "[htmlfile_response_to_client] file_length=${file_length}"
[ -r "${pathfile}" ] \
&& echo -ne "HTTP/1.1 200 OK\r\nContent-Type: text/html\r\nContent-Length: ${file_length}\r\n\r\n" \
&& cat ${pathfile}
[ ! -r "${pathfile}" ] && echo -ne "HTTP/1.1 404 Not Found\r\n"
# Small delay needed for the data to be processed correctly by peer
sleep 0.5s
}
binfile_response_to_client()
{
trace "Entering binfile_response_to_client()..."
local path=${1} local path=${1}
local filename=${2} local filename=${2}

View File

@@ -0,0 +1,23 @@
#!/bin/sh
. ./trace.sh
. ./responsetoclient.sh
status_page() {
cat <<EOF > statuspage.html
<html>
<head>
</head>
<body>
Hello from Cyphernode!<p/>
EOF
cat db/installation.json >> statuspage.html
cat <<EOF >> statuspage.html
</body>
</html>
EOF
htmlfile_response_to_client ./ statuspage.html
}