Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

luci-proto-ipv6/luci-mod-status: Add SNAT fix in map and displaying tunnel status in luci #7301

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 30 additions & 0 deletions modules/luci-base/po/ja/base.po
Original file line number Diff line number Diff line change
Expand Up @@ -11011,6 +11011,35 @@ msgstr ""
"RFC7597の代わりに従来のMAPインターフェース識別子フォーマット(draft-ietf-"
"softwire-map-00)を使用"

#: protocols/luci-proto-ipv6/htdocs/luci-static/resources/protocol/map.js:90
msgid "Enable SNAT fix"
msgstr "SNAT修正を有効化"

#: protocols/luci-proto-ipv6/htdocs/luci-static/resources/protocol/map.js:90
msgid "Apply SNAT fixes with certain ISPs"
msgstr "特定ISPに対してSNAT修正を適用"

#: protocols/luci-proto-ipv6/htdocs/luci-static/resources/protocol/map.js:92
msgid "Exclude SNAT ports"
msgstr "SNATポートを除外"

#: protocols/luci-proto-ipv6/htdocs/luci-static/resources/protocol/map.js:92
msgid "List of ports to exclude from SNAT. Separate ports with spaces"
msgstr "SNATから除外するポートのリスト。スペースで区切る"

#: protocols/luci-proto-ipv6/htdocs/luci-static/resources/protocol/map.js:109
msgid "Duplicate port found:"
msgstr "重複ポート番号検出:"

#: modules/luci-mod-status/htdocs/luci-static/resources/view/status/include/30_network.js:60
#: protocols/luci-proto-ipv6/htdocs/luci-static/resources/protocol/map.js:71
msgid "Available portsets"
msgstr "利用可能ポート"

#: modules/luci-mod-status/htdocs/luci-static/resources/view/status/include/30_network.js:61
msgid "Show"
msgstr "表示"

#: protocols/luci-proto-relay/htdocs/luci-static/resources/protocol/relay.js:179
msgid "Use routing table"
msgstr "ルーティングテーブルを使用"
Expand Down Expand Up @@ -12194,6 +12223,7 @@ msgstr "有効なポートまたはポート範囲(port1-port2)"

#: modules/luci-base/htdocs/luci-static/resources/validation.js:368
#: modules/luci-mod-network/htdocs/luci-static/resources/view/network/dhcp.js:207
#: protocols/luci-proto-ipv6/htdocs/luci-static/resources/protocol/map.js:106
msgid "valid port value"
msgstr "有効なポート番号"

Expand Down
30 changes: 30 additions & 0 deletions modules/luci-base/po/zh_Hans/base.po
Original file line number Diff line number Diff line change
Expand Up @@ -10954,6 +10954,35 @@ msgid ""
msgstr ""
"使用旧式 MAP 接口标识符格式(draft-ietf-softwire-map-00),而非 RFC7597"

#: protocols/luci-proto-ipv6/htdocs/luci-static/resources/protocol/map.js:90
msgid "Enable SNAT fix"
msgstr "启用 SNAT 修复"

#: protocols/luci-proto-ipv6/htdocs/luci-static/resources/protocol/map.js:90
msgid "Apply SNAT fixes with certain ISPs"
msgstr "对某些 ISP 应用 SNAT 修复"

#: protocols/luci-proto-ipv6/htdocs/luci-static/resources/protocol/map.js:92
msgid "Exclude SNAT ports"
msgstr "排除 SNAT 端口"

#: protocols/luci-proto-ipv6/htdocs/luci-static/resources/protocol/map.js:92
msgid "List of ports to exclude from SNAT. Separate ports with spaces"
msgstr "要从 SNAT 中排除的端口列表。用空格分隔"

#: protocols/luci-proto-ipv6/htdocs/luci-static/resources/protocol/map.js:109
msgid "Duplicate port found:"
msgstr "重复的端口号:"

#: modules/luci-mod-status/htdocs/luci-static/resources/view/status/include/30_network.js:60
#: protocols/luci-proto-ipv6/htdocs/luci-static/resources/protocol/map.js:71
msgid "Available portsets"
msgstr "可用的端口组"

#: modules/luci-mod-status/htdocs/luci-static/resources/view/status/include/30_network.js:61
msgid "Show"
msgstr "显示"

#: protocols/luci-proto-relay/htdocs/luci-static/resources/protocol/relay.js:179
msgid "Use routing table"
msgstr "使用路由表"
Expand Down Expand Up @@ -12135,6 +12164,7 @@ msgstr "有效端口或端口范围(port1-port2)"

#: modules/luci-base/htdocs/luci-static/resources/validation.js:368
#: modules/luci-mod-network/htdocs/luci-static/resources/view/network/dhcp.js:207
#: protocols/luci-proto-ipv6/htdocs/luci-static/resources/protocol/map.js:106
msgid "valid port value"
msgstr "有效端口值"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,17 @@ function renderbox(ifc, ipv6) {
addrs = (ipv6 ? ifc.getIP6Addrs() : ifc.getIPAddrs()) || [],
dnssrv = (ipv6 ? ifc.getDNS6Addrs() : ifc.getDNSAddrs()) || [],
expires = ifc.getExpiry(),
uptime = ifc.getUptime();
uptime = ifc.getUptime(),
type = ifc.getOpkgPackage();

if (type === 'map-t' && typeof ifc.callShowPortsets === 'function') {
addrs = ifc.getIPAddrs().concat(ifc.getIPv6Addrs());
var showPortsets = ifc.callShowPortsets();
}

if (type === 'ds-lite') {
addrs = ifc.getIPAddrs().concat(ifc.getIP6Addrs());
}

return E('div', { class: 'ifacebox' }, [
E('div', { class: 'ifacebox-head center ' + (active ? 'active' : '') },
Expand All @@ -31,8 +41,8 @@ function renderbox(ifc, ipv6) {
L.itemlist(E('span'), [
_('Protocol'), ifc.getI18n() || E('em', _('Not connected')),
_('Prefix Delegated'), ipv6 ? ifc.getIP6Prefix() : null,
_('Address'), addrs[0],
_('Address'), addrs[1],
(type === 'map-t' || type === 'ds-lite' ? _('IPv4 address') : _('Address')), addrs[0],
(type === 'map-t' || type === 'ds-lite' ? _('IPv6 address') : _('Address')), addrs[1],
_('Address'), addrs[2],
_('Address'), addrs[3],
_('Address'), addrs[4],
Expand All @@ -47,6 +57,8 @@ function renderbox(ifc, ipv6) {
_('DNS') + ' 3', dnssrv[2],
_('DNS') + ' 4', dnssrv[3],
_('DNS') + ' 5', dnssrv[4],
showPortsets ? _('Available portsets') : null,
showPortsets ? E('button', { class: 'cbi-button cbi-button-apply', click: showPortsets }, _('Show')) : null,
_('Expires'), (expires != null && expires > -1) ? '%t'.format(expires) : null,
_('Connected'), (uptime > 0) ? '%t'.format(uptime) : null
]),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,10 @@ return network.registerProtocol('dslite', {
return null;
},

getGatewayAddr: function () {
return this.get('peeraddr');
},

containsDevice: function(ifname) {
return (network.getIfnameOf(ifname) == this.getIfname());
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,10 @@ return network.registerProtocol('ipip6', {
return null;
},

getGatewayAddr: function () {
return this.get('peeraddr');
},

containsDevice: function (ifname) {
return (network.getIfnameOf(ifname) == this.getIfname());
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,52 @@ return network.registerProtocol('map', {
return (network.getIfnameOf(ifname) == this.getIfname());
},

getGatewayAddr: function () {
return this.get('peeraddr');
},

getIPv6Addrs: function () {
var d = this._ubus('data');
if (L.isObject(d) && typeof (d.ipv6addr) == 'string')
return d.ipv6addr;
return null;
},

callShowPortsets: function () {
var d = this._ubus('data');
if (L.isObject(d) && typeof (d.portsets) == 'string') {
var portSets = d.portsets;
if (portSets) {
var portArray = portSets.split(' ');
var groupedPorts = [];
for (var i = 0; i < portArray.length; i += 2) {
groupedPorts.push(portArray.slice(i, i + 2));
}
portSets = E('table', { style: 'width: 100%; border-collapse: collapse;' },
groupedPorts.map(function (portGroup) {
return E('tr', {}, [
E('td', { style: 'padding: 10px; border: 1px solid #ddd; text-align: center; font-size: 16px;' }, portGroup[0]),
portGroup[1] ? E('td', { style: 'padding: 10px; border: 1px solid #ddd; text-align: center; font-size: 16px;' }, portGroup[1]) : E('td', {})
]);
})
);
}
function showPortsets() {
L.ui.showModal(_('Available portsets'), [
E('div', { style: 'max-height: 400px; overflow-y: auto; padding: 10px; border: 1px solid #ddd;' }, portSets || _('No Data')),
E('div', { class: 'right' }, [
E('button', {
class: 'btn',
click: L.ui.hideModal
}, _('Close'))
])
]);
}
return showPortsets;
}
return null;
},

renderFormOptions: function(s) {
var o;

Expand Down Expand Up @@ -86,5 +132,31 @@ return network.registerProtocol('map', {
o.datatype = 'max(9200)';

o = s.taboption('advanced', form.Flag, 'legacymap', _('Use legacy MAP'), _('Use legacy MAP interface identifier format (draft-ietf-softwire-map-00) instead of RFC7597'));

o = s.taboption('advanced', form.Flag, 'snat_fix', _('Enable SNAT fix'), _('Apply SNAT fixes with certain ISPs'));

o = s.taboption('advanced', form.Value, 'dont_snat_to', _('Exclude SNAT ports'), _('List of ports to exclude from SNAT. Separate ports with spaces'));
missing233 marked this conversation as resolved.
Show resolved Hide resolved
o.depends('snat_fix', '1');
o.datatype = 'string';
o.placeholder = '80 443 8080';
o.validate = function (section_id, value) {
missing233 marked this conversation as resolved.
Show resolved Hide resolved
value = value.trim().replace(/\s+/g, ' ');
if (!value) return true;
let seen = new Set();
for (let port of value.split(' ')) {
let portNum = parseInt(port, 10);
if (!/^\d+$/.test(port) || portNum < 1 || portNum > 65535) {
return _('Expecting: %s').format(_('valid port value'));
}
if (seen.has(port)) {
return _('Duplicate port found:') + port;
}
seen.add(port);
}
return true;
};
o.write = function (section_id, form_value) {
return this.super('write', [section_id, form_value.trim().replace(/\s+/g, ' ')]);
};
}
});