IP归属地加载配置时完成拼接,代理CMSG传输直接使用拼接后的字符串
This commit is contained in:
@@ -410,31 +410,13 @@ static void tsg_proxy_cmsg_ip_location_fill(struct session_runtime_attribute *se
|
||||
const struct location_info *client_location = srt_attribute_get_client_ip_location(session_attr);
|
||||
const struct location_info *server_location = srt_attribute_get_server_ip_location(session_attr);
|
||||
if (client_location) {
|
||||
if (client_location->country_full) {
|
||||
cmsg->src_ip_location_country = client_location->country_full;
|
||||
}
|
||||
if (client_location->province_full) {
|
||||
cmsg->src_ip_location_provine = client_location->province_full;
|
||||
}
|
||||
if (client_location->city_full) {
|
||||
cmsg->src_ip_location_city = client_location->city_full;
|
||||
}
|
||||
if (client_location->subdivision_addr) {
|
||||
cmsg->src_ip_location_subdivision = client_location->subdivision_addr;
|
||||
if (client_location->full_location && client_location->full_location_len) {
|
||||
cmsg->src_ip_full_location = client_location->full_location;
|
||||
}
|
||||
}
|
||||
if (server_location) {
|
||||
if (server_location->country_full) {
|
||||
cmsg->dst_ip_location_country = server_location->country_full;
|
||||
}
|
||||
if (server_location->province_full) {
|
||||
cmsg->dst_ip_location_provine = server_location->province_full;
|
||||
}
|
||||
if (server_location->city_full) {
|
||||
cmsg->dst_ip_location_city = server_location->city_full;
|
||||
}
|
||||
if (server_location->subdivision_addr) {
|
||||
cmsg->dst_ip_location_subdivision = server_location->subdivision_addr;
|
||||
if (server_location->full_location && server_location->full_location_len) {
|
||||
cmsg->dst_ip_full_location = server_location->full_location;
|
||||
}
|
||||
}
|
||||
return;
|
||||
@@ -543,14 +525,8 @@ static void tsg_proxy_tcp_attribute_dump(tsg_proxy_tcp_attribute *tcp_attr, stru
|
||||
"server asn: %s\n"\
|
||||
"client orgnization: %s\n"\
|
||||
"server orgnization: %s\n"\
|
||||
"client ip country: %s\n"\
|
||||
"server ip country: %s\n"\
|
||||
"client ip province: %s\n"\
|
||||
"server ip province: %s\n"\
|
||||
"client ip city: %s\n"\
|
||||
"server ip city: %s\n"\
|
||||
"client ip subdevision: %s\n"\
|
||||
"server ip subdevision: %s\n"\
|
||||
"client ip full_location: %s\n"\
|
||||
"server ip full_location: %s\n"\
|
||||
"ssl ja3 fingerprint:%s\n"\
|
||||
"tcp_seq_route_ctx len: %d\n"\
|
||||
"tcp_ack_route_ctx len: %d\n"\
|
||||
@@ -562,14 +538,8 @@ static void tsg_proxy_tcp_attribute_dump(tsg_proxy_tcp_attribute *tcp_attr, stru
|
||||
cmsg->dst_asn,
|
||||
cmsg->src_organization,
|
||||
cmsg->dst_organization,
|
||||
cmsg->src_ip_location_country,
|
||||
cmsg->dst_ip_location_country,
|
||||
cmsg->src_ip_location_provine,
|
||||
cmsg->dst_ip_location_provine,
|
||||
cmsg->src_ip_location_city,
|
||||
cmsg->dst_ip_location_city,
|
||||
cmsg->src_ip_location_subdivision,
|
||||
cmsg->dst_ip_location_subdivision,
|
||||
cmsg->src_ip_full_location,
|
||||
cmsg->dst_ip_full_location,
|
||||
cmsg->ssl_client_ja3_fingerprint,
|
||||
cmsg->tcp_seq_route_ctx.len,
|
||||
cmsg->tcp_ack_route_ctx.len,
|
||||
|
||||
@@ -556,23 +556,22 @@ void ex_data_location_new(const char *table_name, int table_id, const char* key,
|
||||
char full_address[1024]={0};
|
||||
struct location_info *location=(struct location_info *)calloc(1, sizeof(struct location_info));
|
||||
|
||||
location->country_full=column_string_get_value(table_line, 13); // country_full
|
||||
location->province_full=column_string_get_value(table_line, 15); // province_full
|
||||
location->city_full=column_string_get_value(table_line, 16); // city_full
|
||||
tsg_str_unescape(location->country_full);
|
||||
tsg_str_unescape(location->province_full);
|
||||
tsg_str_unescape(location->city_full);
|
||||
|
||||
location->subdivision_addr=column_string_get_value(table_line, 17); // subdivision_addr
|
||||
tsg_str_unescape(location->subdivision_addr);
|
||||
char *country_full=column_string_get_value(table_line, 13); // country_full
|
||||
char *province_full=column_string_get_value(table_line, 15); // province_full
|
||||
char *city_full=column_string_get_value(table_line, 16); // city_full
|
||||
char *subdivision_addr=column_string_get_value(table_line, 17); // subdivision_addr
|
||||
tsg_str_unescape(country_full);
|
||||
tsg_str_unescape(province_full);
|
||||
tsg_str_unescape(city_full);
|
||||
tsg_str_unescape(subdivision_addr);
|
||||
|
||||
location->full_location_len=snprintf(full_address,
|
||||
sizeof(full_address),
|
||||
"%s.%s.%s.%s.",
|
||||
location->country_full,
|
||||
location->province_full,
|
||||
location->city_full,
|
||||
location->subdivision_addr==NULL ? "" : location->subdivision_addr);
|
||||
country_full,
|
||||
province_full,
|
||||
city_full,
|
||||
subdivision_addr==NULL ? "" : subdivision_addr);
|
||||
|
||||
|
||||
if(location->full_location_len>0)
|
||||
@@ -586,6 +585,11 @@ void ex_data_location_new(const char *table_name, int table_id, const char* key,
|
||||
*ad=(void *)location;
|
||||
|
||||
tsg_stat_sync_exdata_add_update(SYNC_EXDATA_LOCATION, 1);
|
||||
tsg_free_field(country_full);
|
||||
tsg_free_field(province_full);
|
||||
tsg_free_field(city_full);
|
||||
tsg_free_field(subdivision_addr);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -596,10 +600,6 @@ void ex_data_location_free(int table_id, void **ad, long argl, void* argp)
|
||||
struct location_info *location=(struct location_info *)(*ad);
|
||||
if((__sync_sub_and_fetch(&location->ref_cnt, 1) == 0))
|
||||
{
|
||||
tsg_free_field(location->country_full);
|
||||
tsg_free_field(location->province_full);
|
||||
tsg_free_field(location->city_full);
|
||||
tsg_free_field(location->subdivision_addr);
|
||||
tsg_free_field(location->full_location);
|
||||
|
||||
tsg_free_field((char *)(*ad));
|
||||
|
||||
@@ -204,14 +204,8 @@ static void mpack_append_cmsg_value(mpack_writer_t *writer, struct proxy_cmsg *c
|
||||
mpack_append_string(writer, cmsg->dst_asn);
|
||||
mpack_append_string(writer, cmsg->src_organization);
|
||||
mpack_append_string(writer, cmsg->dst_organization);
|
||||
mpack_append_string(writer, cmsg->src_ip_location_country);
|
||||
mpack_append_string(writer, cmsg->dst_ip_location_country);
|
||||
mpack_append_string(writer, cmsg->src_ip_location_provine);
|
||||
mpack_append_string(writer, cmsg->dst_ip_location_provine);
|
||||
mpack_append_string(writer, cmsg->src_ip_location_city);
|
||||
mpack_append_string(writer, cmsg->dst_ip_location_city);
|
||||
mpack_append_string(writer, cmsg->src_ip_location_subdivision);
|
||||
mpack_append_string(writer, cmsg->dst_ip_location_subdivision);
|
||||
mpack_append_string(writer, cmsg->src_ip_full_location);
|
||||
mpack_append_string(writer, cmsg->dst_ip_full_location);
|
||||
mpack_append_string(writer, cmsg->ssl_client_ja3_fingerprint);
|
||||
|
||||
// fqdn_cat_id_val
|
||||
|
||||
@@ -68,7 +68,7 @@ struct proxy_cmsg
|
||||
uint32_t tcp_ts_client_val;
|
||||
uint32_t tcp_ts_server_val;
|
||||
uint32_t tcp_seq;
|
||||
uint32_t tcp_ack;
|
||||
uint32_t tcp_ack;
|
||||
|
||||
char *src_sub_id;
|
||||
char *dst_sub_id;
|
||||
@@ -76,14 +76,8 @@ struct proxy_cmsg
|
||||
char *dst_asn;
|
||||
char *src_organization;
|
||||
char *dst_organization;
|
||||
char *src_ip_location_country;
|
||||
char *dst_ip_location_country;
|
||||
char *src_ip_location_provine;
|
||||
char *dst_ip_location_provine;
|
||||
char *src_ip_location_city;
|
||||
char *dst_ip_location_city;
|
||||
char *src_ip_location_subdivision;
|
||||
char *dst_ip_location_subdivision;
|
||||
char *src_ip_full_location;
|
||||
char *dst_ip_full_location;
|
||||
char *ssl_client_ja3_fingerprint;
|
||||
struct fqdn_cat_id_val fqdn_cat_ids;
|
||||
struct tcp_sids tcp_seq_sids;
|
||||
|
||||
Reference in New Issue
Block a user