cloudcms-server 3.2.310 → 3.2.312

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -813,7 +813,31 @@ exports = module.exports = function()
813
813
  }
814
814
  redirectUrl += "requested_url=" + requested_url;
815
815
 
816
- return res.redirect(redirectUrl);
816
+ res.status(200);
817
+ res.type("text/html");
818
+
819
+ // serve back a redirect via html
820
+ var html = " \
821
+ <html> \
822
+ <head> \
823
+ <script> \
824
+ var _redirectUrl = '" + redirectUrl + "'; \
825
+ var hash = window.location.hash ? window.location.hash : ''; \
826
+ if (hash && hash.indexOf('#') === 0) { \
827
+ hash = hash.substring(1); \
828
+ } \
829
+ if (hash) { \
830
+ _redirectUrl += '&requested_hash=' + hash; \
831
+ } \
832
+ window.location.href = _redirectUrl; \
833
+ </script> \
834
+ </head> \
835
+ </html> \
836
+ ";
837
+ res.send(html);
838
+ return;
839
+
840
+ //return res.redirect(redirectUrl);
817
841
  }
818
842
  else if (loginHandler)
819
843
  {
@@ -163,12 +163,12 @@ exports = module.exports = function()
163
163
  var loadFromRemote = function(finishedLoading) {
164
164
 
165
165
  // check cache to see if we already tried to load this in the past few minutes and were sorely disappointed
166
- process.cache.read(VCSENTINEL_CACHE_KEY, function (err, failedRecently) {
166
+ process.cache.read(VCSENTINEL_CACHE_KEY, function (err, doesNotExist) {
167
167
 
168
- if (failedRecently) {
168
+ if (doesNotExist) {
169
169
  return finishedLoading({
170
170
  "message": "No virtual config found for host (from previous attempt)"
171
- });
171
+ }, null, true);
172
172
  }
173
173
 
174
174
  // load the gitana.json file from Cloud CMS
@@ -183,8 +183,8 @@ exports = module.exports = function()
183
183
 
184
184
  if (!virtualConfig)
185
185
  {
186
- // mark that it failed (5 seconds TTL)
187
- return process.cache.write(VCSENTINEL_CACHE_KEY, SENTINEL_NOT_FOUND_VALUE, 5, function() {
186
+ // mark that it failed (30 minute TTL)
187
+ return process.cache.write(VCSENTINEL_CACHE_KEY, true, 30 * 60, function() {
188
188
  finishedLoading({
189
189
  "message": "No virtual config found for host: " + host
190
190
  });
@@ -314,8 +314,8 @@ exports = module.exports = function()
314
314
  }
315
315
  else
316
316
  {
317
- loadFromRemote(function(err, gitanaJson) {
318
- callback(err, gitanaJson);
317
+ loadFromRemote(function(err, gitanaJson, doesNotExist) {
318
+ callback(err, gitanaJson, doesNotExist);
319
319
  });
320
320
  }
321
321
  });
@@ -341,15 +341,27 @@ exports = module.exports = function()
341
341
  configuration.key = "virtual";
342
342
  }
343
343
 
344
- var completionFunction = function (err, gitanaConfig) {
345
- if (err) {
346
- if (err.message) {
344
+ var completionFunction = function (err, gitanaConfig, doesNotExist)
345
+ {
346
+ if (doesNotExist)
347
+ {
348
+ // are we being spoofed? kill the connection
349
+ console.log("[BLACKLIST KILL: " + req.virtualHost + "]");
350
+ return res.end();
351
+ }
352
+
353
+ if (err)
354
+ {
355
+ if (err.message)
356
+ {
347
357
  req.log(err.message);
348
358
  }
359
+
349
360
  return next();
350
361
  }
351
362
 
352
- if (gitanaConfig) {
363
+ if (gitanaConfig)
364
+ {
353
365
  // store config
354
366
  req.gitanaConfig = gitanaConfig;
355
367
 
@@ -382,28 +394,27 @@ exports = module.exports = function()
382
394
  else
383
395
  {
384
396
  // try to load from disk
385
- acquireGitanaJson(req.virtualHost, req.rootStore, req.log, function (err, gitanaConfig)
397
+ acquireGitanaJson(req.virtualHost, req.rootStore, req.log, function (err, gitanaConfig, doesNotExist)
386
398
  {
387
- if (err)
399
+ if (err && !doesNotExist)
388
400
  {
389
401
  return completionFunction(err);
390
402
  }
391
403
 
392
404
  if (gitanaConfig)
393
405
  {
394
- process.driverConfigCache.write(req.virtualHost, {
406
+ return process.driverConfigCache.write(req.virtualHost, {
395
407
  "config": gitanaConfig
396
408
  }, function (err) {
397
409
  completionFunction(err, gitanaConfig);
398
410
  });
399
411
  }
400
- else
401
- {
402
- // mark with sentinel
403
- process.driverConfigCache.write(req.virtualHost, SENTINEL_NOT_FOUND_VALUE, 5, function (err) {
404
- completionFunction();
405
- });
406
- }
412
+
413
+ // mark with sentinel (30 minutes)
414
+ console.log("[BLACKLIST ADD: " + req.virtualHost + "]");
415
+ process.driverConfigCache.write(req.virtualHost, SENTINEL_NOT_FOUND_VALUE, 30 * 60, function (err) {
416
+ completionFunction(null, null, true);
417
+ });
407
418
  });
408
419
  }
409
420
  });
package/package.json CHANGED
@@ -6,7 +6,7 @@
6
6
  },
7
7
  "name": "cloudcms-server",
8
8
  "description": "Cloud CMS Application Server Module",
9
- "version": "3.2.310",
9
+ "version": "3.2.312",
10
10
  "repository": {
11
11
  "type": "git",
12
12
  "url": "git://github.com/gitana/cloudcms-server.git"