Esempio n. 1
0
            override public Dictionary <string, string> getConnectionInfoAsContext(Ice.Current c)
            {
                Dictionary <string, string> ctx = new Dictionary <string, string>();

                Ice.ConnectionInfo info = c.con.getInfo();
                ctx["adapterName"] = info.adapterName;
                ctx["incoming"]    = info.incoming ? "true" : "false";

                Ice.IPConnectionInfo ipinfo = getIPConnectionInfo(info);
                ctx["localAddress"]  = ipinfo.localAddress;
                ctx["localPort"]     = ipinfo.localPort.ToString();
                ctx["remoteAddress"] = ipinfo.remoteAddress;
                ctx["remotePort"]    = ipinfo.remotePort.ToString();

                if (info is Ice.WSConnectionInfo)
                {
                    Ice.WSConnectionInfo wsinfo = (Ice.WSConnectionInfo)info;
                    foreach (KeyValuePair <string, string> e in wsinfo.headers)
                    {
                        ctx["ws." + e.Key] = e.Value;
                    }
                }

                return(ctx);
            }
Esempio n. 2
0
        protected internal void warning__(System.Exception ex)
        {
            Debug.Assert(instance_ != null);

            using (StringWriter sw = new StringWriter(CultureInfo.CurrentCulture))
            {
                IceUtilInternal.OutputBase output = new IceUtilInternal.OutputBase(sw);
                output.setUseTab(false);
                output.print("dispatch exception:");
                output.print("\nidentity: " + instance_.identityToString(current_.id));
                output.print("\nfacet: " + IceUtilInternal.StringUtil.escapeString(current_.facet, ""));
                output.print("\noperation: " + current_.operation);
                if (connection_ != null)
                {
                    Ice.ConnectionInfo connInfo = connection_.getInfo();
                    if (connInfo is Ice.IPConnectionInfo)
                    {
                        Ice.IPConnectionInfo ipConnInfo = (Ice.IPConnectionInfo)connInfo;
                        output.print("\nremote host: " + ipConnInfo.remoteAddress + " remote port: " +
                                     ipConnInfo.remotePort.ToString());
                    }
                }
                output.print("\n");
                output.print(ex.ToString());
                instance_.initializationData().logger.warning(sw.ToString());
            }
        }
Esempio n. 3
0
 getConnectionObserver(Ice.ConnectionInfo ci,
                       Ice.Endpoint ei,
                       Ice.Instrumentation.ConnectionState s,
                       Ice.Instrumentation.ConnectionObserver o)
 {
     return(null);
 }
Esempio n. 4
0
 public ConnectionHelper(Ice.ConnectionInfo con, Ice.Endpoint endpt, Ice.Instrumentation.ConnectionState state)
     : base(_attributes)
 {
     _connectionInfo = con;
     _endpoint       = endpt;
     _state          = state;
 }
Esempio n. 5
0
        private void warning(Exception ex)
        {
            Debug.Assert(_instance != null);

            using (StringWriter sw = new StringWriter(CultureInfo.CurrentCulture))
            {
                IceUtilInternal.OutputBase output       = new IceUtilInternal.OutputBase(sw);
                Ice.ToStringMode           toStringMode = _instance.toStringMode();
                output.setUseTab(false);
                output.print("dispatch exception:");
                output.print("\nidentity: " + Ice.Util.identityToString(_current.id, toStringMode));
                output.print("\nfacet: " + IceUtilInternal.StringUtil.escapeString(_current.facet, "", toStringMode));
                output.print("\noperation: " + _current.operation);
                if (_current.con != null)
                {
                    try
                    {
                        for (Ice.ConnectionInfo p = _current.con.getInfo(); p != null; p = p.underlying)
                        {
                            Ice.IPConnectionInfo ipinfo = p as Ice.IPConnectionInfo;
                            output.print("\nremote host: " + ipinfo.remoteAddress + " remote port: " + ipinfo.remotePort);
                        }
                    }
                    catch (Ice.LocalException)
                    {
                    }
                }
                output.print("\n");
                output.print(ex.ToString());
                _instance.initializationData().logger.warning(sw.ToString());
            }
        }
Esempio n. 6
0
 public RemoteInvocationHelper(Ice.ConnectionInfo con, Ice.Endpoint endpt, int requestId, int size) :
     base(_attributes)
 {
     _connectionInfo = con;
     _endpoint       = endpt;
     _requestId      = requestId;
     _size           = size;
 }
Esempio n. 7
0
 private static Ice.IPConnectionInfo getIPConnectionInfo(Ice.ConnectionInfo info)
 {
     for (; info != null; info = info.underlying)
     {
         if (info is Ice.IPConnectionInfo)
         {
             return(info as Ice.IPConnectionInfo);
         }
     }
     return(null);
 }
Esempio n. 8
0
 public void attachRemoteObserver(Ice.ConnectionInfo info, Ice.Endpoint endpt, int size)
 {
     if (_observer != null)
     {
         _remoteObserver = _observer.getRemoteObserver(info, endpt, 0, size);
         if (_remoteObserver != null)
         {
             _remoteObserver.attach();
         }
     }
 }
Esempio n. 9
0
 public void attachRemoteObserver(Ice.ConnectionInfo info, Ice.Endpoint endpt, int requestId, int sz)
 {
     if (_observer != null)
     {
         _remoteObserver = _observer.getRemoteObserver(info, endpt, requestId, sz);
         if (_remoteObserver != null)
         {
             _remoteObserver.attach();
         }
     }
 }
Esempio n. 10
0
 getIPConnectionInfo()
 {
     for (Ice.ConnectionInfo p = _connectionInfo; p != null; p = p.underlying)
     {
         if (p is Ice.IPConnectionInfo)
         {
             return((Ice.IPConnectionInfo)p);
         }
     }
     return(null);
 }
Esempio n. 11
0
 public void attachRemoteObserver(Ice.ConnectionInfo info, Ice.Endpoint endpt, int requestId)
 {
     if (observer_ != null)
     {
         int size = os_.size() - Protocol.headerSize - 4;
         childObserver_ = getObserver().getRemoteObserver(info, endpt, requestId, size);
         if (childObserver_ != null)
         {
             childObserver_.attach();
         }
     }
 }
Esempio n. 12
0
 public ConnectionInfo(Ice.ConnectionInfo underlying,
                       bool incoming,
                       string adapterName,
                       string connectionId,
                       string cipher,
                       X509Certificate2[] certs,
                       bool verified) : base(underlying, incoming, adapterName, connectionId)
 {
     this.cipher   = cipher;
     this.certs    = certs;
     this.verified = verified;
 }
Esempio n. 13
0
 public Ice.Instrumentation.RemoteObserver getRemoteObserver(Ice.ConnectionInfo con, Ice.Endpoint endpt,
                                                             int requestId, int size)
 {
     Ice.Instrumentation.RemoteObserver del = null;
     if (delegate_ != null)
     {
         del = delegate_.getRemoteObserver(con, endpt, requestId, size);
     }
     return(getObserver <RemoteMetrics, RemoteObserverI,
                         Ice.Instrumentation.RemoteObserver>("Remote",
                                                             new RemoteInvocationHelper(con, endpt, requestId, size),
                                                             del));
 }
Esempio n. 14
0
 public void AttachRemoteObserver(Ice.ConnectionInfo info, Ice.IEndpoint endpt, int requestId)
 {
     Ice.Instrumentation.IInvocationObserver?observer = GetObserver();
     if (observer != null)
     {
         int size = Os !.Size - Protocol.headerSize - 4;
         ChildObserver = observer.GetRemoteObserver(info, endpt, requestId, size);
         if (ChildObserver != null)
         {
             ChildObserver.Attach();
         }
     }
 }
Esempio n. 15
0
 public Ice.Instrumentation.ConnectionObserver getConnectionObserver(Ice.ConnectionInfo c,
                                                                     Ice.Endpoint e,
                                                                     Ice.Instrumentation.ConnectionState s,
                                                                     Ice.Instrumentation.ConnectionObserver obsv)
 {
     if (_connections.isEnabled())
     {
         try
         {
             Ice.Instrumentation.ConnectionObserver del = null;
             ConnectionObserverI o = obsv is ConnectionObserverI ? (ConnectionObserverI)obsv : null;
             if (_delegate != null)
             {
                 del = _delegate.getConnectionObserver(c, e, s, o != null ? o.getDelegate() : obsv);
             }
             return(_connections.getObserver(new ConnectionHelper(c, e, s), obsv, del));
         }
         catch (Exception ex)
         {
             _metrics.getLogger().error("unexpected exception trying to obtain observer:\n" + ex);
         }
     }
     return(null);
 }
Esempio n. 16
0
 public void setBufferSize(int rcvSize, int sndSize)
 {
     lock(this)
     {
         if(_state >= StateClosed)
         {
             throw _exception;
         }
         _transceiver.setBufferSize(rcvSize, sndSize);
         _info = null; // Invalidate the cached connection info
     }
 }
Esempio n. 17
0
        private ConnectionInfo initConnectionInfo()
        {
            if(_state > StateNotInitialized && _info != null) // Update the connection info until it's initialized
            {
                return _info;
            }

            try
            {
                _info = _transceiver.getInfo();
            }
            catch(Ice.LocalException)
            {
                _info = new ConnectionInfo();
            }
            for(ConnectionInfo info = _info; info != null; info = info.underlying)
            {
                info.connectionId = _endpoint.connectionId();
                info.adapterName = _adapter != null ? _adapter.getName() : "";
                info.incoming = _connector == null;
            }
            return _info;
        }
Esempio n. 18
0
 getRemoteObserver(Ice.ConnectionInfo ci, Ice.Endpoint ei, int i, int j)
 {
     return(null);
 }
Esempio n. 19
0
            public static void allTests(global::Test.TestHelper helper)
            {
                Ice.Communicator communicator = helper.communicator();
                var output = helper.getWriter();

                output.Write("testing proxy endpoint information... ");
                output.Flush();
                {
                    var p1 = IObjectPrx.Parse(
                        "test -t:default -h tcphost -p 10000 -t 1200 -z --sourceAddress 10.10.10.10:" +
                        "udp -h udphost -p 10001 --interface eth0 --ttl 5 --sourceAddress 10.10.10.10:" +
                        "opaque -e 1.8 -t 100 -v ABCD", communicator);

                    Ice.Endpoint[] endps = p1.Endpoints;

                    Ice.EndpointInfo    info        = endps[0].getInfo();
                    Ice.TCPEndpointInfo tcpEndpoint = getTCPEndpointInfo(info);
                    test(tcpEndpoint.host.Equals("tcphost"));
                    test(tcpEndpoint.port == 10000);
                    test(tcpEndpoint.sourceAddress.Equals("10.10.10.10"));
                    test(tcpEndpoint.timeout == 1200);
                    test(tcpEndpoint.compress);
                    test(!tcpEndpoint.datagram());

                    test(tcpEndpoint.type() == Ice.TCPEndpointType.value && !tcpEndpoint.secure() ||
                         tcpEndpoint.type() == Ice.SSLEndpointType.value && tcpEndpoint.secure() ||
                         tcpEndpoint.type() == Ice.WSEndpointType.value && !tcpEndpoint.secure() ||
                         tcpEndpoint.type() == Ice.WSSEndpointType.value && tcpEndpoint.secure());
                    test(tcpEndpoint.type() == Ice.TCPEndpointType.value && info is Ice.TCPEndpointInfo ||
                         tcpEndpoint.type() == Ice.SSLEndpointType.value && info is IceSSL.EndpointInfo ||
                         tcpEndpoint.type() == Ice.WSEndpointType.value && info is Ice.WSEndpointInfo ||
                         tcpEndpoint.type() == Ice.WSSEndpointType.value && info is Ice.WSEndpointInfo);

                    Ice.UDPEndpointInfo udpEndpoint = (Ice.UDPEndpointInfo)endps[1].getInfo();
                    test(udpEndpoint.host.Equals("udphost"));
                    test(udpEndpoint.port == 10001);
                    test(udpEndpoint.mcastInterface.Equals("eth0"));
                    test(udpEndpoint.mcastTtl == 5);
                    test(udpEndpoint.sourceAddress.Equals("10.10.10.10"));
                    test(udpEndpoint.timeout == -1);
                    test(!udpEndpoint.compress);
                    test(!udpEndpoint.secure());
                    test(udpEndpoint.datagram());
                    test(udpEndpoint.type() == 3);

                    Ice.OpaqueEndpointInfo opaqueEndpoint = (Ice.OpaqueEndpointInfo)endps[2].getInfo();
                    test(opaqueEndpoint.rawBytes.Length > 0);
                    test(opaqueEndpoint.rawEncoding.Equals(new Ice.EncodingVersion(1, 8)));
                }
                output.WriteLine("ok");

                Ice.ObjectAdapter adapter;
                output.Write("test object adapter endpoint information... ");
                output.Flush();
                {
                    string host = communicator.getProperties().getPropertyAsInt("Ice.IPv6") != 0 ? "::1" : "127.0.0.1";
                    communicator.getProperties().setProperty("TestAdapter.Endpoints", "tcp -h \"" + host +
                                                             "\" -t 15000:udp -h \"" + host + "\"");
                    adapter = communicator.createObjectAdapter("TestAdapter");

                    Ice.Endpoint[] endpoints = adapter.GetEndpoints();
                    test(endpoints.Length == 2);
                    Ice.Endpoint[] publishedEndpoints = adapter.GetPublishedEndpoints();
                    test(IceUtilInternal.Arrays.Equals(endpoints, publishedEndpoints));

                    Ice.TCPEndpointInfo tcpEndpoint = getTCPEndpointInfo(endpoints[0].getInfo());
                    test(tcpEndpoint.type() == Ice.TCPEndpointType.value ||
                         tcpEndpoint.type() == Ice.SSLEndpointType.value ||
                         tcpEndpoint.type() == Ice.WSEndpointType.value ||
                         tcpEndpoint.type() == Ice.WSSEndpointType.value);

                    test(tcpEndpoint.host.Equals(host));
                    test(tcpEndpoint.port > 0);
                    test(tcpEndpoint.timeout == 15000);

                    Ice.UDPEndpointInfo udpEndpoint = (Ice.UDPEndpointInfo)endpoints[1].getInfo();
                    test(udpEndpoint.host.Equals(host));
                    test(udpEndpoint.datagram());
                    test(udpEndpoint.port > 0);

                    endpoints = new Ice.Endpoint[] { endpoints[0] };
                    test(endpoints.Length == 1);
                    adapter.SetPublishedEndpoints(endpoints);
                    publishedEndpoints = adapter.GetPublishedEndpoints();
                    test(IceUtilInternal.Arrays.Equals(endpoints, publishedEndpoints));

                    adapter.Destroy();

                    int port = helper.getTestPort(1);
                    communicator.getProperties().setProperty("TestAdapter.Endpoints", "default -h * -p " + port);
                    communicator.getProperties().setProperty("TestAdapter.PublishedEndpoints", helper.getTestEndpoint(1));
                    adapter = communicator.createObjectAdapter("TestAdapter");

                    endpoints = adapter.GetEndpoints();
                    test(endpoints.Length >= 1);
                    publishedEndpoints = adapter.GetPublishedEndpoints();
                    test(publishedEndpoints.Length == 1);

                    foreach (Ice.Endpoint endpoint in endpoints)
                    {
                        tcpEndpoint = getTCPEndpointInfo(endpoint.getInfo());
                        test(tcpEndpoint.port == port);
                    }

                    tcpEndpoint = getTCPEndpointInfo(publishedEndpoints[0].getInfo());
                    test(tcpEndpoint.host.Equals("127.0.0.1"));
                    test(tcpEndpoint.port == port);

                    adapter.Destroy();
                }
                output.WriteLine("ok");

                int endpointPort = helper.getTestPort(0);

                var @base = IObjectPrx.Parse("test:" +
                                             helper.getTestEndpoint(0) + ":" +
                                             helper.getTestEndpoint(0, "udp"), communicator);
                var testIntf = Test.TestIntfPrx.CheckedCast(@base);

                string defaultHost = communicator.getProperties().getProperty("Ice.Default.Host");

                output.Write("test connection endpoint information... ");
                output.Flush();
                {
                    Ice.EndpointInfo    info    = @base.GetConnection().getEndpoint().getInfo();
                    Ice.TCPEndpointInfo tcpinfo = getTCPEndpointInfo(info);
                    test(tcpinfo.port == endpointPort);
                    test(!tcpinfo.compress);
                    test(tcpinfo.host.Equals(defaultHost));

                    Dictionary <string, string> ctx = testIntf.getEndpointInfoAsContext();
                    test(ctx["host"].Equals(tcpinfo.host));
                    test(ctx["compress"].Equals("false"));
                    int port = int.Parse(ctx["port"]);
                    test(port > 0);

                    info = @base.Clone(invocationMode: InvocationMode.Datagram).GetConnection().getEndpoint().getInfo();
                    Ice.UDPEndpointInfo udp = (Ice.UDPEndpointInfo)info;
                    test(udp.port == endpointPort);
                    test(udp.host.Equals(defaultHost));
                }
                output.WriteLine("ok");

                output.Write("testing connection information... ");
                output.Flush();
                {
                    Ice.Connection connection = @base.GetConnection();
                    connection.setBufferSize(1024, 2048);

                    Ice.ConnectionInfo    info   = connection.getInfo();
                    Ice.TCPConnectionInfo ipInfo = getTCPConnectionInfo(info);
                    test(!info.incoming);
                    test(info.adapterName.Length == 0);
                    test(ipInfo.remotePort == endpointPort);
                    test(ipInfo.localPort > 0);
                    if (defaultHost.Equals("127.0.0.1"))
                    {
                        test(ipInfo.localAddress.Equals(defaultHost));
                        test(ipInfo.remoteAddress.Equals(defaultHost));
                    }
                    test(ipInfo.rcvSize >= 1024);
                    test(ipInfo.sndSize >= 2048);

                    Dictionary <string, string> ctx = testIntf.getConnectionInfoAsContext();
                    test(ctx["incoming"].Equals("true"));
                    test(ctx["adapterName"].Equals("TestAdapter"));
                    test(ctx["remoteAddress"].Equals(ipInfo.localAddress));
                    test(ctx["localAddress"].Equals(ipInfo.remoteAddress));
                    test(ctx["remotePort"].Equals(ipInfo.localPort.ToString()));
                    test(ctx["localPort"].Equals(ipInfo.remotePort.ToString()));

                    if (@base.GetConnection().type().Equals("ws") || @base.GetConnection().type().Equals("wss"))
                    {
                        Dictionary <string, string> headers = ((Ice.WSConnectionInfo)info).headers;
                        test(headers["Upgrade"].Equals("websocket"));
                        test(headers["Connection"].Equals("Upgrade"));
                        test(headers["Sec-WebSocket-Protocol"].Equals("ice.zeroc.com"));
                        test(headers["Sec-WebSocket-Accept"] != null);

                        test(ctx["ws.Upgrade"].Equals("websocket"));
                        test(ctx["ws.Connection"].Equals("Upgrade"));
                        test(ctx["ws.Sec-WebSocket-Protocol"].Equals("ice.zeroc.com"));
                        test(ctx["ws.Sec-WebSocket-Version"].Equals("13"));
                        test(ctx["ws.Sec-WebSocket-Key"] != null);
                    }

                    connection = @base.Clone(invocationMode: InvocationMode.Datagram).GetConnection();
                    connection.setBufferSize(2048, 1024);

                    Ice.UDPConnectionInfo udpInfo = (Ice.UDPConnectionInfo)connection.getInfo();
                    test(!udpInfo.incoming);
                    test(udpInfo.adapterName.Length == 0);
                    test(udpInfo.localPort > 0);
                    test(udpInfo.remotePort == endpointPort);

                    if (defaultHost.Equals("127.0.0.1"))
                    {
                        test(udpInfo.remoteAddress.Equals(defaultHost));
                        test(udpInfo.localAddress.Equals(defaultHost));
                    }
                    test(udpInfo.rcvSize >= 2048);
                    test(udpInfo.sndSize >= 1024);
                }
                output.WriteLine("ok");

                testIntf.shutdown();

                communicator.shutdown();
                communicator.waitForShutdown();
            }