mirror of
https://github.com/DeNNiiInc/dbgate.git
synced 2026-04-17 22:36:01 +00:00
use DBG info
This commit is contained in:
@@ -13,7 +13,6 @@ const socket = require('./socket');
|
||||
const config = require('../controllers/config');
|
||||
const simpleEncryptor = require('simple-encryptor');
|
||||
const currentVersion = require('../currentVersion');
|
||||
const { getPublicIpInfo } = require('./hardwareFingerprint');
|
||||
|
||||
const logger = getLogger('cloudIntf');
|
||||
|
||||
@@ -423,6 +422,18 @@ function removeCloudCachedConnection(folid, cntid) {
|
||||
delete cloudConnectionCache[cacheKey];
|
||||
}
|
||||
|
||||
async function getPublicIpInfo() {
|
||||
try {
|
||||
const resp = await axios.default.get(`${DBGATE_CLOUD_URL}/ipinfo`);
|
||||
if (!resp.data?.ip) {
|
||||
return { ip: 'unknown-ip' };
|
||||
}
|
||||
return resp.data;
|
||||
} catch (err) {
|
||||
return { ip: 'unknown-ip' };
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
createDbGateIdentitySession,
|
||||
startCloudTokenChecking,
|
||||
@@ -439,4 +450,5 @@ module.exports = {
|
||||
removeCloudCachedConnection,
|
||||
readCloudTokenHolder,
|
||||
readCloudTestTokenHolder,
|
||||
getPublicIpInfo,
|
||||
};
|
||||
|
||||
@@ -2,18 +2,7 @@ const axios = require('axios');
|
||||
const os = require('os');
|
||||
const crypto = require('crypto');
|
||||
const platformInfo = require('./platformInfo');
|
||||
|
||||
async function getPublicIpInfo() {
|
||||
try {
|
||||
const resp = await axios.default.get('https://ipinfo.io/json');
|
||||
if (!resp.data?.ip) {
|
||||
return { ip: 'unknown-ip' };
|
||||
}
|
||||
return resp.data;
|
||||
} catch (err) {
|
||||
return { ip: 'unknown-ip' };
|
||||
}
|
||||
}
|
||||
const { getPublicIpInfo } = require('./cloudIntf');
|
||||
|
||||
function getMacAddress() {
|
||||
try {
|
||||
@@ -42,8 +31,6 @@ async function getHardwareFingerprint() {
|
||||
return {
|
||||
publicIp: publicIpInfo.ip,
|
||||
country: publicIpInfo.country,
|
||||
region: publicIpInfo.region,
|
||||
city: publicIpInfo.city,
|
||||
macAddress,
|
||||
platform,
|
||||
release,
|
||||
@@ -68,9 +55,7 @@ async function getPublicHardwareFingerprint() {
|
||||
hash,
|
||||
payload: {
|
||||
platform: fingerprint.platform,
|
||||
city: fingerprint.city,
|
||||
country: fingerprint.country,
|
||||
region: fingerprint.region,
|
||||
isDocker: platformInfo.isDocker,
|
||||
isAwsUbuntuLayout: platformInfo.isAwsUbuntuLayout,
|
||||
isAzureUbuntuLayout: platformInfo.isAzureUbuntuLayout,
|
||||
@@ -87,5 +72,4 @@ module.exports = {
|
||||
getHardwareFingerprint,
|
||||
getHardwareFingerprintHash,
|
||||
getPublicHardwareFingerprint,
|
||||
getPublicIpInfo,
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user