Browse Source

Merge branch 'add_transport_secure' of git://github.com/matrixise/ranch

Loïc Hoguin 10 years ago
parent
commit
22e0f96a6c
4 changed files with 11 additions and 8 deletions
  1. 0 7
      ROADMAP.md
  2. 5 0
      src/ranch_ssl.erl
  3. 5 0
      src/ranch_tcp.erl
  4. 1 1
      src/ranch_transport.erl

+ 0 - 7
ROADMAP.md

@@ -31,10 +31,3 @@ are not ordered.
 
     We should be able to add more acceptors to a pool but also
     to remove some of them as needed.
-
-*   Add Transport:secure/0.
-
-    Currently Ranch checks if a connection is secure by
-    checking if its name is 'ssl'. This isn't a very modular
-    solution,  adding an API function that returns whether
-    a connection is secure would fix that issue.

+ 5 - 0
src/ranch_ssl.erl

@@ -16,6 +16,7 @@
 -behaviour(ranch_transport).
 
 -export([name/0]).
+-export([secure/0]).
 -export([messages/0]).
 -export([listen/1]).
 -export([accept/2]).
@@ -66,6 +67,10 @@
 
 name() -> ssl.
 
+-spec secure() -> boolean().
+secure() ->
+    true.
+
 messages() -> {ssl, ssl_closed, ssl_error}.
 
 -spec listen(opts()) -> {ok, ssl:sslsocket()} | {error, atom()}.

+ 5 - 0
src/ranch_tcp.erl

@@ -16,6 +16,7 @@
 -behaviour(ranch_transport).
 
 -export([name/0]).
+-export([secure/0]).
 -export([messages/0]).
 -export([listen/1]).
 -export([accept/2]).
@@ -47,6 +48,10 @@
 
 name() -> tcp.
 
+-spec secure() -> boolean().
+secure() ->
+    false.
+
 messages() -> {tcp, tcp_closed, tcp_error}.
 
 -spec listen(opts()) -> {ok, inet:socket()} | {error, atom()}.

+ 1 - 1
src/ranch_transport.erl

@@ -22,7 +22,7 @@
 -export_type([sendfile_opts/0]).
 
 -callback name() -> atom().
-%% @todo -callback caps(secure | sendfile) -> boolean().
+-callback secure() -> boolean().
 -callback messages() -> {OK::atom(), Closed::atom(), Error::atom()}.
 -callback listen(opts()) -> {ok, socket()} | {error, atom()}.
 -callback accept(socket(), timeout())