diff --git a/bin/lib/common.sh b/bin/lib/common.sh index 05eda848..d464f7b6 100644 --- a/bin/lib/common.sh +++ b/bin/lib/common.sh @@ -66,6 +66,19 @@ function check_python_version() { fi } +# Common function to force name/address to address format +#----------------------------------------- +function force_to_ip() +{ + local name=$1 + + if [[ $name =~ ^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$ ]]; then + echo $name + else + echo $(dig +short $name) + fi +} + # ----------------------------------------- # Check the environment for completeness # ----------------------------------------- diff --git a/docker/tools/run_ccf_tests.sh b/docker/tools/run_ccf_tests.sh index 962d2350..5c8f91d4 100755 --- a/docker/tools/run_ccf_tests.sh +++ b/docker/tools/run_ccf_tests.sh @@ -14,13 +14,13 @@ # limitations under the License. # Tests are run EXCLUSIVELY with all services running on localhost -export PDO_HOSTNAME=localhost -export PDO_LEDGER_ADDRESS=$(dig +short ${PDO_HOSTNAME}) -export PDO_LEDGER_URL="http://${PDO_LEDGER_ADDRESS}:6600" - source /project/pdo/tools/environment.sh source ${PDO_HOME}/bin/lib/common.sh +export PDO_HOSTNAME=localhost +export PDO_LEDGER_ADDRESS=$(force_to_ip ${PDO_HOSTNAME}) +export PDO_LEDGER_URL="http://${PDO_LEDGER_ADDRESS}:6600" + export no_proxy=$PDO_HOSTNAME,$PDO_LEDGER_ADDRESS,$no_proxy export NO_PROXY=$PDO_HOSTNAME,$PDO_LEDGER_ADDRESS,$NO_PROXY diff --git a/docker/tools/run_client_tests.sh b/docker/tools/run_client_tests.sh index 996125ba..faa328c7 100755 --- a/docker/tools/run_client_tests.sh +++ b/docker/tools/run_client_tests.sh @@ -14,13 +14,14 @@ # limitations under the License. # Tests are run EXCLUSIVELY with all services running on localhost -export PDO_HOSTNAME=localhost -export PDO_LEDGER_ADDRESS=$(dig +short ${PDO_HOSTNAME}) -export PDO_LEDGER_URL="http://${PDO_LEDGER_ADDRESS}:6600" source /project/pdo/tools/environment.sh source ${PDO_HOME}/bin/lib/common.sh +export PDO_HOSTNAME=localhost +export PDO_LEDGER_ADDRESS=$(force_to_ip ${PDO_HOSTNAME}) +export PDO_LEDGER_URL="http://${PDO_LEDGER_ADDRESS}:6600" + export no_proxy=$PDO_HOSTNAME,$PDO_LEDGER_ADDRESS,$no_proxy export NO_PROXY=$PDO_HOSTNAME,$PDO_LEDGER_ADDRESS,$NO_PROXY diff --git a/docker/tools/run_services_tests.sh b/docker/tools/run_services_tests.sh index 80063e75..b1a2c949 100755 --- a/docker/tools/run_services_tests.sh +++ b/docker/tools/run_services_tests.sh @@ -14,14 +14,15 @@ # limitations under the License. # Tests are run EXCLUSIVELY with all services running on localhost -export PDO_HOSTNAME=localhost -export PDO_LEDGER_ADDRESS=$(dig +short ${PDO_HOSTNAME}) -export PDO_LEDGER_URL="http://${PDO_LEDGER_ADDRESS}:6600" source /opt/intel/sgxsdk/environment source /project/pdo/tools/environment.sh source ${PDO_HOME}/bin/lib/common.sh +export PDO_HOSTNAME=localhost +export PDO_LEDGER_ADDRESS=$(force_to_ip ${PDO_HOSTNAME}) +export PDO_LEDGER_URL="http://${PDO_LEDGER_ADDRESS}:6600" + export no_proxy=$PDO_HOSTNAME,$PDO_LEDGER_ADDRESS,$no_proxy export NO_PROXY=$PDO_HOSTNAME,$PDO_LEDGER_ADDRESS,$NO_PROXY diff --git a/docker/tools/start_ccf.sh b/docker/tools/start_ccf.sh index 206daeee..5bf9ede4 100755 --- a/docker/tools/start_ccf.sh +++ b/docker/tools/start_ccf.sh @@ -55,20 +55,20 @@ done # ----------------------------------------------------------------- # Set up the ledger url and proxy configuration # ----------------------------------------------------------------- +source /project/pdo/tools/environment.sh +source ${PDO_HOME}/bin/lib/common.sh + export PDO_HOSTNAME=${PDO_HOSTNAME:-${HOSTNAME}} if [ ! -z "${F_INTERFACE}" ] ; then export PDO_HOSTNAME=$F_INTERFACE fi -export PDO_LEDGER_ADDRESS=$(dig +short ${PDO_HOSTNAME}) +export PDO_LEDGER_ADDRESS=$(force_to_ip ${PDO_HOSTNAME}) export PDO_LEDGER_URL="http://${PDO_LEDGER_ADDRESS}:6600" export no_proxy=$PDO_HOSTNAME,$PDO_LEDGER_ADDRESS,$no_proxy export NO_PROXY=$PDO_HOSTNAME,$PDO_LEDGER_ADDRESS,$NO_PROXY -source /project/pdo/tools/environment.sh -source ${PDO_HOME}/bin/lib/common.sh - # this is ridiculous. we need to canonicalize the ledger and # sgx keys into the keys directory hierarchy NOT the etc # hierarchy. future PR. diff --git a/docker/tools/start_client.sh b/docker/tools/start_client.sh index e28b4e3c..89c1fcee 100755 --- a/docker/tools/start_client.sh +++ b/docker/tools/start_client.sh @@ -54,12 +54,15 @@ done # ----------------------------------------------------------------- # Set up the interface, ledger url and proxy configuration # ----------------------------------------------------------------- +source /project/pdo/tools/environment.sh +source ${PDO_HOME}/bin/lib/common.sh + export PDO_HOSTNAME=${PDO_HOSTNAME:-$HOSTNAME} if [ ! -z "${F_INTERFACE}" ] ; then export PDO_HOSTNAME=${F_INTERFACE} fi -export PDO_LEDGER_ADDRESS=$(dig +short ${PDO_HOSTNAME}) +export PDO_LEDGER_ADDRESS=$(force_to_ip ${PDO_HOSTNAME}) export PDO_LEDGER_URL=${PDO_LEDGER_URL:-http://${PDO_LEDGER_ADDRESS}:6600} if [ ! -z "${F_LEDGER_URL}" ] ; then export PDO_LEDGER_URL=${F_LEDGER_URL} @@ -68,9 +71,6 @@ fi export no_proxy=$PDO_HOSTNAME,$no_proxy export NO_PROXY=$PDO_HOSTNAME,$NO_PROXY -source /project/pdo/tools/environment.sh -source ${PDO_HOME}/bin/lib/common.sh - # ----------------------------------------------------------------- # Handle the configuration of the services # ----------------------------------------------------------------- diff --git a/docker/tools/start_services.sh b/docker/tools/start_services.sh index 7b287a69..0c333d8c 100755 --- a/docker/tools/start_services.sh +++ b/docker/tools/start_services.sh @@ -60,12 +60,16 @@ done # ----------------------------------------------------------------- # Set up the interface, ledger url and proxy configuration # ----------------------------------------------------------------- +source /opt/intel/sgxsdk/environment +source /project/pdo/tools/environment.sh +source ${PDO_HOME}/bin/lib/common.sh + export PDO_HOSTNAME=${PDO_HOSTNAME:-$HOSTNAME} if [ ! -z "${F_INTERFACE}" ] ; then export PDO_HOSTNAME=${F_INTERFACE} fi -export PDO_LEDGER_ADDRESS=$(dig +short ${PDO_HOSTNAME}) +export PDO_LEDGER_ADDRESS=$(force_to_ip ${PDO_HOSTNAME}) export PDO_LEDGER_URL=${PDO_LEDGER_URL:-http://${PDO_LEDGER_ADDRESS}:6600} if [ ! -z "${F_LEDGER_URL}" ] ; then export PDO_LEDGER_URL=${F_LEDGER_URL} @@ -74,10 +78,6 @@ fi export no_proxy=$PDO_HOSTNAME,$no_proxy export NO_PROXY=$PDO_HOSTNAME,$NO_PROXY -source /opt/intel/sgxsdk/environment -source /project/pdo/tools/environment.sh -source ${PDO_HOME}/bin/lib/common.sh - # ----------------------------------------------------------------- # Handle the configuration of the services # ----------------------------------------------------------------- diff --git a/ledgers/ccf/scripts/start_ccf_network.sh b/ledgers/ccf/scripts/start_ccf_network.sh index 5153d3eb..f4b9864f 100755 --- a/ledgers/ccf/scripts/start_ccf_network.sh +++ b/ledgers/ccf/scripts/start_ccf_network.sh @@ -61,17 +61,17 @@ fi rm -f ${PDO_LEDGER_KEY_ROOT}/networkcert.pem rm -f ${PDO_LEDGER_KEY_ROOT}/ledger_authority_pub.pem -yell "INTERFACE: ${F_INTERFACE}" -yell "PORT: ${F_PORT}" -yell "PDO_HOSTNAME: ${PDO_HOSTNAME}" -yell start with "local://${F_INTERFACE}:${F_PORT}" +# ensure that we use an IP address for the interface +F_INTERFACE_ADDRESS=$(force_to_ip ${F_INTERFACE}) + +yell start ccf network with "local://${F_INTERFACE_ADDRESS}:${F_PORT}" say attempt to start ccf node ${CCF_BASE}/bin/sandbox.sh \ --verbose \ --host-log-level info \ -p ${PDO_HOME}/ccf/lib/libpdoenc \ - -n "local://${F_INTERFACE}:${F_PORT}" \ + -n "local://${F_INTERFACE_ADDRESS}:${F_PORT}" \ -e virtual -t virtual \ --workspace ${PDO_HOME}/ccf/workspace \ --initial-node-cert-validity-days 365 \ @@ -94,7 +94,7 @@ cp ${PDO_HOME}/ccf/workspace/sandbox_common/member0_privk.pem ${PDO_LEDGER_KEY_R say generate the ledger authority try ${PDO_HOME}/ccf/bin/generate_ledger_authority.py \ --logfile __screen__ --loglevel WARNING \ - --interface ${F_INTERFACE} --port ${F_PORT} + --interface ${F_INTERFACE_ADDRESS} --port ${F_PORT} # Set the enclave attestation policy while operating under SGX SIM # mode. When operating in the HW mode, the rpc gets invoked after the @@ -104,11 +104,13 @@ if [ "${SGX_MODE}" == "SIM" ]; then say set check_attestation to false in SGX SIM mode try ${PDO_HOME}/ccf/bin/register_enclave_attestation_verification_policy.py \ --logfile __screen__ --loglevel WARNING \ - --interface ${F_INTERFACE} --port ${F_PORT} + --interface ${F_INTERFACE_ADDRESS} --port ${F_PORT} fi say save the ledger authority key try ${PDO_HOME}/ccf/bin/fetch_ledger_authority.py \ --logfile __screen__ --loglevel WARNING \ - --interface ${F_INTERFACE} --port ${F_PORT} + --interface ${F_INTERFACE_ADDRESS} --port ${F_PORT} + +yell ledger URL is http://${F_INTERFACE_ADDRESS}:${F_PORT}