Skip to content

Commit

Permalink
feat: remove address
Browse files Browse the repository at this point in the history
  • Loading branch information
hyj1991 committed Dec 10, 2024
1 parent 9e647c8 commit 0e31d4c
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 11 deletions.
1 change: 0 additions & 1 deletion .autod.conf.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ module.exports = {
'test',
],
dep: [
'address',
'formstream',
'moment',
'nounou',
Expand Down
15 changes: 13 additions & 2 deletions common/utils.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,22 @@
'use strict';

const os = require('os');
const address = require('address');
const crypto = require('crypto');
const { promisify } = require('util');
const path = require('path');

exports.getIp = function getIp() {
const interfaces = os.networkInterfaces();
for (const interfaceItems of Object.values(interfaces)) {
for (const item of interfaceItems) {
if (item.family === 'IPv4' && !item.internal) {
return item.address;
}
}
}
return '127.0.0.1';
};

exports.regularWsServer = function(server) {
return server.startsWith('ws://') || server.startsWith('wss://');
};
Expand All @@ -22,7 +33,7 @@ exports.getAgentId = function(customAgent, ipMode) {
if (!ipMode) {
return `${os.hostname()}`;
}
return `${address.ip()}::${os.hostname()}`;
return `${exports.getIp()}::${os.hostname()}`;
};

exports.sign = function(message, secret) {
Expand Down
1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@
},
"homepage": "https://github.com/X-Profiler/xtransit#readme",
"dependencies": {
"address": "^1.1.2",
"form-data": "^4.0.0",
"moment": "^2.28.0",
"nounou": "^1.2.1",
Expand Down
6 changes: 0 additions & 6 deletions test/fixtures/files/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion test/fixtures/files/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@
},
"homepage": "https://github.com/X-Profiler/xtransit#readme",
"dependencies": {
"address": "^1.1.2",
"formstream": "^1.1.0",
"moment": "^2.26.0",
"nounou": "^1.2.1",
Expand Down
Empty file added test/fixtures/files/test_error
Empty file.

0 comments on commit 0e31d4c

Please sign in to comment.