Use new built in public IP detection

This commit is contained in:
Björn Dahlgren 2023-07-21 17:25:26 +02:00
parent 9ec8e83090
commit b3574552e2
2 changed files with 25 additions and 30 deletions

View File

@ -3,7 +3,6 @@ var events = require('events')
var fs = require('fs.extra') var fs = require('fs.extra')
var Gamedig = require('gamedig') var Gamedig = require('gamedig')
var path = require('path') var path = require('path')
var publicIp = require('public-ip')
var slugify = require('slugify') var slugify = require('slugify')
var queryInterval = 5000 var queryInterval = 5000
@ -89,7 +88,7 @@ Server.prototype.makeServerConfig = function () {
return { return {
bindAddress: '', bindAddress: '',
bindPort: this.port, bindPort: this.port,
publicAddress: this.ip, publicAddress: '',
publicPort: this.port, publicPort: this.port,
a2s: { a2s: {
address: '127.0.0.1', address: '127.0.0.1',
@ -172,8 +171,6 @@ Server.prototype.start = function () {
} }
var self = this var self = this
publicIp.v4().then(function (ip) {
self.ip = ip
var config = self.makeServerConfig() var config = self.makeServerConfig()
self.saveServerConfig(config, function (err) { self.saveServerConfig(config, function (err) {
if (err) { if (err) {
@ -205,7 +202,6 @@ Server.prototype.start = function () {
self.emit('state') self.emit('state')
}) })
})
return this return this
} }

View File

@ -39,7 +39,6 @@
"lodash": "^4.17.10", "lodash": "^4.17.10",
"morgan": "^1.8.1", "morgan": "^1.8.1",
"multer": "^1.3.0", "multer": "^1.3.0",
"public-ip": "^4.0.4",
"raw-loader": "^0.5.1", "raw-loader": "^0.5.1",
"serve-static": "^1.12.1", "serve-static": "^1.12.1",
"slugify": "^1.1.0", "slugify": "^1.1.0",