@@ -1050,124 +1050,70 @@ struct TSHttp2Priority {
10501050 * or -1 if the stream has no dependency. */
10511051 int32_t stream_dependency ;
10521052};
1053- /**
1054- * A structure for SSL Client Hello data
1055- */
1056- struct tsapi_ssl_client_hello {
1057- uint16_t version {0 };
1058- const uint8_t * cipher_suites {nullptr };
1059- size_t cipher_suites_len {0 };
1060- const uint8_t * extensions {nullptr };
1061- size_t extensions_len {0 };
1062- int * extension_ids {nullptr };
1063- size_t extension_ids_len {0 };
1064- void * ssl_ptr {nullptr };
1065- };
10661053
10671054// Wrapper class that provides controlled access to client hello data
1068- class TSClientHelloImpl
1055+ class TSClientHello
10691056{
10701057public :
1071- // Type alias for extension type list
1072- using TSExtensionTypeList = std ::vector < uint16_t > ;
1058+ class TSExtensionTypeList
1059+ {
1060+ public :
1061+ TSExtensionTypeList (void * ch ) : _ch (ch ) {}
10731062
1074- TSClientHelloImpl (std ::unique_ptr < tsapi_ssl_client_hello > ch ) : _ssl_client_hello (std ::move (ch )) {}
1063+ class Iterator
1064+ {
1065+ public :
1066+ Iterator (const void * ite ) ;
1067+ Iterator & operator ++ ();
1068+ bool operator == (const Iterator & b ) const ;
1069+ int operator * () const ;
10751070
1076- ~TSClientHelloImpl () = default ;
1071+ private :
1072+ char _real_iterator [24 ];
1073+ };
10771074
1078- uint16_t
1079- get_version () const
1080- {
1081- return _ssl_client_hello -> version ;
1082- }
1075+ Iterator begin ();
1076+ Iterator end ();
10831077
1084- const uint8_t *
1085- get_cipher_suites () const
1086- {
1087- return _ssl_client_hello -> cipher_suites ;
1088- }
1078+ private :
1079+ void * _ch ;
1080+ };
10891081
1090- size_t
1091- get_cipher_suites_len () const
1092- {
1093- return _ssl_client_hello -> cipher_suites_len ;
1094- }
1082+ TSClientHello (void * ch ) : _client_hello (ch ) {}
10951083
1096- const uint8_t *
1097- get_extensions () const
1098- {
1099- return _ssl_client_hello -> extensions ;
1100- }
1084+ ~TSClientHello () = default ;
11011085
1102- size_t
1103- get_extensions_len () const
1086+ explicit
1087+ operator bool () const
11041088 {
1105- return _ssl_client_hello -> extensions_len ;
1089+ return _client_hello != nullptr ;
11061090 }
11071091
1108- const int *
1109- get_extension_ids () const
1110- {
1111- return _ssl_client_hello -> extension_ids ;
1112- }
1092+ bool is_available () const ;
11131093
1114- size_t
1115- get_extension_ids_len () const
1116- {
1117- return _ssl_client_hello -> extension_ids_len ;
1118- }
1094+ uint16_t get_version () const ;
11191095
1120- void *
1121- get_ssl_ptr () const
1122- {
1123- return _ssl_client_hello -> ssl_ptr ;
1124- }
1096+ const uint8_t * get_cipher_suites () const ;
1097+
1098+ size_t get_cipher_suites_len () const ;
11251099
11261100 // Returns an iterable container of extension type IDs
11271101 // This abstracts the difference between BoringSSL (extensions buffer) and OpenSSL (extension_ids array)
11281102 TSExtensionTypeList
11291103 get_extension_types () const
11301104 {
1131- TSExtensionTypeList result ;
1132-
1133- // For BoringSSL, parse the extensions buffer
1134- if (_ssl_client_hello -> extensions != nullptr ) {
1135- const uint8_t * ext = _ssl_client_hello -> extensions ;
1136- size_t remaining = _ssl_client_hello -> extensions_len ;
1137-
1138- while (remaining >= 4 ) {
1139- uint16_t ext_type = (ext [0 ] << 8 ) | ext [1 ];
1140- uint16_t ext_len = (ext [2 ] << 8 ) | ext [3 ];
1141- size_t total_ext_size = 4 + ext_len ;
1142-
1143- result .push_back (ext_type );
1144-
1145- if (total_ext_size > remaining ) {
1146- break ;
1147- }
1148- ext += total_ext_size ;
1149- remaining -= total_ext_size ;
1150- }
1151- }
1152- // For OpenSSL, use the extension IDs array
1153- else if (_ssl_client_hello -> extension_ids != nullptr ) {
1154- for (size_t i = 0 ; i < _ssl_client_hello -> extension_ids_len ; i ++ ) {
1155- result .push_back (static_cast < uint16_t > (_ssl_client_hello -> extension_ids [i ]));
1156- }
1157- }
1158-
1159- return result ;
1105+ return TSExtensionTypeList (_client_hello );
11601106 }
11611107
11621108 // Internal accessor for API implementation
1163- tsapi_ssl_client_hello *
1109+ void *
11641110 _get_internal () const
11651111 {
1166- return _ssl_client_hello . get () ;
1112+ return _client_hello ;
11671113 }
11681114
11691115private :
1170- std :: unique_ptr < tsapi_ssl_client_hello > _ssl_client_hello ;
1116+ void * _client_hello ;
11711117};
11721118
11731119using TSFile = struct tsapi_file * ;
@@ -1205,7 +1151,6 @@ using TSHostLookupResult = struct tsapi_hostlookupresult *;
12051151using TSAIOCallback = struct tsapi_aiocallback * ;
12061152using TSAcceptor = struct tsapi_net_accept * ;
12071153using TSRemapPluginInfo = struct tsapi_remap_plugin_info * ;
1208- using TSClientHello = TSClientHelloImpl * ;
12091154
12101155using TSFetchSM = struct tsapi_fetchsm * ;
12111156
0 commit comments