alfred-screensharing
alfred-screensharing copied to clipboard
Computer name not necessarily hostname
dns-sd -B _rfb._tcp returns the "Instance Name" of the device. The hostname however is discovered by running dns-sd -L "INSTANCE_NAME_HERE" _rfb._tcp. Sometimes instance names and hostnames are not the same. In my case the instance name didn't have the (2) at the end but my hostname was suffixed with -2.
In order to fix this, escape_hostname should be replaced with a command that would run dns-sd -L on the $name variable.
I'd submit a PR myself but I have resolved the name mismatch in my case. Also, I'm not sure how to nest the subshell kills without killing the parent subshell (e.g. ((sleep 0.1; kill -13 0) & within a ((sleep 0.1; kill -13 0) &).
Here was my progress though:
function resolve_hostname {
tail -1 <((sleep 0.1; kill -13 0) & dns-sd -L "$@" _rfb._tcp) | cut -d' ' -f8)
}
Perhaps a separate script would make this work?
I've never seen this case and running another non-terminating process (i.e. dns-sd) is probably not a good solution. If you find a fix, please let me know.
What OS is running on the host that's being resolved in this way?
It was a Yosemite machine. Also the hostname is separately settable from the bonjour name. I could especially see this being the case for FQDNs.
What's being returned by dns-sd -B and what's the advantage / use case of having different names for these services?
Note to myself: http://osxdaily.com/2012/10/24/set-the-hostname-computer-name-and-bonjour-name-separately-in-os-x/
-B is just returning the bonjour name (settable in sharing pref pane) where as -L returns the hostname.
I don't know if there is an advantage per se but the hostname can be set in multiple ways without changing the instance name. The hostname command, editing /etc/hostname or the util you linked. Also under Edit in sharing pref pane. The user may have set it different and not realize why the workflow won't connect to their machine. For me, my Mac had a DHCP lease conflict with itself (happens frequently with reboots or power outage) and for some reason only renamed the hostname (usually I see the instance name renamed too).
I guess one advantage would be having a FQDN which would let you host certain publicly accessible services when not behind NAT (e.g. reverse dns, wide area bonjour, etc).