Преглед на файлове

FIX: token util keyurl definition move to above callback definition

master
Aaron van Meerten преди 5 години
родител
ревизия
36565f0c50
променени са 1 файла, в които са добавени 8 реда и са изтрити 1 реда
  1. 8
    1
      resources/prosody-plugins/token/util.lib.lua

+ 8
- 1
resources/prosody-plugins/token/util.lib.lua Целия файл

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

Loading…
Отказ
Запис