bugfix: 修复了通过cmsg获取IP归属地的问题

This commit is contained in:
fengweihao
2024-04-03 16:50:54 +08:00
committed by luwenpeng
parent 8a2dcfcb31
commit 641c14f55a
7 changed files with 23 additions and 75 deletions

View File

@@ -1149,14 +1149,6 @@ struct edit_element_ctx
int actually_edited;
};
struct ip_data_ctx
{
char *asn_client;
char *asn_server;
char *location_client;
char *location_server;
};
struct proxy_http_ctx
{
int magic_num;
@@ -1177,7 +1169,6 @@ struct proxy_http_ctx
struct insert_ctx * ins_ctx;
struct edit_element_ctx * edit_ctx;
struct tsg_script_ctx *tsg_ctx;
struct ip_data_ctx ip_ctx;
int (* resumed_cb)(const struct tfe_stream * stream,
const struct tfe_http_session * session, enum tfe_http_event event, const unsigned char * data,
@@ -1316,18 +1307,6 @@ void http_tsg_ctx_free(struct tsg_script_ctx *tsg_ctx, int thread_id)
return;
}
void http_ip_ctx_free(struct ip_data_ctx *ip_ctx)
{
if(ip_ctx->asn_client)
FREE(&ip_ctx->asn_client);
if(ip_ctx->asn_server)
FREE(&ip_ctx->asn_server);
if(ip_ctx->location_client)
FREE(&ip_ctx->location_client);
if(ip_ctx->location_server)
FREE(&ip_ctx->location_server);
}
#define HTTP_CTX_MAGIC_NUM 20181021
static struct proxy_http_ctx * proxy_http_ctx_new(unsigned int thread_id)
{
@@ -1362,7 +1341,6 @@ static void proxy_http_ctx_free(struct proxy_http_ctx * ctx)
ctx->tsg_ctx = NULL;
}
http_ip_ctx_free(&ctx->ip_ctx);
ctx->manipulate_replaced=0;
FREE(&ctx->enforce_rules);
policy_action_param_free(ctx->param);
@@ -2939,7 +2917,7 @@ void proxy_on_http_begin(const struct tfe_stream *stream, const struct tfe_http_
hit_cnt+=scan_ret;
}
scan_ret = tfe_scan_ip_asn(stream, result, ctx->scan_mid, hit_cnt, g_proxy_rt->local_logger, &(ctx->ip_ctx.asn_server), &(ctx->ip_ctx.asn_client));
scan_ret = tfe_scan_ip_asn(stream, result, ctx->scan_mid, hit_cnt, g_proxy_rt->local_logger);
if(scan_ret>0)
{
hit_cnt+=scan_ret;
@@ -3021,9 +2999,8 @@ void proxy_on_http_end(const struct tfe_stream * stream,
}
}
struct proxy_log log_msg = {.stream=stream, .http=session, .result=(struct log_rule_t *)ctx->enforce_rules, .result_num=ctx->n_enforce,
.req_body=ctx->log_req_body, .resp_body=ctx->log_resp_body, .action=0, .inject_sz=ctx->inject_sz,
.asn_client=ctx->ip_ctx.asn_client, .asn_server=ctx->ip_ctx.asn_server, .location_client=ctx->ip_ctx.location_client,
.location_server=ctx->ip_ctx.location_server, .c2s_byte_num=ctx->c2s_byte_num, .s2c_byte_num=ctx->s2c_byte_num};
.req_body=ctx->log_req_body, .resp_body=ctx->log_resp_body, .action=0, .inject_sz=ctx->inject_sz, .c2s_byte_num=ctx->c2s_byte_num,
.s2c_byte_num=ctx->s2c_byte_num};
if(ctx->action == PX_ACTION_MANIPULATE)
{
log_msg.action = ctx->param->action;