summaryrefslogtreecommitdiff
path: root/src/v1.erl
diff options
context:
space:
mode:
Diffstat (limited to 'src/v1.erl')
-rw-r--r--src/v1.erl17
1 files changed, 14 insertions, 3 deletions
diff --git a/src/v1.erl b/src/v1.erl
index c1b07e6..d16b5c6 100644
--- a/src/v1.erl
+++ b/src/v1.erl
@@ -129,13 +129,20 @@ request(_Method, _App, _Fun, _) ->
none.
%% Private functions.
+-define(INPUT_TRIMLEN, 80).
err400(Text, Input) ->
+ InputTrimmed = case Input of
+ I when is_binary(I) ->
+ binary_part(I, 0, ?INPUT_TRIMLEN);
+ I when is_list(I) ->
+ lists:sublist(I, ?INPUT_TRIMLEN)
+ end,
{400, [{"Content-Type", "text/html"}],
io_lib:format(
"<html><body><p>~n" ++
"~s~n" ++
"~p~n" ++
- "</body></html>~n", [Text, Input])}.
+ "</body></html>~n", [Text, InputTrimmed])}.
success(Data) ->
{200, [{"Content-Type", "text/json"}], mochijson2:encode(Data)}.
@@ -165,9 +172,13 @@ add_rr_chain(Input) ->
add_chain_helper(Data) ->
case dnssecport:validate(Data) of
- {valid, [DS | Chain]} ->
+ {valid, ChainBin} ->
lager:debug("succesful DNSSEC validation"),
- success(catlfish:add_chain(DS, Chain, normal));
+ {DS, Chain} = lists:split(2, dns:decode_rrset(ChainBin)),
+ %%lager:debug("DS: ~p~nChain: ~p", [DS, Chain]),
+ success(catlfish:add_chain(dns:encode_rrset(DS),
+ [dns:encode_rrset(Chain)], % FIXME
+ normal));
{invalid, Reason} ->
lager:debug("DNSSEC validation failed with ~p", [Reason]),
err400(io_lib:format("add-rr-chain: invalid DS record: ~p",