Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Is it possible to limit the transfer size in a correct way? #84

Open
Speedkore opened this issue Oct 31, 2017 · 2 comments
Open

Is it possible to limit the transfer size in a correct way? #84

Speedkore opened this issue Oct 31, 2017 · 2 comments

Comments

@Speedkore
Copy link

i had to modify the source code in my way to limit big transfers, how could i do it in a right way?
i never receive fragment packets or anything, if i send for example a file of 100MB it is done in one step by Socket.Web.recv() in memory

this is what i did, in file web.ex, line 577:

@SPEC recv(t, boolean, non_neg_integer, Keyword.t) :: { :ok, binary } | { :error, error }
defp recv(%W{socket: socket, version: 13}, mask, length, options) do
length = cond do
length == 127 ->
case socket |> Socket.Stream.recv(8, options) do
{ :ok, << length :: 64 >> } ->
if length > 5_000_000 do
{:error, :transfer_too_large}
else
length
end

@meh
Copy link
Owner

meh commented Oct 31, 2017

The server/client should fragment the packets.

@Speedkore
Copy link
Author

I'm doing this to avoid a malicious attack from the client side that eats all the memory of the server, sending a large bunch of data. How do i tell the server to fragment packets when receiving them? or it's just enough what i did to avoid this kind of attack?

Thanks a lot for the response , you made a great library and it works very well!!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants