Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Pleroma
pleroma
Commits
5075e8ab
Commit
5075e8ab
authored
Mar 08, 2019
by
kaniini
Browse files
Merge branch 'bugfix/tesla-safety' into 'develop'
tesla hardening Closes
#712
and
#672
See merge request
!912
parents
46200d8f
1f78d23e
Pipeline
#8779
passed with stages
in 3 minutes and 25 seconds
Changes
5
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
lib/pleroma/http/connection.ex
View file @
5075e8ab
...
...
@@ -8,8 +8,8 @@ defmodule Pleroma.HTTP.Connection do
"""
@hackney_options
[
timeout:
10
000
,
recv_timeout:
20000
,
connect_
timeout:
2_
000
,
recv_timeout:
20
_
000
,
follow_redirect:
true
,
pool:
:federation
]
...
...
@@ -31,6 +31,10 @@ def new(opts \\ []) do
#
defp
hackney_options
(
opts
)
do
options
=
Keyword
.
get
(
opts
,
:adapter
,
[])
@hackney_options
++
options
adapter_options
=
Pleroma
.
Config
.
get
([
:http
,
:adapter
],
[])
@hackney_options
|>
Keyword
.
merge
(
adapter_options
)
|>
Keyword
.
merge
(
options
)
end
end
lib/pleroma/http/http.ex
View file @
5075e8ab
...
...
@@ -27,22 +27,29 @@ defmodule Pleroma.HTTP do
"""
def
request
(
method
,
url
,
body
\\
""
,
headers
\\
[],
options
\\
[])
do
options
=
process_request_options
(
options
)
|>
process_sni_options
(
url
)
|>
process_adapter_options
()
params
=
Keyword
.
get
(
options
,
:params
,
[])
%{}
|>
Builder
.
method
(
method
)
|>
Builder
.
headers
(
headers
)
|>
Builder
.
opts
(
options
)
|>
Builder
.
url
(
url
)
|>
Builder
.
add_param
(
:body
,
:body
,
body
)
|>
Builder
.
add_param
(
:query
,
:query
,
params
)
|>
Enum
.
into
([])
|>
(
&
Tesla
.
request
(
Connection
.
new
(),
&1
))
.
()
try
do
options
=
process_request_options
(
options
)
|>
process_sni_options
(
url
)
params
=
Keyword
.
get
(
options
,
:params
,
[])
%{}
|>
Builder
.
method
(
method
)
|>
Builder
.
headers
(
headers
)
|>
Builder
.
opts
(
options
)
|>
Builder
.
url
(
url
)
|>
Builder
.
add_param
(
:body
,
:body
,
body
)
|>
Builder
.
add_param
(
:query
,
:query
,
params
)
|>
Enum
.
into
([])
|>
(
&
Tesla
.
request
(
Connection
.
new
(
options
),
&1
))
.
()
rescue
e
->
{
:error
,
e
}
catch
:exit
,
e
->
{
:error
,
e
}
end
end
defp
process_sni_options
(
options
,
nil
),
do
:
options
...
...
@@ -57,12 +64,6 @@ defp process_sni_options(options, url) do
end
end
def
process_adapter_options
(
options
)
do
adapter_options
=
Pleroma
.
Config
.
get
([
:http
,
:adapter
],
[])
options
++
[
adapter:
adapter_options
]
end
def
process_request_options
(
options
)
do
config
=
Application
.
get_env
(
:pleroma
,
:http
,
[])
proxy
=
Keyword
.
get
(
config
,
:proxy_url
,
nil
)
...
...
lib/pleroma/web/mastodon_api/mastodon_api_controller.ex
View file @
5075e8ab
...
...
@@ -1452,7 +1452,6 @@ def suggestions(%{assigns: %{user: user}} = conn, _) do
url
,
[],
adapter:
[
timeout:
timeout
,
recv_timeout:
timeout
,
pool:
:default
]
...
...
lib/pleroma/web/rel_me.ex
View file @
5075e8ab
...
...
@@ -5,7 +5,6 @@
defmodule
Pleroma
.
Web
.
RelMe
do
@hackney_options
[
pool:
:media
,
timeout:
2_000
,
recv_timeout:
2_000
,
max_body:
2_000_000
]
...
...
lib/pleroma/web/rich_media/parser.ex
View file @
5075e8ab
...
...
@@ -11,7 +11,6 @@ defmodule Pleroma.Web.RichMedia.Parser do
@hackney_options
[
pool:
:media
,
timeout:
2_000
,
recv_timeout:
2_000
,
max_body:
2_000_000
]
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment