Skip to content

Commit

Permalink
luci-proto-ipv6: map: Add SNAT fix option for specific ISP
Browse files Browse the repository at this point in the history
Ensure that the multiple port ranges used with specific ISP
MAP-E implementation are actually SNAT-ed correctly.

Signed-off-by: Arayuki Mago <ms@missing233.com>
  • Loading branch information
missing233 committed Oct 4, 2024
1 parent 69035ab commit 01a4451
Show file tree
Hide file tree
Showing 3 changed files with 68 additions and 0 deletions.
21 changes: 21 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,26 @@ 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 "重複ポート番号検出:"

#: protocols/luci-proto-relay/htdocs/luci-static/resources/protocol/relay.js:179
msgid "Use routing table"
msgstr "ルーティングテーブルを使用"
Expand Down Expand Up @@ -12194,6 +12214,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
21 changes: 21 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,26 @@ 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 "重复的端口号:"

#: protocols/luci-proto-relay/htdocs/luci-static/resources/protocol/relay.js:179
msgid "Use routing table"
msgstr "使用路由表"
Expand Down Expand Up @@ -12135,6 +12155,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 @@ -86,5 +86,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'));
o.depends('snat_fix', '1');
o.datatype = 'string';
o.placeholder = '80 443 8080';
o.validate = function (section_id, value) {
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, ' ')]);
};
}
});

0 comments on commit 01a4451

Please sign in to comment.