gpt4 book ai didi

delphi - IdHTTP + socks + socks 5

转载 作者:太空宇宙 更新时间:2023-11-03 12:41:34 25 4
gpt4 key购买 nike

我在使用 IdHTTP 客户端组件时遇到一般 Indy 错误结合 SOCKS5 代理服务器并使用 SSL

  • 如果我将 IdHTTP 组件与我的 SOCKS5 代理(和非 https URL)一起使用,一切正常。
  • 如果我使用带有 SSL URL 的 IdHTTP 组件(没有 SOCKS5 代理),一切正常。
  • 如果我将 IdHTTP 组件与 SSL URL 和 SOCKS5 代理一起使用,我会收到以下错误:
错误输出的

405行idSocks.pas (引发 EIdSocksServerGeneralError.Create(RSSocksServerGeneralError);

这是我的代码

var
HTTP : TIdHTTP;
Cookie : TIdCookieManager;
SSL : TIdSSLIOHandlerSocketOpenSSL;
Params : TStringList;
HTMLSource : String;
CurrentProxy : String;
ProxyPort : Integer;
ProxyHost : String;
ProxyUsername : String;
ProxyPW : String;
begin
Synchronize(AddItem);
HTTP := TIdHTTP.Create(NIL);
Cookie := TIdCookieManager.Create(HTTP);
SSL := TIdSSLIOHandlerSocketOpenSSL.Create(HTTP);
HTTP.CookieManager := Cookie;
HTTP.IOHandler := SSL;
HTTP.HandleRedirects := True;
Params := TStringList.Create;
HTTP.Request.UserAgent := Task^.Useragent;
try
while True do begin
if terminated then Exit;
Params.Clear;
Cookie.CookieCollection.Clear;
if Task^.Proxytype >= 0 then begin // if proxy enabled
CurrentProxy := Task^.Form.GetProxyFromPool;
ProxyHost := ParsingW(':', CurrentProxy, 1);
ProxyPort := strtoint(ParsingW(':', CurrentProxy, 2));
HTTP.ConnectTimeout := (Task^.Proxytimeout * 1000);
if Task^.ProxyAuth then begin
ProxyUsername := ParsingW(':', CurrentProxy, 3);
ProxyPW := ParsingW(':', CurrentProxy, 4);
end;
end;
if Task^.Proxytype = 0 then begin //HTTP(s)
HTTP.ProxyParams.ProxyServer := ProxyHost;
HTTP.ProxyParams.ProxyPort := ProxyPort;
if Task^.ProxyAuth then begin
HTTP.ProxyParams.ProxyUsername := ProxyUsername;
HTTP.ProxyParams.ProxyPassword := ProxyPW;
end;
end;
if (Task^.Proxytype = 1) or (Task^.Proxytype = 2) then begin // Socks 4 or 5
SSL.TransparentProxy := TIdSocksInfo.Create(HTTP);
(SSL.TransparentProxy as TIdSocksInfo).Port := ProxyPort;
(SSL.TransparentProxy as TIdSocksInfo).Host := ProxyHost;
if Task^.ProxyAuth then begin
(SSL.TransparentProxy as TIdSocksInfo).Username := ProxyUsername;
(SSL.TransparentProxy as TIdSocksInfo).Password := ProxyPW;
(SSL.TransparentProxy as TIdSocksInfo).Authentication := saUsernamePassword;
end else begin
(SSL.TransparentProxy as TIdSocksInfo).Authentication := saNoAuthentication;
end;
if (Task^.Proxytype = 1) then (SSL.TransparentProxy as TIdSocksInfo).Version := svSocks4;
if (Task^.Proxytype = 2) then (SSL.TransparentProxy as TIdSocksInfo).Version := svSocks5;
end;

我是否遗漏了什么或者无法使用 Socks5 代理连接到 SSL 站点?

最佳答案

您收到 EIdSocksServerGeneralError 引发的事实意味着 TIdHTTP 已成功与 SOCKS 代理通信,并且它正在验证您的请求以在无需身份验证的情况下访问它,但是然后无法与您在 HTTPS 网址中指定的目标服务器建立连接。代理正在回复错误代码 1(一般故障)。确保网址准确无误。代理无法将主机名解析为 IP(尝试在 url 中指定 IP 而不是主机名,看看是否有所不同),或者代理没有到达该 IP 的有效路由,或者是其他一些错误发生在代理端。如果您有权访问代理,请尝试查看其日志以了解实际出了什么问题。

关于delphi - IdHTTP + socks + socks 5,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19001591/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com