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

Uw dlink tls #8

Open
wants to merge 9 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 9 additions & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,17 @@
sudo: true
language: erlang
otp_release: R16B03-1
python: 2.7
before_install:
- sudo apt-get install bluez libbluetooth-dev
- sudo apt-get install python-dev libffi-dev
- sudo apt-get install bluez libbluetooth-dev lynx
before_script:
- export PATH=$HOME/.local/bin:$PATH
- pip install -r requirements.txt --user `whoami`
script: "make ci"
after_failure: "echo 'logs/raw.log\n'; cat logs/raw.log; for f in `find logs/ct_run*/log*/ -type f`; do echo \"\n$f\n\" ; cat $f; done"
after_failure:
- "echo 'logs/raw.log\n'"
- "html2text logs/index.html"
- "cat logs/raw.log"
- "for f in `find logs/ct_run*/log*/ -type f`; do echo \"\n$f\n\" ; cat $f; done"
- "for f in `ls -1 logs/ct_run*/*.rvi_core.logs/run*/rvi_core_suite*.html`; do echo \"\"; echo \"$f:\"; lynx -dump $f; done"
- "for f in `ls logs/ct_run*/*/log/erlang.log.*`; do echo \"\"; echo \"$f:\"; echo \"\"; cat $f; done"
6 changes: 3 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
# Makefile for the RVI node.
#

.PHONY: all deps compile clean rpm rpmclean test xref ci
.PHONY: all deps compile clean rpm rpmclean test xref ci escript

SCRIPTS=scripts/setup_gen \
scripts/author
Expand Down Expand Up @@ -54,8 +54,8 @@ xref: compile

ci: xref test

test: compile
rebar ct
test: compile escript
rebar ct skip_deps=true

# Create a SOURCES tarball for RPM
rpm_tarball: rpmclean clean
Expand Down
7 changes: 6 additions & 1 deletion components/authorize/src/author.erl
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ cmd("read_sig", Opts) ->
{_, Pub} = get_key_pair(Root),
case file:read_file(Sig) of
{ok, JWT} ->
case authorize_sig:decode_jwt(JWT, Pub) of
case authorize_sig:decode_jwt(strip_nl(JWT), Pub) of
invalid ->
fail("Cannot validate ~s~n", [Sig]);
{Header, Payload} ->
Expand Down Expand Up @@ -182,6 +182,11 @@ l2i(Str) ->
i2l(I) ->
integer_to_list(I).

strip_nl(Bin) ->
case re:split(Bin,"\\s+$",[{return,binary},trim]) of
[Trimmed] -> Trimmed;
_ -> Bin
end.

make_auth(RPriv, Pub, Fmt, Opts) ->
case Fmt of
Expand Down
5 changes: 4 additions & 1 deletion components/authorize/src/authorize.app.src
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,8 @@
rvi_common
]},
{mod, { authorize_app, []}},
{start_phases, [{ json_rpc, []}]}
{start_phases, [{ json_rpc, []}, {announce, []}]},
{env, [
{rvi_core_await, [{n,l,authorize}]}
]}
]}.
3 changes: 3 additions & 0 deletions components/authorize/src/authorize_app.erl
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@ start_phase(json_rpc, _, _) ->
authorize_rpc:start_json_server(),
ok;

start_phase(announce, _, _) ->
rvi_common:announce({n, l, authorize});

start_phase(_Other, _, _) ->
ok.

Expand Down
11 changes: 9 additions & 2 deletions components/authorize/src/authorize_keys.erl
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,8 @@ init([]) ->
ProvisioningKey = get_pub_key(get_env(provisioning_key)),
?debug("ProvisioningKey = ~p~n", [ProvisioningKey]),
CertDir = setup:verify_dir(get_env(cert_dir)),
{ok, AuthJwt} = file:read_file(get_env(authorize_jwt)),
{ok, AuthJwt0} = file:read_file(get_env(authorize_jwt)),
AuthJwt = strip_nl(AuthJwt0),
?debug("CertDir = ~p~n", [CertDir]),
Certs = scan_certs(CertDir, ProvisioningKey),
?debug("scan_certs found ~p certificates~n", [length(Certs)]),
Expand Down Expand Up @@ -390,7 +391,7 @@ scan_certs(Dir, Key) ->
process_cert(F, Key, UTC, Acc) ->
case file:read_file(F) of
{ok, Bin} ->
try authorize_sig:decode_jwt(Bin, Key) of
try authorize_sig:decode_jwt(strip_nl(Bin), Key) of
{_, Cert} ->
?info("Unpacked Cert ~p:~n~p~n", [F, Cert]),
case process_cert_struct(Cert, Bin, UTC) of
Expand All @@ -413,6 +414,12 @@ process_cert(F, Key, UTC, Acc) ->
Acc
end.

strip_nl(Bin) ->
case re:split(Bin,"\\s+$",[{return,binary},trim]) of
[Trimmed] -> Trimmed;
_ -> Bin
end.

process_cert_struct(Cert, Bin) ->
process_cert_struct(Cert, Bin, rvi_common:utc_timestamp()).

Expand Down
9 changes: 7 additions & 2 deletions components/dlink_bt/src/dlink_bt.app.src
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
%% -*- erlang-indent-level: 4;indent-tabs-mode: nil -*-
%%
%% Copyright (C) 2014, Jaguar Land Rover
%%
Expand All @@ -16,8 +17,12 @@
{applications, [
kernel,
stdlib,
rvi_common
rvi_common,
bt
]},
{mod, { dlink_bt_app, []}},
{start_phases, [{json_rpc, []}, {connection_manager, []}]}
{start_phases, [{json_rpc, []}, {connection_manager, []}, {announce, []}]},
{env, [
{rvi_core_await, [{n,l,dlink_dt}]}
]}
]}.
4 changes: 3 additions & 1 deletion components/dlink_bt/src/dlink_bt_app.erl
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,10 @@ start_phase(json_rpc, _, _) ->

start_phase(connection_manager, _, _) ->
dlink_bt_rpc:start_connection_manager(),
ok.
ok;

start_phase(announce, _, _) ->
rvi_common:announce({n, l, dlink_bt}).

stop(_State) ->
ok.
5 changes: 4 additions & 1 deletion components/dlink_sms/src/dlink_sms.app.src
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,8 @@
rvi_common
]},
{mod, { dlink_sms_app, []}},
{start_phases, [{json_rpc, []}, {connection_manager, []}]}
{start_phases, [{json_rpc, []}, {connection_manager, []}, {announce, []}]},
{env, [
{rvi_core_await, [{n,l,dlink_sms}]}
]}
]}.
6 changes: 5 additions & 1 deletion components/dlink_sms/src/dlink_sms_app.erl
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
start_phase/3,
stop/1]).

-include_lib("lager/include/log.hrl").

%% ===================================================================
%% Application callbacks
%% ===================================================================
Expand All @@ -32,8 +34,10 @@ start_phase(json_rpc, _, _) ->

start_phase(connection_manager, _, _) ->
dlink_sms_rpc:start_connection_manager(),
ok.
ok;

start_phase(announce, _, _) ->
rvi_common:announce({n, l, dlink_sms}).

stop(_State) ->
ok.
5 changes: 4 additions & 1 deletion components/dlink_tcp/src/dlink_tcp.app.src
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,8 @@
rvi_common
]},
{mod, { dlink_tcp_app, []}},
{start_phases, [{json_rpc, []}, {connection_manager, []}, {announce, []}]}
{start_phases, [{json_rpc, []}, {connection_manager, []}, {announce, []}]},
{env, [
{rvi_core_await, [{n,l,dlink_tcp}]}
]}
]}.
5 changes: 3 additions & 2 deletions components/dlink_tcp/src/dlink_tcp_app.erl
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
start_phase/3,
stop/1]).

-include_lib("lager/include/log.hrl").

%% ===================================================================
%% Application callbacks
%% ===================================================================
Expand All @@ -35,8 +37,7 @@ start_phase(connection_manager, _, _) ->
ok;

start_phase(announce, _, _) ->
gproc:reg({n, l, dlink_tcp}),
ok.
rvi_common:announce({n, l, dlink_tcp}).

stop(_State) ->
ok.
Loading