diff --git a/docker/config.ini b/docker/config.ini index 32dd45e9..f226d556 100644 --- a/docker/config.ini +++ b/docker/config.ini @@ -4,9 +4,12 @@ sync_interval_s=10 [lnd] host=lnd +tls_cert_path=~/.lnd/tls.cert +macaroon_path=~/.lnd/data/chain/bitcoin/testnet/admin.macaroon [bitcoin] rpc_host=bitcoin-core +rpc_port=18332 rpc_user=devuser rpc_pass=devpass diff --git a/docker/docker-compose.yml b/docker/docker-compose.yml index 38f883da..231929ae 100644 --- a/docker/docker-compose.yml +++ b/docker/docker-compose.yml @@ -55,3 +55,33 @@ services: # sysctls: # - net.ipv6.conf.all.disable_ipv6=0 # entrypoint: ["./start-squeaknode.sh"] + + # squeaknode: + # image: squeaknode + # container_name: squeaknode + # build: + # context: ../ + # dockerfile: Dockerfile + # depends_on: + # - "bitcoin-core" + # - "lnd" + # volumes: + # - ~/.lnd:/root/.lnd:rw + # - ./config.ini:/config.ini + # ports: + # - 12994:12994 + # - 8994:8994 + # links: + # - "bitcoin-core:bitcoin-core" + # - "lnd:lnd" + # sysctls: + # - net.ipv6.conf.all.disable_ipv6=0 + # entrypoint: ["./start-squeaknode.sh"] + + envoy: + image: envoyproxy/envoy:v1.16.0 + ports: + - 15081:15081 + network_mode: "host" + volumes: + - ../frontend/envoy.yaml:/etc/envoy/envoy.yaml:ro diff --git a/docker/envoy/Dockerfile b/docker/envoy/Dockerfile new file mode 100644 index 00000000..8b314b37 --- /dev/null +++ b/docker/envoy/Dockerfile @@ -0,0 +1,31 @@ +# Copyright 2018 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +FROM envoyproxy/envoy:v1.15.0 + +#COPY "frontend/envoy.yaml" /etc/envoy/envoy.yaml + +#CMD /usr/local/bin/envoy -c /etc/envoy/envoy.yaml -l trace --log-path /tmp/envoy_info.log + + + +COPY "frontend/envoy.yaml" /tmpl/envoy.yaml.tmpl +COPY docker/envoy/docker-entrypoint.sh / + +RUN chmod 500 /docker-entrypoint.sh + +RUN apt-get update && \ + apt-get install gettext -y + +ENTRYPOINT ["/docker-entrypoint.sh"] diff --git a/docker/envoy/docker-entrypoint.sh b/docker/envoy/docker-entrypoint.sh new file mode 100644 index 00000000..f221bef8 --- /dev/null +++ b/docker/envoy/docker-entrypoint.sh @@ -0,0 +1,8 @@ +#!/bin/sh +set -e + +echo "Generating envoy.yaml config file..." +cat /tmpl/envoy.yaml.tmpl | envsubst \$ENVOY_LB_ALG,\$SERVICE_NAME > /etc/envoy.yaml + +echo "Starting Envoy..." +/usr/local/bin/envoy -c /etc/envoy.yaml diff --git a/frontend/envoy.yaml b/frontend/envoy.yaml new file mode 100644 index 00000000..30081208 --- /dev/null +++ b/frontend/envoy.yaml @@ -0,0 +1,49 @@ +static_resources: + listeners: + - name: listener_0 + address: + socket_address: { address: 0.0.0.0, port_value: 15081 } + filter_chains: + - filters: + - name: envoy.filters.network.http_connection_manager + typed_config: + "@type": type.googleapis.com/envoy.extensions.filters.network.http_connection_manager.v3.HttpConnectionManager + codec_type: auto + stat_prefix: ingress_http + route_config: + name: local_route + virtual_hosts: + - name: local_service + domains: ["*"] + routes: + - match: { prefix: "/" } + route: + cluster: squeak_admin_service + max_stream_duration: + grpc_timeout_header_max: 0s + cors: + allow_origin_string_match: + - prefix: "*" + allow_methods: GET, PUT, DELETE, POST, OPTIONS + allow_headers: keep-alive,user-agent,cache-control,content-type,content-transfer-encoding,custom-header-1,x-accept-content-transfer-encoding,x-accept-response-streaming,x-user-agent,x-grpc-web,grpc-timeout + max_age: "1728000" + expose_headers: custom-header-1,grpc-status,grpc-message + http_filters: + - name: envoy.filters.http.grpc_web + - name: envoy.filters.http.cors + - name: envoy.filters.http.router + clusters: + - name: squeak_admin_service + connect_timeout: 0.25s + type: logical_dns + http2_protocol_options: {} + lb_policy: round_robin + load_assignment: + cluster_name: cluster_0 + endpoints: + - lb_endpoints: + - endpoint: + address: + socket_address: + address: 0.0.0.0 + port_value: 8994 diff --git a/frontend/src/squeakclient/requests.js b/frontend/src/squeakclient/requests.js index 7f515e5b..c397a252 100644 --- a/frontend/src/squeakclient/requests.js +++ b/frontend/src/squeakclient/requests.js @@ -122,6 +122,10 @@ import { DownloadRepliesReply, } from "../proto/squeak_admin_pb" +import { SqueakAdminClient } from "../proto/squeak_admin_grpc_web_pb" + +console.log("Using SqueakAdminClient"); + console.log('The value of REACT_APP_SERVER_PORT is:', process.env.REACT_APP_SERVER_PORT); const SERVER_PORT = process.env.REACT_APP_SERVER_PORT || window.location.port; @@ -179,15 +183,17 @@ export function getUserRequest(handleResponse) { } export function getTimelineSqueakDisplaysRequest(handleResponse) { - var request = new GetTimelineSqueakDisplaysRequest(); - makeRequest( - 'gettimelinesqueakdisplays', - request, - GetTimelineSqueakDisplaysReply.deserializeBinary, - (response) => { - handleResponse(response.getSqueakDisplayEntriesList()); - } - ); + console.log(SqueakAdminClient); + var clientUrl = 'http://' + window.location.hostname + ':15081'; + console.log("Using clientUrl: " + clientUrl); + var client = new SqueakAdminClient(clientUrl); + //var client = new SqueakAdminClient("envoy" + ':8080') + var getTimelineSqueakDisplaysRequest = new GetTimelineSqueakDisplaysRequest() + client.getTimelineSqueakDisplays(getTimelineSqueakDisplaysRequest, {}, (err, response) => { + console.log(response); + console.log(response.getSqueakDisplayEntriesList()); + handleResponse(response.getSqueakDisplayEntriesList()); + }); } export function lndGetInfoRequest(handleResponse, handleErr) { diff --git a/squeaknode/config/config.py b/squeaknode/config/config.py index c1df115b..32960987 100644 --- a/squeaknode/config/config.py +++ b/squeaknode/config/config.py @@ -74,7 +74,7 @@ class ServerConfig(Config): @section('admin') class AdminConfig(Config): - rpc_enabled = key(cast=bool, required=False, default=False) + rpc_enabled = key(cast=bool, required=False, default=True) rpc_host = key(cast=str, required=False, default=DEFAULT_ADMIN_RPC_HOST) rpc_port = key(cast=int, required=False, default=DEFAULT_ADMIN_RPC_PORT)