From 374900dca397ba8fe38fc028e9eb657feb5ce073 Mon Sep 17 00:00:00 2001 From: Linus Nordberg Date: Sat, 16 Jul 2016 17:26:54 +0200 Subject: WIP NOTE: tests don't work -- SCT's don't validate --- src/v1.erl | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) (limited to 'src/v1.erl') 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( "

~n" ++ "~s~n" ++ "~p~n" ++ - "~n", [Text, Input])}. + "~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", -- cgit v1.1