Refactoring: Make SOCKS server state machine explicitly defined
- 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.
This was supposed to be done as part of #3569 (moved), but wasn't. We should do it anyway.