luci-app-xinetd: introduce bind setting
authorPaul Donald <newtwen+github@gmail.com>
Sun, 12 May 2024 21:14:47 +0000 (23:14 +0200)
committerPaul Donald <newtwen+github@gmail.com>
Tue, 14 May 2024 12:19:13 +0000 (14:19 +0200)
Signed-off-by: Paul Donald <newtwen+github@gmail.com>
(cherry picked from commit aa942bdfcefc39a43ae5ad0b478056dd406d2ec8)

applications/luci-app-xinetd/htdocs/luci-static/resources/view/xinetd/xinetd.js

index c8caa5292f2ee0287915abd9feb4fcfef2e36296..8f5583f7bdda72c56c098955762a0a9d7d0d6741 100644 (file)
@@ -4,6 +4,7 @@
 'require form';
 'require view';
 'require fs';
+'require network';
 'require tools.widgets as widgets';
 
 function validateEmpty(section, value) {
@@ -16,8 +17,15 @@ function validateEmpty(section, value) {
 }
 
 return view.extend({
-       render: function() {
+       load: function() {
+               return Promise.all([
+                       network.getNetworks()
+               ]);
+       },
+
+       render: function(promises) {
                var m, s, o;
+               var networks = promises[0];
 
                m = new form.Map('xinetd', _('Xinetd Settings'), _('Here you can configure Xinetd services'));
 
@@ -97,6 +105,24 @@ return view.extend({
                o.rmempty = false;
                o.modalonly = true;
 
+               o = s.taboption('basic', form.Value, 'bind', _('Bind address'), _('To which address to bind'));
+               o.datatype = 'ipaddr';
+               [4, 6].forEach(family => {
+                       networks.forEach(network => {
+                               if (network.getName() !== 'loopback') {
+                                       const addrs = (family === 6) ? network.getIP6Addrs() : network.getIPAddrs();
+                                       addrs.forEach(addr => {
+                                               o.value(addr.split('/')[0], E([], [
+                                                       addr.split('/')[0], ' (',
+                                                       widgets.NetworkSelect.prototype.renderIfaceBadge(network),
+                                                       ')'
+                                               ]));
+                                       });
+                               }
+                       });
+               });
+               o.rmempty = true;
+
                o = s.taboption('basic', form.Value, 'id', _('Identification'), _('Required if a services can use tcp and udp.'));
                o.datatype = 'string';
                o.value('time-stream');