summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/frontend.erl6
-rw-r--r--src/fsdb.erl6
-rw-r--r--src/perm.erl5
-rw-r--r--src/permdb.erl10
-rw-r--r--src/plop_httputil.erl17
5 files changed, 26 insertions, 18 deletions
diff --git a/src/frontend.erl b/src/frontend.erl
index e4d8e40..8a593b4 100644
--- a/src/frontend.erl
+++ b/src/frontend.erl
@@ -33,7 +33,7 @@ request(post, ?APPURL_PLOP_FRONTEND, "sendentry", Input) ->
request(post, ?APPURL_PLOP_FRONTEND, "sendlog", Input) ->
case (catch mochijson2:decode(Input)) of
{error, E} ->
- html("sendentry: bad input:", E);
+ html("sendlog: bad input:", E);
{struct, PropList} ->
Start = proplists:get_value(<<"start">>, PropList),
Hashes = lists:map(fun (S) -> base64:decode(S) end, proplists:get_value(<<"hashes">>, PropList)),
@@ -142,7 +142,7 @@ request(post, ?APPURL_PLOP_MERGE, "sendentry", Input) ->
request(post, ?APPURL_PLOP_MERGE, "sendlog", Input) ->
case (catch mochijson2:decode(Input)) of
{error, E} ->
- html("sendentry: bad input:", E);
+ html("sendlog: bad input:", E);
{struct, PropList} ->
Start = proplists:get_value(<<"start">>, PropList),
Hashes = lists:map(fun (S) -> base64:decode(S) end, proplists:get_value(<<"hashes">>, PropList)),
@@ -152,7 +152,7 @@ request(post, ?APPURL_PLOP_MERGE, "sendlog", Input) ->
request(post, ?APPURL_PLOP_MERGE, "verifyroot", Input) ->
case (catch mochijson2:decode(Input)) of
{error, E} ->
- html("sendentry: bad input:", E);
+ html("verifyroot: bad input:", E);
{struct, PropList} ->
OldSize = db:verifiedsize(),
Treesize = proplists:get_value(<<"tree_size">>, PropList),
diff --git a/src/fsdb.erl b/src/fsdb.erl
index 4a85cdc..d644128 100644
--- a/src/fsdb.erl
+++ b/src/fsdb.erl
@@ -1,10 +1,10 @@
-%%% Copyright (c) 2014-2015, NORDUnet A/S.
+%%% Copyright (c) 2014-2015,2017, NORDUnet A/S.
%%% See LICENSE for licensing information.
-module(fsdb).
-behaviour(gen_server).
--export([start_link/2, stop/1, init_module/0]).
+-export([start_link/3, stop/1, init_module/0]).
-export([getvalue/2, addvalue/3, commit/1, commit/2]).
%% gen_server callbacks.
@@ -24,7 +24,7 @@ init_module() ->
end,
ets:new(?DIRECTORY_TABLE, [set, public, named_table]).
-start_link(Name, Filename) ->
+start_link(Name, Filename, _Options) ->
gen_server:start_link({local, Name}, ?MODULE,
[Name, Filename], []).
diff --git a/src/perm.erl b/src/perm.erl
index 2e12fdf..e571d23 100644
--- a/src/perm.erl
+++ b/src/perm.erl
@@ -1,4 +1,4 @@
-%%% Copyright (c) 2015, NORDUnet A/S.
+%%% Copyright (c) 2015,2017, NORDUnet A/S.
%%% See LICENSE for licensing information.
-module(perm).
@@ -8,7 +8,8 @@
start_link(Name, Filename) ->
Module = application:get_env(plop, db_backend, fsdb),
- Module:start_link(Name, Filename).
+ Options = application:get_env(plop, db_backend_opt, []),
+ Module:start_link(Name, Filename, Options).
stop(Name) ->
Module = application:get_env(plop, db_backend, fsdb),
diff --git a/src/permdb.erl b/src/permdb.erl
index 0a1765e..faca986 100644
--- a/src/permdb.erl
+++ b/src/permdb.erl
@@ -1,11 +1,11 @@
-%%% Copyright (c) 2015-2016, NORDUnet A/S.
+%%% Copyright (c) 2015-2017, NORDUnet A/S.
%%% See LICENSE for licensing information.
-module(permdb).
-behaviour(gen_server).
--export([start_link/2, start_link/3, stop/1, init_module/0]).
+-export([start_link/3, stop/1, init_module/0]).
-export([getvalue/2, addvalue/3, commit/1, commit/2, keyexists/2]).
%% gen_server callbacks.
@@ -61,10 +61,8 @@ init([Name, Filename, WriteFlag]) ->
init_module() ->
ok.
-start_link(Name, Filename) ->
- start_link(Name, Filename, write).
-
-start_link(Name, Filename, WriteFlag) ->
+start_link(Name, Filename, Options) ->
+ WriteFlag = proplists:get_value(write_flag, Options, write),
gen_server:start_link({local, Name}, ?MODULE,
[Name, Filename, WriteFlag], []).
diff --git a/src/plop_httputil.erl b/src/plop_httputil.erl
index af4a5d1..e428297 100644
--- a/src/plop_httputil.erl
+++ b/src/plop_httputil.erl
@@ -64,15 +64,24 @@ read_and_verify_cacertfile(Filename) ->
[KeyPem] = public_key:pem_decode(PemBin),
{'Certificate', Der, _} = KeyPem,
CalculatedHash = crypto:hash(sha256, Der),
- CorrectHash = application:get_env(catlfish, https_cacert_fingerprint, none),
+ CorrectHash = application:get_env(plop, https_cacert_fingerprint, none),
CorrectHash = CalculatedHash,
Der.
+request(DebugTag, URL, Headers, <<>>) ->
+ request(DebugTag, URL, Headers, <<>>, get);
request(DebugTag, URL, Headers, RequestBody) ->
+ request(DebugTag, URL, Headers, RequestBody, post).
+
+request(DebugTag, URL, Headers, RequestBody, Method) ->
Starttime = os:timestamp(),
ParsedURL = hackney_url:parse_url(URL),
- CACertFile = application:get_env(catlfish, https_cacertfile, none),
+ CACertFile = application:get_env(plop, https_cacertfile, none),
CACert = read_and_verify_cacertfile(CACertFile),
+ MethodString = case Method of
+ get -> "GET";
+ post -> "POST"
+ end,
#hackney_url{path = Path, host = Host} = ParsedURL,
lager:debug("~s: sending http request to ~p",
[DebugTag, URL]),
@@ -87,8 +96,8 @@ request(DebugTag, URL, Headers, RequestBody) ->
[DebugTag, URL]),
{ok, StatusCode, RespHeaders, ClientRef} =
hackney:send_request(ConnRef,
- {post, Path,
- add_auth("POST", Path, Headers,
+ {Method, Path,
+ add_auth(MethodString, Path, Headers,
RequestBody),
RequestBody}),
lager:debug("~s: received headers for ~p: ~p",