luci-app-homeproxy: sync upstream

last commit: f94668b296
This commit is contained in:
gitea-action 2024-09-19 12:30:07 +08:00
parent 637c1be433
commit 6606aeea2c
2 changed files with 31 additions and 11 deletions

View File

@ -1007,9 +1007,9 @@ return view.extend({
so.rmempty = false; so.rmempty = false;
so = ss.option(form.ListValue, 'format', _('Format')); so = ss.option(form.ListValue, 'format', _('Format'));
so.value('source', _('Source file'));
so.value('binary', _('Binary file')); so.value('binary', _('Binary file'));
so.default = 'source'; so.value('source', _('Source file'));
so.default = 'binary';
so.rmempty = false; so.rmempty = false;
so = ss.option(form.Value, 'path', _('Path')); so = ss.option(form.Value, 'path', _('Path'));

View File

@ -30,6 +30,26 @@ function resolve_ipv6(str) {
return `& ${ipv6.mask} == ${ipv6.addr}`; return `& ${ipv6.mask} == ${ipv6.addr}`;
} }
function resolve_mark(str) {
if (isEmpty(str))
return null;
let mark = fw4.parse_mark(str);
if (isEmpty(mark))
return null;
if (mark.mask === 0xffffffff)
return fw4.hex(mark.mark);
else if (mark.mark === 0)
return `mark and ${fw4.hex(~mark.mask & 0xffffffff)}`;
else if (mark.mark === mark.mask)
return `mark or ${fw4.hex(mark.mark)}`;
else if (mark.mask === 0)
return `mark xor ${fw4.hex(mark.mark)}`;
else
return `mark and ${fw4.hex(~mark.mask & 0xffffffff)} xor ${fw4.hex(mark.mark)}`;
}
/* Misc config */ /* Misc config */
const resources_dir = '/etc/homeproxy/resources'; const resources_dir = '/etc/homeproxy/resources';
@ -68,11 +88,11 @@ if (match(proxy_mode, /redirect/)) {
if (match(proxy_mode, /tproxy/)) if (match(proxy_mode, /tproxy/))
if (outbound_udp_node !== 'nil' || routing_mode === 'custom') { if (outbound_udp_node !== 'nil' || routing_mode === 'custom') {
tproxy_port = uci.get(cfgname, 'infra', 'tproxy_port') || '5332'; tproxy_port = uci.get(cfgname, 'infra', 'tproxy_port') || '5332';
tproxy_mark = uci.get(cfgname, 'infra', 'tproxy_mark') || '101'; tproxy_mark = resolve_mark(uci.get(cfgname, 'infra', 'tproxy_mark') || '101');
} }
if (match(proxy_mode, /tun/)) { if (match(proxy_mode, /tun/)) {
tun_name = uci.get(cfgname, 'infra', 'tun_name') || 'singtun0'; tun_name = uci.get(cfgname, 'infra', 'tun_name') || 'singtun0';
tun_mark = uci.get(cfgname, 'infra', 'tun_mark') || '102'; tun_mark = resolve_mark(uci.get(cfgname, 'infra', 'tun_mark') || '102');
} }
const control_options = [ const control_options = [
@ -356,9 +376,9 @@ chain homeproxy_output_redir {
{# UDP tproxy #} {# UDP tproxy #}
{% if (match(proxy_mode, /tproxy/) && (outbound_udp_node !== 'nil' || routing_mode === 'custom')): %} {% if (match(proxy_mode, /tproxy/) && (outbound_udp_node !== 'nil' || routing_mode === 'custom')): %}
chain homeproxy_mangle_tproxy { chain homeproxy_mangle_tproxy {
meta l4proto udp mark set {{ tproxy_mark }} tproxy ip to 127.0.0.1:{{ tproxy_port }} counter accept meta l4proto udp meta mark set {{ tproxy_mark }} tproxy ip to 127.0.0.1:{{ tproxy_port }} counter accept
{% if (ipv6_support === '1'): %} {% if (ipv6_support === '1'): %}
meta l4proto udp mark set {{ tproxy_mark }} tproxy ip6 to [::1]:{{ tproxy_port }} counter accept meta l4proto udp meta mark set {{ tproxy_mark }} tproxy ip6 to [::1]:{{ tproxy_port }} counter accept
{% endif %} {% endif %}
} }
@ -373,7 +393,7 @@ chain homeproxy_mangle_mark {
{% if (routing_port): %} {% if (routing_port): %}
udp dport != @homeproxy_routing_port counter return udp dport != @homeproxy_routing_port counter return
{% endif %} {% endif %}
meta l4proto udp mark set {{ tproxy_mark }} counter accept meta l4proto udp meta mark set {{ tproxy_mark }} counter accept
} }
chain homeproxy_mangle_lanac { chain homeproxy_mangle_lanac {
@ -564,7 +584,7 @@ chain homeproxy_mangle_tun_mark {
udp dport != @homeproxy_routing_port counter return udp dport != @homeproxy_routing_port counter return
{% endif /* routing_port */ %} {% endif /* routing_port */ %}
counter mark set {{ tun_mark }} counter meta mark set {{ tun_mark }}
} }
chain homeproxy_mangle_tun { chain homeproxy_mangle_tun {
@ -621,13 +641,13 @@ chain homeproxy_mangle_tun {
{% endif /* routing_mode */ %} {% endif /* routing_mode */ %}
{% if (!isEmpty(control_info.lan_gaming_mode_ipv4_ips)): %} {% if (!isEmpty(control_info.lan_gaming_mode_ipv4_ips)): %}
ip saddr {{ array_to_nftarr(control_info.lan_gaming_mode_ipv4_ips) }} counter mark set {{ tun_mark }} ip saddr {{ array_to_nftarr(control_info.lan_gaming_mode_ipv4_ips) }} counter meta mark set {{ tun_mark }}
{% endif /* lan_gaming_mode_ipv4_ips */ %} {% endif /* lan_gaming_mode_ipv4_ips */ %}
{% for (let ipv6 in control_info.lan_gaming_mode_ipv6_ips): %} {% for (let ipv6 in control_info.lan_gaming_mode_ipv6_ips): %}
ip6 saddr {{ resolve_ipv6(ipv6) }} counter mark set {{ tun_mark }} ip6 saddr {{ resolve_ipv6(ipv6) }} counter meta mark set {{ tun_mark }}
{% endfor /* lan_gaming_mode_ipv6_ips */ %} {% endfor /* lan_gaming_mode_ipv6_ips */ %}
{% if (!isEmpty(control_info.lan_gaming_mode_mac_addrs)): %} {% if (!isEmpty(control_info.lan_gaming_mode_mac_addrs)): %}
ether saddr {{ array_to_nftarr(control_info.lan_gaming_mode_mac_addrs) }} counter mark set {{ tun_mark }} ether saddr {{ array_to_nftarr(control_info.lan_gaming_mode_mac_addrs) }} counter meta mark set {{ tun_mark }}
{% endif /* lan_gaming_mode_mac_addrs */ %} {% endif /* lan_gaming_mode_mac_addrs */ %}
counter goto homeproxy_mangle_tun_mark counter goto homeproxy_mangle_tun_mark