diff options
author | Benoit Foucher <benoit@zeroc.com> | 2016-06-27 17:54:30 +0200 |
---|---|---|
committer | Benoit Foucher <benoit@zeroc.com> | 2016-06-27 17:54:30 +0200 |
commit | c56f8ab6ca6ca0bdb9536fcce1ef24f1ef40ddc7 (patch) | |
tree | 5cb64dfe155e5d2349efb6c7dc4b0f5b5284d44a /csharp/src | |
parent | Fix Windows php build to restore nuget packages (diff) | |
download | ice-c56f8ab6ca6ca0bdb9536fcce1ef24f1ef40ddc7.tar.bz2 ice-c56f8ab6ca6ca0bdb9536fcce1ef24f1ef40ddc7.tar.xz ice-c56f8ab6ca6ca0bdb9536fcce1ef24f1ef40ddc7.zip |
Refactored SSL and iAP transports, support for running SSL on top
of TCP/iAP/Bluetooth.
Diffstat (limited to 'csharp/src')
24 files changed, 476 insertions, 788 deletions
diff --git a/csharp/src/Ice/ConnectionI.cs b/csharp/src/Ice/ConnectionI.cs index 93f6efb87cb..ba5668eac74 100644 --- a/csharp/src/Ice/ConnectionI.cs +++ b/csharp/src/Ice/ConnectionI.cs @@ -2702,9 +2702,12 @@ namespace Ice { _info = new ConnectionInfo(); } - _info.connectionId = _endpoint.connectionId(); - _info.adapterName = _adapter != null ? _adapter.getName() : ""; - _info.incoming = _connector == null; + 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; } diff --git a/csharp/src/Ice/EndpointFactory.cs b/csharp/src/Ice/EndpointFactory.cs index c3bae69ecbe..613a9e66b9c 100644 --- a/csharp/src/Ice/EndpointFactory.cs +++ b/csharp/src/Ice/EndpointFactory.cs @@ -19,7 +19,7 @@ namespace IceInternal EndpointI read(Ice.InputStream s); void destroy(); - EndpointFactory clone(ProtocolInstance instance); + EndpointFactory clone(ProtocolInstance instance, EndpointFactory del); } } diff --git a/csharp/src/Ice/EndpointI.cs b/csharp/src/Ice/EndpointI.cs index 926e547ddff..ca009e6fba7 100644 --- a/csharp/src/Ice/EndpointI.cs +++ b/csharp/src/Ice/EndpointI.cs @@ -60,7 +60,13 @@ namespace IceInternal // // Marshal the endpoint. // - public abstract void streamWrite(Ice.OutputStream s); + virtual public void streamWrite(Ice.OutputStream s) + { + s.startEncapsulation(); + streamWriteImpl(s); + s.endEncapsulation(); + } + public abstract void streamWriteImpl(Ice.OutputStream s); // // Return the endpoint type. diff --git a/csharp/src/Ice/IPEndpointI.cs b/csharp/src/Ice/IPEndpointI.cs index 3a0263407bd..874bdc5f069 100644 --- a/csharp/src/Ice/IPEndpointI.cs +++ b/csharp/src/Ice/IPEndpointI.cs @@ -80,13 +80,6 @@ namespace IceInternal return info; } - public override void streamWrite(Ice.OutputStream s) - { - s.startEncapsulation(); - streamWriteImpl(s); - s.endEncapsulation(); - } - public override short type() { return instance_.type(); @@ -249,17 +242,7 @@ namespace IceInternal return string.Compare(connectionId_, p.connectionId_, StringComparison.Ordinal); } - public string host() - { - return host_; - } - - public int port() - { - return port_; - } - - public virtual void streamWriteImpl(Ice.OutputStream s) + public override void streamWriteImpl(Ice.OutputStream s) { s.writeString(host_); s.writeInt(port_); diff --git a/csharp/src/Ice/Incoming.cs b/csharp/src/Ice/Incoming.cs index 1f4c24c7fb7..47d892986af 100644 --- a/csharp/src/Ice/Incoming.cs +++ b/csharp/src/Ice/Incoming.cs @@ -227,12 +227,10 @@ namespace IceInternal output.print("\noperation: " + current_.operation); if(current_.con != null) { - Ice.ConnectionInfo connInfo = current_.con.getInfo(); - if(connInfo is Ice.IPConnectionInfo) + for(Ice.ConnectionInfo p = current_.con.getInfo(); p != null; p = p.underlying) { - Ice.IPConnectionInfo ipConnInfo = (Ice.IPConnectionInfo)connInfo; - output.print("\nremote host: " + ipConnInfo.remoteAddress + " remote port: " + - ipConnInfo.remotePort.ToString()); + Ice.IPConnectionInfo ipinfo = p as Ice.IPConnectionInfo; + output.print("\nremote host: " + ipinfo.remoteAddress + " remote port: " + ipinfo.remotePort); } } output.print("\n"); diff --git a/csharp/src/Ice/Instance.cs b/csharp/src/Ice/Instance.cs index 4aef3c883d5..09d3a9a83b1 100644 --- a/csharp/src/Ice/Instance.cs +++ b/csharp/src/Ice/Instance.cs @@ -952,13 +952,13 @@ namespace IceInternal if(tcpFactory != null) { ProtocolInstance instance = new ProtocolInstance(this, Ice.WSEndpointType.value, "ws", false); - _endpointFactoryManager.add(new WSEndpointFactory(instance, tcpFactory.clone(instance))); + _endpointFactoryManager.add(new WSEndpointFactory(instance, tcpFactory.clone(instance, null))); } EndpointFactory sslFactory = _endpointFactoryManager.get(Ice.SSLEndpointType.value); if(sslFactory != null) { ProtocolInstance instance = new ProtocolInstance(this, Ice.WSSEndpointType.value, "wss", true); - _endpointFactoryManager.add(new WSEndpointFactory(instance, sslFactory.clone(instance))); + _endpointFactoryManager.add(new WSEndpointFactory(instance, sslFactory.clone(instance, null))); } // diff --git a/csharp/src/Ice/InstrumentationI.cs b/csharp/src/Ice/InstrumentationI.cs index 74cfc36382f..3eca65b7ed6 100644 --- a/csharp/src/Ice/InstrumentationI.cs +++ b/csharp/src/Ice/InstrumentationI.cs @@ -17,7 +17,7 @@ namespace IceInternal using IceMX; public class ObserverWithDelegate<T, O> : Observer<T> - where T : Metrics, new() + where T : Metrics, new() where O : Ice.Instrumentation.Observer { override public void @@ -40,7 +40,7 @@ namespace IceInternal } } - override public void + override public void failed(string exceptionName) { base.failed(exceptionName); @@ -80,7 +80,7 @@ namespace IceInternal } public class ObserverFactoryWithDelegate<T, OImpl, O> : ObserverFactory<T, OImpl> - where T : Metrics, new() + where T : Metrics, new() where OImpl : ObserverWithDelegate<T, O>, O, new() where O : Ice.Instrumentation.Observer { @@ -124,7 +124,7 @@ namespace IceInternal r.add("endpointIsSecure", cl.GetMethod("getEndpointInfo"), cli.GetMethod("secure")); r.add("endpointTimeout", cl.GetMethod("getEndpointInfo"), cli.GetField("timeout")); r.add("endpointCompress", cl.GetMethod("getEndpointInfo"), cli.GetField("compress")); - + cli = typeof(Ice.IPEndpointInfo); r.add("endpointHost", cl.GetMethod("getEndpointInfo"), cli.GetField("host")); r.add("endpointPort", cl.GetMethod("getEndpointInfo"), cli.GetField("port")); @@ -137,17 +137,17 @@ namespace IceInternal r.add("incoming", cl.GetMethod("getConnectionInfo"), cli.GetField("incoming")); r.add("adapterName", cl.GetMethod("getConnectionInfo"), cli.GetField("adapterName")); r.add("connectionId", cl.GetMethod("getConnectionInfo"), cli.GetField("connectionId")); - + cli = typeof(Ice.IPConnectionInfo); r.add("localHost", cl.GetMethod("getConnectionInfo"), cli.GetField("localAddress")); r.add("localPort", cl.GetMethod("getConnectionInfo"), cli.GetField("localPort")); r.add("remoteHost", cl.GetMethod("getConnectionInfo"), cli.GetField("remoteAddress")); r.add("remotePort", cl.GetMethod("getConnectionInfo"), cli.GetField("remotePort")); - + cli = typeof(Ice.UDPConnectionInfo); r.add("mcastHost", cl.GetMethod("getConnectionInfo"), cli.GetField("mcastAddress")); r.add("mcastPort", cl.GetMethod("getConnectionInfo"), cli.GetField("mcastPort")); - + AttrsUtil.addEndpointAttributes<T>(r, cl); } } @@ -173,8 +173,8 @@ namespace IceInternal } } static AttributeResolver _attributes = new AttributeResolverI(); - - public ConnectionHelper(Ice.ConnectionInfo con, Ice.Endpoint endpt, Ice.Instrumentation.ConnectionState state) + + public ConnectionHelper(Ice.ConnectionInfo con, Ice.Endpoint endpt, Ice.Instrumentation.ConnectionState state) : base(_attributes) { _connectionInfo = con; @@ -187,9 +187,9 @@ namespace IceInternal if(_id == null) { StringBuilder os = new StringBuilder(); - if(_connectionInfo is Ice.IPConnectionInfo) + Ice.IPConnectionInfo info = getIPConnectionInfo(); + if(info != null) { - Ice.IPConnectionInfo info = (Ice.IPConnectionInfo)_connectionInfo; os.Append(info.localAddress).Append(':').Append(info.localPort); os.Append(" -> "); os.Append(info.remoteAddress).Append(':').Append(info.remotePort); @@ -226,7 +226,7 @@ namespace IceInternal return ""; } } - + public string getParent() { if(_connectionInfo.adapterName != null && _connectionInfo.adapterName.Length > 0) @@ -238,7 +238,7 @@ namespace IceInternal return "Communicator"; } } - + public Ice.ConnectionInfo getConnectionInfo() { return _connectionInfo; @@ -258,6 +258,19 @@ namespace IceInternal return _endpointInfo; } + private Ice.IPConnectionInfo + getIPConnectionInfo() + { + for(Ice.ConnectionInfo p = _connectionInfo; p != null; p = p.underlying) + { + if(p is Ice.IPConnectionInfo) + { + return (Ice.IPConnectionInfo)p; + } + } + return null; + } + readonly private Ice.ConnectionInfo _connectionInfo; readonly private Ice.Endpoint _endpoint; readonly private Ice.Instrumentation.ConnectionState _state; @@ -276,9 +289,9 @@ namespace IceInternal Type cl = typeof(DispatchHelper); add("parent", cl.GetMethod("getParent")); add("id", cl.GetMethod("getId")); - + AttrsUtil.addConnectionAttributes<DispatchMetrics>(this, cl); - + Type clc = typeof(Ice.Current); add("operation", cl.GetMethod("getCurrent"), clc.GetField("operation")); add("identity", cl.GetMethod("getIdentity")); @@ -293,7 +306,7 @@ namespace IceInternal } } static AttributeResolver _attributes = new AttributeResolverI(); - + public DispatchHelper(Ice.Current current, int size) : base(_attributes) { _current = current; @@ -317,7 +330,7 @@ namespace IceInternal { v.size += _size; } - + public string getMode() { return _current.requestId == 0 ? "oneway" : "twoway"; @@ -342,7 +355,7 @@ namespace IceInternal { return _current.adapter.getName(); } - + public Ice.ConnectionInfo getConnectionInfo() { if(_current.con != null) @@ -351,7 +364,7 @@ namespace IceInternal } return null; } - + public Ice.Endpoint getEndpoint() { if(_current.con != null) @@ -365,7 +378,7 @@ namespace IceInternal { return _current.con; } - + public Ice.EndpointInfo getEndpointInfo() { if(_current.con != null && _endpointInfo == null) @@ -379,12 +392,12 @@ namespace IceInternal { return _current; } - + public string getIdentity() { return _current.adapter.getCommunicator().identityToString(_current.id); } - + readonly private Ice.Current _current; readonly private int _size; private string _id; @@ -394,7 +407,7 @@ namespace IceInternal class InvocationHelper : MetricsHelper<InvocationMetrics> { class AttributeResolverI : MetricsHelper<InvocationMetrics>.AttributeResolver - { + { public AttributeResolverI() { try @@ -402,10 +415,10 @@ namespace IceInternal Type cl = typeof(InvocationHelper); add("parent", cl.GetMethod("getParent")); add("id", cl.GetMethod("getId")); - + add("operation", cl.GetMethod("getOperation")); add("identity", cl.GetMethod("getIdentity")); - + Type cli = typeof(Ice.ObjectPrx); add("facet", cl.GetMethod("getProxy"), cli.GetMethod("ice_getFacet")); add("encoding", cl.GetMethod("getEncodingVersion")); @@ -419,7 +432,7 @@ namespace IceInternal } } static AttributeResolver _attributes = new AttributeResolverI(); - + public InvocationHelper(Ice.ObjectPrx proxy, string op, Dictionary<string, string> ctx) : base(_attributes) { _proxy = proxy; @@ -439,34 +452,34 @@ namespace IceInternal } throw new ArgumentOutOfRangeException(attribute); } - + public string getMode() { if(_proxy == null) { throw new ArgumentOutOfRangeException("mode"); } - + if(_proxy.ice_isTwoway()) { return "twoway"; - } + } else if(_proxy.ice_isOneway()) { return "oneway"; - } + } else if(_proxy.ice_isBatchOneway()) { return "batch-oneway"; - } + } else if(_proxy.ice_isDatagram()) { return "datagram"; - } + } else if(_proxy.ice_isBatchDatagram()) { return "batch-datagram"; - } + } else { throw new ArgumentOutOfRangeException("mode"); @@ -499,12 +512,12 @@ namespace IceInternal } return _id; } - + public string getParent() { return "Communicator"; } - + public Ice.ObjectPrx getProxy() { return _proxy; @@ -514,7 +527,7 @@ namespace IceInternal { return Ice.Util.encodingVersionToString(_proxy.ice_getEncodingVersion()); } - + public string getIdentity() { if(_proxy != null) @@ -526,12 +539,12 @@ namespace IceInternal return ""; } } - + public string getOperation() { return _operation; } - + readonly private Ice.ObjectPrx _proxy; readonly private string _operation; readonly private Dictionary<string, string> _context; @@ -539,11 +552,11 @@ namespace IceInternal readonly static private Ice.Endpoint[] emptyEndpoints = new Ice.Endpoint[0]; } - + class ThreadHelper : MetricsHelper<ThreadMetrics> { class AttributeResolverI : MetricsHelper<ThreadMetrics>.AttributeResolver - { + { public AttributeResolverI() { try @@ -584,7 +597,7 @@ namespace IceInternal break; } } - + readonly public string _parent; readonly public string _id; readonly private Ice.Instrumentation.ThreadState _state; @@ -593,7 +606,7 @@ namespace IceInternal class EndpointHelper : MetricsHelper<Metrics> { class AttributeResolverI : MetricsHelper<Metrics>.AttributeResolver - { + { public AttributeResolverI() { try @@ -621,7 +634,7 @@ namespace IceInternal { _endpoint = endpt; } - + public Ice.EndpointInfo getEndpointInfo() { if(_endpointInfo == null) @@ -635,7 +648,7 @@ namespace IceInternal { return "Communicator"; } - + public string getId() { if(_id == null) @@ -644,21 +657,21 @@ namespace IceInternal } return _id; } - + public string getEndpoint() { return _endpoint.ToString(); } - + readonly private Ice.Endpoint _endpoint; private string _id; private Ice.EndpointInfo _endpointInfo; } - + public class RemoteInvocationHelper : MetricsHelper<RemoteMetrics> { class AttributeResolverI : MetricsHelper<RemoteMetrics>.AttributeResolver - { + { public AttributeResolverI() { try @@ -708,7 +721,7 @@ namespace IceInternal { return _requestId; } - + public string getParent() { if(_connectionInfo.adapterName != null && _connectionInfo.adapterName.Length > 0) @@ -720,12 +733,12 @@ namespace IceInternal return "Communicator"; } } - + public Ice.ConnectionInfo getConnectionInfo() { return _connectionInfo; } - + public Ice.Endpoint getEndpoint() { return _endpoint; @@ -751,7 +764,7 @@ namespace IceInternal public class CollocatedInvocationHelper : MetricsHelper<CollocatedMetrics> { class AttributeResolverI : MetricsHelper<CollocatedMetrics>.AttributeResolver - { + { public AttributeResolverI() { try @@ -791,12 +804,12 @@ namespace IceInternal { return _requestId; } - + public string getParent() { return "Communicator"; } - + readonly private int _size; readonly private int _requestId; readonly private string _id; @@ -925,8 +938,8 @@ namespace IceInternal delegate_.retried(); } } - - public Ice.Instrumentation.RemoteObserver getRemoteObserver(Ice.ConnectionInfo con, Ice.Endpoint endpt, + + public Ice.Instrumentation.RemoteObserver getRemoteObserver(Ice.ConnectionInfo con, Ice.Endpoint endpt, int requestId, int size) { Ice.Instrumentation.RemoteObserver del = null; @@ -934,14 +947,14 @@ namespace IceInternal { del = delegate_.getRemoteObserver(con, endpt, requestId, size); } - return getObserver<RemoteMetrics, RemoteObserverI, - Ice.Instrumentation.RemoteObserver>("Remote", + return getObserver<RemoteMetrics, RemoteObserverI, + Ice.Instrumentation.RemoteObserver>("Remote", new RemoteInvocationHelper(con, endpt, requestId, size), del); } - public Ice.Instrumentation.CollocatedObserver getCollocatedObserver(Ice.ObjectAdapter adapter, - int requestId, + public Ice.Instrumentation.CollocatedObserver getCollocatedObserver(Ice.ObjectAdapter adapter, + int requestId, int size) { Ice.Instrumentation.CollocatedObserver del = null; @@ -950,7 +963,7 @@ namespace IceInternal del = delegate_.getCollocatedObserver(adapter, requestId, size); } return getObserver<CollocatedMetrics, CollocatedObserverI, - Ice.Instrumentation.CollocatedObserver>("Collocated", + Ice.Instrumentation.CollocatedObserver>("Collocated", new CollocatedInvocationHelper(adapter, requestId, size), del); } @@ -1088,8 +1101,8 @@ namespace IceInternal } return null; } - - public Ice.Instrumentation.ConnectionObserver getConnectionObserver(Ice.ConnectionInfo c, + + public Ice.Instrumentation.ConnectionObserver getConnectionObserver(Ice.ConnectionInfo c, Ice.Endpoint e, Ice.Instrumentation.ConnectionState s, Ice.Instrumentation.ConnectionObserver obsv) @@ -1113,9 +1126,9 @@ namespace IceInternal } return null; } - - public Ice.Instrumentation.ThreadObserver getThreadObserver(string parent, string id, - Ice.Instrumentation.ThreadState s, + + public Ice.Instrumentation.ThreadObserver getThreadObserver(string parent, string id, + Ice.Instrumentation.ThreadState s, Ice.Instrumentation.ThreadObserver obsv) { if(_threads.isEnabled()) @@ -1137,8 +1150,8 @@ namespace IceInternal } return null; } - - public Ice.Instrumentation.InvocationObserver getInvocationObserver(Ice.ObjectPrx prx, string operation, + + public Ice.Instrumentation.InvocationObserver getInvocationObserver(Ice.ObjectPrx prx, string operation, Dictionary<string, string> ctx) { if(_invocations.isEnabled()) @@ -1159,7 +1172,7 @@ namespace IceInternal } return null; } - + public Ice.Instrumentation.DispatchObserver getDispatchObserver(Ice.Current c, int size) { if(_dispatch.isEnabled()) @@ -1180,7 +1193,7 @@ namespace IceInternal } return null; } - + public void setObserverUpdater(Ice.Instrumentation.ObserverUpdater updater) { if(updater == null) diff --git a/csharp/src/Ice/MetricsObserverI.cs b/csharp/src/Ice/MetricsObserverI.cs index ad3f4ad2412..0157e163e88 100644 --- a/csharp/src/Ice/MetricsObserverI.cs +++ b/csharp/src/Ice/MetricsObserverI.cs @@ -24,9 +24,9 @@ namespace IceMX { _name = name; } - + protected abstract object resolve(object obj); - + public string resolveImpl(object obj) { try @@ -47,7 +47,34 @@ namespace IceMX throw new ArgumentOutOfRangeException(_name, ex); } } - + + protected object getField(System.Reflection.FieldInfo field, object obj) + { + while(obj != null) + { + try + { + return field.GetValue(obj); + } + catch(ArgumentException ex) + { + if(obj is Ice.EndpointInfo) + { + obj = ((Ice.EndpointInfo)obj).underlying; + } + else if(obj is Ice.ConnectionInfo) + { + obj = ((Ice.ConnectionInfo)obj).underlying; + } + else + { + throw ex; + } + } + } + return null; + } + readonly protected string _name; } @@ -58,15 +85,15 @@ namespace IceMX Debug.Assert(field != null); _field = field; } - + override protected object resolve(object obj) { - return _field.GetValue(obj); + return getField(_field, obj); } - + readonly private System.Reflection.FieldInfo _field; } - + class MethodResolverI : Resolver { internal MethodResolverI(string name, System.Reflection.MethodInfo method) : base(name) @@ -74,12 +101,12 @@ namespace IceMX Debug.Assert(method != null); _method = method; } - + override protected object resolve(object obj) { return _method.Invoke(obj, null); } - + readonly private System.Reflection.MethodInfo _method; } @@ -93,24 +120,24 @@ namespace IceMX _method = method; _field = field; } - + override protected object resolve(object obj) { object o = _method.Invoke(obj, null); if(o != null) { - return _field.GetValue(o); + return getField(_field, o); } throw new ArgumentOutOfRangeException(_name); } - + readonly private System.Reflection.MethodInfo _method; readonly private System.Reflection.FieldInfo _field; } - + class MemberMethodResolverI : Resolver { - internal MemberMethodResolverI(string name, System.Reflection.MethodInfo method, + internal MemberMethodResolverI(string name, System.Reflection.MethodInfo method, System.Reflection.MethodInfo subMeth) : base(name) { @@ -118,7 +145,7 @@ namespace IceMX _method = method; _subMethod = subMeth; } - + override protected object resolve(object obj) { object o = _method.Invoke(obj, null); @@ -128,7 +155,7 @@ namespace IceMX } throw new ArgumentOutOfRangeException(_name); } - + readonly private System.Reflection.MethodInfo _method; readonly private System.Reflection.MethodInfo _subMethod; } @@ -155,26 +182,26 @@ namespace IceMX } return resolver.resolveImpl(helper); } - - public void + + public void add(string name, System.Reflection.MethodInfo method) { _attributes.Add(name, new MethodResolverI(name, method)); } - - public void + + public void add(string name, System.Reflection.FieldInfo field) { _attributes.Add(name, new FieldResolverI(name, field)); } - - public void + + public void add(string name, System.Reflection.MethodInfo method, System.Reflection.FieldInfo field) { _attributes.Add(name, new MemberFieldResolverI(name, method, field)); } - - public void + + public void add(string name, System.Reflection.MethodInfo method, System.Reflection.MethodInfo subMethod) { _attributes.Add(name, new MemberMethodResolverI(name, method, subMethod)); @@ -209,7 +236,7 @@ namespace IceMX public class Observer<T> : Stopwatch, Ice.Instrumentation.Observer where T : Metrics, new() { public delegate void MetricsUpdate(T m); - + virtual public void attach() { Start(); @@ -232,7 +259,7 @@ namespace IceMX e.failed(exceptionName); } } - + public void forEach(MetricsUpdate u) { foreach(MetricsMap<T>.Entry e in _objects) @@ -249,7 +276,7 @@ namespace IceMX { return; } - + _previousDelay = previous._previousDelay + (long)(previous.ElapsedTicks / (Frequency / 1000000.0)); foreach(MetricsMap<T>.Entry e in previous._objects) { @@ -259,7 +286,7 @@ namespace IceMX } } } - + public ObserverImpl getObserver<S, ObserverImpl>(string mapName, MetricsHelper<S> helper) where S : Metrics, new() where ObserverImpl : Observer<S>, new() @@ -307,7 +334,7 @@ namespace IceMX } return null; } - + private List<MetricsMap<T>.Entry> _objects; private long _previousDelay = 0; } @@ -365,7 +392,7 @@ namespace IceMX metricsObjects.Add(e); } } - + if(metricsObjects == null) { if(old != null) @@ -428,7 +455,7 @@ namespace IceMX _updater = updater; } } - + private readonly IceInternal.MetricsAdminI _metrics; private readonly string _name; private List<MetricsMap<T>> _maps = new List<MetricsMap<T>>(); diff --git a/csharp/src/Ice/OpaqueEndpointI.cs b/csharp/src/Ice/OpaqueEndpointI.cs index 020878a3e38..a8749d4ec17 100644 --- a/csharp/src/Ice/OpaqueEndpointI.cs +++ b/csharp/src/Ice/OpaqueEndpointI.cs @@ -13,6 +13,7 @@ namespace IceInternal using System.Collections; using System.Collections.Generic; using System.Globalization; + using System.Diagnostics; sealed class OpaqueEndpointI : EndpointI { @@ -57,6 +58,11 @@ namespace IceInternal s.endEncapsulation(); } + public override void streamWriteImpl(Ice.OutputStream s) + { + Debug.Assert(false); + } + // // Convert the endpoint to its string form // @@ -69,7 +75,7 @@ namespace IceInternal private sealed class InfoI : Ice.OpaqueEndpointInfo { public InfoI(short type, Ice.EncodingVersion rawEncoding, byte[] rawBytes) : - base(-1, false, rawEncoding, rawBytes) + base(null, -1, false, rawEncoding, rawBytes) { _type = type; } diff --git a/csharp/src/Ice/TcpEndpointI.cs b/csharp/src/Ice/TcpEndpointI.cs index bb8c0e18638..579ab230366 100644 --- a/csharp/src/Ice/TcpEndpointI.cs +++ b/csharp/src/Ice/TcpEndpointI.cs @@ -13,7 +13,7 @@ namespace IceInternal using System.Net; using System.Globalization; - sealed class TcpEndpointI : IPEndpointI, WSEndpointDelegate + sealed class TcpEndpointI : IPEndpointI { public TcpEndpointI(ProtocolInstance instance, string ho, int po, EndPoint sourceAddr, int ti, string conId, bool co) : @@ -62,43 +62,17 @@ namespace IceInternal private IPEndpointI _endpoint; } - public override Ice.EndpointInfo getInfo() - { - InfoI info = new InfoI(this); - fillEndpointInfo(info); - return info; - } - - private sealed class WSInfoI : Ice.WSEndpointInfo + public override void streamWriteImpl(Ice.OutputStream s) { - public WSInfoI(IPEndpointI e) - { - _endpoint = e; - } - - public override short type() - { - return _endpoint.type(); - } - - public override bool datagram() - { - return _endpoint.datagram(); - } - - public override bool secure() - { - return _endpoint.secure(); - } - - private IPEndpointI _endpoint; + base.streamWriteImpl(s); + s.writeInt(_timeout); + s.writeBool(_compress); } - public Ice.EndpointInfo getWSInfo(string resource) + public override Ice.EndpointInfo getInfo() { - WSInfoI info = new WSInfoI(this); + InfoI info = new InfoI(this); fillEndpointInfo(info); - info.resource = resource; return info; } @@ -219,13 +193,6 @@ namespace IceInternal return base.CompareTo(p); } - public override void streamWriteImpl(Ice.OutputStream s) - { - base.streamWriteImpl(s); - s.writeInt(_timeout); - s.writeBool(_compress); - } - public override void hashInit(ref int h) { base.hashInit(ref h); @@ -352,7 +319,7 @@ namespace IceInternal _instance = null; } - public EndpointFactory clone(ProtocolInstance instance) + public EndpointFactory clone(ProtocolInstance instance, EndpointFactory del) { return new TcpEndpointFactory(instance); } diff --git a/csharp/src/Ice/TcpTransceiver.cs b/csharp/src/Ice/TcpTransceiver.cs index 42cf3319890..9ac3b249040 100644 --- a/csharp/src/Ice/TcpTransceiver.cs +++ b/csharp/src/Ice/TcpTransceiver.cs @@ -14,7 +14,7 @@ namespace IceInternal using System.Net; using System.Net.Sockets; - sealed class TcpTransceiver : Transceiver, WSTransceiverDelegate + sealed class TcpTransceiver : Transceiver { public Socket fd() { @@ -87,15 +87,17 @@ namespace IceInternal public Ice.ConnectionInfo getInfo() { Ice.TCPConnectionInfo info = new Ice.TCPConnectionInfo(); - fillConnectionInfo(info); - return info; - } - - public Ice.ConnectionInfo getWSInfo(Dictionary<string, string> headers) - { - Ice.WSConnectionInfo info = new Ice.WSConnectionInfo(); - fillConnectionInfo(info); - info.headers = headers; + if(_stream.fd() != null) + { + EndPoint localEndpoint = Network.getLocalAddress(_stream.fd()); + info.localAddress = Network.endpointAddressToString(localEndpoint); + info.localPort = Network.endpointPort(localEndpoint); + EndPoint remoteEndpoint = Network.getRemoteAddress(_stream.fd()); + info.remoteAddress = Network.endpointAddressToString(remoteEndpoint); + info.remotePort = Network.endpointPort(remoteEndpoint); + info.rcvSize = Network.getRecvBufferSize(_stream.fd()); + info.sndSize = Network.getSendBufferSize(_stream.fd()); + } return info; } @@ -127,21 +129,6 @@ namespace IceInternal _stream = stream; } - private void fillConnectionInfo(Ice.TCPConnectionInfo info) - { - if(_stream.fd() != null) - { - EndPoint localEndpoint = Network.getLocalAddress(_stream.fd()); - info.localAddress = Network.endpointAddressToString(localEndpoint); - info.localPort = Network.endpointPort(localEndpoint); - EndPoint remoteEndpoint = Network.getRemoteAddress(_stream.fd()); - info.remoteAddress = Network.endpointAddressToString(remoteEndpoint); - info.remotePort = Network.endpointPort(remoteEndpoint); - info.rcvSize = Network.getRecvBufferSize(_stream.fd()); - info.sndSize = Network.getSendBufferSize(_stream.fd()); - } - } - private readonly ProtocolInstance _instance; private readonly StreamSocket _stream; } diff --git a/csharp/src/Ice/UdpEndpointI.cs b/csharp/src/Ice/UdpEndpointI.cs index 28807066dd3..bdaa9ef35e9 100644 --- a/csharp/src/Ice/UdpEndpointI.cs +++ b/csharp/src/Ice/UdpEndpointI.cs @@ -438,7 +438,7 @@ namespace IceInternal _instance = null; } - public EndpointFactory clone(ProtocolInstance instance) + public EndpointFactory clone(ProtocolInstance instance, EndpointFactory del) { return new UdpEndpointFactory(instance); } diff --git a/csharp/src/Ice/WSConnector.cs b/csharp/src/Ice/WSConnector.cs index 91a51e2c400..5b1479d47cb 100644 --- a/csharp/src/Ice/WSConnector.cs +++ b/csharp/src/Ice/WSConnector.cs @@ -13,7 +13,7 @@ namespace IceInternal { public IceInternal.Transceiver connect() { - return new WSTransceiver(_instance, _delegate.connect(), _host, _port, _resource); + return new WSTransceiver(_instance, _delegate.connect(), _host, _resource); } public short type() @@ -21,12 +21,11 @@ namespace IceInternal return _delegate.type(); } - internal WSConnector(ProtocolInstance instance, IceInternal.Connector del, string host, int port, string resource) + internal WSConnector(ProtocolInstance instance, IceInternal.Connector del, string host, string resource) { _instance = instance; _delegate = del; _host = host; - _port = port; _resource = resource; } @@ -69,7 +68,6 @@ namespace IceInternal private ProtocolInstance _instance; private IceInternal.Connector _delegate; private string _host; - private int _port; private string _resource; } } diff --git a/csharp/src/Ice/WSEndpoint.cs b/csharp/src/Ice/WSEndpoint.cs index affc7d0bdfd..09b26b24acb 100644 --- a/csharp/src/Ice/WSEndpoint.cs +++ b/csharp/src/Ice/WSEndpoint.cs @@ -13,28 +13,19 @@ namespace IceInternal using System.Diagnostics; using System.Collections.Generic; - // - // Delegate interface implemented by TcpEndpoint or IceSSL.EndpointI or any endpoint that WS can - // delegate to. - // - public interface WSEndpointDelegate - { - Ice.EndpointInfo getWSInfo(string resource); - } - sealed class WSEndpoint : EndpointI { internal WSEndpoint(ProtocolInstance instance, EndpointI del, string res) { _instance = instance; - _delegate = (IPEndpointI)del; + _delegate = del; _resource = res; } internal WSEndpoint(ProtocolInstance instance, EndpointI del, List<string> args) { _instance = instance; - _delegate = (IPEndpointI)del; + _delegate = del; initWithOptions(args); @@ -47,7 +38,7 @@ namespace IceInternal internal WSEndpoint(ProtocolInstance instance, EndpointI del, Ice.InputStream s) { _instance = instance; - _delegate = (IPEndpointI)del; + _delegate = del; _resource = s.readString(); } @@ -79,8 +70,12 @@ namespace IceInternal public override Ice.EndpointInfo getInfo() { - Debug.Assert(_delegate is WSEndpointDelegate); - return ((WSEndpointDelegate)_delegate).getWSInfo(_resource); + Ice.WSEndpointInfo info = new InfoI(this); + info.underlying = _delegate.getInfo(); + info.resource = _resource; + info.compress = info.underlying.compress; + info.timeout = info.underlying.timeout; + return info; } public override short type() @@ -93,12 +88,10 @@ namespace IceInternal return _delegate.protocol(); } - public override void streamWrite(Ice.OutputStream s) + public override void streamWriteImpl(Ice.OutputStream s) { - s.startEncapsulation(); _delegate.streamWriteImpl(s); s.writeString(_resource); - s.endEncapsulation(); } public override int timeout() @@ -169,13 +162,11 @@ namespace IceInternal private sealed class EndpointI_connectorsI : EndpointI_connectors { - public EndpointI_connectorsI(ProtocolInstance instance, string host, int port, string resource, - EndpointI_connectors cb) + public EndpointI_connectorsI(ProtocolInstance instance, string host, string res, EndpointI_connectors cb) { _instance = instance; _host = host; - _port = port; - _resource = resource; + _resource = res; _callback = cb; } @@ -184,7 +175,7 @@ namespace IceInternal List<Connector> l = new List<Connector>(); foreach(Connector c in connectors) { - l.Add(new WSConnector(_instance, c, _host, _port, _resource)); + l.Add(new WSConnector(_instance, c, _host, _resource)); } _callback.connectors(l); } @@ -196,23 +187,27 @@ namespace IceInternal private ProtocolInstance _instance; private string _host; - private int _port; private string _resource; private EndpointI_connectors _callback; } - public override void connectors_async(Ice.EndpointSelectionType selType, - EndpointI_connectors callback) + public override void connectors_async(Ice.EndpointSelectionType selType, EndpointI_connectors callback) { - EndpointI_connectorsI cb = - new EndpointI_connectorsI(_instance, _delegate.host(), _delegate.port(), _resource, callback); - _delegate.connectors_async(selType, cb); + string host = ""; + for(Ice.EndpointInfo p = _delegate.getInfo(); p != null; p = p.underlying) + { + if(p is Ice.IPEndpointInfo) + { + Ice.IPEndpointInfo ipInfo = (Ice.IPEndpointInfo)p; + host = ipInfo.host + ":" + ipInfo.port; + } + } + _delegate.connectors_async(selType, new EndpointI_connectorsI(_instance, host, _resource, callback)); } public override Acceptor acceptor(string adapterName) { - Acceptor delAcc = _delegate.acceptor(adapterName); - return new WSAcceptor(this, _instance, delAcc); + return new WSAcceptor(this, _instance, _delegate.acceptor(adapterName)); } public WSEndpoint endpoint(EndpointI delEndp) @@ -299,11 +294,6 @@ namespace IceInternal return _delegate.CompareTo(p._delegate); } - public EndpointI getDelegate() - { - return _delegate; - } - protected override bool checkOption(string option, string argument, string endpoint) { switch(option[1]) @@ -328,7 +318,7 @@ namespace IceInternal } private ProtocolInstance _instance; - private IPEndpointI _delegate; + private EndpointI _delegate; private string _resource; } @@ -366,10 +356,9 @@ namespace IceInternal _instance = null; } - public EndpointFactory clone(ProtocolInstance instance) + public EndpointFactory clone(ProtocolInstance instance, EndpointFactory del) { - Debug.Assert(false); // We don't support cloning this transport. - return null; + return new WSEndpointFactory(instance, del); } private ProtocolInstance _instance; diff --git a/csharp/src/Ice/WSTransceiver.cs b/csharp/src/Ice/WSTransceiver.cs index 761cb164264..7945d22d684 100644 --- a/csharp/src/Ice/WSTransceiver.cs +++ b/csharp/src/Ice/WSTransceiver.cs @@ -16,15 +16,6 @@ namespace IceInternal using System.Security.Cryptography; using System.Text; - // - // Delegate interface implemented by TcpTransceiver or IceSSL.TransceiverI or any endpoint that WS can - // delegate to. - // - public interface WSTransceiverDelegate - { - Ice.ConnectionInfo getWSInfo(Dictionary<string, string> headers); - } - sealed class WSTransceiver : Transceiver { public Socket fd() @@ -70,9 +61,7 @@ namespace IceInternal // StringBuilder @out = new StringBuilder(); @out.Append("GET " + _resource + " HTTP/1.1\r\n"); - @out.Append("Host: " + _host + ":"); - @out.Append(_port); - @out.Append("\r\n"); + @out.Append("Host: " + _host + "\r\n"); @out.Append("Upgrade: websocket\r\n"); @out.Append("Connection: Upgrade\r\n"); @out.Append("Sec-WebSocket-Protocol: " + _iceProtocol + "\r\n"); @@ -665,8 +654,10 @@ namespace IceInternal public Ice.ConnectionInfo getInfo() { - Debug.Assert(_delegate is WSTransceiverDelegate); - return ((WSTransceiverDelegate)_delegate).getWSInfo(_parser.getHeaders()); + Ice.WSConnectionInfo info = new Ice.WSConnectionInfo(); + info.headers = _parser.getHeaders(); + info.underlying = _delegate.getInfo(); + return info; } public void checkSendSize(Buffer buf) @@ -690,11 +681,10 @@ namespace IceInternal } internal - WSTransceiver(ProtocolInstance instance, Transceiver del, string host, int port, string resource) + WSTransceiver(ProtocolInstance instance, Transceiver del, string host, string resource) { init(instance, del); _host = host; - _port = port; _resource = resource; _incoming = false; @@ -718,7 +708,6 @@ namespace IceInternal { init(instance, del); _host = ""; - _port = -1; _resource = ""; _incoming = true; @@ -1619,7 +1608,6 @@ namespace IceInternal private ProtocolInstance _instance; private Transceiver _delegate; private string _host; - private int _port; private string _resource; private bool _incoming; diff --git a/csharp/src/IceSSL/AcceptorI.cs b/csharp/src/IceSSL/AcceptorI.cs index 3539b3e8782..f0f50b84b45 100644 --- a/csharp/src/IceSSL/AcceptorI.cs +++ b/csharp/src/IceSSL/AcceptorI.cs @@ -12,38 +12,17 @@ namespace IceSSL using System; using System.Collections.Generic; using System.Diagnostics; - using System.IO; - using System.Net; - using System.Net.Security; - using System.Net.Sockets; - using System.Security.Cryptography.X509Certificates; - using System.Text; class AcceptorI : IceInternal.Acceptor { public void close() { - Debug.Assert(_acceptFd == null); - if(_fd != null) - { - IceInternal.Network.closeSocketNoThrow(_fd); - _fd = null; - } + _delegate.close(); } public IceInternal.EndpointI listen() { - try - { - _addr = IceInternal.Network.doBind(_fd, _addr); - IceInternal.Network.doListen(_fd, _backlog); - } - catch(SystemException) - { - _fd = null; - throw; - } - _endpoint = _endpoint.endpoint(this); + _endpoint = _endpoint.endpoint(_delegate.listen()); return _endpoint; } @@ -58,144 +37,55 @@ namespace IceSSL ex.reason = "IceSSL: plug-in is not initialized"; throw ex; } - - try - { - _result = _fd.BeginAccept(delegate(IAsyncResult result) - { - if(!result.CompletedSynchronously) - { - callback(result.AsyncState); - } - }, state); - return _result.CompletedSynchronously; - } - catch(SocketException ex) - { - throw new Ice.SocketException(ex); - } + return _delegate.startAccept(callback, state); } public void finishAccept() { - if(_fd != null) - { - Debug.Assert(_result != null); - try - { - _acceptFd = _fd.EndAccept(_result); - _result = null; - } - catch(SocketException ex) - { - _acceptError = ex; - } - } + _delegate.finishAccept(); } public IceInternal.Transceiver accept() { - if(_acceptFd == null) - { - throw _acceptError; - } - - Socket acceptFd = _acceptFd; - _acceptFd = null; - _acceptError = null; - return new TransceiverI(_instance, new IceInternal.StreamSocket(_instance, acceptFd), _adapterName, true); + return new TransceiverI(_instance, _delegate.accept(), _adapterName, true); } public string protocol() { - return _instance.protocol(); + return _delegate.protocol(); } public override string ToString() { - return IceInternal.Network.addrToString(_addr); + return _delegate.ToString(); } public string toDetailedString() { - StringBuilder s = new StringBuilder("local address = "); - s.Append(ToString()); - - List<string> intfs = IceInternal.Network.getHostsForEndpointExpand(_addr.Address.ToString(), - _instance.protocolSupport(), - true); - if(intfs.Count != 0) - { - s.Append("\nlocal interfaces = "); - s.Append(String.Join(", ", intfs.ToArray())); - } - return s.ToString(); + return _delegate.toDetailedString(); } - internal int effectivePort() - { - return _addr.Port; - } - - internal AcceptorI(EndpointI endpoint, Instance instance, string adapterName, string host, int port) + internal AcceptorI(EndpointI endpoint, Instance instance, IceInternal.Acceptor del, string adapterName) { _endpoint = endpoint; + _delegate = del; _instance = instance; _adapterName = adapterName; - _backlog = instance.properties().getPropertyAsIntWithDefault("Ice.TCP.Backlog", 511); // // .NET requires that a certificate be supplied. // - X509Certificate2Collection certs = instance.certs(); - if(certs.Count == 0) + if(instance.certs().Count == 0) { Ice.SecurityException ex = new Ice.SecurityException(); ex.reason = "IceSSL: certificate required for server endpoint"; throw ex; } - - try - { - int protocol = instance.protocolSupport(); - _addr = IceInternal.Network.getAddressForServer(host, port, protocol, instance.preferIPv6()) as - IPEndPoint; - _fd = IceInternal.Network.createServerSocket(false, _addr.AddressFamily, protocol); - IceInternal.Network.setBlock(_fd, false); - IceInternal.Network.setTcpBufSize(_fd, _instance); - if(IceInternal.AssemblyUtil.platform_ != IceInternal.AssemblyUtil.Platform.Windows) - { - // - // Enable SO_REUSEADDR on Unix platforms to allow - // re-using the socket even if it's in the TIME_WAIT - // state. On Windows, this doesn't appear to be - // necessary and enabling SO_REUSEADDR would actually - // not be a good thing since it allows a second - // process to bind to an address even it's already - // bound by another process. - // - // TODO: using SO_EXCLUSIVEADDRUSE on Windows would - // probably be better but it's only supported by recent - // Windows versions (XP SP2, Windows Server 2003). - // - IceInternal.Network.setReuseAddress(_fd, true); - } - } - catch(System.Exception) - { - _fd = null; - throw; - } } private EndpointI _endpoint; + private IceInternal.Acceptor _delegate; private Instance _instance; private string _adapterName; - private Socket _fd; - private Socket _acceptFd; - private System.Exception _acceptError; - private int _backlog; - private IPEndPoint _addr; - private IAsyncResult _result; } } diff --git a/csharp/src/IceSSL/ConnectorI.cs b/csharp/src/IceSSL/ConnectorI.cs index bac3ad376db..ca68ea09acc 100644 --- a/csharp/src/IceSSL/ConnectorI.cs +++ b/csharp/src/IceSSL/ConnectorI.cs @@ -29,37 +29,22 @@ namespace IceSSL throw ex; } - return new TransceiverI(_instance, new IceInternal.StreamSocket(_instance, _proxy, _addr, _sourceAddr), - _host, false); + return new TransceiverI(_instance, _delegate.connect(), _host, false); } public short type() { - return _instance.type(); + return _delegate.type(); } // // Only for use by EndpointI. // - internal ConnectorI(Instance instance, string host, EndPoint addr, IceInternal.NetworkProxy proxy, - EndPoint sourceAddr, int timeout, string conId) + internal ConnectorI(Instance instance, IceInternal.Connector del, string host) { _instance = instance; + _delegate = del; _host = host; - _addr = (IPEndPoint)addr; - _proxy = proxy; - _sourceAddr = sourceAddr; - _timeout = timeout; - _connectionId = conId; - - _hashCode = 5381; - IceInternal.HashUtil.hashAdd(ref _hashCode, _addr); - if(_sourceAddr != null) - { - IceInternal.HashUtil.hashAdd(ref _hashCode, _sourceAddr); - } - IceInternal.HashUtil.hashAdd(ref _hashCode, _timeout); - IceInternal.HashUtil.hashAdd(ref _hashCode, _connectionId); } public override bool Equals(object obj) @@ -75,41 +60,21 @@ namespace IceSSL } ConnectorI p = (ConnectorI)obj; - if(_timeout != p._timeout) - { - return false; - } - - if(!_connectionId.Equals(p._connectionId)) - { - return false; - } - - if(!IceInternal.Network.addressEquals(_sourceAddr, p._sourceAddr)) - { - return false; - } - - return _addr.Equals(p._addr); + return _delegate.Equals(p._delegate); } public override string ToString() { - return IceInternal.Network.addrToString(_proxy == null ? _addr : _proxy.getAddress()); + return _delegate.ToString(); } public override int GetHashCode() { - return _hashCode; + return _delegate.GetHashCode(); } private Instance _instance; + private IceInternal.Connector _delegate; private string _host; - private IPEndPoint _addr; - private IceInternal.NetworkProxy _proxy; - private EndPoint _sourceAddr; - private int _timeout; - private string _connectionId; - private int _hashCode; } } diff --git a/csharp/src/IceSSL/EndpointI.cs b/csharp/src/IceSSL/EndpointI.cs index 998c604c367..438ece37433 100644 --- a/csharp/src/IceSSL/EndpointI.cs +++ b/csharp/src/IceSSL/EndpointI.cs @@ -15,30 +15,17 @@ namespace IceSSL using System.Net; using System.Globalization; - sealed class EndpointI : IceInternal.IPEndpointI, IceInternal.WSEndpointDelegate + sealed class EndpointI : IceInternal.EndpointI { - internal EndpointI(Instance instance, string ho, int po, EndPoint sourceAddr, int ti, string conId, bool co) : - base(instance, ho, po, sourceAddr, conId) + internal EndpointI(Instance instance, IceInternal.EndpointI del) { _instance = instance; - _timeout = ti; - _compress = co; + _delegate = del; } - internal EndpointI(Instance instance) : - base(instance) + public override void streamWriteImpl(Ice.OutputStream os) { - _instance = instance; - _timeout = instance.defaultTimeout(); - _compress = false; - } - - internal EndpointI(Instance instance, Ice.InputStream s) : - base(instance, s) - { - _instance = instance; - _timeout = s.readInt(); - _compress = s.readBool(); + _delegate.streamWriteImpl(os); } private sealed class InfoI : IceSSL.EndpointInfo @@ -66,341 +53,245 @@ namespace IceSSL private EndpointI _endpoint; } - // - // Return the endpoint information. - // public override Ice.EndpointInfo getInfo() { InfoI info = new InfoI(this); - fillEndpointInfo(info); + info.underlying = _delegate.getInfo(); + info.compress = info.underlying.compress; + info.timeout = info.underlying.timeout; return info; } - private sealed class WSSInfoI : IceSSL.WSSEndpointInfo + public override short type() { - public WSSInfoI(EndpointI e) - { - _endpoint = e; - } - - override public short type() - { - return _endpoint.type(); - } - - override public bool datagram() - { - return _endpoint.datagram(); - } - - override public bool secure() - { - return _endpoint.secure(); - } - - private EndpointI _endpoint; + return _delegate.type(); } - // - // Return the endpoint information. - // - public Ice.EndpointInfo getWSInfo(string resource) + public override string protocol() { - WSSInfoI info = new WSSInfoI(this); - fillEndpointInfo(info); - info.resource = resource; - return info; + return _delegate.protocol(); } - // - // Return the timeout for the endpoint in milliseconds. 0 means - // non-blocking, -1 means no timeout. - // public override int timeout() { - return _timeout; + return _delegate.timeout(); } - // - // Return a new endpoint with a different timeout value, provided - // that timeouts are supported by the endpoint. Otherwise the same - // endpoint is returned. - // public override IceInternal.EndpointI timeout(int timeout) { - if(timeout == _timeout) + if(timeout == _delegate.timeout()) { return this; } else { - return new EndpointI(_instance, host_, port_, sourceAddr_, timeout, connectionId_, _compress); + return new EndpointI(_instance, _delegate.timeout(timeout)); } } - // - // Return true if the endpoints support bzip2 compress, or false - // otherwise. - // - public override bool compress() + public override string connectionId() { - return _compress; + return _delegate.connectionId(); } - // - // Return a new endpoint with a different compression value, - // provided that compression is supported by the - // endpoint. Otherwise the same endpoint is returned. - // - public override IceInternal.EndpointI compress(bool compress) + public override IceInternal.EndpointI connectionId(string connectionId) { - if(compress == _compress) + if(connectionId.Equals(_delegate.connectionId())) { return this; } else { - return new EndpointI(_instance, host_, port_, sourceAddr_, _timeout, connectionId_, compress); + return new EndpointI(_instance, _delegate.connectionId(connectionId)); } } - // - // Return true if the endpoint is datagram-based. - // - public override bool datagram() + public override bool compress() { - return false; + return _delegate.compress(); } - // - // Return a server side transceiver for this endpoint, or null if a - // transceiver can only be created by an acceptor. - // - public override IceInternal.Transceiver transceiver() + public override IceInternal.EndpointI compress(bool compress) { - return null; + if(compress == _delegate.compress()) + { + return this; + } + else + { + return new EndpointI(_instance, _delegate.compress(compress)); + } } - // - // Return an acceptor for this endpoint, or null if no acceptor - // is available. - // - public override IceInternal.Acceptor acceptor(string adapterName) + public override bool datagram() { - return new AcceptorI(this, _instance, adapterName, host_, port_); + return _delegate.datagram(); } - public EndpointI endpoint(AcceptorI acceptor) + public override bool secure() { - return new EndpointI(_instance, host_, acceptor.effectivePort(), sourceAddr_, _timeout, connectionId_, - _compress); + return _delegate.secure(); } - public override string options() + public override IceInternal.Transceiver transceiver() { - // - // WARNING: Certain features, such as proxy validation in Glacier2, - // depend on the format of proxy strings. Changes to toString() and - // methods called to generate parts of the reference string could break - // these features. Please review for all features that depend on the - // format of proxyToString() before changing this and related code. - // - string s = base.options(); - - if(_timeout == -1) - { - s += " -t infinite"; - } - else - { - s += " -t " + _timeout; - } - - if(_compress) - { - s += " -z"; - } - - return s; + return null; } - // - // Compare endpoints for sorting purposes - // - public override int CompareTo(IceInternal.EndpointI obj) + private sealed class EndpointI_connectorsI : IceInternal.EndpointI_connectors { - if(!(obj is EndpointI)) + public EndpointI_connectorsI(Instance instance, string host, IceInternal.EndpointI_connectors cb) { - return type() < obj.type() ? -1 : 1; + _instance = instance; + _host = host; + _callback = cb; } - EndpointI p = (EndpointI)obj; - if(this == p) + public void connectors(List<IceInternal.Connector> connectors) { - return 0; - } - - if(_timeout < p._timeout) - { - return -1; - } - else if(p._timeout < _timeout) - { - return 1; + List<IceInternal.Connector> l = new List<IceInternal.Connector>(); + foreach(IceInternal.Connector c in connectors) + { + l.Add(new ConnectorI(_instance, c, _host)); + } + _callback.connectors(l); } - if(!_compress && p._compress) - { - return -1; - } - else if(!p._compress && _compress) + public void exception(Ice.LocalException ex) { - return 1; + _callback.exception(ex); } - return base.CompareTo(p); + private Instance _instance; + private string _host; + private IceInternal.EndpointI_connectors _callback; } - public override void streamWriteImpl(Ice.OutputStream s) + public override void connectors_async(Ice.EndpointSelectionType selType, + IceInternal.EndpointI_connectors callback) { - base.streamWriteImpl(s); - s.writeInt(_timeout); - s.writeBool(_compress); + string host = ""; + for(Ice.EndpointInfo p = _delegate.getInfo(); p != null; p = p.underlying) + { + if(p is Ice.IPEndpointInfo) + { + host = ((Ice.IPEndpointInfo)p).host; + break; + } + } + _delegate.connectors_async(selType, new EndpointI_connectorsI(_instance, host, callback)); } - public override void hashInit(ref int h) + public override IceInternal.Acceptor acceptor(string adapterName) { - base.hashInit(ref h); - IceInternal.HashUtil.hashAdd(ref h, _timeout); - IceInternal.HashUtil.hashAdd(ref h, _compress); + return new AcceptorI(this, _instance, _delegate.acceptor(adapterName), adapterName); } - public override void fillEndpointInfo(Ice.IPEndpointInfo info) + public EndpointI endpoint(IceInternal.EndpointI del) { - base.fillEndpointInfo(info); - info.timeout = _timeout; - info.compress = _compress; + return new EndpointI(_instance, del); } - protected override bool checkOption(string option, string argument, string endpoint) + public override List<IceInternal.EndpointI> expand() { - if(base.checkOption(option, argument, endpoint)) + List<IceInternal.EndpointI> l = new List<IceInternal.EndpointI>(); + foreach(IceInternal.EndpointI e in _delegate.expand()) { - return true; + l.Add(e == _delegate ? this : new EndpointI(_instance, e)); } + return l; + } - switch(option[1]) - { - case 't': + public override bool equivalent(IceInternal.EndpointI endpoint) + { + if(!(endpoint is EndpointI)) { - if(argument == null) - { - Ice.EndpointParseException e = new Ice.EndpointParseException(); - e.str = "no argument provided for -t option in endpoint " + endpoint; - throw e; - } - - if(argument.Equals("infinite")) - { - _timeout = -1; - } - else - { - try - { - _timeout = System.Int32.Parse(argument, CultureInfo.InvariantCulture); - if(_timeout < 1) - { - Ice.EndpointParseException e = new Ice.EndpointParseException(); - e.str = "invalid timeout value `" + argument + "' in endpoint " + endpoint; - throw e; - } - } - catch(System.FormatException ex) - { - Ice.EndpointParseException e = new Ice.EndpointParseException(ex); - e.str = "invalid timeout value `" + argument + "' in endpoint " + endpoint; - throw e; - } - } - - return true; + return false; } + EndpointI endpointI = (EndpointI)endpoint; + return _delegate.equivalent(endpointI._delegate); + } - case 'z': - { - if(argument != null) - { - Ice.EndpointParseException e = new Ice.EndpointParseException(); - e.str = "unexpected argument `" + argument + "' provided for -z option in " + endpoint; - throw e; - } + public override string options() + { + return _delegate.options(); + } - _compress = true; - return true; + // + // Compare endpoints for sorting purposes + // + public override int CompareTo(IceInternal.EndpointI obj) + { + if(!(obj is EndpointI)) + { + return type() < obj.type() ? -1 : 1; } - default: + EndpointI p = (EndpointI)obj; + if(this == p) { - return false; - } + return 0; } + + return _delegate.CompareTo(p._delegate); } - protected override IceInternal.Connector createConnector(EndPoint addr, IceInternal.NetworkProxy proxy) + public override int GetHashCode() { - return new ConnectorI(_instance, host_, addr, proxy, sourceAddr_, _timeout, connectionId_); + return _delegate.GetHashCode(); } - protected override IceInternal.IPEndpointI createEndpoint(string host, int port, string connectionId) + protected override bool checkOption(string option, string argument, string endpoint) { - return new EndpointI(_instance, host, port, sourceAddr_, _timeout, connectionId, _compress); + return false; } private Instance _instance; - private int _timeout; - private bool _compress; + private IceInternal.EndpointI _delegate; } internal sealed class EndpointFactoryI : IceInternal.EndpointFactory { - internal EndpointFactoryI(Instance instance) + internal EndpointFactoryI(Instance instance, IceInternal.EndpointFactory del) { _instance = instance; + _delegate = del; } public short type() { - return _instance.type(); + return _delegate.type(); } public string protocol() { - return _instance.protocol(); + return _delegate.protocol(); } public IceInternal.EndpointI create(List<string> args, bool oaEndpoint) { - IceInternal.IPEndpointI endpt = new EndpointI(_instance); - endpt.initWithOptions(args, oaEndpoint); - return endpt; + return new EndpointI(_instance, _delegate.create(args, oaEndpoint)); } public IceInternal.EndpointI read(Ice.InputStream s) { - return new EndpointI(_instance, s); + return new EndpointI(_instance, _delegate.read(s)); } public void destroy() { + _delegate.destroy(); _instance = null; } - public IceInternal.EndpointFactory clone(IceInternal.ProtocolInstance instance) + public IceInternal.EndpointFactory clone(IceInternal.ProtocolInstance inst, + IceInternal.EndpointFactory del) { - return new EndpointFactoryI(new Instance(_instance.engine(), instance.type(), instance.protocol())); + Instance instance = new Instance(_instance.engine(), inst.type(), inst.protocol()); + return new EndpointFactoryI(instance, del != null ? del : _delegate.clone(instance, null)); } private Instance _instance; + private IceInternal.EndpointFactory _delegate; } } diff --git a/csharp/src/IceSSL/Instance.cs b/csharp/src/IceSSL/Instance.cs index 6b08ecdbd71..b115e682db8 100644 --- a/csharp/src/IceSSL/Instance.cs +++ b/csharp/src/IceSSL/Instance.cs @@ -68,9 +68,9 @@ namespace IceSSL _engine.traceStream(stream, connInfo); } - internal void verifyPeer(NativeConnectionInfo info, System.Net.Sockets.Socket fd, string address) + internal void verifyPeer(string address, NativeConnectionInfo info, string desc) { - _engine.verifyPeer(info, fd, address); + _engine.verifyPeer(address, info, desc); } private SSLEngine _engine; diff --git a/csharp/src/IceSSL/PluginI.cs b/csharp/src/IceSSL/PluginI.cs index a7470596b74..9c0e3825a47 100644 --- a/csharp/src/IceSSL/PluginI.cs +++ b/csharp/src/IceSSL/PluginI.cs @@ -41,12 +41,14 @@ namespace IceSSL _engine = new SSLEngine(facade); // - // Register the endpoint factory. We have to do this now, rather than - // in initialize, because the communicator may need to interpret - // proxies before the plug-in is fully initialized. + // SSL based on TCP // - EndpointFactoryI factory = new EndpointFactoryI(new Instance(_engine, IceSSL.EndpointType.value, "ssl")); - facade.addEndpointFactory(factory); + IceInternal.EndpointFactory tcp = facade.getEndpointFactory(Ice.TCPEndpointType.value); + if(tcp != null) + { + Instance instance = new Instance(_engine, Ice.SSLEndpointType.value, "ssl"); + facade.addEndpointFactory(new EndpointFactoryI(instance, tcp.clone(instance, null))); + } } public override void initialize() diff --git a/csharp/src/IceSSL/SSLEngine.cs b/csharp/src/IceSSL/SSLEngine.cs index bd8f527b8e4..6845b3143fe 100644 --- a/csharp/src/IceSSL/SSLEngine.cs +++ b/csharp/src/IceSSL/SSLEngine.cs @@ -534,7 +534,7 @@ namespace IceSSL _logger.trace(_securityTraceCategory, s.ToString()); } - internal void verifyPeer(NativeConnectionInfo info, System.Net.Sockets.Socket fd, string address) + internal void verifyPeer(string address, NativeConnectionInfo info, string desc) { // // For an outgoing connection, we compare the proxy address (if any) against @@ -732,8 +732,7 @@ namespace IceSSL { string msg = (info.incoming ? "incoming" : "outgoing") + " connection rejected:\n" + "length of peer's certificate chain (" + info.nativeCerts.Length + ") exceeds maximum of " + - _verifyDepthMax + "\n" + - IceInternal.Network.fdToString(fd); + _verifyDepthMax + "\n" + desc; if(_securityTraceLevel >= 1) { _logger.trace(_securityTraceCategory, msg); @@ -743,10 +742,10 @@ namespace IceSSL throw ex; } - if(!_trustManager.verify(info)) + if(!_trustManager.verify(info, desc)) { string msg = (info.incoming ? "incoming" : "outgoing") + " connection rejected by trust manager\n" + - IceInternal.Network.fdToString(fd); + desc; if(_securityTraceLevel >= 1) { _logger.trace(_securityTraceCategory, msg); @@ -760,7 +759,7 @@ namespace IceSSL if(_verifier != null && !_verifier.verify(info)) { string msg = (info.incoming ? "incoming" : "outgoing") + - " connection rejected by certificate verifier\n" + IceInternal.Network.fdToString(fd); + " connection rejected by certificate verifier\n" + desc; if(_securityTraceLevel >= 1) { _logger.trace(_securityTraceCategory, msg); diff --git a/csharp/src/IceSSL/TransceiverI.cs b/csharp/src/IceSSL/TransceiverI.cs index 171211fb3b5..5ec9afccf8a 100644 --- a/csharp/src/IceSSL/TransceiverI.cs +++ b/csharp/src/IceSSL/TransceiverI.cs @@ -20,47 +20,60 @@ namespace IceSSL using System.Security.Cryptography.X509Certificates; using System.Text; - sealed class TransceiverI : IceInternal.Transceiver, IceInternal.WSTransceiverDelegate + sealed class TransceiverI : IceInternal.Transceiver { public Socket fd() { - return _stream.fd(); + return _delegate.fd(); } public int initialize(IceInternal.Buffer readBuffer, IceInternal.Buffer writeBuffer, ref bool hasMoreData) { - int status = _stream.connect(readBuffer, writeBuffer, ref hasMoreData); - if(status != IceInternal.SocketOperation.None) + if(!_isConnected) { - return status; + int status = _delegate.initialize(readBuffer, writeBuffer, ref hasMoreData); + if(status != IceInternal.SocketOperation.None) + { + return status; + } + _isConnected = true; } - _stream.setBlock(true); // SSL requires a blocking socket + IceInternal.Network.setBlock(fd(), true); // SSL requires a blocking socket + + // + // For timeouts to work properly, we need to receive/send + // the data in several chunks. Otherwise, we would only be + // notified when all the data is received/written. The + // connection timeout could easily be triggered when + // receiging/sending large messages. + // + _maxSendPacketSize = System.Math.Max(512, IceInternal.Network.getSendBufferSize(fd())); + _maxRecvPacketSize = System.Math.Max(512, IceInternal.Network.getRecvBufferSize(fd())); if(_sslStream == null) { - NetworkStream ns = new NetworkStream(_stream.fd(), false); - _sslStream = new SslStream(ns, false, new RemoteCertificateValidationCallback(validationCallback), - new LocalCertificateSelectionCallback(selectCertificate)); + _sslStream = new SslStream(new NetworkStream(_delegate.fd(), false), + false, + new RemoteCertificateValidationCallback(validationCallback), + new LocalCertificateSelectionCallback(selectCertificate)); return IceInternal.SocketOperation.Connect; } Debug.Assert(_sslStream.IsAuthenticated); _authenticated = true; - _instance.verifyPeer((NativeConnectionInfo)getInfo(), _stream.fd(), _host); + _instance.verifyPeer(_host, (NativeConnectionInfo)getInfo(), ToString()); if(_instance.securityTraceLevel() >= 1) { - _instance.traceStream(_sslStream, _stream.ToString()); + _instance.traceStream(_sslStream, ToString()); } return IceInternal.SocketOperation.None; } public int closing(bool initiator, Ice.LocalException ex) { - // If we are initiating the connection closure, wait for the peer - // to close the TCP/IP connection. Otherwise, close immediately. - return initiator ? IceInternal.SocketOperation.Read : IceInternal.SocketOperation.None; + return _delegate.closing(initiator, ex); } public void close() @@ -71,7 +84,7 @@ namespace IceSSL _sslStream = null; } - _stream.close(); + _delegate.close(); } public IceInternal.EndpointI bind() @@ -82,7 +95,7 @@ namespace IceSSL public void destroy() { - _stream.destroy(); + _delegate.destroy(); } public int write(IceInternal.Buffer buf) @@ -103,14 +116,14 @@ namespace IceSSL public bool startRead(IceInternal.Buffer buf, IceInternal.AsyncCallback callback, object state) { - if(!_stream.isConnected()) + if(!_isConnected) { - return _stream.startRead(buf, callback, state); + return _delegate.startRead(buf, callback, state); } Debug.Assert(_sslStream != null && _sslStream.IsAuthenticated); - int packetSz = _stream.getRecvPacketSize(buf.b.remaining()); + int packetSz = getRecvPacketSize(buf.b.remaining()); try { _readCallback = callback; @@ -141,9 +154,9 @@ namespace IceSSL public void finishRead(IceInternal.Buffer buf) { - if(!_stream.isConnected()) + if(!_isConnected) { - _stream.finishRead(buf); + _delegate.finishRead(buf); return; } else if(_sslStream == null) // Transceiver was closed @@ -191,29 +204,28 @@ namespace IceSSL } } - public bool startWrite(IceInternal.Buffer buf, IceInternal.AsyncCallback callback, object state, - out bool completed) + public bool startWrite(IceInternal.Buffer buf, IceInternal.AsyncCallback cb, object state, out bool completed) { - if(!_stream.isConnected()) + if(!_isConnected) { - return _stream.startWrite(buf, callback, state, out completed); + return _delegate.startWrite(buf, cb, state, out completed); } Debug.Assert(_sslStream != null); if(!_authenticated) { completed = false; - return startAuthenticate(callback, state); + return startAuthenticate(cb, state); } // // We limit the packet size for beingWrite to ensure connection timeouts are based // on a fixed packet size. // - int packetSize = _stream.getSendPacketSize(buf.b.remaining()); + int packetSize = getSendPacketSize(buf.b.remaining()); try { - _writeCallback = callback; + _writeCallback = cb; _writeResult = _sslStream.BeginWrite(buf.b.rawBytes(), buf.b.position(), packetSize, writeCompleted, state); completed = packetSize == buf.b.remaining(); @@ -243,14 +255,14 @@ namespace IceSSL public void finishWrite(IceInternal.Buffer buf) { - if(!_stream.isConnected()) + if(!_isConnected) { - _stream.finishWrite(buf); + _delegate.finishWrite(buf); return; } else if(_sslStream == null) // Transceiver was closed { - if(_stream.getSendPacketSize(buf.b.remaining()) == buf.b.remaining()) // Sent last packet + if(getSendPacketSize(buf.b.remaining()) == buf.b.remaining()) // Sent last packet { buf.b.position(buf.b.limit()); // Assume all the data was sent for at-most-once semantics. } @@ -264,7 +276,7 @@ namespace IceSSL } Debug.Assert(_writeResult != null); - int sent = _stream.getSendPacketSize(buf.b.remaining()); + int sent = getSendPacketSize(buf.b.remaining()); try { _sslStream.EndWrite(_writeResult); @@ -295,50 +307,72 @@ namespace IceSSL public string protocol() { - return _instance.protocol(); + return _delegate.protocol(); } public Ice.ConnectionInfo getInfo() { NativeConnectionInfo info = new NativeConnectionInfo(); - info.nativeCerts = fillConnectionInfo(info); - return info; - } + info.underlying = _delegate.getInfo(); + info.incoming = _incoming; + info.adapterName = _adapterName; + if(_sslStream != null) + { + info.cipher = _sslStream.CipherAlgorithm.ToString(); + if(_chain.ChainElements != null && _chain.ChainElements.Count > 0) + { + info.nativeCerts = new X509Certificate2[_chain.ChainElements.Count]; + for(int i = 0; i < _chain.ChainElements.Count; ++i) + { + info.nativeCerts[i] = _chain.ChainElements[i].Certificate; + } + } - public Ice.ConnectionInfo getWSInfo(Dictionary<string, string> headers) - { - WSSNativeConnectionInfo info = new WSSNativeConnectionInfo(); - info.nativeCerts = fillConnectionInfo(info); - info.headers = headers; + List<string> certs = new List<string>(); + if(info.nativeCerts != null) + { + foreach(X509Certificate2 cert in info.nativeCerts) + { + StringBuilder s = new StringBuilder(); + s.Append("-----BEGIN CERTIFICATE-----\n"); + s.Append(Convert.ToBase64String(cert.Export(X509ContentType.Cert))); + s.Append("\n-----END CERTIFICATE-----"); + certs.Add(s.ToString()); + } + } + info.certs = certs.ToArray(); + info.verified = _verified; + } return info; } public void checkSendSize(IceInternal.Buffer buf) { + _delegate.checkSendSize(buf); } public void setBufferSize(int rcvSize, int sndSize) { - _stream.setBufferSize(rcvSize, sndSize); + _delegate.setBufferSize(rcvSize, sndSize); } public override string ToString() { - return _stream.ToString(); + return _delegate.ToString(); } public string toDetailedString() { - return ToString(); + return _delegate.toDetailedString(); } // // Only for use by ConnectorI, AcceptorI. // - internal TransceiverI(Instance instance, IceInternal.StreamSocket stream, string hostOrAdapterName, bool incoming) + internal TransceiverI(Instance instance, IceInternal.Transceiver del, string hostOrAdapterName, bool incoming) { _instance = instance; - _stream = stream; + _delegate = del; _incoming = incoming; if(_incoming) { @@ -348,6 +382,7 @@ namespace IceSSL { _host = hostOrAdapterName; } + _sslStream = null; _verifyPeer = _instance.properties().getPropertyAsIntWithDefault("IceSSL.VerifyPeer", 2); @@ -373,55 +408,6 @@ namespace IceSSL } } - private X509Certificate2[] fillConnectionInfo(ConnectionInfo info) - { - X509Certificate2[] nativeCerts = null; - if(_stream.fd() != null) - { - IPEndPoint localEndpoint = (IPEndPoint)IceInternal.Network.getLocalAddress(_stream.fd()); - info.localAddress = localEndpoint.Address.ToString(); - info.localPort = localEndpoint.Port; - IPEndPoint remoteEndpoint = (IPEndPoint)IceInternal.Network.getRemoteAddress(_stream.fd()); - if(remoteEndpoint != null) - { - info.remoteAddress = remoteEndpoint.Address.ToString(); - info.remotePort = remoteEndpoint.Port; - } - info.rcvSize = IceInternal.Network.getRecvBufferSize(_stream.fd()); - info.sndSize = IceInternal.Network.getSendBufferSize(_stream.fd()); - } - if(_sslStream != null) - { - info.cipher = _sslStream.CipherAlgorithm.ToString(); - if(_chain.ChainElements != null && _chain.ChainElements.Count > 0) - { - nativeCerts = new X509Certificate2[_chain.ChainElements.Count]; - for(int i = 0; i < _chain.ChainElements.Count; ++i) - { - nativeCerts[i] = _chain.ChainElements[i].Certificate; - } - } - - List<string> certs = new List<string>(); - if(nativeCerts != null) - { - foreach(X509Certificate2 cert in nativeCerts) - { - StringBuilder s = new StringBuilder(); - s.Append("-----BEGIN CERTIFICATE-----\n"); - s.Append(Convert.ToBase64String(cert.Export(X509ContentType.Cert))); - s.Append("\n-----END CERTIFICATE-----"); - certs.Add(s.ToString()); - } - } - info.certs = certs.ToArray(); - info.verified = _verified; - } - info.adapterName = _adapterName; - info.incoming = _incoming; - return nativeCerts; - } - private bool startAuthenticate(IceInternal.AsyncCallback callback, object state) { try @@ -527,12 +513,8 @@ namespace IceSSL } } - private X509Certificate selectCertificate( - object sender, - string targetHost, - X509CertificateCollection certs, - X509Certificate remoteCertificate, - string[] acceptableIssuers) + private X509Certificate selectCertificate(object sender, string targetHost, X509CertificateCollection certs, + X509Certificate remoteCertificate, string[] acceptableIssuers) { if(certs == null || certs.Count == 0) { @@ -758,13 +740,24 @@ namespace IceSSL } } + private int getSendPacketSize(int length) + { + return _maxSendPacketSize > 0 ? System.Math.Min(length, _maxSendPacketSize) : length; + } + + public int getRecvPacketSize(int length) + { + return _maxRecvPacketSize > 0 ? System.Math.Min(length, _maxRecvPacketSize) : length; + } + private Instance _instance; - private IceInternal.StreamSocket _stream; + private IceInternal.Transceiver _delegate; private string _host = ""; private string _adapterName = ""; private bool _incoming; private SslStream _sslStream; private int _verifyPeer; + private bool _isConnected; private bool _authenticated; private IAsyncResult _writeResult; private IAsyncResult _readResult; @@ -772,5 +765,7 @@ namespace IceSSL private IceInternal.AsyncCallback _writeCallback; private X509Chain _chain; private bool _verified; + private int _maxSendPacketSize; + private int _maxRecvPacketSize; } } diff --git a/csharp/src/IceSSL/TrustManager.cs b/csharp/src/IceSSL/TrustManager.cs index b9cba557a25..2813ecdc942 100644 --- a/csharp/src/IceSSL/TrustManager.cs +++ b/csharp/src/IceSSL/TrustManager.cs @@ -58,7 +58,7 @@ namespace IceSSL } } - internal bool verify(NativeConnectionInfo info) + internal bool verify(NativeConnectionInfo info, string desc) { List<List<List<RFC2253.RDNPair>>> reject = new List<List<List<RFC2253.RDNPair>>>(), accept = new List<List<List<RFC2253.RDNPair>>>(); @@ -143,17 +143,12 @@ namespace IceSSL if(info.incoming) { communicator_.getLogger().trace("Security", "trust manager evaluating client:\n" + - "subject = " + subjectName + "\n" + - "adapter = " + info.adapterName + "\n" + - "local addr = " + info.localAddress + ":" + info.localPort + "\n" + - "remote addr = " + info.remoteAddress + ":" + info.remotePort); + "subject = " + subjectName + "\n" + "adapter = " + info.adapterName + "\n" + desc); } else { communicator_.getLogger().trace("Security", "trust manager evaluating server:\n" + - "subject = " + subjectName + "\n" + - "local addr = " + info.localAddress + ":" + info.localPort + "\n" + - "remote addr = " + info.remoteAddress + ":" + info.remotePort); + "subject = " + subjectName + "\n" + desc); } } diff --git a/csharp/src/IceSSL/Util.cs b/csharp/src/IceSSL/Util.cs index 7b64a30befc..1b617dff0a0 100644 --- a/csharp/src/IceSSL/Util.cs +++ b/csharp/src/IceSSL/Util.cs @@ -28,20 +28,6 @@ namespace IceSSL public System.Security.Cryptography.X509Certificates.X509Certificate2[] nativeCerts; } - /// <summary> - /// This class provides information about a connection to applications - /// that require information about a peer. - /// </summary> - public sealed class WSSNativeConnectionInfo : WSSConnectionInfo - { - /// <summary> - /// The certificate chain. This may be null if the peer did not - /// supply a certificate. The peer's certificate (if any) is the - /// first one in the chain. - /// </summary> - public System.Security.Cryptography.X509Certificates.X509Certificate2[] nativeCerts; - } - public sealed class Util { public static X509Certificate2 createCertificate(string certPEM) |