Skip to content

Commit a664070

Browse files
committed
add ipv6 support via env var
1 parent 91ddbef commit a664070

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

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)