mirror of
https://github.com/aljazceru/cyphernode.git
synced 2025-12-18 13:14:56 +01:00
Status page
This commit is contained in:
@@ -12,6 +12,7 @@ RUN apk add --update --no-cache \
|
||||
|
||||
COPY auth.sh /etc/nginx/conf.d
|
||||
COPY default-ssl.conf /etc/nginx/conf.d/default.conf
|
||||
COPY statuspage.html /etc/nginx/conf.d/status
|
||||
COPY entrypoint.sh entrypoint.sh
|
||||
COPY trace.sh /etc/nginx/conf.d
|
||||
COPY tests.sh /etc/nginx/conf.d
|
||||
|
||||
@@ -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"]
|
||||
@@ -7,6 +7,12 @@ server {
|
||||
ssl_certificate /etc/ssl/certs/cert.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 / {
|
||||
auth_request /auth;
|
||||
proxy_pass http://proxy:8888;
|
||||
|
||||
19
build.sh
19
build.sh
@@ -35,26 +35,28 @@ build_docker_images() {
|
||||
trace "Updating SatoshiPortal repos"
|
||||
git submodule update --recursive --remote
|
||||
|
||||
local archpath=$(uname -m)
|
||||
local clightning_dockerfile=Dockerfile
|
||||
local bitcoin_dockerfile=Dockerfile.amd64
|
||||
local clightning_dockerfile=Dockerfile.amd64
|
||||
local proxy_dockerfile=Dockerfile.amd64
|
||||
|
||||
# compat mode for SatoshiPortal repo
|
||||
# TODO: add more mappings?
|
||||
if [[ $archpath == 'armv7l' ]]; then
|
||||
archpath="rpi"
|
||||
clightning_dockerfile="Dockerfile-alpine"
|
||||
if [[ $(uname -m) == 'armv7l' ]]; then
|
||||
bitcoin_dockerfile="Dockerfile.arm32v6"
|
||||
clightning_dockerfile="Dockerfile.arm32v6"
|
||||
proxy_dockerfile="Dockerfile.arm32v6"
|
||||
fi
|
||||
|
||||
trace "Creating cyphernodeconf image"
|
||||
build_docker_image install/ cyphernode/cyphernodeconf:cyphernode-0.05
|
||||
|
||||
trace "Creating SatoshiPortal images"
|
||||
build_docker_image install/SatoshiPortal/dockers/$archpath/bitcoin-core cyphernode/bitcoin:cyphernode-0.05
|
||||
build_docker_image install/SatoshiPortal/dockers/$archpath/LN/c-lightning cyphernode/clightning:cyphernode-0.05 $clightning_dockerfile
|
||||
build_docker_image install/SatoshiPortal/dockers/bitcoin-core cyphernode/bitcoin:cyphernode-0.05 $bitcoin_dockerfile
|
||||
build_docker_image install/SatoshiPortal/dockers/c-lightning cyphernode/clightning:cyphernode-0.05 $clightning_dockerfile
|
||||
|
||||
trace "Creating cyphernode images"
|
||||
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 pycoin_docker/ cyphernode/pycoin:cyphernode-0.05
|
||||
build_docker_image otsclient_docker/ cyphernode/otsclient:cyphernode-0.05
|
||||
@@ -62,4 +64,3 @@ build_docker_images() {
|
||||
}
|
||||
|
||||
build_docker_images
|
||||
|
||||
|
||||
1
dist/setup.sh
vendored
1
dist/setup.sh
vendored
@@ -370,6 +370,7 @@ install_docker() {
|
||||
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/key.pem $GATEKEEPER_DATAPATH/private/key.pem 1 $SUDO_REQUIRED
|
||||
copy_file $current_path/gatekeeper/htpasswd $GATEKEEPER_DATAPATH/htpasswd 1 $SUDO_REQUIRED
|
||||
fi
|
||||
|
||||
if [ ! -d $PROXY_DATAPATH ]; then
|
||||
|
||||
@@ -198,6 +198,8 @@ module.exports = class extends Generator {
|
||||
// migrate here
|
||||
}
|
||||
|
||||
this.props.gatekeeper_statuspw = await new Cert().passwd(this.configurationPassword);
|
||||
|
||||
this._assignConfigDefaults();
|
||||
for( let c of this.featureChoices ) {
|
||||
c.checked = this._isChecked( 'features', c.value );
|
||||
|
||||
@@ -113,4 +113,20 @@ module.exports = class Cert {
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -97,6 +97,6 @@ module.exports = {
|
||||
}];
|
||||
},
|
||||
templates: function( props ) {
|
||||
return [ 'keys.properties', 'api.properties', 'cert.pem', 'key.pem' ];
|
||||
return [ 'keys.properties', 'api.properties', 'cert.pem', 'key.pem', 'htpasswd' ];
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1 @@
|
||||
cyphernode:<%- gatekeeper_statuspw %>
|
||||
@@ -13,6 +13,7 @@ services:
|
||||
- "<%= gatekeeper_datapath %>/private:/etc/ssl/private"
|
||||
- "<%= gatekeeper_datapath %>/keys.properties:/etc/nginx/conf.d/keys.properties"
|
||||
- "<%= gatekeeper_datapath %>/api.properties:/etc/nginx/conf.d/api.properties"
|
||||
- "<%= gatekeeper_datapath %>/htpasswd:/etc/nginx/conf.d/status/htpasswd"
|
||||
command: $USER
|
||||
|
||||
# deploy:
|
||||
|
||||
@@ -17,3 +17,7 @@ docker run --rm -it -v $current_path/testfeatures.sh:/testfeatures.sh \
|
||||
-v $current_path/gatekeeper/cert.pem:/cert.pem \
|
||||
-v <%= proxy_datapath %>:/proxy \
|
||||
--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
|
||||
|
||||
@@ -26,6 +26,7 @@ RUN apk add --update --no-cache \
|
||||
|
||||
COPY app/data/cyphernode.sql ${HOME}
|
||||
COPY app/data/sqlmigrate* ${HOME}
|
||||
COPY app/html/statuspage.sh ${HOME}
|
||||
COPY app/script/callbacks_job.sh ${HOME}
|
||||
COPY app/script/blockchainrpc.sh ${HOME}
|
||||
COPY app/script/call_lightningd.sh ${HOME}
|
||||
|
||||
@@ -22,6 +22,7 @@ RUN apk add --update --no-cache \
|
||||
|
||||
COPY app/data/cyphernode.sql ${HOME}
|
||||
COPY app/data/sqlmigrate* ${HOME}
|
||||
COPY app/html/statuspage.sh ${HOME}
|
||||
COPY app/script/callbacks_job.sh ${HOME}
|
||||
COPY app/script/blockchainrpc.sh ${HOME}
|
||||
COPY app/script/call_lightningd.sh ${HOME}
|
||||
|
||||
@@ -221,7 +221,7 @@ serve_ots_getfile()
|
||||
local hash=${1}
|
||||
trace "[serve_ots_getfile] hash=${hash}"
|
||||
|
||||
file_response_to_client "/otsfiles/" "${hash}.ots"
|
||||
binfile_response_to_client "/otsfiles/" "${hash}.ots"
|
||||
returncode=$?
|
||||
trace_rc ${returncode}
|
||||
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
. ./bitcoin.sh
|
||||
. ./call_lightningd.sh
|
||||
. ./ots.sh
|
||||
. ./statuspage.sh
|
||||
|
||||
main()
|
||||
{
|
||||
@@ -243,6 +244,12 @@ main()
|
||||
serve_ots_getfile $(echo "${line}" | cut -d ' ' -f2 | cut -d '/' -f3)
|
||||
break
|
||||
;;
|
||||
status)
|
||||
# curl (GET) http://192.168.111.152:8080/status
|
||||
|
||||
status_page
|
||||
break
|
||||
;;
|
||||
esac
|
||||
break
|
||||
fi
|
||||
|
||||
@@ -8,19 +8,47 @@ response_to_client()
|
||||
|
||||
local response=${1}
|
||||
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"
|
||||
[ -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
|
||||
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 filename=${2}
|
||||
|
||||
23
proxy_docker/app/script/statuspage.sh
Normal file
23
proxy_docker/app/script/statuspage.sh
Normal 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
|
||||
}
|
||||
Reference in New Issue
Block a user