Skip to content

Commit 794c5a3

Browse files
authored
Merge pull request #28 from hiett/ipv6
add ipv6 support via env var
2 parents 91ddbef + 7c3ef62 commit 794c5a3

File tree

2 files changed

+17
-2
lines changed

2 files changed

+17
-2
lines changed

README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,4 +142,6 @@ Once you have created this, mount it to the docker container to the `/app/srh-co
142142
| SRH_MODE | `file` | Can be `env` or `file`. If `file`, see [Connecting to multiple Redis servers](#connecting-to-multiple-redis-servers-at-the-same-time). If set to `env`, you are required to provide the following environment variables: |
143143
| SRH_TOKEN | `<required if SRH_MODE = env>` | Set the token that the Rest API will require |
144144
| SRH_CONNECTION_STRING | `<required if SRH_MODE = env>` | Sets the connection string to the Redis server. |
145-
| SRH_MAX_CONNECTIONS | `3` | Only used if `SRH_MODE=env`.
145+
| SRH_MAX_CONNECTIONS | `3` | Only used if `SRH_MODE=env`. |
146+
| SRH_PORT | `80` | Configure the port SRH runs on. |
147+
| SRH_IPV6 | `false` | Set to `true` to enabled IPv6 support. |

lib/srh.ex

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@ defmodule Srh do
1616
scheme: :http,
1717
plug: Srh.Http.BaseRouter,
1818
options: [
19-
port: port
19+
port: port,
20+
net: check_inet_mode()
2021
]
2122
}
2223
]
@@ -25,4 +26,16 @@ defmodule Srh do
2526

2627
Supervisor.start_link(children, opts)
2728
end
29+
30+
defp check_inet_mode() do
31+
ipv6 = System.get_env("SRH_IPV6", "false")
32+
do_check_inet_mode(ipv6)
33+
end
34+
35+
defp do_check_inet_mode("true") do
36+
IO.puts("Using ipv6.")
37+
:inet6
38+
end
39+
40+
defp do_check_inet_mode(_), do: :inet
2841
end

0 commit comments

Comments
 (0)