summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorliuxueli <[email protected]>2022-05-18 11:41:41 +0800
committerliuxueli <[email protected]>2022-05-18 11:41:41 +0800
commit4899c9e96aa9edef9b50a8e274f9bb0cfc16056b (patch)
tree09da5f10b72ca512a1b0cd29e72575c7afcaeca5
parentf7c0f018be16586ed877aa02a6554a9fa453994f (diff)
TSG-10006: 兼容三、四级(N)地址库
-rw-r--r--src/tsg_entry.h2
-rw-r--r--src/tsg_rule.cpp5
-rw-r--r--src/tsg_send_log.cpp50
3 files changed, 46 insertions, 11 deletions
diff --git a/src/tsg_entry.h b/src/tsg_entry.h
index 3a6dfdc..cb55c34 100644
--- a/src/tsg_entry.h
+++ b/src/tsg_entry.h
@@ -406,6 +406,8 @@ const void *get_struct_project(const struct streaminfo *a_stream, int project_id
//parent_app_name.app_name
int tsg_app_id2name(int app_id, char *app_name, int app_name_len, int is_joint_parent);
+//return 18 or 19: subdivision_addr
+int tsg_get_location_type(void);
void location_free_data(int table_id, MAAT_PLUGIN_EX_DATA* ad, long argl, void* argp);
void ASN_number_free(int table_id, MAAT_PLUGIN_EX_DATA* ad, long argl, void* argp);
void subscriber_id_free(int table_id, MAAT_PLUGIN_EX_DATA* ad, long argl, void* argp);
diff --git a/src/tsg_rule.cpp b/src/tsg_rule.cpp
index f0989ee..23acd97 100644
--- a/src/tsg_rule.cpp
+++ b/src/tsg_rule.cpp
@@ -2930,3 +2930,8 @@ int tsg_set_fqdn_category_id(const struct streaminfo *a_stream, unsigned int *ca
return 0;
}
+
+int tsg_get_location_type(void)
+{
+ return g_tsg_para.location_field_num;
+}
diff --git a/src/tsg_send_log.cpp b/src/tsg_send_log.cpp
index 231b83a..efc62db 100644
--- a/src/tsg_send_log.cpp
+++ b/src/tsg_send_log.cpp
@@ -348,16 +348,31 @@ static int set_location(struct TLD_handle_t *_handle, struct streaminfo *a_strea
return 0;
}
- len+=string_cat(buff+len, buff_len-len, location_info->country_full);
- buff[len++]='.';
- len+=string_cat(buff+len, buff_len-len, location_info->province_full);
- buff[len++]='.';
- len+=string_cat(buff+len, buff_len-len, location_info->city_full);
-
- if(location_info->subdivision_addr!=NULL)
- {
- buff[len++]='.';
- len+=string_cat(buff+len, buff_len-len, location_info->subdivision_addr);
+ int location_type=tsg_get_location_type();
+ 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++]=',';
+ len+=string_cat(buff+len, buff_len-len, location_info->country_full);
+ break;
+ case 19:
+ len+=string_cat(buff+len, buff_len-len, location_info->country_full);
+ buff[len++]='.';
+ len+=string_cat(buff+len, buff_len-len, location_info->province_full);
+ buff[len++]='.';
+ len+=string_cat(buff+len, buff_len-len, location_info->city_full);
+
+ if(location_info->subdivision_addr!=NULL)
+ {
+ buff[len++]='.';
+ len+=string_cat(buff+len, buff_len-len, location_info->subdivision_addr);
+ }
+ break;
+ default:
+ return 0;
}
TLD_append(_handle, field_name, (void *)buff, TLD_TYPE_STRING);
@@ -2074,8 +2089,21 @@ int tsg_send_payload(struct tsg_log_instance_t *instance, int topic_id, char *pa
);
return -1;
}
+ else
+ {
+ update_percent(_instance, topic_id, LOG_COLUMN_STATUS_SUCCESS, thread_id);
+ MESA_handle_runtime_log(_instance->logger,
+ RLOG_LV_DEBUG,
+ "TSG_SEND_LOG",
+ "log send successfully %s: %s",
+ _instance->service2topic[topic_id].name,
+ payload
+ );
+ }
+
+
+
- update_percent(_instance, topic_id, LOG_COLUMN_STATUS_SUCCESS, thread_id);
update_percent(_instance, topic_id, LOG_COLUMN_STATUS_MAX, thread_id);
return 0;