🌴 Sync 2026-03-05 23:51:42

This commit is contained in:
github-actions[bot] committed 2026-03-05 23:51:42 +08:00
1 parent 97c049ed0a
commit 0acff03804
14253 files changed
+3893239

No files matched your search

+11
View File
@@ -0,0 +1,11 @@
# This is free software, licensed under the Apache License, Version 2.0 .
include $(TOPDIR)/rules.mk
LUCI_TITLE:=redsocks config file editor
LUCI_DEPENDS:=+luci-base
LUCI_PKGARCH:=all
include $(TOPDIR)/feeds/luci/luci.mk
# call BuildPackage - OpenWrt buildroot signature
@@ -0,0 +1,115 @@
'use strict';
'require view';
'require rpc';
'require fs';
'require ui';
var isReadonlyView = !L.hasViewPermission() || null;
return view.extend({
callInitList: rpc.declare({
object: 'luci',
method: 'getInitList',
expect: { '': {} }
}),
callInitAction: rpc.declare({
object: 'luci',
method: 'setInitAction',
params: [ 'name', 'action' ],
expect: { result: false }
}),
load: function() {
return Promise.all([
L.resolveDefault(fs.read('/etc/redsocks.conf'), ''),
]);
},
handleAction: function(name, action, ev) {
return this.callInitAction(name, action).then(function(success) {
if (success != true)
throw _('Command failed');
return true;
}).catch(function(e) {
ui.addNotification(null, E('p', _('Failed to execute "/etc/init.d/%s %s" action: %s').format(name, action, e)));
});
},
handleEnableDisable: function(name, isEnabled, ev) {
return this.handleAction(name, isEnabled ? 'disable' : 'enable', ev).then(L.bind(function(name, isEnabled, btn) {
btn.parentNode.replaceChild(this.renderEnableDisable({
name: name,
enabled: isEnabled
}), btn);
}, this, name, !isEnabled, ev.currentTarget));
},
handleRcLocalSave: function(ev) {
var value = (document.querySelector('textarea').value || '').trim().replace(/\r\n/g, '\n') + '\n';
return fs.write('/etc/redsocks.conf', value).then(function() {
document.querySelector('textarea').value = value;
ui.addNotification(null, E('p', _('Contents have been saved.')), 'info');
}).catch(function(e) {
ui.addNotification(null, E('p', _('Unable to save contents: %s').format(e.message)));
});
},
renderEnableDisable: function(init) {
return E('button', {
class: 'btn cbi-button-%s'.format(init.enabled ? 'positive' : 'negative'),
click: ui.createHandlerFn(this, 'handleEnableDisable', init.name, init.enabled),
disabled: isReadonlyView
}, init.enabled ? _('Enabled') : _('Disabled'));
},
render: function(data) {
var rcLocal = data[0],
initList = data[1],
rows = [], list = [];
var table = E('table', { 'class': 'table' }, [
E('tr', { 'class': 'tr table-titles' }, [
E('th', { 'class': 'th' }, _('Start priority')),
E('th', { 'class': 'th' }, _('Initscript')),
E('th', { 'class': 'th nowrap cbi-section-actions' })
])
]);
var view = E('div', {}, [
E('h2', _('Redsocks')),
E('div', {}, [
E('div', { 'data-tab': 'rc', 'data-tab-title': _('Config file') }, [
E('p', {}, _('This is the content of /etc/redsocks.conf.')),
E('p', {}, E('textarea', { 'style': 'width:100%', 'rows': 20, 'disabled': isReadonlyView }, [ (rcLocal != null ? rcLocal : '') ])),
E('div', { 'class': 'cbi-page-actions' }, [
E('button', { 'class': 'btn cbi-button-action', 'click': ui.createHandlerFn(this, 'handleAction', 'redsocks', 'start'), 'disabled': isReadonlyView }, _('Start')),
E('button', { 'class': 'btn cbi-button-action', 'click': ui.createHandlerFn(this, 'handleAction', 'redsocks', 'restart'), 'disabled': isReadonlyView }, _('Restart')),
E('button', { 'class': 'btn cbi-button-action', 'click': ui.createHandlerFn(this, 'handleAction', 'redsocks', 'stop'), 'disabled': isReadonlyView }, _('Stop')),
E('button', {
'class': 'btn cbi-button-save',
'click': ui.createHandlerFn(this, 'handleRcLocalSave'),
'disabled': isReadonlyView
}, _('Save'))
])
])
])
]);
ui.tabs.initTabGroup(view.lastElementChild.childNodes);
return view;
},
handleSaveApply: null,
handleSave: null,
handleReset: null
});
@@ -0,0 +1,13 @@
{
"admin/services/redsocks": {
"title": "Redsocks",
"action": {
"type": "view",
"path": "redsocks"
},
"depends": {
"acl": [ "luci-app-redsocks" ]
}
}
}
@@ -0,0 +1,25 @@
{
"luci-app-redsocks": {
"description": "Grant access to LuCI app redsocks",
"read": {
"file": {
"/etc/redsocks.conf": [ "read" ],
"/usr/sbin/redsocks": [ "exec" ]
},
"ubus": {
"file": [ "read" ],
"luci": [ "getInitList" ]
}
},
"write": {
"file": {
"/etc/redsocks.conf": [ "write" ]
},
"ubus": {
"file": [ "write" ],
"luci": [ "setInitAction" ]
}
}
}
}