예제 #1
0
        public static void Run()
        {
            string host;
            int    port;
            string username;

            // get input from user
            if (!inputConnectionInfo(out host, out port, out username))
            {
                return;
            }

            // connect
            SslEgg sslEgg;

            try
            {
                TcpClient tcpSocket = new TcpClient(host, port);

                // establish ssl
                sslEgg = new SslEgg(tcpSocket);
                sslEgg.AuthenticateAsClient(m_targetCertHost);
            }
            catch (Exception e)
            {
                Logging.WriteLine(String.Format("Unable to establish connection to {0}:{1} : {2}", host, port, e.Message));
                return;
            }

            // create client instance
            CmdClient cmdClient = new CmdClient(sslEgg);

            // run main user I/O loop
            cmdClient.mainInputLoop(username);
        }
예제 #2
0
        // Open a new connection to the server (Unfortunately, CP wasn't designed with FT in mind)
        private SslStream connectFt()
        {
            // connect using existing remote endpoint info
            if (RemoteEndPoint == null)
            {
                return(null);
            }

            try
            {
                TcpClient tcpServer = new TcpClient(RemoteEndPoint.Address.ToString(), RemoteEndPoint.Port);
                SslEgg    egg       = new SslEgg(tcpServer);
                egg.AuthenticateAsClient(m_targetCertHost);
                // write the magic byte (to indicate ftp)
                egg.SslStream.Write(new byte[1] {
                    (byte)CpServersideBase.ConnectionMode.FILE_TRANSFER
                }, 0, 1);
                return(egg.SslStream);
            }
            catch
            {
                return(null);
            }
        }