Skip to content

Commit

Permalink
Adjust buffer sizes
Browse files Browse the repository at this point in the history
  • Loading branch information
LVala committed Aug 21, 2023
1 parent 13c27b7 commit 8ff4258
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions lib/rel/listener.ex
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ defmodule Rel.Listener do
alias ExSTUN.Message.Type
alias ExSTUN.Message.Attribute.{Username, XORMappedAddress}

@buf_size 1024 * 1024 * 1024
@buf_size 2 * 1024
@default_alloc_ports MapSet.new(49_152..65_535)

@spec start_link(term()) :: {:ok, pid()}
Expand All @@ -42,15 +42,14 @@ defmodule Rel.Listener do
:ok = :socket.setopt(socket, {:socket, :reuseport}, true)
:ok = :socket.setopt(socket, {:socket, :rcvbuf}, @buf_size)
:ok = :socket.setopt(socket, {:socket, :sndbuf}, @buf_size)
:ok = :socket.setopt(socket, {:otp, :rcvbuf}, @buf_size)
:ok = :socket.bind(socket, %{family: :inet, addr: ip, port: port})

spawn(Rel.Monitor, :start, [self(), socket])

recv_loop(socket, id)
end

defp recv_loop(socket) do
defp recv_loop(socket, id) do
case :socket.recvfrom(socket) do
{:ok, {%{addr: client_addr, port: client_port}, packet}} ->
:telemetry.execute([:listener, :client], %{inbound: byte_size(packet)}, %{listener_id: id})
Expand Down

0 comments on commit 8ff4258

Please sign in to comment.