diff options
| author | lwp <[email protected]> | 2019-08-16 14:51:43 +0800 |
|---|---|---|
| committer | luwenpeng <[email protected]> | 2019-09-03 11:03:03 +0800 |
| commit | f589f0e4331a4b02eb42818a8b93e34502253a71 (patch) | |
| tree | 67d5b3f0ec7587b7899f09d4f0b6cb0df8f6f7ed /platform/src/ssl_service_cache.cpp | |
| parent | 1f7a32f7f51eeef45bb58dde4e7d5d9d060ff932 (diff) | |
为了便于调试, 将 ssl service cache 的 hash key 都转化成 16 进制格式,并增加 debug 日志
Diffstat (limited to 'platform/src/ssl_service_cache.cpp')
| -rw-r--r-- | platform/src/ssl_service_cache.cpp | 53 |
1 files changed, 39 insertions, 14 deletions
diff --git a/platform/src/ssl_service_cache.cpp b/platform/src/ssl_service_cache.cpp index 1bc3442..11f845c 100644 --- a/platform/src/ssl_service_cache.cpp +++ b/platform/src/ssl_service_cache.cpp @@ -318,18 +318,32 @@ static long app_st_write_cb(void * data, const uchar * key, uint size, void * us int ssl_service_cache_read(struct ssl_service_cache* svc_cache, const struct ssl_chello* chello, const struct tfe_stream_addr * addr, struct ssl_service_status* result) { long cli_st_cb_ret=0, svr_st_cb_ret=0, app_st_cb_ret=0; - char hash_key[2048]; + char temp_key[2048]; + unsigned char hash_key[4096]; // Size must be twice the size of temp_key + size_t temp_key_sz=0; size_t hash_key_sz=0; if(chello->sni==NULL) { return 0; } - hash_key_sz=ssl_svc_client_st_mk_key(chello, addr, hash_key, sizeof(hash_key)); - MESA_htable_search_cb(svc_cache->cli_st_hash, (unsigned char*) hash_key, (unsigned int) hash_key_sz, cli_st_read_cb, result, &cli_st_cb_ret); - hash_key_sz=ssl_svc_server_st_mk_key(chello, addr, hash_key, sizeof(hash_key)); - MESA_htable_search_cb(svc_cache->srv_st_hash, (unsigned char*) hash_key, (unsigned int) hash_key_sz, srv_st_read_cb, result, &svr_st_cb_ret); - hash_key_sz=ssl_svc_app_st_mk_key(chello, addr, hash_key, sizeof(hash_key)); - MESA_htable_search_cb(svc_cache->app_st_hash, (unsigned char*) hash_key, (unsigned int) hash_key_sz, app_st_read_cb, result, &app_st_cb_ret); + + memset(hash_key, 0, sizeof(hash_key)); + temp_key_sz = ssl_svc_client_st_mk_key(chello, addr, temp_key, sizeof(temp_key)); + hash_key_sz = tfe_hexdump(hash_key, (unsigned char *)temp_key, temp_key_sz) - hash_key; + TFE_LOG_DEBUG(g_default_logger, "ssl svc read client table, hash:%s, ori_len:%lu hash_len:%lu\n", hash_key, temp_key_sz, hash_key_sz); + MESA_htable_search_cb(svc_cache->cli_st_hash, hash_key, (unsigned int) hash_key_sz, cli_st_read_cb, result, &cli_st_cb_ret); + + memset(hash_key, 0, sizeof(hash_key)); + temp_key_sz = ssl_svc_server_st_mk_key(chello, addr, temp_key, sizeof(temp_key)); + hash_key_sz = tfe_hexdump(hash_key, (unsigned char *)temp_key, temp_key_sz) - hash_key; + TFE_LOG_DEBUG(g_default_logger, "ssl svc read server table, hash:%s, ori_len:%lu hash_len:%lu\n", hash_key, temp_key_sz, hash_key_sz); + MESA_htable_search_cb(svc_cache->srv_st_hash, hash_key, (unsigned int) hash_key_sz, srv_st_read_cb, result, &svr_st_cb_ret); + + memset(hash_key, 0, sizeof(hash_key)); + temp_key_sz = ssl_svc_app_st_mk_key(chello, addr, temp_key, sizeof(temp_key)); + hash_key_sz = tfe_hexdump(hash_key, (unsigned char *)temp_key, temp_key_sz) - hash_key; + TFE_LOG_DEBUG(g_default_logger, "ssl svc read app table, hash:%s, ori_len:%lu hash_len:%lu\n", hash_key, temp_key_sz, hash_key_sz); + MESA_htable_search_cb(svc_cache->app_st_hash, hash_key, (unsigned int) hash_key_sz, app_st_read_cb, result, &app_st_cb_ret); if(cli_st_cb_ret||svr_st_cb_ret||app_st_cb_ret) { @@ -344,7 +358,9 @@ int ssl_service_cache_read(struct ssl_service_cache* svc_cache, const struct ssl void ssl_service_cache_write(struct ssl_service_cache* svc_cache, const struct ssl_chello* chello, const struct tfe_stream_addr * addr, const struct ssl_service_status* status) { long cli_st_cb_ret=0, svr_st_cb_ret=0; - char hash_key[2048]; + char temp_key[2048]; + unsigned char hash_key[4096]; // Size must be twice the size of temp_key + size_t temp_key_sz=0; size_t hash_key_sz=0; if(chello == NULL || chello->sni==NULL) @@ -354,18 +370,27 @@ void ssl_service_cache_write(struct ssl_service_cache* svc_cache, const struct s struct ssl_service_write_args write_args={svc_cache, status}; if(status->is_mutual_auth||status->cli_pinning_status!=PINNING_ST_NOT_PINNING||status->has_protocol_errors) { - hash_key_sz=ssl_svc_client_st_mk_key(chello, addr, hash_key, sizeof(hash_key)); - MESA_htable_search_cb(svc_cache->cli_st_hash, (unsigned char*)hash_key, (unsigned int) hash_key_sz, cli_st_write_cb, &write_args, &cli_st_cb_ret); + memset(hash_key, 0, sizeof(hash_key)); + temp_key_sz = ssl_svc_client_st_mk_key(chello, addr, temp_key, sizeof(temp_key)); + hash_key_sz = tfe_hexdump(hash_key, (unsigned char *)temp_key, temp_key_sz) - hash_key; + TFE_LOG_DEBUG(g_default_logger, "ssl svc write client table, hash:%s, ori_len:%lu hash_len:%lu\n", hash_key, temp_key_sz, hash_key_sz); + MESA_htable_search_cb(svc_cache->cli_st_hash, hash_key, (unsigned int) hash_key_sz, cli_st_write_cb, &write_args, &cli_st_cb_ret); } if(status->is_ct||status->is_ev) { - hash_key_sz=ssl_svc_server_st_mk_key(chello, addr, hash_key, sizeof(hash_key)); - MESA_htable_search_cb(svc_cache->srv_st_hash, (unsigned char*)hash_key, (unsigned int) hash_key_sz, srv_st_write_cb, &write_args, &svr_st_cb_ret); + memset(hash_key, 0, sizeof(hash_key)); + temp_key_sz = ssl_svc_server_st_mk_key(chello, addr, temp_key, sizeof(temp_key)); + hash_key_sz = tfe_hexdump(hash_key, (unsigned char *)temp_key, temp_key_sz) - hash_key; + TFE_LOG_DEBUG(g_default_logger, "ssl svc write server table, hash:%s, ori_len:%lu hash_len:%lu\n", hash_key, temp_key_sz, hash_key_sz); + MESA_htable_search_cb(svc_cache->srv_st_hash, hash_key, (unsigned int) hash_key_sz, srv_st_write_cb, &write_args, &svr_st_cb_ret); } if(status->is_app_not_pinning) { - hash_key_sz=ssl_svc_app_st_mk_key(chello, addr, hash_key, sizeof(hash_key)); - MESA_htable_search_cb(svc_cache->app_st_hash, (unsigned char*)hash_key, (unsigned int) hash_key_sz, app_st_write_cb, &write_args, &svr_st_cb_ret); + memset(hash_key, 0, sizeof(hash_key)); + temp_key_sz = ssl_svc_app_st_mk_key(chello, addr, temp_key, sizeof(temp_key)); + hash_key_sz = tfe_hexdump(hash_key, (unsigned char *)temp_key, temp_key_sz) - hash_key; + TFE_LOG_DEBUG(g_default_logger, "ssl svc write app table, hash:%s, ori_len:%lu hash_len:%lu\n", hash_key, temp_key_sz, hash_key_sz); + MESA_htable_search_cb(svc_cache->app_st_hash, hash_key, (unsigned int) hash_key_sz, app_st_write_cb, &write_args, &svr_st_cb_ret); } } struct ssl_service_cache* ssl_service_cache_create(unsigned int slot_size, unsigned int expire_seconds, int fail_as_pinning_cnt, int fail_as_proto_err_cnt, int fail_time_win) |
