PROTON-914: Fix for getting the SSL peer hostname in Ruby. Previously the call was returning the result code rather than the actual hostname value.
Project: http://git-wip-us.apache.org/repos/asf/qpid-proton/repo Commit: http://git-wip-us.apache.org/repos/asf/qpid-proton/commit/cbb68004 Tree: http://git-wip-us.apache.org/repos/asf/qpid-proton/tree/cbb68004 Diff: http://git-wip-us.apache.org/repos/asf/qpid-proton/diff/cbb68004 Branch: refs/heads/PROTON-781-ruby-reactor-apis Commit: cbb6800496e88a0a4f22523c0f0f68afd3424323 Parents: 0f90a7e Author: Darryl L. Pierce <mcpie...@gmail.com> Authored: Wed Jun 17 11:12:32 2015 -0400 Committer: Darryl L. Pierce <mcpie...@gmail.com> Committed: Wed Jun 17 11:51:40 2015 -0400 ---------------------------------------------------------------------- proton-c/bindings/ruby/lib/core/ssl.rb | 18 +++++++++++------- proton-c/bindings/ruby/lib/core/transport.rb | 5 ++--- proton-c/bindings/ruby/ruby.i | 13 +------------ 3 files changed, 14 insertions(+), 22 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/cbb68004/proton-c/bindings/ruby/lib/core/ssl.rb ---------------------------------------------------------------------- diff --git a/proton-c/bindings/ruby/lib/core/ssl.rb b/proton-c/bindings/ruby/lib/core/ssl.rb index 9c4a3e9..0b16075 100644 --- a/proton-c/bindings/ruby/lib/core/ssl.rb +++ b/proton-c/bindings/ruby/lib/core/ssl.rb @@ -66,11 +66,6 @@ module Qpid::Proton # @private PROTON_METHOD_PREFIX = "pn_ssl" - # @!attribute peer_hostname - # - # @return [String] The peer hostname. - proton_accessor :peer_hostname - # @private include Util::ErrorHandler @@ -108,10 +103,10 @@ module Qpid::Proton def initialize(impl, domain, session_details, session_id) @impl = impl - @domain = domain + @domain = domain.impl unless domain.nil? @session_details = session_details @session_id = session_id - Cproton.pn_ssl_init(@impl, @domain.impl, @session_id) + Cproton.pn_ssl_init(@impl, @domain, @session_id) end public @@ -155,6 +150,15 @@ module Qpid::Proton Cproton.pn_ssl_resume_status(@impl) end + # Gets the peer hostname. + # + # @return [String] The peer hostname. + def peer_hostname + (error, name) = Cproton.pn_ssl_get_peer_hostname(@impl, 1024) + raise SSLError.new if error < 0 + return name + end + end end http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/cbb68004/proton-c/bindings/ruby/lib/core/transport.rb ---------------------------------------------------------------------- diff --git a/proton-c/bindings/ruby/lib/core/transport.rb b/proton-c/bindings/ruby/lib/core/transport.rb index 206f97d..9ba5dc8 100644 --- a/proton-c/bindings/ruby/lib/core/transport.rb +++ b/proton-c/bindings/ruby/lib/core/transport.rb @@ -398,13 +398,12 @@ module Qpid::Proton # @return [SSL] The SSL object. # def ssl(domain = nil, session_details = nil) - self.ssl = SSL.create(self, domain, session_details) if self.ssl.nil? - self.ssl + @ssl ||= SSL.create(self, domain, session_details) if @ssl.nil? end # @private def ssl? - self.respond_to?(:ssl) && !self.ssl.nil? + !@ssl.nil? end end http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/cbb68004/proton-c/bindings/ruby/ruby.i ---------------------------------------------------------------------- diff --git a/proton-c/bindings/ruby/ruby.i b/proton-c/bindings/ruby/ruby.i index 0534808..678a085 100644 --- a/proton-c/bindings/ruby/ruby.i +++ b/proton-c/bindings/ruby/ruby.i @@ -556,18 +556,7 @@ VALUE pni_address_of(void *object) { // %} //%ignore pn_collector_put; -%rename(pn_ssl_get_peer_hostname) wrap_pn_ssl_get_peer_hostname; -%inline %{ - int wrap_pn_ssl_get_peer_hostname(pn_ssl_t *ssl, char *OUTPUT, size_t *OUTPUT_SIZE) { - ssize_t size = pn_ssl_get_peer_hostname(ssl, OUTPUT, *OUTPUT_SIZE); - if (size >= 0) { - *OUTPUT_SIZE = size; - } else { - *OUTPUT_SIZE = 0; - } - return size; - } - %} +int pn_ssl_get_peer_hostname(pn_ssl_t *ssl, char *OUTPUT, size_t *OUTPUT_SIZE); %ignore pn_ssl_get_peer_hostname; %include "proton/cproton.i" --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@qpid.apache.org For additional commands, e-mail: commits-h...@qpid.apache.org