So today I have dived into OverByteIcsHttpProt.pas and made a few small 
hacks as under to bypass the DNS lookup:

In procedure THttpCli.Login;
<....>
    FCtrlSocket.LocalAddr := FLocalAddr; {bb}
      try
          if SocksServer = '' then
            FCtrlSocket.DnsLookup(FHostName)
          else
            FCtrlSocket.DnsLookup('');    {CW Skip the local DNS lookup, 
but trigger DnsLookupDone}
      except
          on E: Exception do begin
<...>

and in 
procedure THttpCli.SocketDNSLookupDone(Sender: TObject; ErrCode: Word);
begin
    if (ErrCode <> 0) AND ((SocksServer <> '') AND (ErrCode <> 10022)) 
then begin
        if FState = httpAborting then
            Exit;
<....>
    else begin
        if SocksServer = '' then
          FDnsResult            := FCtrlSocket.DnsResult
        else
          FDnsResult            := FHostName;  {CW Use the domain name }
        StateChange(httpDnsLookupDone);  { 19/09/98 }
<....>

It gets the job done, but I'm not really comfortable doing this to the 
work of others who know so much more than me. But hey, I'll use it if a 
better solution doesn't come to light!

For me, a cleaner way would be to get the IP address from the proxy server 
relating to the existing WSocket connection, but I don't know how to go 
about it. 

Thanks to the respondents.
--
Colin


Colin Wall/GGL wrote on 24/11/2017 09:01:17 a.m.:

> From: Colin Wall/GGL
> To: ICS support mailing <twsocket@lists.elists.org>
> Date: 24/11/2017 09:01 a.m.
> Subject: Re: [twsocket] THttpCli and Socks Proxy
> 
> Except that HttpCli doesn't get this far when supplied with a domain
> name. As Angus suggests in his post, it tries to do a dns lookup 
> first, and fails.
> 
> --
> Colin
> 
> "TWSocket" <twsocket-boun...@lists.elists.org> wrote on 24/11/2017 
> 01:24:18 a.m.:
> 
> > From: "A.S." <an...@rambler.ru>
> > To: twsocket@lists.elists.org
> > Date: 24/11/2017 01:24 a.m.
> > Subject: Re: [twsocket] THttpCli and Socks Proxy
> > Sent by: "TWSocket" <twsocket-boun...@lists.elists.org>
> > 
> > TCustomSocksWSocket.SocksDoConnect has this code for SocksLevel <> 
'4':
> > 
> >          Buf[3] := #$03;            { Address type is domain name }
> >          Buf[4] := AnsiChar((Length(FAddrStr)));
> >          { Should check buffer overflow }
> >          Move(AnsiString(FAddrStr)[1], Buf[5], Length(FAddrStr)); // 
No 
> > length change expected (ASCII)
> > 
> > So everything is as it should be
> > 
> > > Is there some way I can encourage it to use the proxy for DNS 
resolution?
> > > Alternatively, how can I get the remote IP address from the existing
> > > TWSocket connection? (PeerAddr only gives me the IP of the proxy 
server).
> > >
> > > Any assistance with this issue will be much appreciated.
> > >
> > > Thanks,
> > > Colin
> > >
> > 
> > -- 
> > A.S.
> > 
> > -- 
> > To unsubscribe or change your settings for TWSocket mailing list
> > please goto http://lists.elists.org/cgi-bin/mailman/listinfo/twsocket
> > Visit our website at http://www.overbyte.be
###########################################################################
This email is confidential and may contain information subject to legal 
privilege.  If you are not the intended recipient please advise us of our
error by return e-mail then delete this email and any attached files.  
You may not copy, disclose or use the contents in any way.  

The views expressed in this email may not be those of Gallagher Group 
Ltd or subsidiary companies thereof.
###########################################################################
-- 
To unsubscribe or change your settings for TWSocket mailing list
please goto http://lists.elists.org/cgi-bin/mailman/listinfo/twsocket
Visit our website at http://www.overbyte.be

Reply via email to