diff options
Diffstat (limited to '')
-rw-r--r-- | lib/irc/puppet_connection.ex | 48 |
1 files changed, 24 insertions, 24 deletions
diff --git a/lib/irc/puppet_connection.ex b/lib/irc/puppet_connection.ex index 4604b04..f12cbf7 100644 --- a/lib/irc/puppet_connection.ex +++ b/lib/irc/puppet_connection.ex @@ -76,14 +76,14 @@ defmodule IRC.PuppetConnection do end def handle_continue(:connect, state) do - ipv6 = if @env == :prod do - subnet = LSG.Subnet.assign(state.account_id) - IRC.Account.put_meta(IRC.Account.get(state.account_id), "subnet", subnet) - ip = Pfx.host(subnet, 1) - {:ok, ipv6} = :inet_parse.ipv6_address(to_charlist(ip)) - System.cmd("add-ip6", [ip]) - ipv6 - end + #ipv6 = if @env == :prod do + # subnet = LSG.Subnet.assign(state.account_id) + # IRC.Account.put_meta(IRC.Account.get(state.account_id), "subnet", subnet) + # ip = Pfx.host(subnet, 1) + # {:ok, ipv6} = :inet_parse.ipv6_address(to_charlist(ip)) + # System.cmd("add-ip6", [ip]) + # ipv6 + #end conn = IRC.Connection.lookup(state.connection_id) client_opts = [] @@ -102,21 +102,21 @@ defmodule IRC.PuppetConnection do {:nodelay, true} ] - {ip, opts} = case {ipv6, :inet_res.resolve(to_charlist(conn.host), :in, :aaaa)} do - {ipv6, {:ok, {:dns_rec, _dns_header, _query, rrs = [{:dns_rr, _, _, _, _, _, _, _, _, _} | _], _, _}}} -> - ip = rrs - |> Enum.map(fn({:dns_rr, _, :aaaa, :in, _, _, ipv6, _, _, _}) -> ipv6 end) - |> Enum.shuffle() - |> List.first() - - opts = [ - :inet6, - {:ifaddr, ipv6} - ] - {ip, opts} - _ -> - {to_charlist(conn.host), []} - end + #{ip, opts} = case {ipv6, :inet_res.resolve(to_charlist(conn.host), :in, :aaaa)} do + # {ipv6, {:ok, {:dns_rec, _dns_header, _query, rrs = [{:dns_rr, _, _, _, _, _, _, _, _, _} | _], _, _}}} -> + # ip = rrs + # |> Enum.map(fn({:dns_rr, _, :aaaa, :in, _, _, ipv6, _, _, _}) -> ipv6 end) + # |> Enum.shuffle() + # |> List.first() + + # opts = [ + # :inet6, + # {:ifaddr, ipv6} + # ] + # {ip, opts} + # _ -> + {ip, opts} = {to_charlist(conn.host), []} + #end conn_fun = if conn.tls, do: :connect_ssl!, else: :connect! apply(ExIRC.Client, conn_fun, [client, ip, conn.port, base_opts ++ opts]) @@ -152,7 +152,7 @@ defmodule IRC.PuppetConnection do reply_fun = fn(text) -> IRC.Connection.broadcast_message(state.network, channel, text) end - message = %IRC.Message{at: NaiveDateTime.utc_now(), text: text, network: state.network, account: account, sender: sender, channel: channel, replyfun: reply_fun, trigger: IRC.Connection.extract_trigger(text), meta: meta} + message = %IRC.Message{id: FlakeId.get(), at: NaiveDateTime.utc_now(), text: text, network: state.network, account: account, sender: sender, channel: channel, replyfun: reply_fun, trigger: IRC.Connection.extract_trigger(text), meta: meta} message = case IRC.UserTrack.messaged(message) do :ok -> message {:ok, message} -> message |