All the good days.
The problem is as follows:
I want to understand the socks5 proxy and write it simple variant on free pascal under Linux, using the library synapse. The client connects to the proxy is authorized successfully, and then zaparka (to connect to my proxy use proxychains). In the attached file is a source code proxy_obj.pas, starting from the line 192. I understand that in addition to the above, there are many drawbacks (destruction of objects, etc.), but it is only necessary to understand this.
source
https://yadi.sk/d/91loZnd8gxxNQ