flyzto 2 týždňov pred
rodič
commit
88004bffdd

+ 9 - 0
server/models/Clients.js

@@ -69,6 +69,14 @@ const getClientKey = (headers) => {
   .join('|');
 }
 
+const getClientIp = (req) => {
+  const ip = getRequestHeader(req, 'X-Real-IP') ||
+    normalizeHeaderValue(req.ip) ||
+    normalizeHeaderValue(req.socket?.remoteAddress) ||
+    normalizeHeaderValue(req.connection?.remoteAddress);
+  return ip.replace(/^::ffff:/, '');
+}
+
 const scheduleSaveClientsToCache = () => {
   if (saveTimer) {
     clearTimeout(saveTimer);
@@ -88,6 +96,7 @@ const recordRequest = (req) => {
     key,
     ...clientFields,
     deviceId: current.deviceId,
+    ip: getClientIp(req),
     route,
     firstRequestTime: current.firstRequestTime ?? now,
     lastRequestTime: now,

+ 8 - 0
web/apps/web-antd/src/views/match/data-sync/index.vue

@@ -15,6 +15,7 @@ type SyncClient = {
   deviceId?: number;
   firstRequestTime?: number;
   groupSequence?: string;
+  ip?: string;
   key: string;
   lastRequestTime?: number;
   marketType?: string;
@@ -107,6 +108,13 @@ const columns = [
     title: '请求接口',
     width: 180,
   },
+  {
+    align: 'center',
+    dataIndex: 'ip',
+    key: 'ip',
+    title: 'IP地址',
+    width: 140,
+  },
   {
     align: 'center',
     dataIndex: 'deviceId',