summaryrefslogtreecommitdiff
path: root/ruby/src
diff options
context:
space:
mode:
authorBenoit Foucher <benoit@zeroc.com>2016-06-27 17:54:30 +0200
committerBenoit Foucher <benoit@zeroc.com>2016-06-27 17:54:30 +0200
commitc56f8ab6ca6ca0bdb9536fcce1ef24f1ef40ddc7 (patch)
tree5cb64dfe155e5d2349efb6c7dc4b0f5b5284d44a /ruby/src
parentFix Windows php build to restore nuget packages (diff)
downloadice-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 'ruby/src')
-rw-r--r--ruby/src/IceRuby/Connection.cpp79
-rw-r--r--ruby/src/IceRuby/Endpoint.cpp58
2 files changed, 36 insertions, 101 deletions
diff --git a/ruby/src/IceRuby/Connection.cpp b/ruby/src/IceRuby/Connection.cpp
index 1b95f3a629b..6b4b57efdc7 100644
--- a/ruby/src/IceRuby/Connection.cpp
+++ b/ruby/src/IceRuby/Connection.cpp
@@ -25,7 +25,6 @@ static VALUE _tcpConnectionInfoClass;
static VALUE _udpConnectionInfoClass;
static VALUE _wsConnectionInfoClass;
static VALUE _sslConnectionInfoClass;
-static VALUE _wssConnectionInfoClass;
// **********************************************************************
// Connection
@@ -293,17 +292,17 @@ IceRuby_ConnectionInfo_free(Ice::ConnectionInfoPtr* p)
VALUE
IceRuby::createConnectionInfo(const Ice::ConnectionInfoPtr& p)
{
+ if(!p)
+ {
+ return Qnil;
+ }
+
VALUE info;
if(Ice::WSConnectionInfoPtr::dynamicCast(p))
{
info = Data_Wrap_Struct(_wsConnectionInfoClass, 0, IceRuby_ConnectionInfo_free, new Ice::ConnectionInfoPtr(p));
Ice::WSConnectionInfoPtr ws = Ice::WSConnectionInfoPtr::dynamicCast(p);
- rb_ivar_set(info, rb_intern("@localAddress"), createString(ws->localAddress));
- rb_ivar_set(info, rb_intern("@localPort"), INT2FIX(ws->localPort));
- rb_ivar_set(info, rb_intern("@remoteAddress"), createString(ws->remoteAddress));
- rb_ivar_set(info, rb_intern("@remotePort"), INT2FIX(ws->remotePort));
-
volatile VALUE result = callRuby(rb_hash_new);
for(Ice::HeaderDict::const_iterator q = ws->headers.begin(); q != ws->headers.end(); ++q)
{
@@ -318,54 +317,24 @@ IceRuby::createConnectionInfo(const Ice::ConnectionInfoPtr& p)
info = Data_Wrap_Struct(_tcpConnectionInfoClass, 0, IceRuby_ConnectionInfo_free, new Ice::ConnectionInfoPtr(p));
Ice::TCPConnectionInfoPtr tcp = Ice::TCPConnectionInfoPtr::dynamicCast(p);
- rb_ivar_set(info, rb_intern("@localAddress"), createString(tcp->localAddress));
- rb_ivar_set(info, rb_intern("@localPort"), INT2FIX(tcp->localPort));
- rb_ivar_set(info, rb_intern("@remoteAddress"), createString(tcp->remoteAddress));
- rb_ivar_set(info, rb_intern("@remotePort"), INT2FIX(tcp->remotePort));
+ rb_ivar_set(info, rb_intern("@rcvSize"), INT2FIX(tcp->rcvSize));
+ rb_ivar_set(info, rb_intern("@sndSize"), INT2FIX(tcp->sndSize));
}
else if(Ice::UDPConnectionInfoPtr::dynamicCast(p))
{
info = Data_Wrap_Struct(_udpConnectionInfoClass, 0, IceRuby_ConnectionInfo_free, new Ice::ConnectionInfoPtr(p));
Ice::UDPConnectionInfoPtr udp = Ice::UDPConnectionInfoPtr::dynamicCast(p);
- rb_ivar_set(info, rb_intern("@localAddress"), createString(udp->localAddress));
- rb_ivar_set(info, rb_intern("@localPort"), INT2FIX(udp->localPort));
- rb_ivar_set(info, rb_intern("@remoteAddress"), createString(udp->remoteAddress));
- rb_ivar_set(info, rb_intern("@remotePort"), INT2FIX(udp->remotePort));
rb_ivar_set(info, rb_intern("@mcastAddress"), createString(udp->mcastAddress));
rb_ivar_set(info, rb_intern("@mcastPort"), INT2FIX(udp->mcastPort));
- }
- else if(IceSSL::WSSConnectionInfoPtr::dynamicCast(p))
- {
- info = Data_Wrap_Struct(_wssConnectionInfoClass, 0, IceRuby_ConnectionInfo_free, new Ice::ConnectionInfoPtr(p));
-
- IceSSL::WSSConnectionInfoPtr wss = IceSSL::WSSConnectionInfoPtr::dynamicCast(p);
- rb_ivar_set(info, rb_intern("@localAddress"), createString(wss->localAddress));
- rb_ivar_set(info, rb_intern("@localPort"), INT2FIX(wss->localPort));
- rb_ivar_set(info, rb_intern("@remoteAddress"), createString(wss->remoteAddress));
- rb_ivar_set(info, rb_intern("@remotePort"), INT2FIX(wss->remotePort));
- rb_ivar_set(info, rb_intern("@cipher"), createString(wss->cipher));
- rb_ivar_set(info, rb_intern("@certs"), stringSeqToArray(wss->certs));
- rb_ivar_set(info, rb_intern("@verified"), wss->verified ? Qtrue : Qfalse);
-
- volatile VALUE result = callRuby(rb_hash_new);
- for(Ice::HeaderDict::const_iterator q = wss->headers.begin(); q != wss->headers.end(); ++q)
- {
- volatile VALUE key = createString(q->first);
- volatile VALUE value = createString(q->second);
- callRuby(rb_hash_aset, result, key, value);
- }
- rb_ivar_set(info, rb_intern("@headers"), result);
+ rb_ivar_set(info, rb_intern("@rcvSize"), INT2FIX(udp->rcvSize));
+ rb_ivar_set(info, rb_intern("@sndSize"), INT2FIX(udp->sndSize));
}
else if(IceSSL::ConnectionInfoPtr::dynamicCast(p))
{
info = Data_Wrap_Struct(_sslConnectionInfoClass, 0, IceRuby_ConnectionInfo_free, new Ice::ConnectionInfoPtr(p));
IceSSL::ConnectionInfoPtr ssl = IceSSL::ConnectionInfoPtr::dynamicCast(p);
- rb_ivar_set(info, rb_intern("@localAddress"), createString(ssl->localAddress));
- rb_ivar_set(info, rb_intern("@localPort"), INT2FIX(ssl->localPort));
- rb_ivar_set(info, rb_intern("@remoteAddress"), createString(ssl->remoteAddress));
- rb_ivar_set(info, rb_intern("@remotePort"), INT2FIX(ssl->remotePort));
rb_ivar_set(info, rb_intern("@cipher"), createString(ssl->cipher));
rb_ivar_set(info, rb_intern("@certs"), stringSeqToArray(ssl->certs));
rb_ivar_set(info, rb_intern("@verified"), ssl->verified ? Qtrue : Qfalse);
@@ -374,20 +343,24 @@ IceRuby::createConnectionInfo(const Ice::ConnectionInfoPtr& p)
{
info = Data_Wrap_Struct(_ipConnectionInfoClass, 0, IceRuby_ConnectionInfo_free, new Ice::ConnectionInfoPtr(p));
+ }
+ else
+ {
+ info = Data_Wrap_Struct(_connectionInfoClass, 0, IceRuby_ConnectionInfo_free, new Ice::ConnectionInfoPtr(p));
+ }
+
+ if(Ice::IPConnectionInfoPtr::dynamicCast(p))
+ {
Ice::IPConnectionInfoPtr ip = Ice::IPConnectionInfoPtr::dynamicCast(p);
rb_ivar_set(info, rb_intern("@localAddress"), createString(ip->localAddress));
rb_ivar_set(info, rb_intern("@localPort"), INT2FIX(ip->localPort));
rb_ivar_set(info, rb_intern("@remoteAddress"), createString(ip->remoteAddress));
rb_ivar_set(info, rb_intern("@remotePort"), INT2FIX(ip->remotePort));
}
- else
- {
- info = Data_Wrap_Struct(_connectionInfoClass, 0, IceRuby_ConnectionInfo_free, new Ice::ConnectionInfoPtr(p));
- }
+
+ rb_ivar_set(info, rb_intern("@underlying"), createConnectionInfo(p->underlying));
rb_ivar_set(info, rb_intern("@incoming"), p->incoming ? Qtrue : Qfalse);
rb_ivar_set(info, rb_intern("@adapterName"), createString(p->adapterName));
- rb_ivar_set(info, rb_intern("@rcvSize"), INT2FIX(p->rcvSize));
- rb_ivar_set(info, rb_intern("@sndSize"), INT2FIX(p->sndSize));
return info;
}
@@ -462,7 +435,7 @@ IceRuby::initConnection(VALUE iceModule)
//
// WSConnectionInfo
//
- _wsConnectionInfoClass = rb_define_class_under(iceModule, "WSConnectionInfo", _ipConnectionInfoClass);
+ _wsConnectionInfoClass = rb_define_class_under(iceModule, "WSConnectionInfo", _connectionInfoClass);
//
// Instance members.
@@ -472,7 +445,7 @@ IceRuby::initConnection(VALUE iceModule)
//
// SSLConnectionInfo
//
- _sslConnectionInfoClass = rb_define_class_under(iceModule, "SSLConnectionInfo", _ipConnectionInfoClass);
+ _sslConnectionInfoClass = rb_define_class_under(iceModule, "SSLConnectionInfo", _connectionInfoClass);
//
// Instance members.
@@ -480,14 +453,4 @@ IceRuby::initConnection(VALUE iceModule)
rb_define_attr(_wsConnectionInfoClass, "cipher", 1, 0);
rb_define_attr(_wsConnectionInfoClass, "certs", 1, 0);
rb_define_attr(_wsConnectionInfoClass, "verified", 1, 0);
-
- //
- // WSSConnectionInfo
- //
- _wssConnectionInfoClass = rb_define_class_under(iceModule, "WSSConnectionInfo", _sslConnectionInfoClass);
-
- //
- // Instance members.
- //
- rb_define_attr(_wssConnectionInfoClass, "headers", 1, 0);
}
diff --git a/ruby/src/IceRuby/Endpoint.cpp b/ruby/src/IceRuby/Endpoint.cpp
index 0b6db76aa83..46ced54ea11 100644
--- a/ruby/src/IceRuby/Endpoint.cpp
+++ b/ruby/src/IceRuby/Endpoint.cpp
@@ -24,7 +24,6 @@ static VALUE _udpEndpointInfoClass;
static VALUE _wsEndpointInfoClass;
static VALUE _opaqueEndpointInfoClass;
static VALUE _sslEndpointInfoClass;
-static VALUE _wssEndpointInfoClass;
// **********************************************************************
// Endpoint
@@ -132,34 +131,28 @@ IceRuby_EndpointInfo_free(Ice::EndpointPtr* p)
VALUE
IceRuby::createEndpointInfo(const Ice::EndpointInfoPtr& p)
{
+ if(!p)
+ {
+ return Qnil;
+ }
+
VALUE info;
if(Ice::WSEndpointInfoPtr::dynamicCast(p))
{
info = Data_Wrap_Struct(_wsEndpointInfoClass, 0, IceRuby_EndpointInfo_free, new Ice::EndpointInfoPtr(p));
Ice::WSEndpointInfoPtr ws = Ice::WSEndpointInfoPtr::dynamicCast(p);
- rb_ivar_set(info, rb_intern("@host"), createString(ws->host));
- rb_ivar_set(info, rb_intern("@port"), INT2FIX(ws->port));
- rb_ivar_set(info, rb_intern("@sourceAddress"), createString(ws->sourceAddress));
rb_ivar_set(info, rb_intern("@resource"), createString(ws->resource));
}
else if(Ice::TCPEndpointInfoPtr::dynamicCast(p))
{
info = Data_Wrap_Struct(_tcpEndpointInfoClass, 0, IceRuby_EndpointInfo_free, new Ice::EndpointInfoPtr(p));
-
- Ice::TCPEndpointInfoPtr tcp = Ice::TCPEndpointInfoPtr::dynamicCast(p);
- rb_ivar_set(info, rb_intern("@host"), createString(tcp->host));
- rb_ivar_set(info, rb_intern("@port"), INT2FIX(tcp->port));
- rb_ivar_set(info, rb_intern("@sourceAddress"), createString(tcp->sourceAddress));
}
else if(Ice::UDPEndpointInfoPtr::dynamicCast(p))
{
info = Data_Wrap_Struct(_udpEndpointInfoClass, 0, IceRuby_EndpointInfo_free, new Ice::EndpointInfoPtr(p));
Ice::UDPEndpointInfoPtr udp = Ice::UDPEndpointInfoPtr::dynamicCast(p);
- rb_ivar_set(info, rb_intern("@host"), createString(udp->host));
- rb_ivar_set(info, rb_intern("@port"), INT2FIX(udp->port));
- rb_ivar_set(info, rb_intern("@sourceAddress"), createString(udp->sourceAddress));
rb_ivar_set(info, rb_intern("@mcastInterface"), createString(udp->mcastInterface));
rb_ivar_set(info, rb_intern("@mcastTtl"), INT2FIX(udp->mcastTtl));
}
@@ -173,39 +166,28 @@ IceRuby::createEndpointInfo(const Ice::EndpointInfoPtr& p)
rb_ivar_set(info, rb_intern("@rawBytes"), v);
rb_ivar_set(info, rb_intern("@rawEncoding"), createEncodingVersion(opaque->rawEncoding));
}
- else if(IceSSL::WSSEndpointInfoPtr::dynamicCast(p))
- {
- info = Data_Wrap_Struct(_wssEndpointInfoClass, 0, IceRuby_EndpointInfo_free, new Ice::EndpointInfoPtr(p));
-
- IceSSL::WSSEndpointInfoPtr wss = IceSSL::WSSEndpointInfoPtr::dynamicCast(p);
- rb_ivar_set(info, rb_intern("@host"), createString(wss->host));
- rb_ivar_set(info, rb_intern("@port"), INT2FIX(wss->port));
- rb_ivar_set(info, rb_intern("@sourceAddress"), createString(wss->sourceAddress));
- rb_ivar_set(info, rb_intern("@resource"), createString(wss->resource));
- }
else if(IceSSL::EndpointInfoPtr::dynamicCast(p))
{
info = Data_Wrap_Struct(_sslEndpointInfoClass, 0, IceRuby_EndpointInfo_free, new Ice::EndpointInfoPtr(p));
-
- IceSSL::EndpointInfoPtr ssl = IceSSL::EndpointInfoPtr::dynamicCast(p);
- rb_ivar_set(info, rb_intern("@host"), createString(ssl->host));
- rb_ivar_set(info, rb_intern("@port"), INT2FIX(ssl->port));
- rb_ivar_set(info, rb_intern("@sourceAddress"), createString(ssl->sourceAddress));
}
else if(Ice::IPEndpointInfoPtr::dynamicCast(p))
{
info = Data_Wrap_Struct(_ipEndpointInfoClass, 0, IceRuby_EndpointInfo_free, new Ice::EndpointInfoPtr(p));
+ }
+ else
+ {
+ info = Data_Wrap_Struct(_endpointInfoClass, 0, IceRuby_EndpointInfo_free, new Ice::EndpointInfoPtr(p));
+ }
+ if(Ice::IPEndpointInfoPtr::dynamicCast(p))
+ {
Ice::IPEndpointInfoPtr ip = Ice::IPEndpointInfoPtr::dynamicCast(p);
rb_ivar_set(info, rb_intern("@host"), createString(ip->host));
rb_ivar_set(info, rb_intern("@port"), INT2FIX(ip->port));
rb_ivar_set(info, rb_intern("@sourceAddress"), createString(ip->sourceAddress));
}
- else
- {
- info = Data_Wrap_Struct(_endpointInfoClass, 0, IceRuby_EndpointInfo_free, new Ice::EndpointInfoPtr(p));
- }
+ rb_ivar_set(info, rb_intern("@underlying"), createEndpointInfo(p->underlying));
rb_ivar_set(info, rb_intern("@timeout"), INT2FIX(p->timeout));
rb_ivar_set(info, rb_intern("@compress"), p->compress ? Qtrue : Qfalse);
return info;
@@ -329,7 +311,7 @@ IceRuby::initEndpoint(VALUE iceModule)
//
// WSEndpointInfo
//
- _wsEndpointInfoClass = rb_define_class_under(iceModule, "WSEndpointInfo", _tcpEndpointInfoClass);
+ _wsEndpointInfoClass = rb_define_class_under(iceModule, "WSEndpointInfo", _endpointInfoClass);
//
// Instance members.
@@ -350,17 +332,7 @@ IceRuby::initEndpoint(VALUE iceModule)
//
// SSLEndpointInfo
//
- _sslEndpointInfoClass = rb_define_class_under(iceModule, "SSLEndpointInfo", _ipEndpointInfoClass);
-
- //
- // WSSEndpointInfo
- //
- _wssEndpointInfoClass = rb_define_class_under(iceModule, "WSSEndpointInfo", _sslEndpointInfoClass);
-
- //
- // Instance members.
- //
- rb_define_attr(_wssEndpointInfoClass, "resource", 1, 0);
+ _sslEndpointInfoClass = rb_define_class_under(iceModule, "SSLEndpointInfo", _endpointInfoClass);
}
bool