From 4b6388a445eb4635c4f31b9094444c96a9921ccc Mon Sep 17 00:00:00 2001 From: cfal Date: Fri, 11 Aug 2023 22:12:35 +0800 Subject: [PATCH] scripts/mock-adapter.sh: fix listen address defaults --- scripts/mock-adapter.sh | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/scripts/mock-adapter.sh b/scripts/mock-adapter.sh index 662a7436..5c51f45c 100755 --- a/scripts/mock-adapter.sh +++ b/scripts/mock-adapter.sh @@ -8,10 +8,21 @@ binary_path="${cache_path}/bin/${binary_name}" bash "$(dirname -- "$0")/mock-adapter.down.sh" -listen_address="127.0.0.1:6060" if [ $# -gt 0 ]; then listen_address="$1" +elif [ "$(uname)" = "Darwin" ]; then + echo "Listening on all interfaces on MacOS" + listen_address="0.0.0.0:6060" +else + docker_ip=$(docker network inspect bridge -f '{{range .IPAM.Config}}{{.Gateway}}{{end}}') + if [ -z "${docker_ip}" ]; then + echo "Could not fetch docker ip." + exit 1 + fi + echo "Listening on docker interface" + listen_address="${docker_ip}:6060" fi + echo "Listen address: ${listen_address}" if [ ! -f "${binary_path}" ]; then