Exemplo n.º 1
0
        public void Dispose()
        {
            if (m_connection == null)
            {
                return;
            }
            try
            {
                m_writer.Close();
            }
            catch { }
            m_writer = null;

            try
            {
                m_reader.Close();
            }
            catch { }
            m_reader = null;

            if (m_connection != null)
            {
                try
                {
                    m_connection.GetStream().Close();
                }
                catch { }
            }
        }
 internal NntpProtocolReaderWriter(TcpClient connection)
 {
     m_connection = connection;
     m_network = m_connection.GetStream();
     m_writer = new StreamWriter(m_network, DefaultTextEncoding);
     m_writer.AutoFlush = true;
     m_reader = new NntpStreamReader(m_network);
 }
Exemplo n.º 3
0
 internal NntpProtocolReaderWriter(TcpClient connection)
 {
     m_connection       = connection;
     m_network          = m_connection.GetStream();
     m_writer           = new StreamWriter(m_network, DefaultTextEncoding);
     m_writer.AutoFlush = true;
     m_reader           = new NntpStreamReader(m_network);
 }
Exemplo n.º 4
0
        internal NntpProtocolReaderWriter(TcpClient connection, bool SSL, string authdomain)
        {
            this.SSL = SSL;

            m_connection = connection;

            //m_connection.ReceiveBufferSize = 6000;

            // ssl needs longer to connect but then its kinda ok after it has done its stuff

            if (!SSL)
            {
                m_network = (NetworkStream)m_connection.GetStream();
            }
            else
            {
                // SslClientStream faster !?

                //#if __IOS__
                // m_network = new SslStream(m_connection.GetStream(), false, new RemoteCertificateValidationCallback((sender, certificate, chain, sslPolicyErrors) => {

                /*
                 * m_network = new Mono.Security.Protocol.Tls.SslClientStream(m_connection.GetStream(), authdomain, true){
                 *      ServerCertValidationDelegate = (certificate, certificateErrors) =>
                 *      {
                 *              var trust = new SecTrust(certificate,
                 *                      SecPolicy.CreateSslPolicy(false, authdomain));
                 *              var result = trust.Evaluate();
                 *
                 *              return result == SecTrustResult.Unspecified || result ==
                 *                      SecTrustResult.Proceed;
                 *      }
                 * };
                 */
                // ((SslStream)m_network).AuthenticateAsClient (authdomain);
                //#else
                m_network = new SslStream(m_connection.GetStream(), false);
                //m_network = new Mono.Security.Protocol.Tls.SslClientStream(m_connection.GetStream(), authdomain, true);
                //#endif
                ((SslStream)m_network).AuthenticateAsClient(authdomain);
            }
            m_writer           = new StreamWriter(m_network, DefaultTextEncoding);
            m_writer.AutoFlush = true;
            m_reader           = new NntpStreamReader(m_network);
        }
        internal void Initialize(TcpClient connection)
        {
            m_connection = connection;
            m_network    = m_connection.GetStream();

            var stream = m_network;

            if (m_useSsl)
            {
                var sslClient = new SslStream(m_network);
                sslClient.AuthenticateAsClient(m_sslSslHostName);
                stream = sslClient;
            }

            m_writer           = new StreamWriter(stream, DefaultTextEncoding);
            m_writer.AutoFlush = true;
            m_reader           = new NntpStreamReader(stream);
        }
Exemplo n.º 6
0
        internal NntpProtocolReaderWriter(TcpClient connection, bool SSL, string authdomain)
        {
            this.SSL     = SSL;
            m_connection = connection;

            //m_connection.ReceiveBufferSize = 6000;

            // ssl needs longer to connect but then its kinda ok after it has done its stuff

            if (!SSL)
            {
                m_network = (NetworkStream)m_connection.GetStream();
            }
            else
            {
                //m_network = new SslStream(m_connection.GetStream(), false, CertValidationCallback);
                m_network = new SslStream(m_connection.GetStream(), true, CertValidationCallback);
                ((SslStream)m_network).AuthenticateAsClient(authdomain);
            }
            m_writer           = new StreamWriter(m_network, DefaultTextEncoding);
            m_writer.NewLine   = NEWLINE;
            m_writer.AutoFlush = true;
            m_reader           = new NntpStreamReader(m_network);
        }
        public void Dispose()
        {
            if (m_connection == null)
            {
                return;
            }
            try
            {
                m_writer.Close();
            }
            catch { }
            m_writer = null;

            try
            {
                m_reader.Close();
            }
            catch { }
            m_reader = null;

            if (m_connection != null)
            {
                try
                {
                    m_connection.GetStream().Close();
                }
                catch { }
            }
        }
        internal void Initialize(TcpClient connection)
        {
            m_connection = connection;
            m_network = m_connection.GetStream();

            var stream = m_network;
            if( m_useSsl )
            {
                var sslClient = new SslStream(m_network);
                sslClient.AuthenticateAsClient(m_sslSslHostName);
                stream = sslClient;
            }

            m_writer = new StreamWriter(stream, DefaultTextEncoding);
            m_writer.AutoFlush = true;
            m_reader = new NntpStreamReader(stream);
        }