summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorliuxueli <[email protected]>2021-08-04 19:25:54 +0800
committerliuxueli <[email protected]>2021-08-04 19:25:54 +0800
commit34aee7ab311cb23707b20d1deed35356be571ba5 (patch)
tree2e936af586f945a577ea068c6a249e3288547df3
parentb862d2490d6c551a81707c5f6c8c8411fe243465 (diff)
限速用户自定义字段参数名称变更,修复误释放ratelimit的空间v5.1.7
-rw-r--r--inc/tsg_rule.h2
-rw-r--r--src/tsg_action.cpp2
-rw-r--r--src/tsg_entry.cpp2
-rw-r--r--src/tsg_rule.cpp5
4 files changed, 6 insertions, 5 deletions
diff --git a/inc/tsg_rule.h b/inc/tsg_rule.h
index a733b40..21b1b6a 100644
--- a/inc/tsg_rule.h
+++ b/inc/tsg_rule.h
@@ -52,7 +52,7 @@ struct deny_user_region
char *message;
char *redirect_url_to;
int profile_id;
- int bytes_per_sec;
+ int bps;
void *para;
};
};
diff --git a/src/tsg_action.cpp b/src/tsg_action.cpp
index fb43e61..9e58291 100644
--- a/src/tsg_action.cpp
+++ b/src/tsg_action.cpp
@@ -499,7 +499,7 @@ static unsigned char do_action_reset(const struct streaminfo *a_stream, Maat_rul
static unsigned char do_action_ratelimit(const struct streaminfo *a_stream, Maat_rule_t *p_result, struct compile_user_region *user_region)
{
struct tcpall_context *context=NULL;
- struct leaky_bucket *bucket=create_bucket((double)((user_region->deny->bytes_per_sec)/1000000), user_region->deny->bytes_per_sec, a_stream->threadnum);
+ struct leaky_bucket *bucket=create_bucket((double)((user_region->deny->bps)/1000000), user_region->deny->bps, a_stream->threadnum);
tsg_set_bucket_to_tcpall(a_stream, &context, bucket, a_stream->threadnum);
context=NULL;
diff --git a/src/tsg_entry.cpp b/src/tsg_entry.cpp
index e8ed01b..f382fe7 100644
--- a/src/tsg_entry.cpp
+++ b/src/tsg_entry.cpp
@@ -1529,7 +1529,7 @@ static unsigned char tsg_master_all_entry(const struct streaminfo *a_stream, uns
break;
}
- ret=is_permit_pass(eth_rawpkt_len, context->bucket, thread_seq);
+ ret=is_permit_pass(eth_rawpkt_len*8, context->bucket, thread_seq);
if(ret==0)
{
state=APP_STATE_GIVEME|APP_STATE_DROPPKT;
diff --git a/src/tsg_rule.cpp b/src/tsg_rule.cpp
index 8533cdc..bbcadd5 100644
--- a/src/tsg_rule.cpp
+++ b/src/tsg_rule.cpp
@@ -38,7 +38,7 @@ const struct _str2index method2index[TSG_METHOD_TYPE_MAX]={ {TSG_METHOD_TYPE_UNK
{TSG_METHOD_TYPE_BLOCK, 5, (char *)"block"},
{TSG_METHOD_TYPE_RESET, 3, (char *)"rst"},
{TSG_METHOD_TYPE_ALERT, 5, (char *)"alert"},
- {TSG_METHOD_TYPE_ALERT, 10, (char *)"rate_limit"}
+ {TSG_METHOD_TYPE_RATE_LINIT, 10, (char *)"rate_limit"}
};
static char* str_unescape(char* s)
@@ -690,7 +690,8 @@ static struct compile_user_region *parse_deny_user_region(cJSON *object)
break;
case TSG_METHOD_TYPE_RATE_LINIT:
user_region->deny=(struct deny_user_region *)calloc(1, sizeof(struct deny_user_region));
- get_integer_from_json(object, "bytes_per_sec", &(user_region->deny->bytes_per_sec));
+ user_region->deny->type=TSG_DENY_TYPE_MAX;
+ get_integer_from_json(object, "bps", &(user_region->deny->bps));
break;
case TSG_METHOD_TYPE_DROP:
case TSG_METHOD_TYPE_RESET: