Inheritance: TransportSettings
コード例 #1
0
 public TcpTransport(Socket socket, TcpTransportSettings transportSettings)
     : base("tcp")
 {
     this.socket                      = socket;
     this.socket.NoDelay              = true;
     this.socket.SendBufferSize       = transportSettings.SendBufferSize;
     this.socket.ReceiveBufferSize    = transportSettings.ReceiveBufferSize;
     this.localEndPoint               = this.socket.LocalEndPoint.ToString();
     this.remoteEndPoint              = this.socket.RemoteEndPoint.ToString();
     this.sendEventArgs               = new WriteAsyncEventArgs(transportSettings.SendBufferSize);
     this.sendEventArgs.Transport     = this;
     this.sendEventArgs.Completed    += onWriteComplete;
     this.receiveEventArgs            = new ReadAsyncEventArgs(transportSettings.ReceiveBufferSize);
     this.receiveEventArgs.Completed += onReadComplete;
     this.receiveEventArgs.Transport  = this;
 }
コード例 #2
0
ファイル: TcpTransport.cs プロジェクト: Azure/azure-amqp
 public TcpTransport(Socket socket, TcpTransportSettings transportSettings)
     : base("tcp")
 {
     this.socket = socket;
     this.socket.NoDelay = true;
     this.socket.SendBufferSize = transportSettings.SendBufferSize;
     this.socket.ReceiveBufferSize = transportSettings.ReceiveBufferSize;
     this.localEndPoint = this.socket.LocalEndPoint;
     this.remoteEndPoint = this.socket.RemoteEndPoint;
     this.sendEventArgs = new WriteAsyncEventArgs(transportSettings.SendBufferSize);
     this.sendEventArgs.Transport = this;
     this.sendEventArgs.Completed += onWriteComplete;
     this.receiveEventArgs = new ReadAsyncEventArgs(transportSettings.ReceiveBufferSize);
     this.receiveEventArgs.Completed += onReadComplete;
     this.receiveEventArgs.Transport = this;
 }
コード例 #3
0
ファイル: TcpTransport.UWP.cs プロジェクト: Azure/azure-amqp
 public TcpTransport(Windows.Networking.Sockets.StreamSocket socket, TcpTransportSettings transportSettings)
     : base("tcp")
 {
     this.socket = socket;
 }
コード例 #4
0
 internal TcpTransportInitiator(TcpTransportSettings transportSettings)
 {
     this.transportSettings = transportSettings;
 }
コード例 #5
0
 internal TcpTransportInitiator(TcpTransportSettings transportSettings)
 {
     this.transportSettings = transportSettings;
 }
コード例 #6
0
        TlsTransportSettings CreateTlsTransportSettings()
        {
            var tcpTransportSettings = new TcpTransportSettings()
            {
                Host = this.connectionString.HostName,
                Port = this.connectionString.AmqpEndpoint.Port
            };

            var tlsTransportSettings = new TlsTransportSettings(tcpTransportSettings)
            {
                TargetHost = this.connectionString.HostName,
                Certificate = null, // TODO: add client cert support
                CertificateValidationCallback = this.OnRemoteCertificateValidation
            };

            return tlsTransportSettings;
        }
コード例 #7
0
ファイル: TestAmqpBroker.cs プロジェクト: Azure/azure-amqp
        public TestAmqpBroker(IList<string> endpoints, string userInfo, string sslValue, string[] queues)
        {
            this.containerId = "TestAmqpBroker-P" + Process.GetCurrentProcess().Id;
            this.maxFrameSize = 64 * 1024;
            this.txnManager = new TxnManager();
            this.connections = new Dictionary<SequenceNumber, AmqpConnection>();
            this.queues = new Dictionary<string, TestQueue>();
            if (queues != null)
            {
                foreach (string q in queues)
                {
                    this.queues.Add(q, new TestQueue(this));
                }
            }
            else
            {
                this.implicitQueue = true;
            }

            // create and initialize AmqpSettings
            AmqpSettings settings = new AmqpSettings();
            X509Certificate2 certificate = sslValue == null ? null : GetCertificate(sslValue);
            settings.RuntimeProvider = this;

            SaslHandler saslHandler;
            if (userInfo != null)
            {
                string[] creds = userInfo.Split(':');
                string usernanme = Uri.UnescapeDataString(creds[0]);
                string password = creds.Length == 1 ? string.Empty : Uri.UnescapeDataString(creds[1]);
                saslHandler = new SaslPlainHandler(new TestPlainAuthenticator(userInfo, password));
            }
            else
            {
                saslHandler = new SaslAnonymousHandler();
            }

            SaslTransportProvider saslProvider = new SaslTransportProvider();
            saslProvider.AddHandler(saslHandler);
            saslProvider.Versions.Add(new AmqpVersion(1, 0, 0));
            settings.TransportProviders.Add(saslProvider);

            AmqpTransportProvider amqpProvider = new AmqpTransportProvider();
            amqpProvider.Versions.Add(new AmqpVersion(1, 0, 0));
            settings.TransportProviders.Add(amqpProvider);

            // create and initialize transport listeners
            TransportListener[] listeners = new TransportListener[endpoints.Count];
            for (int i = 0; i < endpoints.Count; i++)
            {
                Uri addressUri = new Uri(endpoints[i]);

                TcpTransportSettings tcpSettings = new TcpTransportSettings() { Host = addressUri.Host, Port = addressUri.Port };
                if (addressUri.Scheme.Equals(AmqpConstants.SchemeAmqps, StringComparison.OrdinalIgnoreCase))
                {
                    if (certificate == null)
                    {
                        throw new InvalidOperationException("/cert option was not set when amqps address is specified.");
                    }

                    TlsTransportSettings tlsSettings = new TlsTransportSettings(tcpSettings) { Certificate = certificate, IsInitiator = false };
                    listeners[i] = tlsSettings.CreateListener();
                }
                else
                {
                    listeners[i] = tcpSettings.CreateListener();
                }
            }

            this.transportListener = new AmqpTransportListener(listeners, settings);
            this.settings = settings;
        }
コード例 #8
0
        TlsTransportSettings CreateTlsTransportSettings()
        {
            var tcpTransportSettings = new TcpTransportSettings()
            {
                Host = this.hostName,
                Port = this.port
            };

            var tlsTransportSettings = new TlsTransportSettings(tcpTransportSettings)
            {
                TargetHost = this.hostName,
#if !WINDOWS_UWP // Not supported in UWP
                Certificate = null,
                CertificateValidationCallback = OnRemoteCertificateValidation
#endif
            };

#if !WINDOWS_UWP
            if (this.AmqpTransportSettings.ClientCertificate != null)
            {
                tlsTransportSettings.Certificate = this.AmqpTransportSettings.ClientCertificate;
            }
#endif

            return tlsTransportSettings;
        }
コード例 #9
0
 public TcpTransport(Windows.Networking.Sockets.StreamSocket socket, TcpTransportSettings transportSettings)
     : base("tcp")
 {
     this.socket = socket;
 }
コード例 #10
0
        TlsTransportSettings CreateTlsTransportSettings()
        {
            var tcpTransportSettings = new TcpTransportSettings()
            {
                Host = this.hostName,
                Port = this.port
            };

            var tlsTransportSettings = new TlsTransportSettings(tcpTransportSettings)
            {
                TargetHost = this.hostName,
#if !WINDOWS_UWP // Not supported in UWP
                Certificate = null, // TODO: add client cert support
                CertificateValidationCallback = OnRemoteCertificateValidation
#endif
            };

            return tlsTransportSettings;
        }
コード例 #11
0
 public TcpTransportListener(TcpTransportSettings transportSettings)
     : base("tcp-listener")
 {
     this.acceptTransportLoop = this.AcceptTransportLoop;
     this.transportSettings   = transportSettings;
 }
コード例 #12
0
 internal TcpTransportInitiator(TcpTransportSettings transportSettings)
 {
     this.transportSettings = transportSettings;
     this.ProtectionLevel   = SocketProtectionLevel.PlainSocket;
 }
コード例 #13
0
 public TcpTransport(StreamSocket socket, TcpTransportSettings settings)
     : base("tcp")
 {
     this.socket   = socket;
     this.settings = settings;
 }
コード例 #14
0
 public TcpTransportListener(TcpTransportSettings transportSettings)
     : base("tcp-listener")
 {
     this.acceptTransportLoop = this.AcceptTransportLoop;
     this.transportSettings = transportSettings;
 }