aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLoïc Hoguin <[email protected]>2014-09-11 17:15:55 +0200
committerLoïc Hoguin <[email protected]>2014-09-11 17:15:55 +0200
commit22e0f96a6ca9288dca338ffec53f15da06abd839 (patch)
treeaf53d2f49d847755fefe539c55f034b8a817e75e
parent21bc90184f3c904332f5e660f89d3a32bb4289e6 (diff)
parent9176df9eb5a10c3aaee0dd4bc424f9453c441c9d (diff)
downloadranch-22e0f96a6ca9288dca338ffec53f15da06abd839.tar.gz
ranch-22e0f96a6ca9288dca338ffec53f15da06abd839.tar.bz2
ranch-22e0f96a6ca9288dca338ffec53f15da06abd839.zip
Merge branch 'add_transport_secure' of git://github.com/matrixise/ranch
-rw-r--r--ROADMAP.md7
-rw-r--r--src/ranch_ssl.erl5
-rw-r--r--src/ranch_tcp.erl5
-rw-r--r--src/ranch_transport.erl2
4 files changed, 11 insertions, 8 deletions
diff --git a/ROADMAP.md b/ROADMAP.md
index deb6604..c2cb8a5 100644
--- a/ROADMAP.md
+++ b/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.
diff --git a/src/ranch_ssl.erl b/src/ranch_ssl.erl
index 7969401..61b939b 100644
--- a/src/ranch_ssl.erl
+++ b/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()}.
diff --git a/src/ranch_tcp.erl b/src/ranch_tcp.erl
index 8e24d3c..e3bcf81 100644
--- a/src/ranch_tcp.erl
+++ b/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()}.
diff --git a/src/ranch_transport.erl b/src/ranch_transport.erl
index 2ccbd4d..83cc9bb 100644
--- a/src/ranch_transport.erl
+++ b/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())