summaryrefslogtreecommitdiff
path: root/src/tsg_send_log.cpp
diff options
context:
space:
mode:
authorliuxueli <[email protected]>2023-06-18 15:57:17 +0800
committerliuxueli <[email protected]>2023-06-18 15:57:17 +0800
commit9b78e751c1e482c034e39bcc48aa1648501ee09f (patch)
treee2db95272ad784e16b6d930153e2a1dbc3d652f2 /src/tsg_send_log.cpp
parenta9bf36ac67f0131a0f16a061358affaab71d541a (diff)
仅支持4级及以上IP归属地
Diffstat (limited to 'src/tsg_send_log.cpp')
-rw-r--r--src/tsg_send_log.cpp27
1 files changed, 5 insertions, 22 deletions
diff --git a/src/tsg_send_log.cpp b/src/tsg_send_log.cpp
index e0dc307..82fd20b 100644
--- a/src/tsg_send_log.cpp
+++ b/src/tsg_send_log.cpp
@@ -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;
}