summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorhref <href@random.sh>2021-09-08 16:19:06 +0200
committerhref <href@random.sh>2021-09-08 16:19:06 +0200
commitc02feaa5d8858ae4725423cf065924670cfb2e12 (patch)
treea71779508a7c7b242cffe42d0295ea297d977807
parentexirc: update (diff)
the bug and their fixies
-rw-r--r--lib/irc/connection.ex24
-rw-r--r--lib/irc/puppet_connection.ex4
2 files changed, 16 insertions, 12 deletions
diff --git a/lib/irc/connection.ex b/lib/irc/connection.ex
index fafb0d7..eae5362 100644
--- a/lib/irc/connection.ex
+++ b/lib/irc/connection.ex
@@ -189,7 +189,7 @@ defmodule IRC.Connection do
Logger.metadata(conn: conn.id)
backoff = :backoff.init(@min_backoff, @max_backoff)
|> :backoff.type(:jitter)
- {:ok, %{client: nil, backoff: backoff, conn: conn, connected_server: nil, connected_port: nil, network: nil}, {:continue, :connect}}
+ {:ok, %{client: nil, backoff: backoff, conn: conn, connected_server: nil, connected_port: nil, network: conn.network}, {:continue, :connect}}
end
@triggers %{
@@ -263,7 +263,7 @@ defmodule IRC.Connection do
end
# ISUP
- def handle_info({:isup, network}, state) do
+ def handle_info({:isup, network}, state) when is_binary(network) do
IRC.UserTrack.clear_network(state.network)
if network != state.network do
Logger.warn("Possibly misconfigured network: #{network} != #{state.network}")
@@ -280,15 +280,19 @@ defmodule IRC.Connection do
# Received something in a channel
def handle_info({:received, text, sender, chan}, state) do
user = IRC.UserTrack.find_by_nick(state.network, sender.nick)
- if !Map.get(user.options, :puppet) do
- reply_fun = fn(text) -> irc_reply(state, {chan, sender}, text) end
- account = IRC.Account.lookup(sender)
- message = %IRC.Message{at: NaiveDateTime.utc_now(), text: text, network: state.network, account: account, sender: sender, channel: chan, replyfun: reply_fun, trigger: extract_trigger(text)}
- message = case IRC.UserTrack.messaged(message) do
- :ok -> message
- {:ok, message} -> message
+ if !user do
+ Logger.error("Could not lookup user for message: #{inspect {state.network, sender.nick}}")
+ else
+ if !Map.get(user.options, :puppet) do
+ reply_fun = fn(text) -> irc_reply(state, {chan, sender}, text) end
+ account = IRC.Account.lookup(sender)
+ message = %IRC.Message{at: NaiveDateTime.utc_now(), text: text, network: state.network, account: account, sender: sender, channel: chan, replyfun: reply_fun, trigger: extract_trigger(text)}
+ message = case IRC.UserTrack.messaged(message) do
+ :ok -> message
+ {:ok, message} -> message
+ end
+ publish(message, ["#{message.network}/#{chan}:messages"])
end
- publish(message, ["#{message.network}/#{chan}:messages"])
end
{:noreply, state}
end
diff --git a/lib/irc/puppet_connection.ex b/lib/irc/puppet_connection.ex
index b92ef2b..73622da 100644
--- a/lib/irc/puppet_connection.ex
+++ b/lib/irc/puppet_connection.ex
@@ -102,8 +102,8 @@ defmodule IRC.PuppetConnection do
{:nodelay, true}
]
- {ip, opts} = case {@env == :prod && ipv6, :inet_res.resolve(to_charlist(conn.host), :in, :aaaa)} do
- {true, {:ok, {:dns_rec, _dns_header, _query, rrs = [{:dns_rr, _, _, _, _, _, _, _, _, _} | _], _, _}}} ->
+ {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()