--- /dev/null
+'use strict';
+'require form';
+'require fs';
+'require rpc';
+'require view';
+'require tools.widgets as widgets';
+
+var callServiceList = rpc.declare({
+ object: 'service',
+ method: 'list',
+ params: ['name'],
+ expect: { '': {} }
+});
+
+function getInstances() {
+ return L.resolveDefault(callServiceList('natmap'), {}).then(function(res) {
+ try {
+ return res.natmap.instances || {};
+ } catch (e) {}
+ return {};
+ });
+}
+
+function getStatus() {
+ return getInstances().then(function(instances) {
+ var promises = [];
+ var status = {};
+ for (var key in instances) {
+ var i = instances[key];
+ if (i.running && i.pid) {
+ var f = '/var/run/natmap/' + i.pid + '.json';
+ (function(k) {
+ promises.push(fs.read(f).then(function(res) {
+ status[k] = JSON.parse(res);
+ }).catch(function(e){}));
+ })(key);
+ }
+ }
+ return Promise.all(promises).then(function() { return status; });
+ });
+}
+
+return view.extend({
+ load: function() {
+ return getStatus();
+ },
+ render: function(status) {
+ var m, s, o;
+
+ m = new form.Map('natmap', _('NATMap'));
+ s = m.section(form.GridSection, 'natmap');
+ s.addremove = true;
+ s.anonymous = true;
+
+ o = s.option(form.Flag, 'enable', _('Enable'));
+ o.editable = true;
+ o.modalonly = false;
+
+ o = s.option(form.ListValue, 'udp_mode', _('Protocol'));
+ o.default = '1';
+ o.value('0', 'TCP');
+ o.value('1', 'UDP');
+ o.textvalue = function(section_id) {
+ var cval = this.cfgvalue(section_id);
+ var i = this.keylist.indexOf(cval);
+ return this.vallist[i];
+ };
+
+ o = s.option(form.ListValue, 'family', _('Restrict to address family'));
+ o.modalonly = true;
+ o.value('', _('IPv4 and IPv6'));
+ o.value('ipv4', _('IPv4 only'));
+ o.value('ipv6', _('IPv6 only'));
+
+ o = s.option(widgets.NetworkSelect, 'interface', _('Interface'));
+ o.modalonly = true;
+
+ o = s.option(form.Value, 'interval', _('Keep-alive interval'));
+ o.datatype = 'uinteger';
+ o.modalonly = true;
+
+ o = s.option(form.Value, 'stun_server', _('STUN server'), _('For UDP mode'));
+ o.datatype = 'host';
+ o.modalonly = true;
+ o.optional = false;
+ o.rmempty = false;
+
+ o = s.option(form.Value, 'http_server', _('HTTP server'), _('For TCP mode'));
+ o.datatype = 'host';
+ o.modalonly = true;
+ o.optional = false;
+ o.rmempty = false;
+
+ o = s.option(form.Value, 'port', _('Port'));
+ o.datatype = 'port';
+ o.optional = false;
+ o.rmempty = false;
+
+ o = s.option(form.Flag, '_forward_mode', _('Forward mode'));
+ o.modalonly = true;
+ o.ucioption = 'forward_target';
+ o.load = function(section_id) {
+ return this.super('load', section_id) ? '1' : '0';
+ };
+ o.write = function(section_id, formvalue) {};
+
+ o = s.option(form.Value, 'forward_target', _('Forward target'));
+ o.datatype = 'host';
+ o.modalonly = true;
+ o.depends('_forward_mode', '1');
+
+ o = s.option(form.Value, 'notify_script', _('Notify script'));
+ o.datatype = 'file';
+ o.modalonly = true;
+
+ o = s.option(form.DummyValue, '_external_ip', _('External IP'));
+ o.modalonly = false;
+ o.textvalue = function(section_id) {
+ var s = status[section_id];
+ if (s) return s.ip;
+ };
+
+ o = s.option(form.DummyValue, '_external_port', _('External Port'));
+ o.modalonly = false;
+ o.textvalue = function(section_id) {
+ var s = status[section_id];
+ if (s) return s.port;
+ };
+
+ return m.render();
+ }
+});
--- /dev/null
+msgid ""
+msgstr "Content-Type: text/plain; charset=UTF-8"
+
+#: applications/luci-app-natmap/htdocs/luci-static/resources/view/natmap.js:56
+msgid "Enable"
+msgstr ""
+
+#: applications/luci-app-natmap/htdocs/luci-static/resources/view/natmap.js:117
+msgid "External IP"
+msgstr ""
+
+#: applications/luci-app-natmap/htdocs/luci-static/resources/view/natmap.js:124
+msgid "External Port"
+msgstr ""
+
+#: applications/luci-app-natmap/htdocs/luci-static/resources/view/natmap.js:89
+msgid "For TCP mode"
+msgstr ""
+
+#: applications/luci-app-natmap/htdocs/luci-static/resources/view/natmap.js:83
+msgid "For UDP mode"
+msgstr ""
+
+#: applications/luci-app-natmap/htdocs/luci-static/resources/view/natmap.js:100
+msgid "Forward mode"
+msgstr ""
+
+#: applications/luci-app-natmap/htdocs/luci-static/resources/view/natmap.js:108
+msgid "Forward target"
+msgstr ""
+
+#: applications/luci-app-natmap/root/usr/share/rpcd/acl.d/luci-app-natmap.json:3
+msgid "Grant access to LuCI app natmap"
+msgstr ""
+
+#: applications/luci-app-natmap/htdocs/luci-static/resources/view/natmap.js:89
+msgid "HTTP server"
+msgstr ""
+
+#: applications/luci-app-natmap/htdocs/luci-static/resources/view/natmap.js:72
+msgid "IPv4 and IPv6"
+msgstr ""
+
+#: applications/luci-app-natmap/htdocs/luci-static/resources/view/natmap.js:73
+msgid "IPv4 only"
+msgstr ""
+
+#: applications/luci-app-natmap/htdocs/luci-static/resources/view/natmap.js:74
+msgid "IPv6 only"
+msgstr ""
+
+#: applications/luci-app-natmap/htdocs/luci-static/resources/view/natmap.js:76
+msgid "Interface"
+msgstr ""
+
+#: applications/luci-app-natmap/htdocs/luci-static/resources/view/natmap.js:79
+msgid "Keep-alive interval"
+msgstr ""
+
+#: applications/luci-app-natmap/htdocs/luci-static/resources/view/natmap.js:51
+#: applications/luci-app-natmap/root/usr/share/luci/menu.d/luci-app-natmap.json:3
+msgid "NATMap"
+msgstr ""
+
+#: applications/luci-app-natmap/htdocs/luci-static/resources/view/natmap.js:113
+msgid "Notify script"
+msgstr ""
+
+#: applications/luci-app-natmap/htdocs/luci-static/resources/view/natmap.js:95
+msgid "Port"
+msgstr ""
+
+#: applications/luci-app-natmap/htdocs/luci-static/resources/view/natmap.js:60
+msgid "Protocol"
+msgstr ""
+
+#: applications/luci-app-natmap/htdocs/luci-static/resources/view/natmap.js:70
+msgid "Restrict to address family"
+msgstr ""
+
+#: applications/luci-app-natmap/htdocs/luci-static/resources/view/natmap.js:83
+msgid "STUN server"
+msgstr ""