仅支持4级及以上IP归属地

This commit is contained in:
liuxueli
2023-06-18 15:57:17 +08:00
parent a9bf36ac67
commit 9b78e751c1
6 changed files with 21 additions and 31 deletions

View File

@@ -105,7 +105,6 @@ struct maat_runtime_para
{
int level;
int default_compile_id;
int location_field_num;
int session_record_switch;
char data_center[MAX_STRING_LEN128];
char device_tag[MAX_STRING_LEN128];
@@ -149,7 +148,6 @@ void *matched_rule_cites_dns_profile_record(struct maat *feather, long long prof
char *tsg_data_center_get(void);
char *tsg_device_tag_get(void);
int tsg_location_type_get(void);
int tsg_session_record_switch_get(void);
int tsg_domain_table_idx_get(enum TSG_PROTOCOL proto);
int tsg_fqdn_category_table_idx_get(enum TSG_PROTOCOL proto);

View File

@@ -317,33 +317,16 @@ static int set_asn(struct TLD_handle_t *_handle, const struct streaminfo *a_stre
static int set_location(struct TLD_handle_t *_handle, const struct streaminfo *a_stream, char *field_name, struct location_info *location_info)
{
if(location_info==NULL)
if(location_info==NULL || location_info->full_location==NULL || location_info->full_location_len<=0)
{
return 0;
}
int len=0;
char buff[1024]={0};
int buff_len=sizeof(buff);
int location_type=tsg_location_type_get();
switch(location_type)
{
case 18:
len+=string_cat(buff+len, buff_len-len, location_info->city_full);
buff[len++]=',';
len+=string_cat(buff+len, buff_len-len, location_info->province_full);
buff[len++]=',';
string_cat(buff+len, buff_len-len, location_info->country_full);
char location[1024]={0};
memcpy(location, location_info->full_location, MIN((int)sizeof(location), location_info->full_location_len-1));
TLD_append(_handle, field_name, (void *)location, TLD_TYPE_STRING);
TLD_append(_handle, field_name, (void *)buff, TLD_TYPE_STRING);
break;
case 19:
TLD_append(_handle, field_name, (void *)location_info->full_location, TLD_TYPE_STRING);
break;
default:
return 0;
}
return 1;
}