@domain.js/main 0.7.6 → 0.7.8

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.
@@ -336,6 +336,12 @@ function Utils(cnf, deps) {
336
336
  where[sequelize_1.Op.and] = [];
337
337
  where[sequelize_1.Op.and].push(sequelize_1.Sequelize.where(sequelize_1.Sequelize.fn("FIND_IN_SET", params[`${name}_ins`], sequelize_1.Sequelize.col(`${modelAlias4Ins}.${col}`)), sequelize_1.Op.gte, 1));
338
338
  }
339
+ // 处理 json_contains 方式的过滤
340
+ if (_.isString(params[`${name}_contains`]) || _.isNumber(params[`${name}_contains`])) {
341
+ if (!where[sequelize_1.Op.and])
342
+ where[sequelize_1.Op.and] = [];
343
+ where[sequelize_1.Op.and].push(sequelize_1.Sequelize.where(sequelize_1.Sequelize.fn("JSON_CONTAINS", sequelize_1.Sequelize.col(`${modelAlias4Ins}.${col}`), params[`${name}_contains`]), true));
344
+ }
339
345
  // 处理 find_in_set 方式的过滤 _ins_and
340
346
  if (_.isString(params[`${name}_ins_and`])) {
341
347
  if (!where[sequelize_1.Op.and])
@@ -34,6 +34,18 @@ const enc = encodeURI;
34
34
  const TMPDIR = os.tmpdir();
35
35
  function Utils(cnf) {
36
36
  const proxyIps = new Set((cnf.proxyIps || "127.0.0.1").split(","));
37
+ /**
38
+ * 判断是否是内网ip
39
+ * 10.0.0.0 - 10.255.255.255 (10/8 前缀)
40
+ * 172.16.0.0 - 172.31.255.255 (172.16/12 到 172.31/12 前缀)
41
+ * 192.168.0.0 - 192.168.255.255 (192.168/16 前缀)
42
+ */
43
+ const isInternalIp = (ip) => {
44
+ const parts = ip.split(".").map(Number);
45
+ return (parts[0] === 10 ||
46
+ (parts[0] === 192 && parts[1] === 168) ||
47
+ (parts[0] === 172 && parts[1] >= 16 && parts[1] <= 31));
48
+ };
37
49
  const utils = {
38
50
  ucwords(value) {
39
51
  return `${value[0].toUpperCase()}${value.substring(1)}`;
@@ -56,7 +68,7 @@ function Utils(cnf) {
56
68
  */
57
69
  realIp(req) {
58
70
  const remoteIp = utils.remoteIp(req);
59
- if (!proxyIps.has(remoteIp))
71
+ if (!proxyIps.has(remoteIp) && !isInternalIp(remoteIp))
60
72
  return remoteIp;
61
73
  return (req.headers["x-real-ip"] || remoteIp).toString();
62
74
  },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@domain.js/main",
3
- "version": "0.7.6",
3
+ "version": "0.7.8",
4
4
  "description": "DDD framework",
5
5
  "main": "dist/index.js",
6
6
  "bin": {
@@ -78,10 +78,10 @@
78
78
  "mysql2": "^2.3.3",
79
79
  "restify": "^11.1.0",
80
80
  "restify-errors": "^8.0.2",
81
- "sequelize": "^6.16.1",
81
+ "sequelize": "^6.37.3",
82
82
  "socket.io": "^4.4.1",
83
83
  "type-fest": "^2.8.0",
84
84
  "uuid": "^8.3.2",
85
- "xlsx": "^0.17.4"
85
+ "xlsx": "^0.18.5"
86
86
  }
87
87
  }