From 4e679c1241cec6adbcf9d66a7e26016a7205b32e Mon Sep 17 00:00:00 2001 From: gitea-action Date: Mon, 24 Feb 2025 15:00:28 +0800 Subject: [PATCH] nikki: sync upstream last commit: https://github.com/nikkinikki-org/OpenWrt-nikki/commit/8db4e27cf1143383d52cbd61581cb5f914281d6d --- nikki/Makefile | 2 +- nikki/files/ucode/hijack.ut | 4 +- nikki/files/ucode/mixin.uc | 85 +++++++++++++++++++++---------------- 3 files changed, 52 insertions(+), 39 deletions(-) diff --git a/nikki/Makefile b/nikki/Makefile index 1e6521fb3..cf11f245b 100644 --- a/nikki/Makefile +++ b/nikki/Makefile @@ -1,7 +1,7 @@ include $(TOPDIR)/rules.mk PKG_NAME:=nikki -PKG_RELEASE:=3 +PKG_RELEASE:=4 PKG_SOURCE_PROTO:=git PKG_SOURCE_URL:=https://github.com/MetaCubeX/mihomo.git diff --git a/nikki/files/ucode/hijack.ut b/nikki/files/ucode/hijack.ut index a5a975521..e3a5303b7 100644 --- a/nikki/files/ucode/hijack.ut +++ b/nikki/files/ucode/hijack.ut @@ -40,8 +40,8 @@ const bypass_user = filter(ensure_array(uci.get('nikki', 'proxy', 'bypass_user')), (x) => x != "root" && index(users, x) >= 0); const bypass_group = filter(ensure_array(uci.get('nikki', 'proxy', 'bypass_group')), (x) => x != "root" && index(groups, x) >= 0); - const proxy_tcp_dport = ensure_array(uci.get('nikki', 'proxy', 'proxy_tcp_dport')); - const proxy_udp_dport = ensure_array(uci.get('nikki', 'proxy', 'proxy_udp_dport')); + const proxy_tcp_dport = split((uci.get('nikki', 'proxy', 'proxy_tcp_dport') ?? '0-65535'), ' '); + const proxy_udp_dport = split((uci.get('nikki', 'proxy', 'proxy_udp_dport') ?? '0-65535'), ' '); const bypass_dscp = ensure_array(uci.get('nikki', 'proxy', 'bypass_dscp')); const dns_hijack_nfproto = []; diff --git a/nikki/files/ucode/mixin.uc b/nikki/files/ucode/mixin.uc index 57a37913c..0b6faec1c 100644 --- a/nikki/files/ucode/mixin.uc +++ b/nikki/files/ucode/mixin.uc @@ -13,51 +13,52 @@ const config = {}; const mixin = uci.get('nikki', 'config', 'mixin') == '1'; -config['log-level'] = uci.get('nikki', 'mixin', 'log_level') || 'info'; -config['mode'] = uci.get('nikki', 'mixin', 'mode') || 'rule'; -config['find-process-mode'] = uci.get('nikki', 'mixin', 'match_process') || 'off'; -config['interface-name'] = ubus.call('network.interface', 'status', {'interface': uci.get('nikki', 'mixin', 'outbound_interface')})?.l3_device || ''; +config['log-level'] = uci.get('nikki', 'mixin', 'log_level') ?? 'info'; +config['mode'] = uci.get('nikki', 'mixin', 'mode') ?? 'rule'; +config['find-process-mode'] = uci.get('nikki', 'mixin', 'match_process') ?? 'off'; +config['interface-name'] = ubus.call('network.interface', 'status', {'interface': uci.get('nikki', 'mixin', 'outbound_interface')})?.l3_device ?? ''; config['ipv6'] = uci.get('nikki', 'mixin', 'ipv6') == '1'; if (mixin) { config['unified-delay'] = uci.get('nikki', 'mixin', 'unify_delay') == '1'; config['tcp-concurrent'] = uci.get('nikki', 'mixin', 'tcp_concurrent') == '1'; - config['keep-alive-idle'] = int(uci.get('nikki', 'mixin', 'tcp_keep_alive_idle') || '600'); - config['keep-alive-interval'] = int(uci.get('nikki', 'mixin', 'tcp_keep_alive_interval') || '15'); + config['keep-alive-idle'] = int(uci.get('nikki', 'mixin', 'tcp_keep_alive_idle') ?? '600'); + config['keep-alive-interval'] = int(uci.get('nikki', 'mixin', 'tcp_keep_alive_interval') ?? '15'); } -config['external-ui'] = uci.get('nikki', 'mixin', 'ui_path') || 'ui'; -config['external-ui-name'] = uci.get('nikki', 'mixin', 'ui_name') || ''; +config['external-ui'] = uci.get('nikki', 'mixin', 'ui_path') ?? 'ui'; +config['external-ui-name'] = uci.get('nikki', 'mixin', 'ui_name') ?? ''; config['external-ui-url'] = uci.get('nikki', 'mixin', 'ui_url'); -config['external-controller'] = '0.0.0.0' + ':' + (uci.get('nikki', 'mixin', 'api_port') || '9090'); -config['secret'] = uci.get('nikki', 'mixin', 'api_secret') || '666666'; +config['external-controller'] = '0.0.0.0' + ':' + (uci.get('nikki', 'mixin', 'api_port') ?? '9090'); +config['secret'] = uci.get('nikki', 'mixin', 'api_secret') ?? '666666'; config['profile'] = {}; config['profile']['store-selected'] = uci.get('nikki', 'mixin', 'selection_cache') == '1'; config['profile']['store-fake-ip'] = uci.get('nikki', 'mixin', 'fake_ip_cache') == '1'; config['allow-lan'] = uci.get('nikki', 'mixin', 'allow_lan') == '1'; -config['port'] = int(uci.get('nikki', 'mixin', 'http_port') || '8080'); -config['socks-port'] = int(uci.get('nikki', 'mixin', 'socks_port') || '1080'); -config['mixed-port'] = int(uci.get('nikki', 'mixin', 'mixed_port') || '7890'); -config['redir-port'] = int(uci.get('nikki', 'mixin', 'redir_port') || '7891'); -config['tproxy-port'] = int(uci.get('nikki', 'mixin', 'tproxy_port') || '7892'); +config['port'] = int(uci.get('nikki', 'mixin', 'http_port') ?? '8080'); +config['socks-port'] = int(uci.get('nikki', 'mixin', 'socks_port') ?? '1080'); +config['mixed-port'] = int(uci.get('nikki', 'mixin', 'mixed_port') ?? '7890'); +config['redir-port'] = int(uci.get('nikki', 'mixin', 'redir_port') ?? '7891'); +config['tproxy-port'] = int(uci.get('nikki', 'mixin', 'tproxy_port') ?? '7892'); if (uci.get('nikki', 'mixin', 'authentication') == '1') { config['authentication'] = []; uci.foreach('nikki', 'authentication', (section) => { - if (section.enabled == '1') { - push(config['authentication'], `${section.username}:${section.password}`); + if (section.enabled != '1') { + return; } + push(config['authentication'], `${section.username}:${section.password}`); }); } config['tun'] = {}; if (uci.get('nikki', 'proxy', 'tcp_transparent_proxy_mode') == 'tun' || uci.get('nikki', 'proxy', 'udp_transparent_proxy_mode') == 'tun') { config['tun']['enable'] = true; - config['tun']['device'] = uci.get('nikki', 'mixin', 'tun_device') || 'nikki'; - config['tun']['stack'] = uci.get('nikki', 'mixin', 'tun_stack') || 'system'; - config['tun']['mtu'] = int(uci.get('nikki', 'mixin', 'tun_mtu') || '9000'); + config['tun']['device'] = uci.get('nikki', 'mixin', 'tun_device') ?? 'nikki'; + config['tun']['stack'] = uci.get('nikki', 'mixin', 'tun_stack') ?? 'system'; + config['tun']['mtu'] = int(uci.get('nikki', 'mixin', 'tun_mtu') ?? '9000'); config['tun']['gso'] = uci.get('nikki', 'mixin', 'tun_gso') == '1'; - config['tun']['gso-max-size'] = int(uci.get('nikki', 'mixin', 'tun_gso_max_size') || '65536'); + config['tun']['gso-max-size'] = int(uci.get('nikki', 'mixin', 'tun_gso_max_size') ?? '65536'); config['tun']['endpoint-independent-nat'] = uci.get('nikki', 'mixin', 'tun_endpoint_independent_nat') == '1'; config['tun']['auto-route'] = false; config['tun']['auto-redirect'] = false; @@ -70,12 +71,12 @@ if (uci.get('nikki', 'proxy', 'tcp_transparent_proxy_mode') == 'tun' || uci.get( } config['dns'] = {}; -config['dns']['listen'] = '0.0.0.0' + ':' + (uci.get('nikki', 'mixin', 'dns_port') || '1053'); -config['dns']['enhanced-mode'] = uci.get('nikki', 'mixin', 'dns_mode') || 'redir-host'; -config['dns']['fake-ip-range'] = uci.get('nikki', 'mixin', 'fake_ip_range') || '198.18.0.1/16'; +config['dns']['listen'] = '0.0.0.0' + ':' + (uci.get('nikki', 'mixin', 'dns_port') ?? '1053'); +config['dns']['enhanced-mode'] = uci.get('nikki', 'mixin', 'dns_mode') ?? 'redir-host'; +config['dns']['fake-ip-range'] = uci.get('nikki', 'mixin', 'fake_ip_range') ?? '198.18.0.1/16'; if (uci.get('nikki', 'mixin', 'fake_ip_filter') == '1') { config['dns']['fake-ip-filter'] = ensure_array(uci.get('nikki', 'mixin', 'fake_ip_filters')); - config['dns']['fake-ip-filter-mode'] = uci.get('nikki', 'mixin', 'fake_ip_filter_mode') || 'blacklist'; + config['dns']['fake-ip-filter-mode'] = uci.get('nikki', 'mixin', 'fake_ip_filter_mode') ?? 'blacklist'; } if (mixin) { config['dns']['respect-rules'] = uci.get('nikki', 'mixin', 'dns_respect_rules') == '1'; @@ -86,9 +87,10 @@ if (mixin) { if (uci.get('nikki', 'mixin', 'hosts') == '1') { config['hosts'] = {}; uci.foreach('nikki', 'hosts', (section) => { - if (section.enabled == '1') { - config['hosts'][section.domain_name] = ensure_array(section.ip); + if (section.enabled != '1') { + return; } + config['hosts'][section.domain_name] = ensure_array(section.ip); }); } if (uci.get('nikki', 'mixin', 'dns_nameserver') == '1') { @@ -98,15 +100,19 @@ if (mixin) { config['dns']['nameserver'] = []; config['dns']['fallback'] = []; uci.foreach('nikki', 'nameserver', (section) => { + if (section.enabled != '1') { + return; + } push(config['dns'][section.type], ...ensure_array(section.nameserver)); }) } if (uci.get('nikki', 'mixin', 'dns_nameserver_policy') == '1') { config['dns']['nameserver-policy'] = {}; uci.foreach('nikki', 'nameserver_policy', (section) => { - if (section.enabled == '1') { - config['dns']['nameserver-policy'][section.matcher] = ensure_array(section.nameserver); + if (section.enabled != '1') { + return; } + config['dns']['nameserver-policy'][section.matcher] = ensure_array(section.nameserver); }); } } @@ -129,10 +135,11 @@ if (mixin) { config['sniffer']['sniff']['TLS'] = {}; config['sniffer']['sniff']['QUIC'] = {}; uci.foreach('nikki', 'sniff', (section) => { - if (section.enabled == '1') { - config['sniffer']['sniff'][section.protocol]['port'] = ensure_array(section.port); - config['sniffer']['sniff'][section.protocol]['override-destination'] = section.overwrite_destination == '1'; + if (section.enabled != '1') { + return; } + config['sniffer']['sniff'][section.protocol]['port'] = ensure_array(section.port); + config['sniffer']['sniff'][section.protocol]['override-destination'] = section.overwrite_destination == '1'; }); } } @@ -140,6 +147,9 @@ if (mixin) { if (uci.get('nikki', 'mixin', 'rule_provider') == '1') { config['rule-providers'] = {}; uci.foreach('nikki', 'rule_provider', (section) => { + if (section.enabled != '1') { + return; + } if (section.type == 'http') { config['rule-providers'][section.name] = { type: section.type, @@ -163,8 +173,11 @@ if (uci.get('nikki', 'mixin', 'rule_provider') == '1') { if (uci.get('nikki', 'mixin', 'rule') == '1') { config['nikki-rules'] = []; uci.foreach('nikki', 'rule', (section) => { + if (section.enabled != '1') { + return; + } let rule; - if (section.type == null || section.type == '') { + if (section.type == null ?? section.type == '') { rule = `${section.matcher},${section.node}`; } else { rule = `${section.type},${section.matcher},${section.node}`; @@ -177,15 +190,15 @@ if (uci.get('nikki', 'mixin', 'rule') == '1') { } if (mixin) { - config['geodata-mode'] = (uci.get('nikki', 'mixin', 'geoip_format') || 'mmdb') == 'dat'; - config['geodata-loader'] = uci.get('nikki', 'mixin', 'geodata_loader') || 'memconservative'; + config['geodata-mode'] = (uci.get('nikki', 'mixin', 'geoip_format') ?? 'mmdb') == 'dat'; + config['geodata-loader'] = uci.get('nikki', 'mixin', 'geodata_loader') ?? 'memconservative'; config['geox-url'] = {}; config['geox-url']['geosite'] = uci.get('nikki', 'mixin', 'geosite_url'); config['geox-url']['mmdb'] = uci.get('nikki', 'mixin', 'geoip_mmdb_url'); config['geox-url']['geoip'] = uci.get('nikki', 'mixin', 'geoip_dat_url'); config['geox-url']['asn'] = uci.get('nikki', 'mixin', 'geoip_asn_url'); config['geo-auto-update'] = uci.get('nikki', 'mixin', 'geox_auto_update') == '1'; - config['geo-update-interval'] = int(uci.get('nikki', 'mixin', 'geox_update_interval') || '24'); + config['geo-update-interval'] = int(uci.get('nikki', 'mixin', 'geox_update_interval') ?? '24'); } print(config); \ No newline at end of file