-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
MVP of Consul storage adapter to lua-resty-auto-ssl #25
Comments
I'm trying to make VSCode show the code outline like the other languages. Having same issue as here microsoft/vscode#43131 (maybe some conflict with other extensions on my VSCode, since I have a lot). Also here someone else also tould one specific extension of VSCode can do the outline microsoft/vscode#56209. Anyway, I'm doing some reverse engineering of the code redis.lua and file.lua to discover what lua-resty-auto-ssl expect |
…of file.lua & redis.lua (to try undestand the bare minimum to implement
About the error, I just had this outdated extension https://github.com/patrys/vscode-code-outline (discovered by using |
Ok, This VSCode extension seems to be very powerful to use with lua. The demos are better than ones for Python or PHP. But I will leave for other day configure such extension since I just want syntax highligth for now. Will use some more simpler than a full development ambient. But yeah is very nice to know that have this type of extension for lua |
…y(), _M.new, _M.get, _M.set, based on redis.lua and direct comparison with the API of lua-resty-consul
…ction; documentation now respect ldoc
There is another code style for lua at
|
…centralzed this time (not really need in the end product, but I need to inspect lua things without killing openresty
…ore than once a minute calls from the same caller (way too many retrys will polute logs for debuggin)
O get agora deve estar relativamente ok. O Set ainda falta implementar clausula de expire para keys não ficarem para sempre armazenadas |
…s get return string or nil, but the Consul implementation returns a full lua-resty-http response object
Humm... I guess we will also need to put some hardcoded prefix. Redis equivalent at least the person have to choose betwen 16 databases, to no prefix does not make much differente. But Consul the scope is made using slashs "/". So, even the delete operations (the recursive ones) cannot be made without some prefix |
At consul.lua I was able to change the first prefix from Both The file that have references for this is this one https://github.com/GUI/lua-resty-auto-ssl/blob/86d09dcd98224639da1ed36d02bf0eda4b2f0baa/lib/resty/auto-ssl/storage.lua Maybe I will leave this specific point to another issue. |
…resty-auto-ssl'; fixed prefix char to '/' instead of ':', moved helper functions temporary to the main file (they will be removed later)
This is most a note to self: diff if using "/" instead of ":". Hardcoded, ideally should be configured. And is outside the target file. diff --git a/lib/resty/auto-ssl/storage.lua b/lib/resty/auto-ssl/storage.lua
index 0f18f35..69f6673 100644
--- a/lib/resty/auto-ssl/storage.lua
+++ b/lib/resty/auto-ssl/storage.lua
@@ -12,19 +12,19 @@ function _M.new(options)
end
function _M.get_challenge(self, domain, path)
- return self.adapter:get(domain .. ":challenge:" .. path)
+ return self.adapter:get(domain .. "/challenge/" .. path)
end
function _M.set_challenge(self, domain, path, value)
- return self.adapter:set(domain .. ":challenge:" .. path, value)
+ return self.adapter:set(domain .. "/challenge/" .. path, value)
end
function _M.delete_challenge(self, domain, path)
- return self.adapter:delete(domain .. ":challenge:" .. path)
+ return self.adapter:delete(domain .. "/challenge/" .. path)
end
function _M.get_cert(self, domain)
- local json, err = self.adapter:get(domain .. ":latest")
+ local json, err = self.adapter:get(domain .. "/latest")
if err then
return nil, err
elseif not json then
@@ -57,22 +57,22 @@ function _M.set_cert(self, domain, fullchain_pem, privkey_pem, cert_pem, expiry)
end
-- Store the cert under the "latest" alias, which is what this app will use.
- return self.adapter:set(domain .. ":latest", string)
+ return self.adapter:set(domain .. "/latest", string)
end
function _M.delete_cert(self, domain)
- return self.adapter:delete(domain .. ":latest")
+ return self.adapter:delete(domain .. "/latest")
end
function _M.all_cert_domains(self)
- local keys, err = self.adapter:keys_with_suffix(":latest")
+ local keys, err = self.adapter:keys_with_suffix("/latest")
if err then
return nil, err
end
local domains = {}
for _, key in ipairs(keys) do
- local domain = ngx.re.sub(key, ":latest$", "", "jo")
+ local domain = ngx.re.sub(key, "/latest$", "", "jo")
table.insert(domains, domain)
end
@@ -91,7 +91,7 @@ end
-- but in combination with resty-lock, it should prevent the vast majority of
-- double requests.
function _M.issue_cert_lock(self, domain)
- local key = domain .. ":issue_cert_lock"
+ local key = domain .. "/issue_cert_lock"
local lock_rand_value = str.to_hex(resty_random.bytes(32))
-- Wait up to 30 seconds for any existing locks to be unlocked.
@@ -119,7 +119,7 @@ function _M.issue_cert_lock(self, domain)
end
function _M.issue_cert_unlock(self, domain, lock_rand_value)
- local key = domain .. ":issue_cert_lock"
+ local key = domain .. "/issue_cert_lock"
-- Remove the existing lock if it matches the expected value.
local current_value, err = self.adapter:get(key) |
From https://github.com/GUI/lua-resty-auto-ssl/search?q=exptime&unscoped_q=exptime the But for what I see, both file.lua and redis.lua actually does not set TTL or expiration, they just use ngx.timer and do it more manually. Humm... |
…ent commit (true/false instead of true/false)
I will try do some MVP of storage adapter for https://github.com/GUI/lua-resty-auto-ssl using https://github.com/hamishforbes/lua-resty-consul as library to talk with Consul.
GUI/lua-resty-auto-ssl does not have formal documentation on how to implement one adapter, but looking at redis.lua (134 lines) and file.lua (92 lines) is likely to be more easy learn the bare minimum of Lua to make a Consul adapter than the not-very-efficient way to create some way to synchronize both ways Consul with files in some folder.
If take too much time or get some hard issues I will prioritize other tasks. But this open issue here is to do try do some Minimal Viable Product that could just works.
The text was updated successfully, but these errors were encountered: