zoukankan      html  css  js  c++  java
  • How do I use SOCKS proxy in delphi?

    TCP
    ======

    For Indy 8.0

    In Delphi, do the following:

    IdTCPClient1.SocksInfo.Host := [the DNS name of the proxy server or its IP address]
    IdTCPClient1.SocksInfo.Protocol := [svNoSocks for no SOCKS support, svSocks4 for SOCKS 4, svSocks4A for SOCKS 4 with protocol extension, and svSocks5 for SOCKS 5 protocol]
    IdTCPClient1.SocksInfo.Authentication := [saNoAuthentication for no SOCKS authentication or saUsernamePassword for username and password authentication]

    In C++Builder, do the following:

    IdTCPClient1->SocksInfo->Host = [the DNS name of the proxy server or its IP address]
    IdTCPClient1->SocksInfo->Protocol = [svNoSocks for no SOCKS support, svSocks4 for SOCKS 4, svSocks4A for SOCKS 4 with protocol extension, and svSocks5 for SOCKS 5 protocol]
    IdTCPClient1->SocksInfo->Authentication = [saNoAuthentication for no SOCKS authentication or saUsernamePassword for username and password authentication]

    For Indy 9.0

    1. Create an IOHandler such as TIdIOHandlerSocket or TIdSSLIOHandlerSocket and assign the TCPClient.IOHandler property this.
    2. Create a TIdSocksInfo object and assign it to the IOHandler's SocksInfo property.
    3. Set the TIdSocksInfo properties as required.

    For Indy 10

    1. Create an IOHandler such as TIdIOHandlerStack or SSL IOHandler and assign the TCPClient.IOHandler property this.
    2. Create a TIdSocksInfo object and assign it to the IOHandler's TransparentProxy property.
    3. Set the TIdSocksInfo properties as required.
    4. If there is another proxy that the SOCKS Proxy itself needs to use, you have to use, set the Chained Proxy to a TIdCustomTransparentProxy such as TIdSocksInfo for another socks Proxy or a TIdConnectThroughHttpProxy for a HTTP Tunneling proxy.

    UDP
    ======

    Starting with Indy 10 build 51, we introduced the ability to use a SOCKS with UDP. However, this will only work with SOCKS protocol version 5 and the proxy server must support the UDP Associate method described in RFC 1928 - SOCKS Protocol Version 5.

    1. Create a TIdSocksInfo object and assign it to the TIdUDPClient.TransparentProxy property.
    2. Set the TIdSocksInfo properties as required.
    3. Call TIdUDPClient.OpenProxy just before you use any receive or send calls.
    4. After completing all of your receive and send calls, call TIdUDPClient.CloseProxy.

    or if you are using the optional TIdUDPClient.Connect and TIdUDPClient.Disconnect methods, you can simply:

    1. Create a TIdSocksInfo object and assign it to the TIdUDPClient.TransparentProxy property.
    2. Set the TIdSocksInfo properties as required.
    3. Call the TIdUDPClient.Connect method and it will open a connection to your proxy and call TIdUDPClient.Disconnect to close the connection to the proxy.

  • 相关阅读:
    Java中的System类
    关于Java IO流学习总结
    Java InputStream、String、File相互转化
    Java 里把 InputStream 转换成 String 的几种方法
    详细讲解JAVA中的IO流
    获取 request 中 json 数据
    oracle count 百万级 分页查询记要总数、总条数优化
    ORACLE分页SQL语句
    ORACLE中用rownum分页并排序的SQL语句
    day7
  • 原文地址:https://www.cnblogs.com/allegro/p/4952986.html
Copyright © 2011-2022 走看看