Skip to content

Commit 390dfed

Browse files
Merge pull request #273 from tt/use-get-peer-data-function
Use `get_peer_data` function
2 parents 5e688de + 81b76ed commit 390dfed

File tree

4 files changed

+4
-6
lines changed

4 files changed

+4
-6
lines changed

lib/sentry/plug.ex

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@ if Code.ensure_loaded?(Plug) do
171171
headers: handle_data(conn, header_scrubber),
172172
env: %{
173173
"REMOTE_ADDR" => remote_address(conn.remote_ip),
174-
"REMOTE_PORT" => remote_port(conn.peer),
174+
"REMOTE_PORT" => Plug.Conn.get_peer_data(conn).port,
175175
"SERVER_NAME" => conn.host,
176176
"SERVER_PORT" => conn.port,
177177
"REQUEST_ID" => Plug.Conn.get_resp_header(conn, request_id) |> List.first()
@@ -185,8 +185,6 @@ if Code.ensure_loaded?(Plug) do
185185
|> to_string()
186186
end
187187

188-
defp remote_port({_, port}), do: port
189-
190188
defp handle_data(_conn, nil), do: %{}
191189

192190
defp handle_data(conn, {module, fun}) do

mix.exs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ defmodule Sentry.Mixfile do
2727
{:hackney, "~> 1.8 or 1.6.5"},
2828
{:uuid, "~> 1.0"},
2929
{:poison, "~> 1.5 or ~> 2.0 or ~> 3.0"},
30-
{:plug, "~> 1.0", optional: true},
30+
{:plug, "~> 1.6", optional: true},
3131
{:phoenix, "~> 1.3", optional: true},
3232
{:dialyxir, "> 0.0.0", only: [:dev], runtime: false},
3333
{:ex_doc, "~> 0.18.0", only: :dev},

mix.lock

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
"parse_trans": {:hex, :parse_trans, "3.2.0", "2adfa4daf80c14dc36f522cf190eb5c4ee3e28008fc6394397c16f62a26258c2", [:rebar3], [], "hexpm"},
1717
"phoenix": {:hex, :phoenix, "1.3.2", "2a00d751f51670ea6bc3f2ba4e6eb27ecb8a2c71e7978d9cd3e5de5ccf7378bd", [:mix], [{:cowboy, "~> 1.0", [hex: :cowboy, repo: "hexpm", optional: true]}, {:phoenix_pubsub, "~> 1.0", [hex: :phoenix_pubsub, repo: "hexpm", optional: false]}, {:plug, "~> 1.3.3 or ~> 1.4", [hex: :plug, repo: "hexpm", optional: false]}, {:poison, "~> 2.2 or ~> 3.0", [hex: :poison, repo: "hexpm", optional: false]}], "hexpm"},
1818
"phoenix_pubsub": {:hex, :phoenix_pubsub, "1.0.2", "bfa7fd52788b5eaa09cb51ff9fcad1d9edfeb68251add458523f839392f034c1", [:mix], [], "hexpm"},
19-
"plug": {:hex, :plug, "1.5.0", "224b25b4039bedc1eac149fb52ed456770b9678bbf0349cdd810460e1e09195b", [:mix], [{:cowboy, "~> 1.0.1 or ~> 1.1 or ~> 2.1", [hex: :cowboy, repo: "hexpm", optional: true]}, {:mime, "~> 1.0", [hex: :mime, repo: "hexpm", optional: false]}], "hexpm"},
19+
"plug": {:hex, :plug, "1.6.0", "90d338a44c8cd762c32d3ea324f6728445c6145b51895403854b77f1536f1617", [:mix], [{:cowboy, "~> 1.0.1 or ~> 1.1 or ~> 2.4", [hex: :cowboy, repo: "hexpm", optional: true]}, {:mime, "~> 1.0", [hex: :mime, repo: "hexpm", optional: false]}], "hexpm"},
2020
"poison": {:hex, :poison, "3.1.0", "d9eb636610e096f86f25d9a46f35a9facac35609a7591b3be3326e99a0484665", [:mix], [], "hexpm"},
2121
"ranch": {:hex, :ranch, "1.3.2", "e4965a144dc9fbe70e5c077c65e73c57165416a901bd02ea899cfd95aa890986", [:rebar3], [], "hexpm"},
2222
"ssl_verify_fun": {:hex, :ssl_verify_fun, "1.1.1", "28a4d65b7f59893bc2c7de786dec1e1555bd742d336043fe644ae956c3497fbe", [:make, :rebar], [], "hexpm"},

test/event_test.exs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -462,7 +462,7 @@ defmodule Sentry.EventTest do
462462
mime: "1.2.0",
463463
mimerl: "1.0.2",
464464
parse_trans: "3.2.0",
465-
plug: "1.5.0",
465+
plug: "1.6.0",
466466
poison: "3.1.0",
467467
ranch: "1.3.2",
468468
ssl_verify_fun: "1.1.1",

0 commit comments

Comments
 (0)