Skip to content

Commit 0f22dc2

Browse files
author
zhuchao-hit
committed
nocase for add/remove pwd/enpwd command
1 parent 811d0bd commit 0f22dc2

File tree

1 file changed

+8
-7
lines changed

1 file changed

+8
-7
lines changed

lib/admin.lua

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -198,8 +198,8 @@ function read_query(packet)
198198
string.sub(user_pwd, pos+1)
199199
}
200200
end
201-
elseif string.find(query, "^add%s+pwd%s+(.+):(.+)$") then
202-
local user, pwd = string.match(query, "^add%s+pwd%s+(.+):(.+)$")
201+
elseif string.find(query, "^[aA][dD][dD]%s+[pP][wW][dD]%s+(.+):(.+)$") then
202+
local user, pwd = string.match(query, "^[aA][dD][dD]%s+[pP][wW][dD]%s+(.+):(.+)$")
203203
local ret = proxy.global.backends(user, pwd, 1)
204204

205205
if ret == 1 then
@@ -216,8 +216,8 @@ function read_query(packet)
216216
{ name = "status",
217217
type = proxy.MYSQL_TYPE_STRING },
218218
}
219-
elseif string.find(query, "^add%s+enpwd%s+(.+):(.+)$") then
220-
local user, pwd = string.match(query, "^add%s+enpwd%s+(.+):(.+)$")
219+
elseif string.find(query, "^[aA][dD][dD]%s+[eE][nN][pP][wW][dD]%s+(.+):(.+)$") then
220+
local user, pwd = string.match(query, "^[aA][dD][dD]%s+[eE][nN][pP][wW][dD]%s+(.+):(.+)$")
221221
local ret = proxy.global.backends(user, pwd, 2)
222222

223223
if ret == 1 then
@@ -234,8 +234,8 @@ function read_query(packet)
234234
{ name = "status",
235235
type = proxy.MYSQL_TYPE_STRING },
236236
}
237-
elseif string.find(query, "^remove%s+pwd%s+(.+)$") then
238-
local user = string.match(query, "^remove%s+pwd%s+(.+)$")
237+
elseif string.find(query, "^[rR][eE][mM][oO][vV][eE]%s+[pP][wW][dD]%s+(.+)$") then
238+
local user = string.match(query, "^[rR][eE][mM][oO][vV][eE]%s+[pP][wW][dD]%s+(.+)$")
239239
local ret = proxy.global.backends(user, nil, 3)
240240

241241
if ret == 1 then
@@ -280,7 +280,8 @@ function read_query(packet)
280280
rows[#rows + 1] = { "REMOVE CLIENT $client", "example: \"remove client 192.168.1.2\", ..." }
281281

282282
rows[#rows + 1] = { "SELECT * FROM pwds", "lists the pwds" }
283-
rows[#rows + 1] = { "ADD PWD $pwd", "example: \"add pwd user:password\", ..." }
283+
rows[#rows + 1] = { "ADD PWD $pwd", "example: \"add pwd user:raw_password\", ..." }
284+
rows[#rows + 1] = { "ADD ENPWD $pwd", "example: \"add enpwd user:encrypted_password\", ..." }
284285
rows[#rows + 1] = { "REMOVE PWD $pwd", "example: \"remove pwd user\", ..." }
285286

286287
rows[#rows + 1] = { "SAVE CONFIG", "save the backends to config file" }

0 commit comments

Comments
 (0)