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 = (Ice.IPConnectionInfo)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; } } if (info is IceSSL.WSSConnectionInfo) { IceSSL.WSSConnectionInfo wssinfo = (IceSSL.WSSConnectionInfo)info; foreach (KeyValuePair <string, string> e in wssinfo.headers) { ctx["ws." + e.Key] = e.Value; } } return(ctx); }
public static void allTests(Test.TestHelper helper) { Ice.Communicator communicator = helper.communicator(); string sref = "test:" + helper.getTestEndpoint(0); var obj = IObjectPrx.Parse(sref, communicator); test(obj != null); int proxyPort = communicator.Properties.getPropertyAsInt("Ice.HTTPProxyPort"); if (proxyPort == 0) { proxyPort = communicator.Properties.getPropertyAsInt("Ice.SOCKSProxyPort"); } Test.TestIntfPrx testPrx = Test.TestIntfPrx.CheckedCast(obj); var output = helper.getWriter(); output.Write("testing connection... "); output.Flush(); { testPrx.IcePing(); } output.WriteLine("ok"); output.Write("testing connection information... "); output.Flush(); { Ice.IPConnectionInfo info = getIPConnectionInfo(testPrx.GetConnection().getInfo()); test(info.remotePort == proxyPort); // make sure we are connected to the proxy port. } output.WriteLine("ok"); output.Write("shutting down server... "); output.Flush(); { testPrx.shutdown(); } output.WriteLine("ok"); output.Write("testing connection failure... "); output.Flush(); { try { testPrx.IcePing(); test(false); } catch (Ice.LocalException) { } } output.WriteLine("ok"); }
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 = (Ice.IPConnectionInfo)info; ctx["localAddress"] = ipinfo.localAddress; ctx["localPort"] = ipinfo.localPort.ToString(); ctx["remoteAddress"] = ipinfo.remoteAddress; ctx["remotePort"] = ipinfo.remotePort.ToString(); return(ctx); }
public static void allTests(Ice.Communicator communicator) #endif { string sref = "test:default -p 12010"; Ice.ObjectPrx obj = communicator.stringToProxy(sref); test(obj != null); Test.TestIntfPrx testPrx = Test.TestIntfPrxHelper.checkedCast(obj); test(testPrx != null); Write("testing connection... "); Flush(); { testPrx.ice_ping(); } WriteLine("ok"); Write("testing connection information... "); Flush(); { Ice.IPConnectionInfo info = (Ice.IPConnectionInfo)testPrx.ice_getConnection().getInfo(); test(info.remotePort == 12030 || info.remotePort == 12031); // make sure we are connected to the proxy port. } WriteLine("ok"); Write("shutting down server... "); Flush(); { testPrx.shutdown(); } WriteLine("ok"); Write("testing connection failure... "); Flush(); { try { testPrx.ice_ping(); test(false); } catch (Ice.LocalException) { } } WriteLine("ok"); }
public string getId() { if (_id == null) { StringBuilder os = new StringBuilder(); Ice.IPConnectionInfo info = getIPConnectionInfo(); if (info != null) { os.Append(info.localAddress).Append(':').Append(info.localPort); os.Append(" -> "); os.Append(info.remoteAddress).Append(':').Append(info.remotePort); } else { os.Append("connection-").Append(_connectionInfo); } if (_connectionInfo.connectionId.Length > 0) { os.Append(" [").Append(_connectionInfo.connectionId).Append("]"); } _id = os.ToString(); } return(_id); }
public static void allTests(Ice.Communicator communicator) { Write("testing proxy endpoint information... "); Flush(); { Ice.ObjectPrx p1 = communicator.stringToProxy( "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"); Ice.Endpoint[] endps = p1.ice_getEndpoints(); Ice.IPEndpointInfo ipEndpoint = (Ice.IPEndpointInfo)endps[0].getInfo(); test(ipEndpoint.host.Equals("tcphost")); test(ipEndpoint.port == 10000); test(ipEndpoint.sourceAddress.Equals("10.10.10.10")); test(ipEndpoint.timeout == 1200); test(ipEndpoint.compress); test(!ipEndpoint.datagram()); test(ipEndpoint.type() == Ice.TCPEndpointType.value && !ipEndpoint.secure() || ipEndpoint.type() == IceSSL.EndpointType.value && ipEndpoint.secure() || ipEndpoint.type() == Ice.WSEndpointType.value && !ipEndpoint.secure() || ipEndpoint.type() == Ice.WSSEndpointType.value && ipEndpoint.secure()); test(ipEndpoint.type() == Ice.TCPEndpointType.value && ipEndpoint is Ice.TCPEndpointInfo || ipEndpoint.type() == IceSSL.EndpointType.value && ipEndpoint is IceSSL.EndpointInfo || ipEndpoint.type() == Ice.WSEndpointType.value && ipEndpoint is Ice.WSEndpointInfo || ipEndpoint.type() == Ice.WSSEndpointType.value && ipEndpoint is IceSSL.WSSEndpointInfo); 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))); } WriteLine("ok"); string defaultHost = communicator.getProperties().getProperty("Ice.Default.Host"); Ice.ObjectAdapter adapter; Write("test object adapter endpoint information... "); Flush(); { communicator.getProperties().setProperty("TestAdapter.Endpoints", "default -t 15000:udp"); 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.IPEndpointInfo ipEndpoint = (Ice.IPEndpointInfo)endpoints[0].getInfo(); test(ipEndpoint.type() == Ice.TCPEndpointType.value || ipEndpoint.type() == IceSSL.EndpointType.value || ipEndpoint.type() == Ice.WSEndpointType.value || ipEndpoint.type() == Ice.WSSEndpointType.value); test(ipEndpoint.host.Equals(defaultHost)); test(ipEndpoint.port > 0); test(ipEndpoint.timeout == 15000); Ice.UDPEndpointInfo udpEndpoint = (Ice.UDPEndpointInfo)endpoints[1].getInfo(); test(udpEndpoint.host.Equals(defaultHost)); test(udpEndpoint.datagram()); test(udpEndpoint.port > 0); adapter.destroy(); communicator.getProperties().setProperty("TestAdapter.Endpoints", "default -h * -p 12020"); communicator.getProperties().setProperty("TestAdapter.PublishedEndpoints", "default -h 127.0.0.1 -p 12020"); adapter = communicator.createObjectAdapter("TestAdapter"); endpoints = adapter.getEndpoints(); test(endpoints.Length >= 1); publishedEndpoints = adapter.getPublishedEndpoints(); test(publishedEndpoints.Length == 1); foreach (Ice.Endpoint endpoint in endpoints) { ipEndpoint = (Ice.IPEndpointInfo)endpoint.getInfo(); test(ipEndpoint.port == 12020); } ipEndpoint = (Ice.IPEndpointInfo)publishedEndpoints[0].getInfo(); test(ipEndpoint.host.Equals("127.0.0.1")); test(ipEndpoint.port == 12020); adapter.destroy(); } WriteLine("ok"); Ice.ObjectPrx @base = communicator.stringToProxy("test:default -p 12010:udp -p 12010"); TestIntfPrx testIntf = TestIntfPrxHelper.checkedCast(@base); Write("test connection endpoint information... "); Flush(); { Ice.EndpointInfo info = @base.ice_getConnection().getEndpoint().getInfo(); Ice.IPEndpointInfo ipinfo = (Ice.IPEndpointInfo)info; test(ipinfo.port == 12010); test(!ipinfo.compress); test(ipinfo.host.Equals(defaultHost)); Dictionary <string, string> ctx = testIntf.getEndpointInfoAsContext(); test(ctx["host"].Equals(ipinfo.host)); test(ctx["compress"].Equals("false")); int port = System.Int32.Parse(ctx["port"]); test(port > 0); info = @base.ice_datagram().ice_getConnection().getEndpoint().getInfo(); Ice.UDPEndpointInfo udp = (Ice.UDPEndpointInfo)info; test(udp.port == 12010); test(udp.host.Equals(defaultHost)); } WriteLine("ok"); Write("testing connection information... "); Flush(); { Ice.Connection connection = @base.ice_getConnection(); connection.setBufferSize(1024, 2048); Ice.IPConnectionInfo info = (Ice.IPConnectionInfo)connection.getInfo(); test(!info.incoming); test(info.adapterName.Length == 0); test(info.remotePort == 12010); test(info.localPort > 0); if (defaultHost.Equals("127.0.0.1")) { test(info.localAddress.Equals(defaultHost)); test(info.remoteAddress.Equals(defaultHost)); } test(info.rcvSize >= 1024); test(info.sndSize >= 2048); Dictionary <string, string> ctx = testIntf.getConnectionInfoAsContext(); test(ctx["incoming"].Equals("true")); test(ctx["adapterName"].Equals("TestAdapter")); test(ctx["remoteAddress"].Equals(info.localAddress)); test(ctx["localAddress"].Equals(info.remoteAddress)); test(ctx["remotePort"].Equals(info.localPort.ToString())); test(ctx["localPort"].Equals(info.remotePort.ToString())); if (@base.ice_getConnection().type().Equals("ws") || @base.ice_getConnection().type().Equals("wss")) { Dictionary <string, string> headers; if (info is Ice.WSConnectionInfo) { headers = ((Ice.WSConnectionInfo)info).headers; } else { headers = ((IceSSL.WSSConnectionInfo)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.ice_datagram().ice_getConnection(); connection.setBufferSize(2048, 1024); info = (Ice.IPConnectionInfo)connection.getInfo(); test(!info.incoming); test(info.adapterName.Length == 0); test(info.localPort > 0); test(info.remotePort == 12010); if (defaultHost.Equals("127.0.0.1")) { test(info.remoteAddress.Equals(defaultHost)); test(info.localAddress.Equals(defaultHost)); } test(info.rcvSize >= 2048); test(info.sndSize >= 1024); } WriteLine("ok"); testIntf.shutdown(); communicator.shutdown(); communicator.waitForShutdown(); }