|
@@ -92,7 +92,7 @@ init_dispatch() ->
|
|
autobahn_fuzzingclient(Config) ->
|
|
autobahn_fuzzingclient(Config) ->
|
|
doc("Autobahn test suite for the Websocket protocol."),
|
|
doc("Autobahn test suite for the Websocket protocol."),
|
|
Self = self(),
|
|
Self = self(),
|
|
- spawn_link(fun() -> start_port(Config, Self) end),
|
|
|
|
|
|
+ spawn_link(fun() -> do_start_port(Config, Self) end),
|
|
receive autobahn_exit -> ok end,
|
|
receive autobahn_exit -> ok end,
|
|
ct:log("<h2><a href=\"log_private/reports/servers/index.html\">Full report</a></h2>~n"),
|
|
ct:log("<h2><a href=\"log_private/reports/servers/index.html\">Full report</a></h2>~n"),
|
|
Report = config(priv_dir, Config) ++ "reports/servers/index.html",
|
|
Report = config(priv_dir, Config) ++ "reports/servers/index.html",
|
|
@@ -103,20 +103,47 @@ autobahn_fuzzingclient(Config) ->
|
|
false -> ok
|
|
false -> ok
|
|
end.
|
|
end.
|
|
|
|
|
|
-start_port(Config, Pid) ->
|
|
|
|
|
|
+do_start_port(Config, Pid) ->
|
|
Port = open_port({spawn, "wstest -m fuzzingclient -s " ++ config(data_dir, Config) ++ "client.json"},
|
|
Port = open_port({spawn, "wstest -m fuzzingclient -s " ++ config(data_dir, Config) ++ "client.json"},
|
|
[{line, 10000}, {cd, config(priv_dir, Config)}, binary, eof]),
|
|
[{line, 10000}, {cd, config(priv_dir, Config)}, binary, eof]),
|
|
- receive_infinity(Port, Pid).
|
|
|
|
|
|
+ do_receive_infinity(Port, Pid).
|
|
|
|
|
|
-receive_infinity(Port, Pid) ->
|
|
|
|
|
|
+do_receive_infinity(Port, Pid) ->
|
|
receive
|
|
receive
|
|
{Port, {data, {eol, Line}}} ->
|
|
{Port, {data, {eol, Line}}} ->
|
|
io:format(user, "~s~n", [Line]),
|
|
io:format(user, "~s~n", [Line]),
|
|
- receive_infinity(Port, Pid);
|
|
|
|
|
|
+ do_receive_infinity(Port, Pid);
|
|
{Port, eof} ->
|
|
{Port, eof} ->
|
|
Pid ! autobahn_exit
|
|
Pid ! autobahn_exit
|
|
end.
|
|
end.
|
|
|
|
|
|
|
|
+unlimited_connections(Config) ->
|
|
|
|
+ doc("Websocket connections are not limited. The connections "
|
|
|
|
+ "are removed from the count after the handshake completes."),
|
|
|
|
+ _ = [begin
|
|
|
|
+ spawn_link(fun() -> do_connect_and_loop(Config) end),
|
|
|
|
+ timer:sleep(1)
|
|
|
|
+ end || _ <- lists:seq(1, 3000)],
|
|
|
|
+ timer:sleep(1000),
|
|
|
|
+ %% We have at least 3000 client and 3000 server sockets.
|
|
|
|
+ true = length(erlang:ports()) > 6000,
|
|
|
|
+ %% Ranch thinks we have no connections.
|
|
|
|
+ 0 = ranch_server:count_connections(ws),
|
|
|
|
+ ok.
|
|
|
|
+
|
|
|
|
+do_connect_and_loop(Config) ->
|
|
|
|
+ {ok, Socket, _} = do_handshake("/ws_echo", Config),
|
|
|
|
+ do_loop(Socket).
|
|
|
|
+
|
|
|
|
+do_loop(Socket) ->
|
|
|
|
+ %% Masked text hello echoed back clear by the server.
|
|
|
|
+ Mask = 16#37fa213d,
|
|
|
|
+ MaskedHello = do_mask(<<"Hello">>, Mask, <<>>),
|
|
|
|
+ ok = gen_tcp:send(Socket, << 1:1, 0:3, 1:4, 1:1, 5:7, Mask:32, MaskedHello/binary >>),
|
|
|
|
+ {ok, << 1:1, 0:3, 1:4, 0:1, 5:7, "Hello" >>} = gen_tcp:recv(Socket, 0, 6000),
|
|
|
|
+ timer:sleep(1000),
|
|
|
|
+ do_loop(Socket).
|
|
|
|
+
|
|
ws0(Config) ->
|
|
ws0(Config) ->
|
|
doc("Websocket version 0 (hixie-76 draft) is no longer supported."),
|
|
doc("Websocket version 0 (hixie-76 draft) is no longer supported."),
|
|
{ok, Socket} = gen_tcp:connect("localhost", config(port, Config), [binary, {active, false}]),
|
|
{ok, Socket} = gen_tcp:connect("localhost", config(port, Config), [binary, {active, false}]),
|