diff options
author | Stéphane Wirtel <[email protected]> | 2014-09-02 18:30:04 +0200 |
---|---|---|
committer | Stéphane Wirtel <[email protected]> | 2014-09-02 18:30:04 +0200 |
commit | 9176df9eb5a10c3aaee0dd4bc424f9453c441c9d (patch) | |
tree | a698cb004409227bf44e464b7af05ccbd627db9f | |
parent | adf1822defc2b7cfdc7aca112adabfa1d614043c (diff) | |
download | ranch-9176df9eb5a10c3aaee0dd4bc424f9453c441c9d.tar.gz ranch-9176df9eb5a10c3aaee0dd4bc424f9453c441c9d.tar.bz2 ranch-9176df9eb5a10c3aaee0dd4bc424f9453c441c9d.zip |
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.
-rw-r--r-- | ROADMAP.md | 7 | ||||
-rw-r--r-- | src/ranch_ssl.erl | 5 | ||||
-rw-r--r-- | src/ranch_tcp.erl | 5 | ||||
-rw-r--r-- | src/ranch_transport.erl | 2 |
4 files changed, 11 insertions, 8 deletions
@@ -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 e30b75c..e25bbd6 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()) |