Skip to content

Commit

Permalink
Adjust TLS plugin
Browse files Browse the repository at this point in the history
  • Loading branch information
Zadamsa committed Oct 3, 2024
1 parent f3f64ac commit 3fc1136
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 12 deletions.
16 changes: 7 additions & 9 deletions process/tls.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -73,13 +73,12 @@ ProcessPlugin *TLSPlugin::copy()
return new TLSPlugin(*this);
}

int TLSPlugin::post_create(Flow &rec, const Packet &pkt)
ProcessPlugin::FlowAction TLSPlugin::post_create(Flow &rec, const Packet &pkt)
{
add_tls_record(rec, pkt);
return 0;
return add_tls_record(rec, pkt);
}

int TLSPlugin::pre_update(Flow &rec, Packet &pkt)
ProcessPlugin::FlowAction TLSPlugin::pre_update(Flow &rec, Packet &pkt)
{
RecordExtTLS *ext = static_cast<RecordExtTLS *>(rec.get_extension(RecordExtTLS::REGISTERED_ID));

Expand All @@ -88,11 +87,9 @@ int TLSPlugin::pre_update(Flow &rec, Packet &pkt)
// Add ALPN from server packet
parse_tls(pkt.payload, pkt.payload_len, ext);
}
return 0;
return ProcessPlugin::FlowAction::GET_ALL_DATA;
}
add_tls_record(rec, pkt);

return 0;
return add_tls_record(rec, pkt);
}

bool TLSPlugin::obtain_tls_data(TLSData &payload, RecordExtTLS *rec, std::string &ja3, uint8_t hs_type)
Expand Down Expand Up @@ -217,7 +214,7 @@ bool TLSPlugin::parse_tls(const uint8_t *data, uint16_t payload_len, RecordExtTL
return payload.obejcts_parsed != 0 || !ja3.empty();
} // TLSPlugin::parse_sni

void TLSPlugin::add_tls_record(Flow &rec, const Packet &pkt)
ProcessPlugin::FlowAction TLSPlugin::add_tls_record(Flow &rec, const Packet &pkt)
{
if (ext_ptr == nullptr) {
ext_ptr = new RecordExtTLS();
Expand All @@ -234,6 +231,7 @@ void TLSPlugin::add_tls_record(Flow &rec, const Packet &pkt)
rec.add_extension(ext_ptr);
ext_ptr = nullptr;
}
return ProcessPlugin::FlowAction::GET_ALL_DATA;
}

void TLSPlugin::finish(bool print_stats)
Expand Down
6 changes: 3 additions & 3 deletions process/tls.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -230,12 +230,12 @@ class TLSPlugin : public ProcessPlugin

ProcessPlugin *copy();

int post_create(Flow &rec, const Packet &pkt);
int pre_update(Flow &rec, Packet &pkt);
ProcessPlugin::FlowAction post_create(Flow &rec, const Packet &pkt);
ProcessPlugin::FlowAction pre_update(Flow &rec, Packet &pkt);
void finish(bool print_stats);

private:
void add_tls_record(Flow&, const Packet&);
ProcessPlugin::FlowAction add_tls_record(Flow&, const Packet&);
bool parse_tls(const uint8_t *, uint16_t, RecordExtTLS *);
bool obtain_tls_data(TLSData&, RecordExtTLS *, std::string&, uint8_t);

Expand Down

0 comments on commit 3fc1136

Please sign in to comment.