# shellcheck shell=bash DESCRIPTION="Finding things on the network with dns-sd (the VM announces its own ssh)" TIER=quick source "$CONNECTOR/configure.d/lib/mdns.sh" finds_type() { mdns_types | grep -qx '_ssh._tcp' } finds_instance() { [ -n "$(mdns_instances _ssh._tcp)" ] } resolves_own_host() { mdns_services _ssh._tcp | cut -d'|' -f3 | grep -qixF "$(mdns_own_host)" } quick_enough() { local start=$SECONDS run_for 2 dns-sd -B _ssh._tcp local. > /dev/null [ $((SECONDS - start)) -le 4 ] } scenario() { step "Remote Login is on in the VM, so it announces _ssh._tcp" check "run_for stops dns-sd on time" quick_enough check "mdns_types lists _ssh._tcp (dns-sd's output comes through a pipe)" finds_type check "mdns_instances lists the VM's ssh" finds_instance check "mdns_services resolves it to this Mac's .local name ($(mdns_own_host))" resolves_own_host check "mdns_hosts runs (and leaves this Mac out)" bash -c \ "source '$CONNECTOR/configure.d/lib/mdns.sh'; ! mdns_hosts | grep -qixF \"\$(mdns_own_host)\"" }