Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

FTP client behind Proxy

17 views
Skip to first unread message

Manish Buttan

unread,
Feb 4, 2004, 1:56:06 AM2/4/04
to
Hi,
I have written an FTP Client in C#.
It works fine without a proxy setting.

Now I want to run this tool behind a proxy server.

Can you please tell me how to enable an ftp client to run from behind a proxy server( Microsoft proxy server ), in passive mode,
without having a proxy client installed on the client machine ?

I also need it to run behind a firewall in "Network Appliance Netcaches" proxy environment, without proxy client installed on the client machine.

Regards,
Manish

Louis Solomon [SteelBytes]

unread,
Feb 4, 2004, 2:05:07 AM2/4/04
to
use HTTP/1.1 CONNECT or SOCKS 4/5 to establish each TCP connection (FTP
command and data streams)

--
Louis Solomon
www.steelbytes.com

"Manish Buttan" <Man...@ccipl.com> wrote in message
news:AFC8F8AE-D053-4B83...@microsoft.com...

Manish Buttan

unread,
Feb 5, 2004, 11:51:06 PM2/5/04
to
Hi Louis,
Thanks for the reply.

SOCKS seems to be unmanaged, while I need a dotnet managed client in place.

Can you please give me more details regarding using "HTTP/1.1 CONNECT" to eatablish the connections ?

regards
-Manish

Louis Solomon [SteelBytes]

unread,
Feb 6, 2004, 12:25:41 AM2/6/04
to
> Can you please give me more details regarding using "HTTP/1.1 CONNECT" to
> eatablish the connections ?

read the http/1.1 rfc :-)
sorry, that wasn't very helpful. ok, by connecting to a proxy server, and
sending the CONNECT verb (read the rfc for specs), you can create a
'outwards' TCP tunnel to a desired target (ip:port). that is of course
assumeing authenication and filtering on the proxy dont stop you ....
once you have established the connection this way, you can then just hand
the socket over to you regular ftp client code to read/write on.

syntax from memory to send to the proxy ...

CONNECT ftp.microsoft.com:21 HTTP/1.1<CRLF>
Content-Type: application/octet-stream<CRLF>
Cache-Control: no-cache<CRLF>
Pragma: no-cache<CRLF>
<CRLF>

then wait for a response such as

HTTP/1.0 200 Connection established<CRLF>
<CRLF>

or an error (something other then 200 as the return code)

you will need to do this also for the data connections.

--
Louis Solomon
www.steelbytes.com


Manish Buttan

unread,
Feb 13, 2004, 8:51:05 AM2/13/04
to
Hi Louise,

I am a bit lost on using HTTP 1.1. connect to get the sockets.

My current implementation employes the following code to get the sockets for FTP.

The "hostname" is the remote ftp site name.

This works for me without proxies.

Socket ftpSocket = new Socket(AddressFamily.InterNetwork,SocketType.Stream,ProtocolType.Tcp);
IPAddress serverAddress = Dns.Resolve("hostName").AddressList[0];
IPEndPoint endPoint = new IPEndPoint(serverAddress,21);

//Connect to the Server.
ftpSocket.Connect(endPoint);

I need this to work from behind a proxy without installing proxy clients.

From your previous reply, I understand that i need to connect the sockets to the ftp site using HTTP 1.1 CONNECT.

How do I do this from behind a proxy.

Is it that I bind the socket to the proxy server's port, using it's ip address
and then send the first command as HTTP 1.1 Connect, with the ftp site name ?

Below is the code which I tried behind proxy server and still could not connect to the FTP site.

Socket ftpSocket = new Socket(AddressFamily.InterNetwork,SocketType.Stream,ProtocolType.Tcp);
IPAddress serverAddress = Dns.Resolve("ProxyServer").AddressList[0];
IPEndPoint endPoint = new IPEndPoint(serverAddress,80);

//Connect to the proxy Server.
ftpSocket.Connect(endPoint);
ftpSocket.Send("CONNECT ftp://hostname:21 HTTP/1.1\r\n");

I am not getting any response from the server after sending this command. I know that atleast the connect command syntax is correct here from reading a white paper :
http://www.web-cache.com/Writings/Internet-Drafts/draft-luotonen-web-proxy-tunneling-01.txt

Can you please guide me as to what I am missing out on?

Regards,
Manish.


Louis Solomon [SteelBytes]

unread,
Feb 16, 2004, 10:20:38 AM2/16/04
to
>                  ftpSocket.Send("CONNECT ftp://hostname:21 HTTP/1.1\r\n");
>                 I am not getting any response from the server after sending this command.
 
try
    ftpSocket.Send("CONNECT ftp://hostname:21 HTTP/1.1\r\nContent-Type: application/octet-stream\r\nCache-Control: no-cachePragma: no-cache\r\n\r\n");

 
also, not sure if you may have to use \n instead of \r\n since the language you are using _may_ translate \n to \r\n

--
Louis Solomon
www.steelbytes.com
 
0 new messages