== Nick here. I tweaked this patch a little to make it apply cleanly to master, to extract some common code into a function, and to replace snprintf with tor_snprintf. -- nickm