qpid-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From acon...@apache.org
Subject [08/24] qpid-proton git commit: PROTON-860: allow acceptor to be configured for ssl
Date Fri, 22 May 2015 19:45:31 GMT
PROTON-860: allow acceptor to be configured for ssl


Project: http://git-wip-us.apache.org/repos/asf/qpid-proton/repo
Commit: http://git-wip-us.apache.org/repos/asf/qpid-proton/commit/995e00d7
Tree: http://git-wip-us.apache.org/repos/asf/qpid-proton/tree/995e00d7
Diff: http://git-wip-us.apache.org/repos/asf/qpid-proton/diff/995e00d7

Branch: refs/heads/go1
Commit: 995e00d70b6f9005e116e352507127d9c930a4db
Parents: d5bd60d
Author: Gordon Sim <gsim@redhat.com>
Authored: Wed May 6 12:50:11 2015 +0100
Committer: Gordon Sim <gsim@redhat.com>
Committed: Thu May 14 13:24:55 2015 +0100

----------------------------------------------------------------------
 proton-c/bindings/python/proton/reactor.py | 12 +++++++++---
 proton-c/include/proton/reactor.h          |  2 ++
 proton-c/src/reactor/acceptor.c            | 15 +++++++++++++++
 3 files changed, 26 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/995e00d7/proton-c/bindings/python/proton/reactor.py
----------------------------------------------------------------------
diff --git a/proton-c/bindings/python/proton/reactor.py b/proton-c/bindings/python/proton/reactor.py
index 09cbc23..0145a25 100644
--- a/proton-c/bindings/python/proton/reactor.py
+++ b/proton-c/bindings/python/proton/reactor.py
@@ -51,6 +51,9 @@ class Acceptor(Wrapper):
     def __init__(self, impl):
         Wrapper.__init__(self, impl)
 
+    def set_ssl_domain(self, ssl_domain):
+        pn_acceptor_set_ssl_domain(self._impl, ssl_domain._domain)
+
     def close(self):
         pn_acceptor_close(self._impl)
 
@@ -742,10 +745,13 @@ class Container(Reactor):
         on the interface and port specified.
         """
         url = Url(url)
+        acceptor = self.acceptor(url.host, url.port)
         ssl_config = ssl_domain
-        if not ssl_config and url.scheme == 'amqps':
-            ssl_config = self.ssl_domain
-        return self.acceptor(url.host, url.port)
+        if not ssl_config and url.scheme == 'amqps' and self.ssl:
+            ssl_config = self.ssl.server
+        if ssl_config:
+            acceptor.set_ssl_domain(ssl_config)
+        return acceptor
 
     def do_work(self, timeout=None):
         if timeout:

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/995e00d7/proton-c/include/proton/reactor.h
----------------------------------------------------------------------
diff --git a/proton-c/include/proton/reactor.h b/proton-c/include/proton/reactor.h
index 36ee336..59b2282 100644
--- a/proton-c/include/proton/reactor.h
+++ b/proton-c/include/proton/reactor.h
@@ -26,6 +26,7 @@
 #include <proton/type_compat.h>
 #include <proton/event.h>
 #include <proton/selectable.h>
+#include <proton/ssl.h>
 
 #ifdef __cplusplus
 extern "C" {
@@ -85,6 +86,7 @@ PN_EXTERN void pn_reactor_run(pn_reactor_t *reactor);
 PN_EXTERN pn_task_t *pn_reactor_schedule(pn_reactor_t *reactor, int delay, pn_handler_t *handler);
 
 
+PN_EXTERN void pn_acceptor_set_ssl_domain(pn_acceptor_t *acceptor, pn_ssl_domain_t *domain);
 PN_EXTERN void pn_acceptor_close(pn_acceptor_t *acceptor);
 
 PN_EXTERN pn_timer_t *pn_timer(pn_collector_t *collector);

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/995e00d7/proton-c/src/reactor/acceptor.c
----------------------------------------------------------------------
diff --git a/proton-c/src/reactor/acceptor.c b/proton-c/src/reactor/acceptor.c
index f7202d4..31fa0cc 100644
--- a/proton-c/src/reactor/acceptor.c
+++ b/proton-c/src/reactor/acceptor.c
@@ -29,6 +29,7 @@
 pn_selectable_t *pn_reactor_selectable_transport(pn_reactor_t *reactor, pn_socket_t sock,
pn_transport_t *transport);
 
 PN_HANDLE(PNI_ACCEPTOR_HANDLER)
+PN_HANDLE(PNI_ACCEPTOR_SSL_DOMAIN)
 
 void pni_acceptor_readable(pn_selectable_t *sel) {
   pn_reactor_t *reactor = (pn_reactor_t *) pni_selectable_get_context(sel);
@@ -36,9 +37,15 @@ void pni_acceptor_readable(pn_selectable_t *sel) {
   pn_socket_t sock = pn_accept(pn_reactor_io(reactor), pn_selectable_get_fd(sel), name, 1024);
   pn_handler_t *handler = (pn_handler_t *) pn_record_get(pn_selectable_attachments(sel),
PNI_ACCEPTOR_HANDLER);
   if (!handler) { handler = pn_reactor_get_handler(reactor); }
+  pn_record_t *record = pn_selectable_attachments(sel);
+  pn_ssl_domain_t *ssl_domain = (pn_ssl_domain_t *) pn_record_get(record, PNI_ACCEPTOR_SSL_DOMAIN);
   pn_connection_t *conn = pn_reactor_connection(reactor, handler);
   pn_transport_t *trans = pn_transport();
   pn_transport_set_server(trans);
+  if (ssl_domain) {
+    pn_ssl_t *ssl = pn_ssl(trans);
+    pn_ssl_init(ssl, ssl_domain, 0);
+  }
   pn_transport_bind(trans, conn);
   pn_decref(trans);
   pn_reactor_selectable_transport(reactor, sock, trans);
@@ -80,3 +87,11 @@ void pn_acceptor_close(pn_acceptor_t *acceptor) {
     pn_reactor_update(reactor, sel);
   }
 }
+
+void pn_acceptor_set_ssl_domain(pn_acceptor_t *acceptor, pn_ssl_domain_t *domain)
+{
+  pn_selectable_t *sel = (pn_selectable_t *) acceptor;
+  pn_record_t *record = pn_selectable_attachments(sel);
+  pn_record_def(record, PNI_ACCEPTOR_SSL_DOMAIN, PN_WEAKREF);
+  pn_record_set(record, PNI_ACCEPTOR_SSL_DOMAIN, domain);
+}


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org


Mime
View raw message