File tree Expand file tree Collapse file tree 3 files changed +15
-29
lines changed Expand file tree Collapse file tree 3 files changed +15
-29
lines changed Original file line number Diff line number Diff line change 11{
22 "name" : " noobaa-core" ,
3- "version" : " 5.2.13 " ,
3+ "version" : " 5.2.12 " ,
44 "private" : true ,
55 "license" : " SEE LICENSE IN LICENSE" ,
66 "description" : " " ,
Original file line number Diff line number Diff line change @@ -362,21 +362,7 @@ class Agent {
362362 } ) ;
363363 }
364364
365- // refresh the public_ip in background if enough time passed from last time
366- _refresh_public_ip ( ) {
367- const now = Date . now ( ) ;
368- const GET_PUBLIC_IP_PERIOD = 10 * 60 * 1000 ; // 10 minutes between retrieve_public_ip
369- if ( this . last_retrieve_public_ip && now < this . last_retrieve_public_ip + GET_PUBLIC_IP_PERIOD ) return ;
370- this . last_retrieve_public_ip = now ;
371- net_utils . retrieve_public_ip ( )
372- . then ( public_ip => {
373- this . public_ip = public_ip ;
374- } )
375- . catch ( err => this . dbg . error ( 'got error in _refresh_public_ip' , err ) ) ;
376- }
377-
378365 _init_node ( ) {
379- this . _refresh_public_ip ( ) ;
380366 return P . resolve ( )
381367 . then ( ( ) => {
382368 if ( this . storage_path ) {
@@ -883,9 +869,8 @@ class Agent {
883869 cpu_usage : cpu_percent ,
884870 location_info : this . location_info ,
885871 io_stats : this . block_store && this . block_store . get_and_reset_io_stats ( ) ,
886- public_ip : this . public_ip
872+ virtual_hosts : this . virtual_hosts
887873 } ;
888- this . _refresh_public_ip ( ) ;
889874 if ( this . cloud_info && this . cloud_info . pool_name ) {
890875 reply . pool_name = this . cloud_info . pool_name ;
891876 }
@@ -973,6 +958,12 @@ class Agent {
973958 // }
974959 // });
975960 } )
961+ . then ( ( ) => net_utils . retrieve_public_ip ( ) )
962+ . then ( public_ip => {
963+ if ( public_ip ) {
964+ reply . public_ip = public_ip ;
965+ }
966+ } )
976967 . return ( reply ) ;
977968 }
978969
Original file line number Diff line number Diff line change @@ -12,7 +12,6 @@ const ip_module = require('ip');
1212const P = require ( './promise' ) ;
1313const dbg = require ( './debug_module' ) ( __filename ) ;
1414const os_utils = require ( './os_utils' ) ;
15- const promise_utils = require ( './promise_utils' ) ;
1615
1716const DEFAULT_PING_OPTIONS = {
1817 timeout : 5000 ,
@@ -88,19 +87,15 @@ function ip_to_long(ip) {
8887}
8988
9089async function retrieve_public_ip ( ) {
91- const IPIFY_TIMEOUT = 30 * 1000 ;
9290 try {
93- return promise_utils . timeout ( async ( ) => {
94- const res = await P . fromCallback ( callback =>
95- request . get ( 'http://api.ipify.org/' , callback )
96- ) ;
97- if ( ! is_ip ( res . body ) ) {
98- return undefined ;
99- }
100- return res . body ;
101- } , IPIFY_TIMEOUT ) ;
91+ const res = await P . fromCallback ( callback =>
92+ request . get ( 'http://api.ipify.org/' , callback )
93+ ) ;
94+ if ( ! is_ip ( res . body ) ) {
95+ return undefined ;
96+ }
97+ return res . body ;
10298 } catch ( err ) {
103- dbg . log0_throttled ( 'failed to ipify' , err ) ;
10499 return undefined ;
105100 }
106101}
You can’t perform that action at this time.
0 commit comments