From a6fde11e70924e62210aa407f5da51717a0f4f4e Mon Sep 17 00:00:00 2001 From: samschreiber Date: Sun, 24 Nov 2013 15:38:59 -0800 Subject: [PATCH] Optionally fetch the zone when generating ping responses from Tiltyard request farm backends. --- src/org/ggp/base/apps/tiltyard/TiltyardRequestFarm.java | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/org/ggp/base/apps/tiltyard/TiltyardRequestFarm.java b/src/org/ggp/base/apps/tiltyard/TiltyardRequestFarm.java index 2018f5c13..73e858cc3 100644 --- a/src/org/ggp/base/apps/tiltyard/TiltyardRequestFarm.java +++ b/src/org/ggp/base/apps/tiltyard/TiltyardRequestFarm.java @@ -67,8 +67,16 @@ static EncodedKeyPair getKeyPair(String keyPairString) { } public static final EncodedKeyPair theBackendKeys = getKeyPair(FileUtils.readFileAsString(new File("src/org/ggp/base/apps/tiltyard/BackendKeys.json"))); public static String generateSignedPing() { + String zone = null; + try { + zone = RemoteResourceLoader.loadRaw("http://metadata/computeMetadata/v1beta1/instance/zone"); + } catch (IOException e1) { + // If we can't acquire the request farm zone, just silently drop it. + } + JSONObject thePing = new JSONObject(); try { + if (zone != null) thePing.put("zone", zone); thePing.put("lastTimeBlock", (System.currentTimeMillis() / 3600000)); thePing.put("nextTimeBlock", (System.currentTimeMillis() / 3600000)+1); SignableJSON.signJSON(thePing, theBackendKeys.thePublicKey, theBackendKeys.thePrivateKey);