[svn.haxx.se] · SVN Dev · SVN Users · SVN Org · TSVN Dev · TSVN Users · Subclipse Dev · Subclipse Users · this month's index

RE: SVN Proxy server

From: Ramprasad Venkata Inala <rinala_at_cordys.com>
Date: 2005-06-02 08:27:53 CEST

Anybody please help me in achieving the connectivity.

Note: Please add me to the cc of the mailing list as i am not a member
of this group.

Thanks and regards
RP

-----Original Message-----
From: Ramprasad Venkata Inala
Sent: Thursday, June 02, 2005 10:45 AM
To: 'dev@subversion.tigris.org'
Subject: RE: SVN Proxy server

Hi Ben,

I had to write a proxy that would pass through our versions as well
before it reaches the svn.

Client-->SVNproxy-->OurVersioningSystem-->SVN.
The above is the process that i need to follow. Considering the
different protocols that svn has like Http, Https( which are already
handled ) and SVN which need to be handled now in our project.

I had written a socket ( SVN Proxy ) server in java.
Let me put the details how i am proceeding in obtaining the connection.

Note: I use the eclipse svn plugin as the client.

1. First I click Team->Share Project-> SVN( Chosen option ) click next
and pick up an existing svn repsoitory on my machine.
2. Now the proxy receives the request( opening a socket ,
ServerSocket.accept method ) then spawns a new thread that would handle
the request then on, like opening input and output streams. when the
proxy receives the first call to open socket then it sends back reponse
in this format
( success ( 1 2 ( ANONYMOUS ) ( edit-pipeline ) ) ) ( 2 ANONYMOUS ( ) (
) )
3. Then the client responds back with this.
( 2 ( edit-pipeline ) 32:svn:///d:/testsvnrep/SVNProtocol )
In my case the testsvnrep is my repository and SVNProtocol is my eclipse
project.
4. Then the proxy sends a reponse to the client in this format
( success ( ( ) 32:localhost/d:/testsvnrep/SVNProtocol ) )

Now the problem starts, after when i send this response to the client
the client opens up anew socket instead of sending on the same socket
that was opened before.

Also attached is the code for the same.

SVNProxy File
--------------

import java.net.ServerSocket;
import java.net.Socket;

public class SVNProxy
{
        public static void main( String[] args ) throws Exception
        {
                ServerSocket serverSoc = new
ServerSocket( 3690 );
                //Socket soc
= null;

                System.out.println("SVN Proxy Started.");
                while( true )
                {
                        System.out.println( "Waiting..." );
                        Socket soc
= serverSoc.accept();
                        System.out.println( "New connection opened on
port::"+soc.getPort() );
                        new Thread( new SVNSession( soc ) ).start();
                        //openSession( soc );
                }
        }

SVNSession File
----------------

import java.net.Socket;
//import java.io.InputStream;
import java.io.OutputStream;
//import java.io.BufferedInputStream;
import java.io.InputStreamReader;
import java.io.BufferedReader;

public class SVNSession implements Runnable
{
        private Socket clientSocket
= null;
        private String OPEN_CONNECTION_RESPONSE = "( success ( 1
2 ( ANONYMOUS ) ( edit-pipeline ) ) ) " +
        
"( 2 ANONYMOUS ( ) ( ) )";
        private String AUTHETICATION_REQUEST = "( success ( (
) ";

        SVNSession( Socket soc ) throws Exception
        {
                this.clientSocket
= soc;
        } // end of constructor SVNSession

        public void run()
        {
                try
                {
                        openSVNSession();
                        readInputStream();
                } // end of try block
                catch( Exception e )
                {
                        e.printStackTrace();
                } // end of catch block
        } // end of run method
        
        private void openSVNSession() throws Exception
        {
                byte[] writeBytes
= OPEN_CONNECTION_RESPONSE.getBytes();
                OutputStream socOutputStream =
this.clientSocket.getOutputStream();
                socOutputStream.write( writeBytes );
                System.out.println("SVN hand shake ack sent.");
        } // end of openConnection method
        

        private void readInputStream() throws Exception
        {
                BufferedReader input
= new BufferedReader( new
        
InputStreamReader( this.clientSocket.
        
getInputStream() ) );
                String message
= null;
                while( true )
                {
                        if(
this.clientSocket.getInputStream().available() > 0 )
                        {
                                System.out.println( "available:" +
this.clientSocket.getInputStream().available() );
                                byte[] readBytes
= new byte[ this.clientSocket.getInputStream().
        
available() ];
                                this.clientSocket.getInputStream().read(
readBytes );
                                System.out.println( new String(
readBytes ) );
                                requestForAuthentication( new String(
readBytes ));
                        }
                } // end of while listening to inputstream
        } // end of readInputStream method
        
        private void processRequest( String request )
        {
        }
        
        private void requestForAuthentication( String response )
                                                throws Exception
        {
                this.clientSocket.getOutputStream().write( (
this.AUTHETICATION_REQUEST + " ( " +
        
response.substring(
        
( response.indexOf( ")" ) + 2 ) ) ).getBytes() );
        }

        private void closeStreams()
                                        throws Exception
        {
                this.clientSocket.getInputStream().close();
                this.clientSocket.getOutputStream().close();
        }
}
 

Please help me in understanding the protocol.

Regards
RP

-----Original Message-----
From: Ben Collins-Sussman [mailto:sussman@collab.net]
Sent: Friday, May 27, 2005 5:30 PM
To: Ramprasad Venkata Inala
Cc: dev@subversion.tigris.org
Subject: Re: SVN Proxy server

On May 27, 2005, at 2:01 AM, Ramprasad Venkata Inala wrote:

> Hi,
>
> I need to write a proxy server for SVN ( using the svn protocol
> i.e., svn:// ).
> I would like to understand protocol for the same. Altough i had
> gone through the protocol text file in the subversion sources
> directory.
> I would be grrate ful somebody gives the exact working of the
> protocol.

Does the 'protocol' document not give a precise-enough description?
If something's unclear, please ask specific questions.

**********************************************************************
The information in this message is confidential and may be legally
privileged. It is intended solely for the addressee. Access to this message
by anyone else is unauthorized. If you are not the intended recipient, any
disclosure, copying, or distribution of the message, or any action or
omission taken by you in reliance on it, is prohibited and may be unlawful.
Please immediately contact the sender if you have received this message in
error.
**********************************************************************

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org
Received on Thu Jun 2 08:28:48 2005

This is an archived mail posted to the Subversion Dev mailing list.

This site is subject to the Apache Privacy Policy and the Apache Public Forum Archive Policy.