@@ -3,6 +3,7 @@ const express = require('express');
33const path = require ( 'path' ) ;
44const cors = require ( 'cors' )
55const bodyParser = require ( 'body-parser' ) ;
6+ const https = require ( 'https' )
67const app = express ( ) ;
78const port = process . env . PORT || 1337 ;
89const db = require ( './db' ) ;
@@ -21,6 +22,7 @@ const configFileManager = {
2122
2223// usado en './controllers/servers';
2324global . serversOnlineQuantityUsers = [ ] ;
25+ global . serverIpAddress = null ;
2426
2527app . use ( '/api/v1/users' , require ( './controllers/users' ) ) ;
2628app . use ( '/api/v1/charfiles' , require ( './controllers/charfiles' ) ) ;
@@ -46,4 +48,32 @@ app.listen(port, function () {
4648 var datetime = new Date ( ) ;
4749 var message = "Argentum Online API on Port:- " + port + " Started at :- " + datetime ;
4850 console . log ( '\x1b[35m%s\x1b[0m' , message ) ;
51+
52+
53+ ///Obtenemos IP del server donde se ejecuta la api.
54+ const options = {
55+ hostname : 'api.ipify.org' ,
56+ method : 'GET'
57+ }
58+
59+ var req = https . request ( options , function ( res ) {
60+ // Buffer the body entirely for processing as a whole.
61+ var bodyChunks = [ ] ;
62+ res . on ( 'data' , function ( chunk ) {
63+ // You can process streamed parts here...
64+ bodyChunks . push ( chunk ) ;
65+ } ) . on ( 'end' , function ( ) {
66+ var body = Buffer . concat ( bodyChunks ) ;
67+ console . log ( 'Ip del Server: ' + body ) ;
68+ global . serverIpAddress = body ;
69+ } )
70+ } ) ;
71+
72+ req . on ( 'error' , error => {
73+ console . error ( error )
74+ } )
75+
76+ req . end ( )
77+ ///Fin Obtenemos IP del server donde se ejecuta la api.
78+
4979} ) ;
0 commit comments