luci-app-udpxy: rewritten in JS

Signed-off-by: Tianling Shen <cnsztl@immortalwrt.org>
This commit is contained in:
Tianling Shen 2022-11-23 19:03:59 +08:00
parent 7dc6f8b607
commit 3aca045ec6
No known key found for this signature in database
GPG key ID: 6850B6345C862176
4 changed files with 64 additions and 67 deletions

View file

@ -7,7 +7,7 @@
include $(TOPDIR)/rules.mk
LUCI_TITLE:=LuCI Support for udpxy
LUCI_DEPENDS:=+luci-compat +udpxy
LUCI_DEPENDS:=+udpxy
include ../../luci.mk

View file

@ -0,0 +1,61 @@
'use strict';
'require form';
'require view';
return view.extend({
render: function () {
var m, s, o;
m = new form.Map('udpxy', _('udpxy'),
_('udpxy is a UDP-to-HTTP multicast traffic relay daemon, here you can configure the settings.'));
s = m.section(form.TypedSection, 'udpxy');
s.anonymous = true;
s.addremove = true;
o = s.option(form.Flag, 'disabled', _('Enabled'));
o.enabled = '0';
o.disabled = '1';
o.default = o.disabled;
o.rmempty = false;
o = s.option(form.Flag, 'respawn', _('Respawn'));
o.default = o.disabled;
o = s.option(form.Flag, 'verbose', _('Verbose'));
o.default = o.disabled;
o = s.option(form.Flag, 'status', _('Status'));
o = s.option(form.Value, 'bind', _('Bind IP/Interface'));
o.datatype = 'or(ipaddr, network)';
o = s.option(form.Value, 'port', _('Port'));
o.datatype = 'port';
o = s.option(form.Value, 'source', _('Source IP/Interface'));
o.datatype = 'or(ipaddr, network)';
o = s.option(form.Value, 'max_clients', _('Max clients'));
o.datatype = 'range(1, 5000)';
o = s.option(form.Value, 'log_file', _('Log file'));
o = s.option(form.Value, 'buffer_size', _('Buffer size'));
o.datatype = 'range(4096, 2097152)';
o = s.option(form.Value, 'buffer_messages', _('Buffer messages'));
o.datatype = 'or(-1, and(min(1),uinteger))';
o = s.option(form.Value, 'buffer_time', _('Buffer time'));
o.datatype = 'or(-1, and(min(1),uinteger))';
o = s.option(form.Value, 'nice_increment', _('Nice increment'));
o.datatype = 'or(and(max(-1),uinteger), and(min(1),uinteger))';
o = s.option(form.Value, 'mcsub_renew', _('Multicast subscription renew'));
o.datatype = 'or(0, range(30, 64000))';
return m.render();
}
});

View file

@ -1,63 +0,0 @@
-- Copyright 2014 Álvaro Fernández Rojas <noltari@gmail.com>
-- Licensed to the public under the Apache License 2.0.
m = Map("udpxy", "udpxy", translate("udpxy is a UDP-to-HTTP multicast traffic relay daemon, here you can configure the settings."))
s = m:section(TypedSection, "udpxy", "")
s.addremove = true
s.anonymous = false
enable=s:option(Flag, "disabled", translate("Enabled"))
enable.enabled="0"
enable.disabled="1"
enable.default = "1"
enable.rmempty = false
respawn=s:option(Flag, "respawn", translate("Respawn"))
respawn.default = false
verbose=s:option(Flag, "verbose", translate("Verbose"))
verbose.default = false
status=s:option(Flag, "status", translate("Status"))
bind=s:option(Value, "bind", translate("Bind IP/Interface"))
bind.rmempty = true
bind.datatype = "or(ipaddr, network)"
port=s:option(Value, "port", translate("Port"))
port.rmempty = true
port.datatype = "port"
source=s:option(Value, "source", translate("Source IP/Interface"))
source.rmempty = true
source.datatype = "or(ipaddr, network)"
max_clients=s:option(Value, "max_clients", translate("Max clients"))
max_clients.rmempty = true
max_clients.datatype = "range(1, 5000)"
log_file=s:option(Value, "log_file", translate("Log file"))
log_file.rmempty = true
--log_file.datatype = "file"
buffer_size=s:option(Value, "buffer_size", translate("Buffer size"))
buffer_size.rmempty = true
buffer_size.datatype = "range(4096,2097152)"
buffer_messages=s:option(Value, "buffer_messages", translate("Buffer messages"))
buffer_messages.rmempty = true
buffer_messages.datatype = "or(-1, and(min(1), uinteger))"
buffer_time=s:option(Value, "buffer_time", translate("Buffer time"))
buffer_time.rmempty = true
buffer_time.datatype = "or(-1, and(min(1), uinteger))"
nice_increment=s:option(Value, "nice_increment", translate("Nice increment"))
nice_increment.rmempty = true
nice_increment.datatype = "or(and(max(-1), integer),and(min(1), integer))"
mcsub_renew=s:option(Value, "mcsub_renew", translate("Multicast subscription renew"))
mcsub_renew.rmempty = true
mcsub_renew.datatype = "or(0, range(30, 64000))"
return m

View file

@ -2,9 +2,8 @@
"admin/services/udpxy": {
"title": "udpxy",
"action": {
"type": "cbi",
"path": "udpxy",
"post": { "cbi.submit": true }
"type": "view",
"path": "udpxy"
},
"depends": {
"acl": [ "luci-app-udpxy" ],