Scott Hiett commited on
Commit
794c5a3
2 Parent(s): 91ddbef 7c3ef62

Merge pull request #28 from hiett/ipv6

Browse files
Files changed (2) hide show
  1. README.md +3 -1
  2. lib/srh.ex +14 -1
README.md CHANGED
@@ -142,4 +142,6 @@ Once you have created this, mount it to the docker container to the `/app/srh-co
142
  | 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: |
143
  | SRH_TOKEN | `<required if SRH_MODE = env>` | Set the token that the Rest API will require |
144
  | 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`.
 
 
 
142
  | 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: |
143
  | SRH_TOKEN | `<required if SRH_MODE = env>` | Set the token that the Rest API will require |
144
  | 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`. |
146
+ | SRH_PORT | `80` | Configure the port SRH runs on. |
147
+ | SRH_IPV6 | `false` | Set to `true` to enabled IPv6 support. |
lib/srh.ex CHANGED
@@ -16,7 +16,8 @@ defmodule Srh do
16
  scheme: :http,
17
  plug: Srh.Http.BaseRouter,
18
  options: [
19
- port: port
 
20
  ]
21
  }
22
  ]
@@ -25,4 +26,16 @@ defmodule Srh do
25
 
26
  Supervisor.start_link(children, opts)
27
  end
 
 
 
 
 
 
 
 
 
 
 
 
28
  end
 
16
  scheme: :http,
17
  plug: Srh.Http.BaseRouter,
18
  options: [
19
+ port: port,
20
+ net: check_inet_mode()
21
  ]
22
  }
23
  ]
 
26
 
27
  Supervisor.start_link(children, opts)
28
  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
41
  end