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.

  • 2
    Um ... I always thought that you first need to know where to connect, and then connect ... And not first connect, and then understand - and where I connected) - SilverIce
  • Google the topic of reading proxy settings in the operating system. - SilverIce
  • 3
    You can first try to connect as an http proxy. If it did not work out, then how to sock the proxy. But heuristics can also be applied. For example, port 1080 - it means that the sox is a proxy and you should first try to connect to it like that. - KoVadim

2 answers 2

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: 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.

    1. Package includes: version and authentication method.
    2. The package includes: the type of connection (connect / bind), IP: Port (remote host), the protocol through which you connect (tcp / udp).
    3. 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).