@@ -509,23 +509,29 @@ json_record_to_erlang([Name, <<"RP">>, Ttl, Data, _Context]) ->
509
509
ttl = Ttl
510
510
};
511
511
json_record_to_erlang ([Name , Type = <<" TXT" >>, Ttl , Data , _Context ]) when is_map (Data ) ->
512
- % % This function call may crash. Handle it as a bad record.
513
- try erldns_txt :parse (maps :get (<<" txt" >>, Data )) of
514
- ParsedText ->
515
- # dns_rr {
516
- name = Name ,
517
- type = ? DNS_TYPE_TXT ,
518
- data = # dns_rrdata_txt {txt = lists :flatten (ParsedText )},
519
- ttl = Ttl
520
- }
521
- catch
522
- Exception :Reason ->
523
- erldns_events :notify ({? MODULE , error , {Name , Type , Data , Exception , Reason }}),
524
- {}
525
- end ;
512
+ Txts =
513
+ case maps :is_key (<<" txts" >>, Data ) of
514
+ true -> maps :get (<<" txts" >>, Data );
515
+ false -> maps :get (<<" txt" >>, Data )
516
+ end ,
517
+ json_record_to_erlang ([Name , Type , Ttl , Data , _Context , Txts ]);
526
518
json_record_to_erlang ([Name , Type = <<" TXT" >>, Ttl , Data , _Context ]) ->
519
+ Txts =
520
+ case erldns_config :keyget (<<" txts" >>, Data ) of
521
+ Value when is_list (Value ) -> Value ;
522
+ _ -> erldns_config :keyget (<<" txt" >>, Data )
523
+ end ,
524
+ json_record_to_erlang ([Name , Type , Ttl , Data , _Context , Txts ]);
525
+ json_record_to_erlang ([Name , <<" TXT" >>, Ttl , _Data , _Context , Value ]) when is_list (Value ) ->
526
+ # dns_rr {
527
+ name = Name ,
528
+ type = ? DNS_TYPE_TXT ,
529
+ data = # dns_rrdata_txt {txt = Value },
530
+ ttl = Ttl
531
+ };
532
+ json_record_to_erlang ([Name , Type = <<" TXT" >>, Ttl , Data , _Context , Value ]) ->
527
533
% % This function call may crash. Handle it as a bad record.
528
- try erldns_txt :parse (erldns_config : keyget (<< " txt " >>, Data ) ) of
534
+ try erldns_txt :parse (Value ) of
529
535
ParsedText ->
530
536
# dns_rr {
531
537
name = Name ,
@@ -539,17 +545,27 @@ json_record_to_erlang([Name, Type = <<"TXT">>, Ttl, Data, _Context]) ->
539
545
{}
540
546
end ;
541
547
json_record_to_erlang ([Name , <<" SPF" >>, Ttl , Data , _Context ]) when is_map (Data ) ->
548
+ Txts =
549
+ case maps :is_key (<<" txts" >>, Data ) of
550
+ true -> maps :get (<<" txts" >>, Data );
551
+ false -> [maps :get (<<" spf" >>, Data )]
552
+ end ,
542
553
# dns_rr {
543
554
name = Name ,
544
555
type = ? DNS_TYPE_SPF ,
545
- data = # dns_rrdata_spf {spf = [ maps : get (<< " spf " >>, Data )] },
556
+ data = # dns_rrdata_spf {spf = Txts },
546
557
ttl = Ttl
547
558
};
548
559
json_record_to_erlang ([Name , <<" SPF" >>, Ttl , Data , _Context ]) ->
560
+ Txts =
561
+ case erldns_config :keyget (<<" txts" >>, Data ) of
562
+ Value when is_list (Value ) -> Value ;
563
+ _ -> [erldns_config :keyget (<<" spf" >>, Data )]
564
+ end ,
549
565
# dns_rr {
550
566
name = Name ,
551
567
type = ? DNS_TYPE_SPF ,
552
- data = # dns_rrdata_spf {spf = [ erldns_config : keyget (<< " spf " >>, Data )] },
568
+ data = # dns_rrdata_spf {spf = Txts },
553
569
ttl = Ttl
554
570
};
555
571
json_record_to_erlang ([Name , <<" PTR" >>, Ttl , Data , _Context ]) when is_map (Data ) ->
@@ -753,7 +769,8 @@ json_record_to_erlang([Name, Type = <<"DNSKEY">>, Ttl, Data, _Context]) when is_
753
769
flags = maps :get (<<" flags" >>, Data ),
754
770
protocol = maps :get (<<" protocol" >>, Data ),
755
771
alg = maps :get (<<" alg" >>, Data ),
756
- public_key = PublicKey
772
+ public_key = PublicKey ,
773
+ key_tag = 0
757
774
},
758
775
ttl = Ttl
759
776
})
@@ -773,7 +790,8 @@ json_record_to_erlang([Name, Type = <<"DNSKEY">>, Ttl, Data, _Context]) ->
773
790
flags = erldns_config :keyget (<<" flags" >>, Data ),
774
791
protocol = erldns_config :keyget (<<" protocol" >>, Data ),
775
792
alg = erldns_config :keyget (<<" alg" >>, Data ),
776
- public_key = PublicKey
793
+ public_key = PublicKey ,
794
+ key_tag = 0
777
795
},
778
796
ttl = Ttl
779
797
})
@@ -793,7 +811,8 @@ json_record_to_erlang([Name, Type = <<"CDNSKEY">>, Ttl, Data, _Context]) when is
793
811
flags = maps :get (<<" flags" >>, Data ),
794
812
protocol = maps :get (<<" protocol" >>, Data ),
795
813
alg = maps :get (<<" alg" >>, Data ),
796
- public_key = PublicKey
814
+ public_key = PublicKey ,
815
+ key_tag = 0
797
816
},
798
817
ttl = Ttl
799
818
})
@@ -813,7 +832,8 @@ json_record_to_erlang([Name, Type = <<"CDNSKEY">>, Ttl, Data, _Context]) ->
813
832
flags = erldns_config :keyget (<<" flags" >>, Data ),
814
833
protocol = erldns_config :keyget (<<" protocol" >>, Data ),
815
834
alg = erldns_config :keyget (<<" alg" >>, Data ),
816
- public_key = PublicKey
835
+ public_key = PublicKey ,
836
+ key_tag = 0
817
837
},
818
838
ttl = Ttl
819
839
})
0 commit comments