luci-app-ddns: avoid Absent Interface: "wan" when it does not exist
authorJan Pazdziora <jan.pazdziora@code.adelton.com>
Fri, 10 Jan 2025 14:06:19 +0000 (15:06 +0100)
committerPaul Donald <newtwen+github@gmail.com>
Wed, 22 Jan 2025 14:42:53 +0000 (15:42 +0100)
and the Alias Interface is likely what we want for the default.

Signed-off-by: Jan Pazdziora <jan.pazdziora@code.adelton.com>
applications/luci-app-ddns/htdocs/luci-static/resources/view/ddns/overview.js

index 46f05a3fc8ebba0adc3df897f93963a333d859e0..1ccb5d69adcbbbe838ecba31f47a49518c9476bb 100644 (file)
@@ -7,6 +7,7 @@
 'require rpc';
 'require fs';
 'require form';
+'require network';
 'require tools.widgets as widgets';
 
 return view.extend({
@@ -100,6 +101,16 @@ return view.extend({
                }, this))
        },
 
+       /*
+       * Figure out what the wan interface on the device is.
+       * Determine if the physical device exist, or if we should use an alias.
+       */
+       callGetWanInterface: function(m, ev) {
+               return network.getDevice('wan').then(dev => dev.getName())
+                       .catch(err => network.getNetwork('wan').then(net => '@' + net.getName()))
+                       .catch(err => null);
+       },
+
        /*
        * Check whether or not the service is supported.
        * If the script doesn't find any JSON, assume a 'service on demand' install.
@@ -243,7 +254,8 @@ return view.extend({
                        this.callDDnsGetStatus(),
                        this.callDDnsGetEnv(),
                        this.callGenServiceList(),
-                       uci.load('ddns')
+                       uci.load('ddns'),
+                       this.callGetWanInterface()
                ]);
        },
 
@@ -252,6 +264,7 @@ return view.extend({
                var status = data[1] || [];
                var env = data[2] || [];
                var logdir = uci.get('ddns', 'global', 'ddns_logdir') || "/var/log/ddns";
+               var wan_interface = data[5];
 
                var _this = this;
 
@@ -865,7 +878,7 @@ return view.extend({
                                        o.modalonly = true;
                                        o.depends("ip_source", "interface")
                                        o.multiple = false;
-                                       o.default = 'wan';
+                                       o.default = wan_interface;
 
                                        o = s.taboption('advanced', form.Value, 'ip_script',
                                                _("Script"),