mirror of
https://github.com/kiddin9/op-packages.git
synced 2026-10-30 11:35:13 +08:00
🤞 Sync 2026-08-09 18:27:19
This commit is contained in:
1 parent
59356ee7dd
commit
df29e10344
54 files changed
+424
-239
No files matched your search
@@ -572,22 +572,22 @@ end
|
||||
function add_node()
|
||||
local redirect = http.formvalue("redirect")
|
||||
|
||||
local uuid = api.gen_short_uuid()
|
||||
uci:section(appname, "nodes", uuid)
|
||||
local uid = api.gen_random_char()
|
||||
uci:section(appname, "nodes", uid)
|
||||
|
||||
local group = http.formvalue("group")
|
||||
if group and group ~= "default" then
|
||||
uci:set(appname, uuid, "group", group)
|
||||
uci:set(appname, uid, "group", group)
|
||||
end
|
||||
|
||||
uci:set(appname, uuid, "type", "Socks")
|
||||
uci:set(appname, uid, "type", "Socks")
|
||||
|
||||
if redirect == "1" then
|
||||
api.uci_save(uci, appname)
|
||||
http.redirect(api.url("node_config", uuid))
|
||||
http.redirect(api.url("node_config", uid))
|
||||
else
|
||||
api.uci_save(uci, appname, true, true)
|
||||
http_write_json({result = uuid})
|
||||
http_write_json({result = uid})
|
||||
end
|
||||
end
|
||||
|
||||
@@ -615,17 +615,17 @@ end
|
||||
|
||||
function copy_node()
|
||||
local section = http.formvalue("section")
|
||||
local uuid = api.gen_short_uuid()
|
||||
uci:section(appname, "nodes", uuid)
|
||||
local uid = api.gen_random_char()
|
||||
uci:section(appname, "nodes", uid)
|
||||
for k, v in pairs(uci:get_all(appname, section)) do
|
||||
if not k:match("^%.") and k ~= "group" then
|
||||
if k == "remarks" then v = (v or "") .. "(1)" end
|
||||
uci:set(appname, uuid, k, v)
|
||||
uci:set(appname, uid, k, v)
|
||||
end
|
||||
end
|
||||
uci:set(appname, uuid, "add_mode", 1)
|
||||
uci:set(appname, uid, "add_mode", 1)
|
||||
api.uci_save(uci, appname)
|
||||
http.redirect(api.url("node_config", uuid))
|
||||
http.redirect(api.url("node_config", uid))
|
||||
end
|
||||
|
||||
function clear_all_nodes()
|
||||
@@ -1242,29 +1242,29 @@ function add_shunt_rule()
|
||||
local add_name = http.formvalue("add_name")
|
||||
local redirect = http.formvalue("redirect")
|
||||
|
||||
local uuid = add_name
|
||||
local uid = add_name
|
||||
if add_name then
|
||||
local has = uci:get(appname, uuid)
|
||||
local has = uci:get(appname, uid)
|
||||
if has then
|
||||
http_write_json_error({ message = "This ID already exists." })
|
||||
return
|
||||
end
|
||||
else
|
||||
uuid = api.gen_short_uuid()
|
||||
uid = api.gen_random_char()
|
||||
end
|
||||
uci:section(appname, "shunt_rules", uuid)
|
||||
uci:section(appname, "shunt_rules", uid)
|
||||
|
||||
local group = http.formvalue("group")
|
||||
if group and group ~= "default" then
|
||||
uci:set(appname, uuid, "group", group)
|
||||
uci:set(appname, uid, "group", group)
|
||||
end
|
||||
|
||||
if redirect == "1" then
|
||||
api.uci_save(uci, appname)
|
||||
http.redirect(api.url("shunt_rules", uuid))
|
||||
http.redirect(api.url("shunt_rules", uid))
|
||||
else
|
||||
api.uci_save(uci, appname)
|
||||
http_write_json_ok({uuid = uuid, redirect_url = api.url("shunt_rules", uuid)})
|
||||
http_write_json_ok({uid = uid, redirect_url = api.url("shunt_rules", uid)})
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
Reference in new issue
Block a user