diff options
| author | liuxueli <[email protected]> | 2020-06-08 17:12:15 +0800 |
|---|---|---|
| committer | liuxueli <[email protected]> | 2020-06-08 17:12:15 +0800 |
| commit | 89496d33f7e3398db7bf9e830eaac1ad57002b4c (patch) | |
| tree | 2c685db50789d3fb191619a9eaa0b137f0139307 | |
| parent | b67882bd6a8cd78efc513e244a68d72218a499d3 (diff) | |
修复IP归属地不命中的BUG,当国家或者城市中出现空格(\\b)时,需要将\\b进行转换为空格(‘ ’)v1.2.7.20.06
| -rw-r--r-- | src/tsg_entry.cpp | 2 | ||||
| -rw-r--r-- | src/tsg_rule.cpp | 47 |
2 files changed, 47 insertions, 2 deletions
diff --git a/src/tsg_entry.cpp b/src/tsg_entry.cpp index 40f543e..7524f7b 100644 --- a/src/tsg_entry.cpp +++ b/src/tsg_entry.cpp @@ -42,7 +42,7 @@ static __attribute__((__used__)) const char * GIT_VERSION_UNKNOWN = NULL; #endif -char TSG_MASTER_VERSION_20200605=0; +char TSG_MASTER_VERSION_20200608=0; const char *tsg_conffile="tsgconf/main.conf"; g_tsg_para_t g_tsg_para; diff --git a/src/tsg_rule.cpp b/src/tsg_rule.cpp index 82d92d5..c346eb6 100644 --- a/src/tsg_rule.cpp +++ b/src/tsg_rule.cpp @@ -55,6 +55,44 @@ const struct _str2index g_tsg_proto_string[PROTO_MAX+1]={{PROTO_UNKONWN, 0, (cha {PROTO_MAX, 0, (char *)""} }; +static char* str_unescape(char* s) +{ + int i=0,j=0; + int len=strlen(s); + for(i=0,j=0;i<len;i++) + { + if(s[i]=='\\') + { + switch(s[i+1]) + { + case '&': + s[j]='&'; + break; + case 'b': + s[j]=' ';//space,0x20; + break; + case '\\': + s[j]='\\'; + break; + default: + s[j]=s[i]; + i--; //undo the followed i++ + break; + } + i++; + j++; + } + else + { + s[j]=s[i]; + j++; + } + } + s[j]='\0'; + return s; +} + + void ASN_dup_data(int table_id, MAAT_PLUGIN_EX_DATA *to, MAAT_PLUGIN_EX_DATA *from, long argl, void* argp) { void *logger=argp; @@ -103,6 +141,8 @@ void ASN_new_data(int table_id, const char* key, const char* table_line, MAAT_PL return; } + str_unescape(asn->organization); + atomic_inc(&asn->ref_cnt); asn->table_id=table_id; *ad=(MAAT_PLUGIN_EX_DATA)asn; @@ -215,6 +255,11 @@ void location_new_data(int table_id, const char* key, const char* table_line, MA ); return; } + + str_unescape(location->continent_full); + str_unescape(location->country_full); + str_unescape(location->province_full); + str_unescape(location->city_full); atomic_inc(&location->ref_cnt); location->table_id=table_id; @@ -804,7 +849,7 @@ int tsg_scan_ip_location(Maat_feather_t maat_feather, const struct streaminfo *a MESA_handle_runtime_log(g_tsg_para.logger, RLOG_LV_DEBUG, "SCAN_IP_LOCATION", - "Hit IP_LOCATION: %s scan ret: %d table_name: %d policy_id: %d service: %d action: %d addr: %s", + "Hit IP_LOCATION: %s scan ret: %d table_name: %s policy_id: %d service: %d action: %d addr: %s", buff, ret, g_tsg_para.table_name[idx], |
