Refactor socks parsing

The function parse_socks and its interactions with the functions that call it have grown nigh-unmaintainably complex. Let's replace it with a simple, more linear function. Key points:

  • State should be kept explicitly. Let's forget this "if the socks version is set, we've parsed this much, ..." business.
  • The function should dispatch first on state, next on anything else.
  • We should think of a much better interface; the functions that call parse_socks have grown way too tricky.