From 46de299032e6f404358559929b0a8103d9ce2d63 Mon Sep 17 00:00:00 2001 From: nabarun Date: Thu, 4 May 2023 18:42:45 +0530 Subject: [PATCH] Add env variable for web apps config denyMultiaddrs Former-commit-id: 859a0f684f9b63591af515e6cd4d12dc6e519db7 --- app/data/compose/docker-compose-mobymask-app.yml | 2 ++ app/data/compose/docker-compose-peer-test-app.yml | 1 + app/data/config/watcher-mobymask-v2/mobymask-app-start.sh | 2 ++ app/data/config/watcher-mobymask-v2/mobymask-params.env | 3 +++ app/data/config/watcher-mobymask-v2/test-app-config.json | 1 + app/data/config/watcher-mobymask-v2/test-app-start.sh | 2 ++ app/data/container-build/cerc-mobymask-ui/Dockerfile | 4 ++-- .../container-build/cerc-mobymask-ui/apply-webapp-config.sh | 2 +- app/data/container-build/cerc-react-peer/Dockerfile | 2 +- .../container-build/cerc-react-peer/apply-webapp-config.sh | 2 +- app/data/stacks/mobymask-v2/web-apps.md | 3 +++ 11 files changed, 19 insertions(+), 5 deletions(-) diff --git a/app/data/compose/docker-compose-mobymask-app.yml b/app/data/compose/docker-compose-mobymask-app.yml index d43e6b44..7d41264a 100644 --- a/app/data/compose/docker-compose-mobymask-app.yml +++ b/app/data/compose/docker-compose-mobymask-app.yml @@ -13,6 +13,7 @@ services: CERC_DEPLOYED_CONTRACT: ${CERC_DEPLOYED_CONTRACT} CERC_APP_WATCHER_URL: ${CERC_APP_WATCHER_URL} CERC_RELAY_NODES: ${CERC_RELAY_NODES} + CERC_DENY_MULTIADDRS: ${CERC_DENY_MULTIADDRS} CERC_BUILD_DIR: "@cerc-io/mobymask-ui/build" working_dir: /scripts command: ["sh", "mobymask-app-start.sh"] @@ -44,6 +45,7 @@ services: CERC_DEPLOYED_CONTRACT: ${CERC_DEPLOYED_CONTRACT} CERC_APP_WATCHER_URL: ${CERC_APP_WATCHER_URL} CERC_RELAY_NODES: ${CERC_RELAY_NODES} + CERC_DENY_MULTIADDRS: ${CERC_DENY_MULTIADDRS} CERC_BUILD_DIR: "@cerc-io/mobymask-ui-lxdao/build" working_dir: /scripts command: ["sh", "mobymask-app-start.sh"] diff --git a/app/data/compose/docker-compose-peer-test-app.yml b/app/data/compose/docker-compose-peer-test-app.yml index f2a22675..f1f5e475 100644 --- a/app/data/compose/docker-compose-peer-test-app.yml +++ b/app/data/compose/docker-compose-peer-test-app.yml @@ -10,6 +10,7 @@ services: environment: CERC_SCRIPT_DEBUG: ${CERC_SCRIPT_DEBUG} CERC_RELAY_NODES: ${CERC_RELAY_NODES} + CERC_DENY_MULTIADDRS: ${CERC_DENY_MULTIADDRS} command: ["sh", "test-app-start.sh"] volumes: - ../config/wait-for-it.sh:/scripts/wait-for-it.sh diff --git a/app/data/config/watcher-mobymask-v2/mobymask-app-start.sh b/app/data/config/watcher-mobymask-v2/mobymask-app-start.sh index 9f343340..6eeb5c1a 100755 --- a/app/data/config/watcher-mobymask-v2/mobymask-app-start.sh +++ b/app/data/config/watcher-mobymask-v2/mobymask-app-start.sh @@ -7,6 +7,7 @@ fi CERC_CHAIN_ID="${CERC_CHAIN_ID:-${DEFAULT_CERC_CHAIN_ID}}" CERC_DEPLOYED_CONTRACT="${CERC_DEPLOYED_CONTRACT:-${DEFAULT_CERC_DEPLOYED_CONTRACT}}" CERC_RELAY_NODES="${CERC_RELAY_NODES:-${DEFAULT_CERC_RELAY_NODES}}" +CERC_DENY_MULTIADDRS="${CERC_DENY_MULTIADDRS:-${DEFAULT_CERC_DENY_MULTIADDRS}}" CERC_APP_WATCHER_URL="${CERC_APP_WATCHER_URL:-${DEFAULT_CERC_APP_WATCHER_URL}}" # If not set (or []), check the mounted volume for relay peer id @@ -37,5 +38,6 @@ yq -n ".address = env(CERC_DEPLOYED_CONTRACT)" > /config/config.yml yq ".watcherUrl = env(CERC_APP_WATCHER_URL)" -i /config/config.yml yq ".chainId = env(CERC_CHAIN_ID)" -i /config/config.yml yq ".relayNodes = strenv(CERC_RELAY_NODES)" -i /config/config.yml +yq ".denyMultiaddrs = strenv(CERC_DENY_MULTIADDRS)" -i /config/config.yml /scripts/start-serving-app.sh diff --git a/app/data/config/watcher-mobymask-v2/mobymask-params.env b/app/data/config/watcher-mobymask-v2/mobymask-params.env index 6d1bf063..39d55016 100644 --- a/app/data/config/watcher-mobymask-v2/mobymask-params.env +++ b/app/data/config/watcher-mobymask-v2/mobymask-params.env @@ -24,3 +24,6 @@ DEFAULT_CERC_CHAIN_ID=42069 # Set of relay nodes to be used by web-apps DEFAULT_CERC_RELAY_NODES=[] + +# Set of multiaddrs to be avoided while dialling +DEFAULT_CERC_DENY_MULTIADDRS=[] diff --git a/app/data/config/watcher-mobymask-v2/test-app-config.json b/app/data/config/watcher-mobymask-v2/test-app-config.json index cce15fd8..a0baf9c6 100644 --- a/app/data/config/watcher-mobymask-v2/test-app-config.json +++ b/app/data/config/watcher-mobymask-v2/test-app-config.json @@ -1,6 +1,7 @@ { "relayNodes": [], "peer": { + "denyMultiaddrs": [], "enableDebugInfo": true } } diff --git a/app/data/config/watcher-mobymask-v2/test-app-start.sh b/app/data/config/watcher-mobymask-v2/test-app-start.sh index 42e4397d..aeeb02d3 100755 --- a/app/data/config/watcher-mobymask-v2/test-app-start.sh +++ b/app/data/config/watcher-mobymask-v2/test-app-start.sh @@ -5,6 +5,7 @@ if [ -n "$CERC_SCRIPT_DEBUG" ]; then fi CERC_RELAY_NODES="${CERC_RELAY_NODES:-${DEFAULT_CERC_RELAY_NODES}}" +CERC_DENY_MULTIADDRS="${CERC_DENY_MULTIADDRS:-${DEFAULT_CERC_DENY_MULTIADDRS}}" # If not set (or []), check the mounted volume for relay peer id if [ -z "$CERC_RELAY_NODES" ] || [ "$CERC_RELAY_NODES" = "[]" ]; then @@ -16,5 +17,6 @@ echo "Using CERC_RELAY_NODES $CERC_RELAY_NODES" # Use yq to create config.yml with environment variables yq -n ".relayNodes = strenv(CERC_RELAY_NODES)" > /config/config.yml +yq ".denyMultiaddrs = strenv(CERC_DENY_MULTIADDRS)" -i /config/config.yml /scripts/start-serving-app.sh diff --git a/app/data/container-build/cerc-mobymask-ui/Dockerfile b/app/data/container-build/cerc-mobymask-ui/Dockerfile index 651d718f..9d4868d2 100644 --- a/app/data/container-build/cerc-mobymask-ui/Dockerfile +++ b/app/data/container-build/cerc-mobymask-ui/Dockerfile @@ -50,9 +50,9 @@ RUN yarn global add http-server # Globally install both versions of the payload web app package # Install old version of MobyMask web app -RUN yarn global add @cerc-io/mobymask-ui@0.1.3 +RUN yarn global add @cerc-io/mobymask-ui@0.1.4 # Install the LXDAO version of MobyMask web app -RUN yarn global add @cerc-io/mobymask-ui-lxdao@npm:@cerc-io/mobymask-ui@0.1.3-lxdao-0.1.1 +RUN yarn global add @cerc-io/mobymask-ui-lxdao@npm:@cerc-io/mobymask-ui@0.1.4-lxdao-0.1.1 # Expose port for http EXPOSE 80 diff --git a/app/data/container-build/cerc-mobymask-ui/apply-webapp-config.sh b/app/data/container-build/cerc-mobymask-ui/apply-webapp-config.sh index 9f32cd23..2779b3a1 100755 --- a/app/data/container-build/cerc-mobymask-ui/apply-webapp-config.sh +++ b/app/data/container-build/cerc-mobymask-ui/apply-webapp-config.sh @@ -33,7 +33,7 @@ do echo "Substituting: ${template_string_to_replace} = ${template_value_to_substitute}" # TODO: Pass keys to be replaced without double quotes - if [[ "$template_string_to_replace" =~ ^${config_prefix}_(relayNodes|chainId)$ ]]; then + if [[ "$template_string_to_replace" =~ ^${config_prefix}_(relayNodes|chainId|denyMultiaddrs)$ ]]; then find ${webapp_files_dir} -type f -exec sed -i 's#"'"${template_string_to_replace}"'"#'"${template_value_to_substitute}"'#g' {} + else # Note: we do not escape our strings, on the expectation they do not container the '#' char. diff --git a/app/data/container-build/cerc-react-peer/Dockerfile b/app/data/container-build/cerc-react-peer/Dockerfile index 191f986b..50670e03 100644 --- a/app/data/container-build/cerc-react-peer/Dockerfile +++ b/app/data/container-build/cerc-react-peer/Dockerfile @@ -21,7 +21,7 @@ RUN mkdir -p /config RUN yarn global add http-server # Globally install the payload web app package -RUN yarn global add @cerc-io/test-app@0.2.33 +RUN yarn global add @cerc-io/test-app@0.2.34 # Expose port for http EXPOSE 80 diff --git a/app/data/container-build/cerc-react-peer/apply-webapp-config.sh b/app/data/container-build/cerc-react-peer/apply-webapp-config.sh index a7f0a28e..59dee869 100755 --- a/app/data/container-build/cerc-react-peer/apply-webapp-config.sh +++ b/app/data/container-build/cerc-react-peer/apply-webapp-config.sh @@ -33,7 +33,7 @@ do echo "Substituting: ${template_string_to_replace} = ${template_value_to_substitute}" # TODO: Pass keys to be replaced without double quotes - if [[ "$template_string_to_replace" == "${config_prefix}_relayNodes" ]]; then + if [[ "$template_string_to_replace" =~ ^${config_prefix}_(relayNodes|denyMultiaddrs)$ ]]; then find ${webapp_files_dir} -type f -exec sed -i 's#"'"${template_string_to_replace}"'"#'"${template_value_to_substitute}"'#g' {} + else # Note: we do not escape our strings, on the expectation they do not container the '#' char. diff --git a/app/data/stacks/mobymask-v2/web-apps.md b/app/data/stacks/mobymask-v2/web-apps.md index 2eb037f6..d1570c93 100644 --- a/app/data/stacks/mobymask-v2/web-apps.md +++ b/app/data/stacks/mobymask-v2/web-apps.md @@ -26,6 +26,9 @@ Create and update an env file to be used in the next step ([defaults](../../conf # Eg. CERC_RELAY_NODES=["/dns4/example.com/tcp/443/wss/p2p/12D3KooWGHmDDCc93XUWL16FMcTPCGu2zFaMkf67k8HZ4gdQbRDr"] CERC_RELAY_NODES=[] + # Set of multiaddrs to be avoided while dialling + CERC_DENY_MULTIADDRS=[] + # Also add if running MobyMask app: # Watcher endpoint used by the app for GQL queries