fun (I) when is_integer(I), I >= 0 -> I end;
opt_type(websocket_timeout) ->
fun (I) when is_integer(I), I > 0 -> I end;
+opt_type(websocket_origin) ->
+ fun (O) -> O end;
opt_type(_) ->
- [websocket_ping_interval, websocket_timeout].
+ [websocket_ping_interval, websocket_timeout, websocket_origin].
RequiredHeaders = [{'Upgrade', <<"websocket">>},
{'Connection', ignore}, {'Host', ignore},
{<<"Sec-Websocket-Key">>, ignore},
- {<<"Sec-Websocket-Version">>, <<"13">>}],
+ {<<"Sec-Websocket-Version">>, <<"13">>},
+ {<<"Origin">>, get_origin()}],
F = fun ({Tag, Val}) ->
case lists:keyfind(Tag, 1, Headers) of
websocket_close(Socket, WsHandleLoopPid, SocketMode, _CloseCode) ->
WsHandleLoopPid ! closed,
SocketMode:close(Socket).
+
+get_origin() ->
+ ejabberd_config:get_option({websocket_origin, ejabberd_config:get_myname()}, ignore).
\ No newline at end of file