#pragma once #include /* { "flow": { "client_conn": { "address": [ "::1", 37570, 0, 0 ], "alpn_proto_negotiated": "http/1.1", "cipher_name": "TLS_AES_256_GCM_SHA384", "clientcert": null, "id": "a1e82917-2d58-4b99-be9e-2b962bc499b2", "mitmcert": "mitmcertstring", "sni": "yolo.jetzt", "timestamp_end": null, "timestamp_start": 1597284668.6260498, "timestamp_tls_setup": 1597284669.8449724, "tls_established": true, "tls_extensions": [...], "tls_version": "TLSv1.3" }, "error": null, "id": "a6aa4e6e-ca31-4f58-bf47-2da7bfcf0000", "intercepted": false, "marked": false, "metadata": {}, "mode": "transparent", "request": { "content": "", "first_line_format": "relative", "headers": [ [ "Host", "yolo.jetzt" ], [ "User-Agent", "curl/7.68.0" ], [ "Accept", ] ], "host": "yolo.jetzt", "http_version": "HTTP/1.1", "is_replay": false, "method": "GET", "path": "/", "port": 443, "scheme": "https", "timestamp_end": 1597284669.92817, "timestamp_start": 1597284669.8761458 }, "response": null, "server_conn": { "address": [ "yolo.jetzt", 443 ], "alpn_proto_negotiated": "http/1.1", "cert": "certstring", "id": "50a3b79d-2912-45f3-991b-c03406a1018f", "ip_address": [ "95.156.226.69", 443 ], "sni": "yolo.jetzt", "source_address": [ "192.168.42.102", 44949 ], "timestamp_end": null, "timestamp_start": 1597284669.2133315, "timestamp_tcp_setup": 1597284669.2892282, "timestamp_tls_setup": 1597284669.584602, "tls_established": true, "tls_version": "TLSv1.2", "via": null }, "type": "http", "version": 7 }, "msg": "request" } */ namespace http { struct Request { std::string server_ip_address; bool tls; std::string content; std::string scheme; std::string method; std::string host; std::string address; unsigned short port; std::string http_version; std::string path; double timestamp_start; double timestamp_end; std::vector> headers; std::string error; }; struct Response { int status_code; std::string http_version; std::string reason; std::string content; double timestamp_start; double timestamp_end; std::vector> headers; }; struct Flow { std::string uid; Request request; Response response; }; inline void to_json(json& j, const Flow& flow) {} inline void from_json(const json& j, Flow& flow) { std::cout << std::setw(4) << j << "\n\n"; if(!j.contains("flow")) { return; } j.at("flow").at("id").get_to(flow.id); if(j.at("flow").contains("server_conn")) { j.at("flow").at("server_conn").at("tls_established").get_to(flow.request.tls); } if(j.at("flow").contains("request")) { j.at("flow").at("request").at("port").get_to(flow.request.port); j.at("flow").at("request").at("host").get_to(flow.request.host); j.at("flow").at("request").at("scheme").get_to(flow.request.scheme); j.at("flow").at("request").at("path").get_to(flow.request.path); j.at("flow").at("request").at("content").get_to(flow.request.content); j.at("flow").at("request").at("method").get_to(flow.request.method); j.at("flow").at("request").at("http_version").get_to(flow.request.http_version); //j.at("server_conn").at("address").get_to(flow.server_conn_address); } } } Q_DECLARE_METATYPE(http::Flow)