diff options
Diffstat (limited to 'src/v1.erl')
-rw-r--r-- | src/v1.erl | 17 |
1 files changed, 14 insertions, 3 deletions
@@ -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", |