Skip to content

Commit

Permalink
Make options unique
Browse files Browse the repository at this point in the history
  • Loading branch information
danschultzer committed Feb 24, 2024
1 parent fcf8fe1 commit e208da4
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 6 deletions.
9 changes: 6 additions & 3 deletions lib/thousand_island/transports/ssl.ex
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,12 @@ defmodule ThousandIsland.Transports.SSL do

# We can't use Keyword functions here because :ssl accepts non-keyword style options
resolved_options =
default_options ++
user_options ++
@hardcoded_options
Enum.uniq_by(
@hardcoded_options ++ user_options ++ default_options,
fn
{key, _} when is_atom(key) -> key
key when is_atom(key) -> key
end)

if not Enum.any?(
[:keyfile, :key, :sni_hosts, :sni_fun],
Expand Down
9 changes: 6 additions & 3 deletions lib/thousand_island/transports/tcp.ex
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,12 @@ defmodule ThousandIsland.Transports.TCP do

# We can't use Keyword functions here because :gen_tcp accepts non-keyword style options
resolved_options =
default_options ++
user_options ++
@hardcoded_options
Enum.uniq_by(
@hardcoded_options ++ user_options ++ default_options,
fn
{key, _} when is_atom(key) -> key
key when is_atom(key) -> key
end)

:gen_tcp.listen(port, resolved_options)
end
Expand Down

0 comments on commit e208da4

Please sign in to comment.