mirror of
https://github.com/kiddin9/op-packages.git
synced 2026-11-04 23:33:56 +08:00
🤞 Sync 2026-03-15 21:44:24
This commit is contained in:
1 parent
a5cbeb474b
commit
ceeb3a33dc
11 files changed
+414
-1065
No files matched your search
@@ -133,6 +133,49 @@ methods.get_settings = {
|
||||
}
|
||||
};
|
||||
|
||||
methods.set_settings = {
|
||||
args: { form_data: {} },
|
||||
call: function(request) {
|
||||
const form_data = request.args.form_data;
|
||||
if (form_data == null || length(form_data) == 0) {
|
||||
return { error: 'Missing or invalid form_data parameter. Please provide settings data.' };
|
||||
}
|
||||
let args = ['set'];
|
||||
|
||||
push(args,'--accept-routes=' + (form_data.accept_routes == '1'));
|
||||
push(args,'--advertise-exit-node=' + ((form_data.advertise_exit_node == '1')&&(form_data.exit_node == "")));
|
||||
if (form_data.exit_node == "") push(args,'--exit-node-allow-lan-access=' + (form_data.exit_node_allow_lan_access == '1'));
|
||||
push(args,'--ssh=' + (form_data.ssh == '1'));
|
||||
push(args,'--accept-dns=' + (form_data.disable_magic_dns != '1'));
|
||||
push(args,'--shields-up=' + (form_data.shields_up == '1'));
|
||||
push(args,'--webclient=' + (form_data.runwebclient == '1'));
|
||||
push(args,'--snat-subnet-routes=' + (form_data.nosnat != '1'));
|
||||
push(args,'--advertise-routes ' + (shell_quote(join(',',form_data.advertise_routes)) || '\"\"'));
|
||||
push(args,'--exit-node=' + (shell_quote(form_data.exit_node) || '\"\"'));
|
||||
if (form_data.exit_node != "") push(args,' --exit-node-allow-lan-access=true');
|
||||
push(args,'--hostname ' + (shell_quote(form_data.hostname) || '\"\"'));
|
||||
|
||||
let cmd_array = 'tailscale '+join(' ', args);
|
||||
let set_result = exec(cmd_array);
|
||||
if (set_result.code != 0) {
|
||||
return { error: 'Failed to apply node settings: ' + set_result.stderr };
|
||||
}
|
||||
|
||||
uci.load('tailscale');
|
||||
for (let key in form_data) {
|
||||
uci.set('tailscale', 'settings', key, form_data[key]);
|
||||
}
|
||||
uci.save('tailscale');
|
||||
uci.commit('tailscale');
|
||||
|
||||
// process reduce memory https://github.com/GuNanOvO/openwrt-tailscale
|
||||
// some new versions of Tailscale may not work well with this method
|
||||
//if (form_data.daemon_mtu != "" || form_data.daemon_reduce_memory != "") {
|
||||
// popen('/bin/sh -c ". ' + env_script_path + ' && /etc/init.d/tailscale restart" &');
|
||||
//}
|
||||
return { success: true };
|
||||
}
|
||||
};
|
||||
|
||||
methods.do_login = {
|
||||
args: { form_data: {} },
|
||||
|
||||
Reference in new issue
Block a user