I recently adopted v3 onions, which brought up the issue of having to detect if the Tor daemon that the user uses can or cannot handle v3 onions. (As context: my users encountered this issue mainly on Ubuntu 16.04 or distros based on it, like Elementary OS.)
Normally by connecting to the destination I get a success answer:
But, if the Tor daemon is out of date I get the following answer from the daemon:
So, we can see the
REP field is the difference.
Quote from SOCKS5 RFC:
REP Reply field:
o X'00' succeeded
o X'01' general SOCKS server failure
o X'02' connection not allowed by ruleset o X'03' ...
o And so on...
So I get a
general SOCKS server failure response, which is problematic, because it can mean many things. It would be unwise to catch this error and say "please update your Tor instance".
Any ideas what to do? Any way to detect Tor version or Tor v3 capability through the SOCKS port?