修改日志,输出 sni

This commit is contained in:
luwenpeng
2019-08-30 21:14:47 +08:00
parent 4a8a7d95ce
commit 3e7d7ea7a3

View File

@@ -333,19 +333,19 @@ int ssl_service_cache_read(struct ssl_service_cache* svc_cache, const struct ssl
temp_key_sz = ssl_svc_client_st_mk_key(chello, addr, temp_key, sizeof(temp_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; hash_key_sz = tfe_hexdump(hash_key, (unsigned char *)temp_key, temp_key_sz) - hash_key;
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); 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);
TFE_LOG_DEBUG(g_default_logger, "ssl svc read client table, hash:%s, found:%d", hash_key, cli_st_cb_ret); TFE_LOG_DEBUG(g_default_logger, "ssl svc read client table, hash:%s, found:%d, sni:%s", hash_key, cli_st_cb_ret, chello->sni);
memset(hash_key, 0, sizeof(hash_key)); memset(hash_key, 0, sizeof(hash_key));
temp_key_sz = ssl_svc_server_st_mk_key(chello, addr, temp_key, sizeof(temp_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; hash_key_sz = tfe_hexdump(hash_key, (unsigned char *)temp_key, temp_key_sz) - hash_key;
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); 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);
TFE_LOG_DEBUG(g_default_logger, "ssl svc read server table, hash:%s, found:%d", hash_key, svr_st_cb_ret); TFE_LOG_DEBUG(g_default_logger, "ssl svc read server table, hash:%s, found:%d, sni:%s", hash_key, svr_st_cb_ret, chello->sni);
memset(hash_key, 0, sizeof(hash_key)); memset(hash_key, 0, sizeof(hash_key));
temp_key_sz = ssl_svc_app_st_mk_key(chello, addr, temp_key, sizeof(temp_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; hash_key_sz = tfe_hexdump(hash_key, (unsigned char *)temp_key, temp_key_sz) - hash_key;
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); 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);
TFE_LOG_DEBUG(g_default_logger, "ssl svc read app table, hash:%s, found:%d", hash_key, app_st_cb_ret); TFE_LOG_DEBUG(g_default_logger, "ssl svc read app table, hash:%s, found:%d, sni:%s", hash_key, app_st_cb_ret, chello->sni);
if(cli_st_cb_ret||svr_st_cb_ret||app_st_cb_ret) if(cli_st_cb_ret||svr_st_cb_ret||app_st_cb_ret)
{ {
@@ -375,7 +375,7 @@ void ssl_service_cache_write(struct ssl_service_cache* svc_cache, const struct s
memset(hash_key, 0, sizeof(hash_key)); memset(hash_key, 0, sizeof(hash_key));
temp_key_sz = ssl_svc_client_st_mk_key(chello, addr, temp_key, sizeof(temp_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; 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", hash_key); TFE_LOG_DEBUG(g_default_logger, "ssl svc write client table, hash:%s, sni:%s", hash_key, chello->sni);
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); 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) if(status->is_ct||status->is_ev)
@@ -383,7 +383,7 @@ void ssl_service_cache_write(struct ssl_service_cache* svc_cache, const struct s
memset(hash_key, 0, sizeof(hash_key)); memset(hash_key, 0, sizeof(hash_key));
temp_key_sz = ssl_svc_server_st_mk_key(chello, addr, temp_key, sizeof(temp_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; 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", hash_key); TFE_LOG_DEBUG(g_default_logger, "ssl svc write server table, hash:%s, sni:%s", hash_key, chello->sni);
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); 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) if(status->is_app_not_pinning)
@@ -391,7 +391,7 @@ void ssl_service_cache_write(struct ssl_service_cache* svc_cache, const struct s
memset(hash_key, 0, sizeof(hash_key)); memset(hash_key, 0, sizeof(hash_key));
temp_key_sz = ssl_svc_app_st_mk_key(chello, addr, temp_key, sizeof(temp_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; 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", hash_key); TFE_LOG_DEBUG(g_default_logger, "ssl svc write app table, hash:%s, sni:%s", hash_key, chello->sni);
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); 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);
} }
} }
@@ -423,16 +423,16 @@ struct ssl_service_cache* ssl_service_cache_create(unsigned int slot_size, unsig
{ {
unsigned int app_expire_seconds = 2 * expire_seconds; unsigned int app_expire_seconds = 2 * expire_seconds;
ret = MESA_htable_set_opt(htable, MHO_EXPIRE_TIME, &app_expire_seconds, sizeof(app_expire_seconds)); ret = MESA_htable_set_opt(htable, MHO_EXPIRE_TIME, &app_expire_seconds, sizeof(app_expire_seconds));
opt_val = HASH_ELIMINATE_ALGO_LRU;
ret = MESA_htable_set_opt(htable, MHO_ELIMIMINATE_TYPE, &opt_val, sizeof(int));
} }
// for client table and server table // for client table and server table
else else
{ {
ret = MESA_htable_set_opt(htable, MHO_EXPIRE_TIME, &expire_seconds, sizeof(expire_seconds)); ret = MESA_htable_set_opt(htable, MHO_EXPIRE_TIME, &expire_seconds, sizeof(expire_seconds));
opt_val = HASH_ELIMINATE_ALGO_FIFO;
ret = MESA_htable_set_opt(htable, MHO_ELIMIMINATE_TYPE, &opt_val, sizeof(int));
} }
opt_val = HASH_ELIMINATE_ALGO_FIFO;
ret = MESA_htable_set_opt(htable, MHO_ELIMIMINATE_TYPE, &opt_val, sizeof(int));
ret = MESA_htable_set_opt(htable, MHO_CBFUN_DATA_FREE, ret = MESA_htable_set_opt(htable, MHO_CBFUN_DATA_FREE,
(void*)free_func[i], sizeof(free_func[i])); (void*)free_func[i], sizeof(free_func[i]));