summaryrefslogtreecommitdiff
path: root/components/dlink_tcp
diff options
context:
space:
mode:
authorUlf Wiger <ulf@wiger.net>2015-06-02 18:06:24 +0200
committerUlf Wiger <ulf@feuerlabs.com>2015-06-10 11:31:17 +0200
commit72d6344a9e95b79ac5166a43255f14481641b30c (patch)
tree2c6e4955f0ab668d6edc8db79d2cd4887c643c42 /components/dlink_tcp
parent328c1c0917ca36ce4aaa46ca529548d4e14f9b30 (diff)
downloadrvi_core-72d6344a9e95b79ac5166a43255f14481641b30c.tar.gz
Service invocation signed and validated
Diffstat (limited to 'components/dlink_tcp')
-rw-r--r--components/dlink_tcp/src/dlink_tcp_rpc.erl21
1 files changed, 15 insertions, 6 deletions
diff --git a/components/dlink_tcp/src/dlink_tcp_rpc.erl b/components/dlink_tcp/src/dlink_tcp_rpc.erl
index cae4143..192452f 100644
--- a/components/dlink_tcp/src/dlink_tcp_rpc.erl
+++ b/components/dlink_tcp/src/dlink_tcp_rpc.erl
@@ -303,9 +303,17 @@ handle_socket(FromPid, PeerIP, PeerPort, data,
false
end;
-handle_socket(FromPid, RemoteIP, RemotePort, data,
- { service_announce, TransactionID, JWT }, [CompSpec]) ->
- Conn = {RemoteIP, RemotePort},
+handle_socket(FromPid, IP, Port, data,
+ { service_announce, TransactionID, JWT } = _Data, [CompSpec]) ->
+ ?debug("dlink_tcp_rpc:handle_socket(~p,~p,~p,data,~p)~n",
+ [FromPid, IP, Port, _Data]),
+ Conn = {RemoteIP, RemotePort} =
+ case connection_manager:find_connection_by_pid(FromPid) of
+ {ok, IP1, Port1} ->
+ {IP1, Port1};
+ not_found ->
+ {IP, Port}
+ end,
case authorize_rpc:validate_message(CompSpec, JWT, Conn) of
[ok, Msg] ->
handle_availability_msg(
@@ -341,8 +349,9 @@ handle_socket(FromPid, RemoteIP, RemotePort, data,
handle_socket(_FromPid, SetupIP, SetupPort, data,
{ receive_data, ProtocolMod, Data}, [CompSpec]) ->
%% ?info("dlink_tcp:receive_data(): ~p", [ Data ]),
- ?debug("dlink_tcp:receive_data(): SetupAddress: {~p, ~p}", [ SetupIP, SetupPort ]),
- ProtocolMod:receive_message(CompSpec, Data),
+ ?debug("dlink_tcp:receive_data(): SetupAddress: {~p, ~p} "
+ "ProtocolMod = ~p~n", [ SetupIP, SetupPort, ProtocolMod ]),
+ ProtocolMod:receive_message(CompSpec, {SetupIP, SetupPort}, Data),
ok;
@@ -495,7 +504,7 @@ handle_rpc("setup_data_link", Args) ->
{ok, [ {status, rvi_common:json_rpc_status(Res)} , { timeout, Timeout }]};
-handle_rpc("disconenct_data_link", Args) ->
+handle_rpc("disconnect_data_link", Args) ->
{ ok, NetworkAddress} = rvi_common:get_json_element(["network_address"], Args),
[Res] = gen_server:call(?SERVER, { rvi, disconnect_data_link, [NetworkAddress]}),
{ok, [ {status, rvi_common:json_rpc_status(Res)} ]};