From 52d0ba9fbb302ba318e597dcaeaa994f3f97f291 Mon Sep 17 00:00:00 2001 From: liuxueli Date: Sat, 8 May 2021 09:58:15 +0800 Subject: [PATCH] =?UTF-8?q?FQDN=E5=90=8E=E6=90=BA=E5=B8=A6=E7=AB=AF?= =?UTF-8?q?=E5=8F=A3=EF=BC=8C=E6=89=AB=E6=8F=8F=E6=97=B6=E9=99=A4=E5=8E=BB?= =?UTF-8?q?":"=E5=8F=8A=E4=B9=8B=E5=90=8E=E7=9A=84=E5=86=85=E5=AE=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/tsg_rule.cpp | 27 +++++++++++++++++++++++---- 1 file changed, 23 insertions(+), 4 deletions(-) diff --git a/src/tsg_rule.cpp b/src/tsg_rule.cpp index ba93bc4..9dda5cf 100644 --- a/src/tsg_rule.cpp +++ b/src/tsg_rule.cpp @@ -77,6 +77,24 @@ static char* str_unescape(char* s) return s; } +static int get_fqdn_len(char *domain) +{ + char *p=NULL; + int fqdn_len=0; + + p=index(domain, ':'); + if(p==NULL) + { + fqdn_len=strlen(domain); + } + else + { + fqdn_len=p-domain; + } + + return fqdn_len; +} + static int get_data_center(char *accept_tag, char *effective_tag_key, char *data_center, int data_center_len) { int i=0,len; @@ -1309,14 +1327,15 @@ int tsg_scan_nesting_addr(Maat_feather_t maat_feather, const struct streaminfo * //return value: -1: failed, 0: not hit, >0: hit count int tsg_scan_shared_policy(Maat_feather_t maat_feather, const struct streaminfo *a_stream, char *domain, Maat_rule_t *result, int result_num, scan_status_t *mid, int table_id, int thread_seq) { - int ret=0; - + int ret=0,fqdn_len=0; + if(table_id<0 || domain==NULL) { return 0; } - - ret=Maat_full_scan_string(g_tsg_maat_feather, table_id, CHARSET_UTF8, domain, strlen(domain), result, NULL, result_num, mid, thread_seq); + + fqdn_len=get_fqdn_len(domain); + ret=Maat_full_scan_string(g_tsg_maat_feather, table_id, CHARSET_UTF8, domain, fqdn_len, result, NULL, result_num, mid, thread_seq); if(ret>0) { FS_operate(g_tsg_para.fs2_handle, g_tsg_para.fs2_field_id[TSG_FS2_HIT_SHARE], 0, FS_OP_ADD, 1);