diff options
author | Linus Nordberg <linus@nordu.net> | 2016-07-16 17:26:54 +0200 |
---|---|---|
committer | Linus Nordberg <linus@nordu.net> | 2016-07-16 17:26:54 +0200 |
commit | 374900dca397ba8fe38fc028e9eb657feb5ce073 (patch) | |
tree | 708bfe4081bf50961bab983e0e4a610cd7ac1355 /src/v1.erl | |
parent | cde186313b20e46be41736c9ac506674fa4f2d23 (diff) |
WIP
NOTE: tests don't work -- SCT's don't validate
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", |