Przeglądaj źródła

FIX: token util keyurl definition move to above callback definition

master
Aaron van Meerten 5 lat temu
rodzic
commit
36565f0c50
1 zmienionych plików z 8 dodań i 1 usunięć
  1. 8
    1
      resources/prosody-plugins/token/util.lib.lua

+ 8
- 1
resources/prosody-plugins/token/util.lib.lua Wyświetl plik

@@ -119,6 +119,10 @@ function Util:set_asap_require_room_claim(checkRoom)
119 119
     self.requireRoomClaim = checkRoom;
120 120
 end
121 121
 
122
+function Util:clear_asap_cache()
123
+    self.cache = require"util.cache".new(cacheSize);
124
+end
125
+
122 126
 --- Returns the public key by keyID
123 127
 -- @param keyId the key ID to request
124 128
 -- @return the public key (the content of requested resource) or nil
@@ -130,6 +134,9 @@ function Util:get_public_key(keyId)
130 134
         local code;
131 135
         local timeout_occurred;
132 136
         local wait, done = async.waiter();
137
+
138
+        local keyurl = path.join(self.asapKeyServer, hex.to(sha256(keyId))..'.pem');
139
+
133 140
         local function cb(content_, code_, response_, request_)
134 141
             if timeout_occurred == nil then
135 142
                 content, code = content_, code_;
@@ -144,6 +151,7 @@ function Util:get_public_key(keyId)
144 151
                 module:log("warn", "public key reply delivered after timeout from: %s",keyurl);
145 152
             end
146 153
         end
154
+
147 155
         -- TODO: Is the done() call racey? Can we cancel this if the request
148 156
         --       succeedes?
149 157
         local function cancel()
@@ -159,7 +167,6 @@ function Util:get_public_key(keyId)
159 167
             end
160 168
         end
161 169
 
162
-        local keyurl = path.join(self.asapKeyServer, hex.to(sha256(keyId))..'.pem');
163 170
         module:log("debug", "Fetching public key from: "..keyurl);
164 171
 
165 172
         -- We hash the key ID to work around some legacy behavior and make

Ładowanie…
Anuluj
Zapisz