@@ -683,6 +683,13 @@ namespace stun {
683683
684684 bool has_magic_cookie () const { return tid_has_magic_cookie; }
685685
686+ // / returns true if this header corresponds to a success
687+ // / response or an error response
688+ // /
689+ bool is_response () {
690+ return (get_message_class () & 0b10 ) == 0b10 ;
691+ }
692+
686693 // return the number of zero bytes in the transaction_id
687694 //
688695 size_t tid_zero_count () const {
@@ -919,6 +926,17 @@ namespace stun {
919926 return ;
920927 }
921928
929+ if (hdr.is_response ()) {
930+ //
931+ // we don't generate fingerprints for responses, so we
932+ // set the truncated bit in the fingerprint buffer, to
933+ // indicate that it does not contain an actual
934+ // fingerprint
935+ //
936+ buf.set_truncated ();
937+ return ;
938+ }
939+
922940 hdr.write_fingerprint (buf);
923941
924942 // the attr_fingerprint_type determines what data from a
@@ -1003,22 +1021,10 @@ namespace stun {
10031021 //
10041022 utf8_safe_string<MAX_USER_AGENT_LEN> utf8_software{software};
10051023
1006- // handle message classes appropriately: reverse the
1007- // addresses and ports in the flow key for responses,
1008- // leave the flow key untouched for requests, and ignore
1009- // all other message classes
1010- //
1011- key k{flow_key};
1012- if ((hdr.get_message_class () & 0b10 ) == 0b10 ) {
1013- //
1014- // success_resp and error_resp: swap addrs and ports
1015- //
1016- k.reverse ();
1017- }
10181024 ac.destination .init ({nullptr ,nullptr }, // domain name
10191025 utf8_software.get_datum (), // user agent
10201026 {nullptr ,nullptr }, // alpn
1021- k // flow key, used for dst_addr and dst_port
1027+ flow_key // flow key, used for dst_addr and dst_port
10221028 );
10231029
10241030 if (c == nullptr ) {
0 commit comments