Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow 'rediss' URL scheme to define whether SSL is enabled #58

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ Option | Description
`:host` | The redis-server host IP | `"127.0.0.1"` |
`:port` | The redis-server port | `6379` |
`:password` | The redis-server password | `""` |
`:ssl` | The redis-server SSL flag | `false` |
`:compression_level` | Compression level applied to serialized terms (`0` - none, `9` - highest) | `0` |
`:socket_opts` | The redis-server network layer options | `[]` |

Expand Down
5 changes: 4 additions & 1 deletion lib/phoenix_pubsub_redis/redis.ex
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ defmodule Phoenix.PubSub.Redis do
* `:host` - The redis-server host IP, defaults `"127.0.0.1"`
* `:port` - The redis-server port, defaults `6379`
* `:password` - The redis-server password, defaults `""`
* `:ssl` - The redis-server ssl option, defaults `false`
* `:ssl` - The redis-server ssl option, defaults `false`, unless the URL scheme is `rediss`
* `:redis_pool_size` - The size of the redis connection pool. Defaults `5`
* `:compression_level` - Compression level applied to serialized terms - from `0` (no compression), to `9` (highest). Defaults `0`
* `:socket_opts` - List of options that are passed to the network layer when connecting to the Redis server. Default `[]`
Expand Down Expand Up @@ -111,9 +111,12 @@ defmodule Phoenix.PubSub.Redis do
[username, password] -> [username: username, password: password]
end

ssl = info.scheme == "rediss"

opts
|> Keyword.merge(user_opts)
|> Keyword.merge(host: info.host, port: info.port || @defaults[:port])
|> Keyword.put(:ssl, ssl)
end

defp validate_node_name!(node_name) do
Expand Down