Esempio n. 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);
        }
Esempio n. 2
0
 public AmTcpClient(SslEgg egg)
 {
     m_client        = new AmTcpMuxer(egg);
     Serializer      = new SerializationAdapterAsync(m_client.WriteStream);
     EventSerializer = new SerializationAdapterAsync(m_client.WriteEventStream);
     Deserializer    = new DeserializationAdapterAsync(m_client.ReadStream);
 }
Esempio n. 3
0
        private async void startClientServiceLoopAsync(TcpClient tcpClient)
        {
            // establish ssl
            SslEgg egg = new SslEgg(tcpClient);

            try
            {
                await egg.AuthenticateAsServerAsync(m_certificatePath);
            }
            catch (Exception e)
            {
                Logging.DebugWriteLine(String.Format("Unable to establish secure connection with {0} : {1}", tcpClient.Client.RemoteEndPoint.ToString(), e.Message));
                tcpClient.Close();
                return;
            }

            // begin service loop
            await clientServiceLoop(egg);
        }
Esempio n. 4
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);
            }
        }
Esempio n. 5
0
 // constructor
 public CmdClient(SslEgg egg)
     : base(egg)
 {
 }