How to use delphi to distinguish http, socks4, socks5 proxy? There is an idea: connect to the proxy and go to some site and watch the request data, but I don’t know by what data I should make the program distinguish 3 types of proxies.
Usually, in software where it is necessary to specify a list of proxies, either a specific type of proxy is used, or it is possible to specify both of them as different lists. Those. the type definition falls on the user. And users of such software usually cope normally.
If you have a specific task in this. You should assume the type of proxy on the port, for example 8080 - http. Try to connect. If it comes out, good. No - try another type.
HTTP / s protocol
HTTP / s Proxy we only send headers to the server - headers , example:
GET /index.php HTTP/1.1 Host: www.domain.com Connection: keep-alive
How does Socks 4/5 work?
Socks 4/5 works through several stages of data (packets), which you must send to the socks-server before it can earn.
- Package includes: version and authentication method.
- The package includes: the type of connection (connect / bind), IP: Port (remote host), the protocol through which you connect (tcp / udp).
- At the third stage there is data exchange, if the connection type is set to Bind.
For your reference, I advise you to read the specification of the work of the Socks5 RFC1928 Protocol.
Practice and examples
To practice and find the complete answer to your question, I recommend that you install Synapse . In the documentation, you can find the examples you need (connect to any server using socks-proxy or get the http page via http / s proxy).