From d0da97015667246a6e4a7c7cca335e2082ae1166 Mon Sep 17 00:00:00 2001 From: Ulf Wiger Date: Tue, 15 Dec 2015 11:22:06 -0800 Subject: fixes during debugging on test3 --- components/authorize/src/authorize_keys.erl | 6 +++++- components/authorize/src/authorize_rpc.erl | 4 ++-- components/dlink_tls/src/dlink_tls_rpc.erl | 6 +++--- components/service_edge/src/service_edge_rpc.erl | 2 +- 4 files changed, 11 insertions(+), 7 deletions(-) (limited to 'components') diff --git a/components/authorize/src/authorize_keys.erl b/components/authorize/src/authorize_keys.erl index f651a60..55a950e 100644 --- a/components/authorize/src/authorize_keys.erl +++ b/components/authorize/src/authorize_keys.erl @@ -19,6 +19,7 @@ json_to_public_key/1]). -export([self_signed_public_key/0]). % just temporary +-export([strip_nl/1]). -export([pp_key/1, abbrev/1, abbrev_bin/1, @@ -669,7 +670,10 @@ abbrev_payload(PL) -> abbrev_jwt({Hdr, Body} = X) -> try {Hdr, abbrev_payload(Body)} - catch error:_ -> X end. + catch error:_ -> X end; +abbrev_jwt(X) -> + X. + abbrev_pl(#cred{} = Payload) -> list_to_tuple(lists:map(fun(B) when is_binary(B) -> abbrev_bin(B); diff --git a/components/authorize/src/authorize_rpc.erl b/components/authorize/src/authorize_rpc.erl index 2291d21..ba54f3a 100644 --- a/components/authorize/src/authorize_rpc.erl +++ b/components/authorize/src/authorize_rpc.erl @@ -238,7 +238,7 @@ handle_call({rvi, validate_message, [JWT, Conn | LogId]}, _, State) -> log(LogId, error, "validation FAILED", []), {reply, [not_found], State} end; -handle_call({rvi, get_credentials, [_LogId]}, _From, State) -> +handle_call({rvi, get_credentials, _Args}, _From, State) -> {reply, [ ok, authorize_keys:get_credentials() ], State}; handle_call({rvi, validate_authorization, [JWT, Conn | [_] = LogId]}, _From, State) -> @@ -369,7 +369,7 @@ get_json_element(Path, JSON, Default) -> end. store_cred(CredJWT, Conn, PeerCert, LogId) -> - case authorize_sig:decode_jwt(CredJWT, authorize_keys:provisioning_key()) of + case authorize_sig:decode_jwt(authorize_keys:strip_nl(CredJWT), authorize_keys:provisioning_key()) of {_CHeader, CredStruct} -> case authorize_keys:save_cred(CredStruct, CredJWT, Conn, PeerCert, LogId) of ok -> diff --git a/components/dlink_tls/src/dlink_tls_rpc.erl b/components/dlink_tls/src/dlink_tls_rpc.erl index c0fb3a5..e4d6adf 100644 --- a/components/dlink_tls/src/dlink_tls_rpc.erl +++ b/components/dlink_tls/src/dlink_tls_rpc.erl @@ -44,7 +44,7 @@ -define(DEFAULT_TCP_ADDRESS, "0.0.0.0"). -define(DEFAULT_PING_INTERVAL, 300000). %% Five minutes -define(SERVER, ?MODULE). --define(DLINK_TLS_VERSION, "1.0"). +-define(DLINK_TLS_VERSION, <<"1.0">>). -define(CONNECTION_TABLE, rvi_dlink_tls_connections). -define(SERVICE_TABLE, rvi_dlink_tls_services). @@ -565,7 +565,7 @@ handle_info({ rvi_ping, Pid, Address, Port, Timeout}, St) -> case dlink_tls_conn:is_connection_up(Pid) of true -> ?info("dlink_tls:ping(): Pinging: ~p:~p", [Address, Port]), - dlink_tls_conn:send(Pid, term_to_json({ struct, [{ ?DLINK_ARG_CMD, ?DLINK_CMD_PING }]})), + dlink_tls_conn:send(Pid, [{ ?DLINK_ARG_CMD, ?DLINK_CMD_PING }]), erlang:send_after(Timeout, self(), { rvi_ping, Pid, Address, Port, Timeout }); @@ -689,7 +689,7 @@ send_authorize(Pid, CompSpec) -> [{?DLINK_ARG_CMD, ?DLINK_CMD_AUTHORIZE}, {?DLINK_ARG_VERSION, ?DLINK_TLS_VERSION}, {?DLINK_ARG_ADDRESS, LocalIP}, - {?DLINK_ARG_PORT, integer_to_list(LocalPort)}, + {?DLINK_ARG_PORT, LocalPort}, {?DLINK_ARG_CREDENTIALS, Creds}], CompSpec)). %% dlink_tls_conn:send(Pid, %% term_to_json( diff --git a/components/service_edge/src/service_edge_rpc.erl b/components/service_edge/src/service_edge_rpc.erl index 576dc13..77884d2 100644 --- a/components/service_edge/src/service_edge_rpc.erl +++ b/components/service_edge/src/service_edge_rpc.erl @@ -225,7 +225,7 @@ handle_websocket(WSock, Mesg, Arg) -> {ok, Reply} -> EncReply = rvi_common:term_to_json([{id, ID} |Reply]), ?debug("service_edge_rpc:handle_websocket(~p/~p) reply: ~s", [ WSock, ID, EncReply]), - wse_server:send(WSock, list_to_binary(EncReply)) + wse_server:send(WSock, iolist_to_binary(EncReply)) end, ok. -- cgit v1.2.1