diff --git a/lib/up-storage.js b/lib/up-storage.js index 3d6b5f47d..0176975f9 100644 --- a/lib/up-storage.js +++ b/lib/up-storage.js @@ -34,14 +34,21 @@ function Storage(config, mainconfig) { _setupProxy.call(this, this.url.hostname, config, mainconfig, this.url.protocol === 'https:') this.config.url = this.config.url.replace(/\/$/, '') - this.maxage = parse_interval(this.config.maxage || '2m') if (Number(this.config.timeout) >= 1000) { this.logger.warn('Too big timeout value: ' + this.config.timeout + '\nWe changed time format to nginx-like one\n(see http://wiki.nginx.org/ConfigNotation)\nso please update your config accordingly') } - this.timeout = parse_interval(this.config.timeout || '30s') - this.max_fails = Number(this.config.max_fails) || 2 - this.fail_timeout = parse_interval(this.config.fail_timeout || '5m') + + // a bunch of different configurable timers + this.maxage = parse_interval(config_get('maxage' , '2m' )) + this.timeout = parse_interval(config_get('timeout' , '30s')) + this.max_fails = Number(config_get('max_fails' , 2 )) + this.fail_timeout = parse_interval(config_get('fail_timeout', '5m' )) return this + + // just a helper (`config[key] || default` doesn't work because of zeroes) + function config_get(key, def) { + return config[key] != null ? config[key] : def + } } function _setupProxy(hostname, config, mainconfig, isHTTPS) { diff --git a/test/functional/config-2.yaml b/test/functional/config-2.yaml index 8491025d3..2f38072fc 100644 --- a/test/functional/config-2.yaml +++ b/test/functional/config-2.yaml @@ -7,6 +7,7 @@ users: uplinks: server1: url: http://localhost:55551/ + maxage: 0 logs: - {type: stdout, format: pretty, level: trace} @@ -15,7 +16,7 @@ packages: 'testfwd': allow_access: all allow_publish: all - + 'testloop': allow_access: all allow_publish: all