Gopher server doesn't support binding to localhost
In my prod.exs
, I have:
config :pleroma, :gopher,
enabled: true,
ip: {127, 0, 0, 1},
port: 7070
In https://git.pleroma.social/pleroma/pleroma/blob/develop/lib/pleroma/gopher/server.ex , I see:
defmodule Pleroma.Gopher.Server do
use GenServer
require Logger
@gopher Application.get_env(:pleroma, :gopher)
def start_link() do
ip = Keyword.get(@gopher, :ip, {0, 0, 0, 0})
port = Keyword.get(@gopher, :port, 1234)
GenServer.start_link(__MODULE__, [ip, port], [])
end
def init([ip, port]) do
if Keyword.get(@gopher, :enabled, false) do
Logger.info("Starting gopher server on #{port}")
:ranch.start_listener(
:gopher,
100,
:ranch_tcp,
[port: port],
__MODULE__.ProtocolHandler,
[]
)
{:ok, %{ip: ip, port: port}}
else
Logger.info("Gopher server disabled")
{:ok, nil}
end
end
end
So start_link
seems to respect the ip
parameter, but despite it being passed to init
, it's not used anywhere.
With this hunk, ip: {127,0,0,1}
in the configuration has the expected behaviour:
diff --git a/lib/pleroma/gopher/server.ex b/lib/pleroma/gopher/server.ex
index 82e241f..2f89177 100644
--- a/lib/pleroma/gopher/server.ex
+++ b/lib/pleroma/gopher/server.ex
@@ -17,7 +17,7 @@ defmodule Pleroma.Gopher.Server do
:gopher,
100,
:ranch_tcp,
- [port: port],
+ [{:ip, ip}, {:port, port}],
__MODULE__.ProtocolHandler,
[]
)
I'll see about putting an MR together, but I suspect the test framework will be beyond my current elixir powers :/