Fix Gopher server to use modern :ranch
This commit is contained in:
parent
7b8d6eca65
commit
d67ab670b0
1 changed files with 16 additions and 12 deletions
|
|
@ -22,14 +22,18 @@ defmodule Pleroma.Gopher.Server do
|
||||||
def init([ip, port]) do
|
def init([ip, port]) do
|
||||||
Logger.info("Starting gopher server on #{port}")
|
Logger.info("Starting gopher server on #{port}")
|
||||||
|
|
||||||
:ranch.start_listener(
|
{:ok, _pid} =
|
||||||
:gopher,
|
:ranch.start_listener(
|
||||||
100,
|
:gopher,
|
||||||
:ranch_tcp,
|
:ranch_tcp,
|
||||||
[ip: ip, port: port],
|
%{
|
||||||
__MODULE__.ProtocolHandler,
|
num_acceptors: 100,
|
||||||
[]
|
max_connections: 100,
|
||||||
)
|
socket_opts: [ip: ip, port: port]
|
||||||
|
},
|
||||||
|
__MODULE__.ProtocolHandler,
|
||||||
|
[]
|
||||||
|
)
|
||||||
|
|
||||||
{:ok, %{ip: ip, port: port}}
|
{:ok, %{ip: ip, port: port}}
|
||||||
end
|
end
|
||||||
|
|
@ -43,13 +47,13 @@ defmodule Pleroma.Gopher.Server.ProtocolHandler do
|
||||||
alias Pleroma.Web.ActivityPub.ActivityPub
|
alias Pleroma.Web.ActivityPub.ActivityPub
|
||||||
alias Pleroma.Web.ActivityPub.Visibility
|
alias Pleroma.Web.ActivityPub.Visibility
|
||||||
|
|
||||||
def start_link(ref, socket, transport, opts) do
|
def start_link(ref, transport, opts) do
|
||||||
pid = spawn_link(__MODULE__, :init, [ref, socket, transport, opts])
|
pid = spawn_link(__MODULE__, :init, [ref, transport, opts])
|
||||||
{:ok, pid}
|
{:ok, pid}
|
||||||
end
|
end
|
||||||
|
|
||||||
def init(ref, socket, transport, [] = _Opts) do
|
def init(ref, transport, opts \\ []) do
|
||||||
:ok = :ranch.accept_ack(ref)
|
{:ok, socket} = :ranch.handshake(ref, opts)
|
||||||
loop(socket, transport)
|
loop(socket, transport)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue