@things-factory/shell 6.2.52 → 6.2.65

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@things-factory/shell",
3
- "version": "6.2.52",
3
+ "version": "6.2.65",
4
4
  "description": "Core module for framework",
5
5
  "bin": {
6
6
  "things-factory": "bin/things-factory",
@@ -133,5 +133,5 @@
133
133
  "pg": "^8.7.3",
134
134
  "sqlite3": "^5.0.8"
135
135
  },
136
- "gitHead": "234f95b63937521f1791a9e2141024ee7816d26d"
136
+ "gitHead": "320f62ab586b0c7058e7879f3e6592c960ae97bc"
137
137
  }
@@ -13,7 +13,7 @@ export async function domainMiddleware(context: any, next: any) {
13
13
  }
14
14
 
15
15
  if (domain) {
16
- const ip = context.ip || requestIp.getClientIp(context.req)
16
+ const ip = requestIp.getClientIp(context.req)
17
17
  const { whitelist = [], blacklist = [], protectedlist = [], privileges = [] } = domain.iplist || {}
18
18
 
19
19
  if (Array.isArray(whitelist) && whitelist.length > 0) {
@@ -1,4 +1,5 @@
1
1
  import Router from 'koa-router'
2
+ import requestIp from 'request-ip'
2
3
 
3
4
  import { getLicenseInfo } from '@things-factory/operato-license-checker'
4
5
  import { domainMiddleware } from '../middlewares/domain-middleware'
@@ -54,16 +55,17 @@ globalPublicRouter.get('/opensource-licenses', (context, next) => {
54
55
  })
55
56
 
56
57
  globalPublicRouter.get('/request-info', context => {
57
- const clientIP = context.headers['x-forwarded-for'] || context.ip
58
- const protocol = context.headers['x-forwarded-proto'] || context.protocol
59
- const host = context.headers['x-forwarded-host'] || context.host
60
- const port = context.headers['x-forwarded-port'] || context.host.split(':')[1]
61
-
62
58
  context.body = `
63
- Client IP: ${clientIP}
64
- Protocol: ${protocol}
65
- Host: ${host}
66
- Port: ${port}
59
+ Client info. from "requestIp": ${requestIp.getClientIp(context.req)}
60
+
61
+ Client info. from "context.ip": ${context.ip}
62
+ Client info. from "context.protocol": ${context.protocol}
63
+ Client info. from "context.host": ${context.host}
64
+
65
+ Client info. from "x-forwarded-for": ${context.headers['x-forwarded-for']}
66
+ Client info. from "x-forwarded-proto": ${context.headers['x-forwarded-proto']}
67
+ Client info. from "x-forwarded-host": ${context.headers['x-forwarded-host']}
68
+ Client info. from "x-forwarded-port": ${context.headers['x-forwarded-port']}
67
69
  `
68
70
  })
69
71