mm_ip 1.0.3 → 1.0.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/eslint.config.js CHANGED
@@ -1,68 +1,68 @@
1
- const jsdoc = require('eslint-plugin-jsdoc');
2
-
3
- module.exports = [
4
- {
5
- files: ['lib/**/*.js'],
6
- languageOptions: {
7
- ecmaVersion: 2020,
8
- sourceType: 'script'
9
- },
10
- plugins: {
11
- jsdoc: jsdoc
12
- },
13
- rules: {
14
- // JSDoc相关规则 - 设置为error级别强制要求
15
- 'jsdoc/require-jsdoc': ['error', {
16
- require: {
17
- FunctionDeclaration: true,
18
- MethodDefinition: true,
19
- ClassDeclaration: true,
20
- ArrowFunctionExpression: true
21
- }
22
- }],
23
- 'jsdoc/check-param-names': 'off',
24
- 'jsdoc/check-tag-names': 'off',
25
- 'jsdoc/check-types': 'off',
26
- 'jsdoc/require-param': 'off',
27
- 'jsdoc/require-param-description': 'off',
28
- 'jsdoc/require-returns': 'off',
29
- 'jsdoc/require-returns-description': 'off',
30
-
31
- // 基础语法规则
32
- 'no-unused-vars': ['error', { args: 'none', vars: 'all' }],
33
- 'no-console': 'warn',
34
-
35
- // 代码风格规则
36
- 'indent': ['error', 2],
37
- 'quotes': ['error', 'single'],
38
- 'semi': ['error', 'always'],
39
- 'comma-dangle': ['error', 'never'],
40
- 'no-trailing-spaces': 'error',
41
- 'eol-last': 'error',
42
- 'max-len': ['error', { code: 100 }],
43
- 'max-lines-per-function': ['error', { max: 40 }],
44
- 'complexity': ['error', 12],
45
- 'max-depth': ['error', 4],
46
- 'max-params': ['error', 4],
47
-
48
- // 命名规则
49
- 'id-length': ['error', {
50
- min: 1,
51
- max: 20,
52
- properties: 'always'
53
- }]
54
- }
55
- },
56
- {
57
- files: ['test/**/*.js'],
58
- languageOptions: {
59
- ecmaVersion: 2020,
60
- sourceType: 'script'
61
- },
62
- rules: {
63
- // 测试文件中允许使用console
64
- 'no-console': 'off',
65
- 'no-unused-vars': 'off'
66
- }
67
- }
1
+ const jsdoc = require('eslint-plugin-jsdoc');
2
+
3
+ module.exports = [
4
+ {
5
+ files: ['index.js','lib/**/*.js'],
6
+ languageOptions: {
7
+ ecmaVersion: 2020,
8
+ sourceType: 'script'
9
+ },
10
+ plugins: {
11
+ jsdoc: jsdoc
12
+ },
13
+ rules: {
14
+ // JSDoc相关规则 - 设置为error级别强制要求
15
+ 'jsdoc/require-jsdoc': ['error', {
16
+ require: {
17
+ FunctionDeclaration: true,
18
+ MethodDefinition: true,
19
+ ClassDeclaration: true,
20
+ ArrowFunctionExpression: true
21
+ }
22
+ }],
23
+ 'jsdoc/check-param-names': 'off',
24
+ 'jsdoc/check-tag-names': 'off',
25
+ 'jsdoc/check-types': 'off',
26
+ 'jsdoc/require-param': 'off',
27
+ 'jsdoc/require-param-description': 'off',
28
+ 'jsdoc/require-returns': 'off',
29
+ 'jsdoc/require-returns-description': 'off',
30
+
31
+ // 基础语法规则
32
+ 'no-unused-vars': ['error', { args: 'none', vars: 'all' }],
33
+ 'no-console': 'warn',
34
+
35
+ // 代码风格规则
36
+ 'indent': ['error', 2],
37
+ 'quotes': ['error', 'single'],
38
+ 'semi': ['error', 'always'],
39
+ 'comma-dangle': ['error', 'never'],
40
+ 'no-trailing-spaces': 'error',
41
+ 'eol-last': 'error',
42
+ 'max-len': ['error', { code: 100 }],
43
+ 'max-lines-per-function': ['error', { max: 40 }],
44
+ 'complexity': ['error', 12],
45
+ 'max-depth': ['error', 4],
46
+ 'max-params': ['error', 4],
47
+
48
+ // 命名规则
49
+ 'id-length': ['error', {
50
+ min: 1,
51
+ max: 20,
52
+ properties: 'always'
53
+ }]
54
+ }
55
+ },
56
+ {
57
+ files: ['test/**/*.js'],
58
+ languageOptions: {
59
+ ecmaVersion: 2020,
60
+ sourceType: 'script'
61
+ },
62
+ rules: {
63
+ // 测试文件中允许使用console
64
+ 'no-console': 'off',
65
+ 'no-unused-vars': 'off'
66
+ }
67
+ }
68
68
  ];
package/index.js CHANGED
@@ -92,7 +92,6 @@ Ip.prototype.addWhite = function(ip) {
92
92
  }
93
93
 
94
94
  this._white.add(ip);
95
- this.log('info', '添加白名单IP:', ip);
96
95
 
97
96
  // 自动保存到持久化存储
98
97
  if (this._config.dir) {
@@ -205,7 +204,6 @@ Ip.prototype.record = function(ip) {
205
204
  // 检查是否过期
206
205
  if (this._isBlackExpired(ip)) {
207
206
  this.delBlack(ip);
208
- this.log('info', '黑名单IP已过期,自动移除:', ip);
209
207
  } else {
210
208
  this.log('warn', '黑名单IP请求被拒绝:', ip);
211
209
  // 记录违规:黑名单IP尝试访问
@@ -490,7 +488,6 @@ Ip.prototype._cleanExpiredBlack = function() {
490
488
  for (const ip of expired) {
491
489
  this.delBlack(ip);
492
490
  this._black_time.delete(ip);
493
- this.log('info', '清理过期黑名单IP:', ip);
494
491
  }
495
492
  };
496
493
 
@@ -564,13 +561,6 @@ Ip.prototype.recordViolation = function(ip, reason) {
564
561
  this._violation_count.set(ip, count);
565
562
  this._violation_time.set(ip, now);
566
563
 
567
- this.log('info', 'IP违规记录:', {
568
- ip,
569
- reason,
570
- count,
571
- time: new Date(now).toISOString()
572
- });
573
-
574
564
  // 检查是否达到自动拉黑条件
575
565
  if (this._config.violation_auto_black && count >= this._config.violation_max_count) {
576
566
  this.blackByHighFreq(ip, this._config.auto_black_duration);
@@ -765,7 +755,6 @@ Ip.prototype.load = function() {
765
755
  }
766
756
  }
767
757
  loadedCount++;
768
- this.log('info', '白名单数据已加载:', whitePath);
769
758
  }
770
759
  }
771
760
 
@@ -794,7 +783,6 @@ Ip.prototype.load = function() {
794
783
  }
795
784
 
796
785
  loadedCount++;
797
- this.log('info', '黑名单数据已加载:', blackPath);
798
786
  }
799
787
 
800
788
  // 加载违规记录数据
@@ -821,18 +809,6 @@ Ip.prototype.load = function() {
821
809
  }
822
810
 
823
811
  loadedCount++;
824
- this.log('info', '违规记录数据已加载:', violationPath);
825
- }
826
-
827
- if (loadedCount === 0) {
828
- this.log('info', '未找到任何IP数据文件,跳过加载');
829
- } else {
830
- this.log('info', 'IP数据加载完成,统计:', {
831
- white_count: this.getAllWhite().length,
832
- black_count: this.getAllBlack().length,
833
- violation_count: this.getAllViolationIps().length,
834
- files_loaded: loadedCount
835
- });
836
812
  }
837
813
 
838
814
  return true;
@@ -854,8 +830,6 @@ Ip.prototype.autoSave = function(interval = 300000) {
854
830
  this._autoSaveTimer = setInterval(() => {
855
831
  this.save();
856
832
  }, interval);
857
-
858
- this.log('info', '自动保存已启动,间隔:', interval, 'ms');
859
833
  };
860
834
 
861
835
  /**
@@ -865,7 +839,6 @@ Ip.prototype.stopAutoSave = function() {
865
839
  if (this._autoSaveTimer) {
866
840
  clearInterval(this._autoSaveTimer);
867
841
  this._autoSaveTimer = null;
868
- this.log('info', '自动保存已停止');
869
842
  }
870
843
  };
871
844
 
@@ -918,11 +891,6 @@ Ip.prototype.del = function(ip) {
918
891
 
919
892
  // 如果有任何删除操作,记录日志并自动保存
920
893
  if (Object.values(result).some(Boolean)) {
921
- this.log('info', '删除IP记录:', {
922
- ip,
923
- result
924
- });
925
-
926
894
  // 自动保存到持久化存储
927
895
  if (this._config.dir) {
928
896
  this.save();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mm_ip",
3
- "version": "1.0.3",
3
+ "version": "1.0.4",
4
4
  "description": "用于管理IP名单,可设置白名单、黑名单和IP检查,查询IP请求次数、频率等。",
5
5
  "main": "index.js",
6
6
  "scripts": {