nikki: sync upstream

last commit: 8db4e27cf1
This commit is contained in:
gitea-action 2025-02-24 15:00:28 +08:00
parent d768a347c9
commit 4e679c1241
3 changed files with 52 additions and 39 deletions

View File

@ -1,7 +1,7 @@
include $(TOPDIR)/rules.mk include $(TOPDIR)/rules.mk
PKG_NAME:=nikki PKG_NAME:=nikki
PKG_RELEASE:=3 PKG_RELEASE:=4
PKG_SOURCE_PROTO:=git PKG_SOURCE_PROTO:=git
PKG_SOURCE_URL:=https://github.com/MetaCubeX/mihomo.git PKG_SOURCE_URL:=https://github.com/MetaCubeX/mihomo.git

View File

@ -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_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 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_tcp_dport = split((uci.get('nikki', 'proxy', 'proxy_tcp_dport') ?? '0-65535'), ' ');
const proxy_udp_dport = ensure_array(uci.get('nikki', 'proxy', 'proxy_udp_dport')); 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 bypass_dscp = ensure_array(uci.get('nikki', 'proxy', 'bypass_dscp'));
const dns_hijack_nfproto = []; const dns_hijack_nfproto = [];

View File

@ -13,51 +13,52 @@ const config = {};
const mixin = uci.get('nikki', 'config', 'mixin') == '1'; const mixin = uci.get('nikki', 'config', 'mixin') == '1';
config['log-level'] = uci.get('nikki', 'mixin', 'log_level') || 'info'; config['log-level'] = uci.get('nikki', 'mixin', 'log_level') ?? 'info';
config['mode'] = uci.get('nikki', 'mixin', 'mode') || 'rule'; config['mode'] = uci.get('nikki', 'mixin', 'mode') ?? 'rule';
config['find-process-mode'] = uci.get('nikki', 'mixin', 'match_process') || 'off'; 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['interface-name'] = ubus.call('network.interface', 'status', {'interface': uci.get('nikki', 'mixin', 'outbound_interface')})?.l3_device ?? '';
config['ipv6'] = uci.get('nikki', 'mixin', 'ipv6') == '1'; config['ipv6'] = uci.get('nikki', 'mixin', 'ipv6') == '1';
if (mixin) { if (mixin) {
config['unified-delay'] = uci.get('nikki', 'mixin', 'unify_delay') == '1'; config['unified-delay'] = uci.get('nikki', 'mixin', 'unify_delay') == '1';
config['tcp-concurrent'] = uci.get('nikki', 'mixin', 'tcp_concurrent') == '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-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-interval'] = int(uci.get('nikki', 'mixin', 'tcp_keep_alive_interval') ?? '15');
} }
config['external-ui'] = uci.get('nikki', 'mixin', 'ui_path') || 'ui'; config['external-ui'] = uci.get('nikki', 'mixin', 'ui_path') ?? 'ui';
config['external-ui-name'] = uci.get('nikki', 'mixin', 'ui_name') || ''; config['external-ui-name'] = uci.get('nikki', 'mixin', 'ui_name') ?? '';
config['external-ui-url'] = uci.get('nikki', 'mixin', 'ui_url'); 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['external-controller'] = '0.0.0.0' + ':' + (uci.get('nikki', 'mixin', 'api_port') ?? '9090');
config['secret'] = uci.get('nikki', 'mixin', 'api_secret') || '666666'; config['secret'] = uci.get('nikki', 'mixin', 'api_secret') ?? '666666';
config['profile'] = {}; config['profile'] = {};
config['profile']['store-selected'] = uci.get('nikki', 'mixin', 'selection_cache') == '1'; 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['profile']['store-fake-ip'] = uci.get('nikki', 'mixin', 'fake_ip_cache') == '1';
config['allow-lan'] = uci.get('nikki', 'mixin', 'allow_lan') == '1'; config['allow-lan'] = uci.get('nikki', 'mixin', 'allow_lan') == '1';
config['port'] = int(uci.get('nikki', 'mixin', 'http_port') || '8080'); config['port'] = int(uci.get('nikki', 'mixin', 'http_port') ?? '8080');
config['socks-port'] = int(uci.get('nikki', 'mixin', 'socks_port') || '1080'); config['socks-port'] = int(uci.get('nikki', 'mixin', 'socks_port') ?? '1080');
config['mixed-port'] = int(uci.get('nikki', 'mixin', 'mixed_port') || '7890'); config['mixed-port'] = int(uci.get('nikki', 'mixin', 'mixed_port') ?? '7890');
config['redir-port'] = int(uci.get('nikki', 'mixin', 'redir_port') || '7891'); config['redir-port'] = int(uci.get('nikki', 'mixin', 'redir_port') ?? '7891');
config['tproxy-port'] = int(uci.get('nikki', 'mixin', 'tproxy_port') || '7892'); config['tproxy-port'] = int(uci.get('nikki', 'mixin', 'tproxy_port') ?? '7892');
if (uci.get('nikki', 'mixin', 'authentication') == '1') { if (uci.get('nikki', 'mixin', 'authentication') == '1') {
config['authentication'] = []; config['authentication'] = [];
uci.foreach('nikki', 'authentication', (section) => { uci.foreach('nikki', 'authentication', (section) => {
if (section.enabled == '1') { if (section.enabled != '1') {
push(config['authentication'], `${section.username}:${section.password}`); return;
} }
push(config['authentication'], `${section.username}:${section.password}`);
}); });
} }
config['tun'] = {}; config['tun'] = {};
if (uci.get('nikki', 'proxy', 'tcp_transparent_proxy_mode') == 'tun' || uci.get('nikki', 'proxy', 'udp_transparent_proxy_mode') == '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']['enable'] = true;
config['tun']['device'] = uci.get('nikki', 'mixin', 'tun_device') || 'nikki'; config['tun']['device'] = uci.get('nikki', 'mixin', 'tun_device') ?? 'nikki';
config['tun']['stack'] = uci.get('nikki', 'mixin', 'tun_stack') || 'system'; config['tun']['stack'] = uci.get('nikki', 'mixin', 'tun_stack') ?? 'system';
config['tun']['mtu'] = int(uci.get('nikki', 'mixin', 'tun_mtu') || '9000'); config['tun']['mtu'] = int(uci.get('nikki', 'mixin', 'tun_mtu') ?? '9000');
config['tun']['gso'] = uci.get('nikki', 'mixin', 'tun_gso') == '1'; 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']['endpoint-independent-nat'] = uci.get('nikki', 'mixin', 'tun_endpoint_independent_nat') == '1';
config['tun']['auto-route'] = false; config['tun']['auto-route'] = false;
config['tun']['auto-redirect'] = 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'] = {};
config['dns']['listen'] = '0.0.0.0' + ':' + (uci.get('nikki', 'mixin', 'dns_port') || '1053'); 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']['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']['fake-ip-range'] = uci.get('nikki', 'mixin', 'fake_ip_range') ?? '198.18.0.1/16';
if (uci.get('nikki', 'mixin', 'fake_ip_filter') == '1') { 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'] = 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) { if (mixin) {
config['dns']['respect-rules'] = uci.get('nikki', 'mixin', 'dns_respect_rules') == '1'; 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') { if (uci.get('nikki', 'mixin', 'hosts') == '1') {
config['hosts'] = {}; config['hosts'] = {};
uci.foreach('nikki', 'hosts', (section) => { uci.foreach('nikki', 'hosts', (section) => {
if (section.enabled == '1') { if (section.enabled != '1') {
config['hosts'][section.domain_name] = ensure_array(section.ip); return;
} }
config['hosts'][section.domain_name] = ensure_array(section.ip);
}); });
} }
if (uci.get('nikki', 'mixin', 'dns_nameserver') == '1') { if (uci.get('nikki', 'mixin', 'dns_nameserver') == '1') {
@ -98,15 +100,19 @@ if (mixin) {
config['dns']['nameserver'] = []; config['dns']['nameserver'] = [];
config['dns']['fallback'] = []; config['dns']['fallback'] = [];
uci.foreach('nikki', 'nameserver', (section) => { uci.foreach('nikki', 'nameserver', (section) => {
if (section.enabled != '1') {
return;
}
push(config['dns'][section.type], ...ensure_array(section.nameserver)); push(config['dns'][section.type], ...ensure_array(section.nameserver));
}) })
} }
if (uci.get('nikki', 'mixin', 'dns_nameserver_policy') == '1') { if (uci.get('nikki', 'mixin', 'dns_nameserver_policy') == '1') {
config['dns']['nameserver-policy'] = {}; config['dns']['nameserver-policy'] = {};
uci.foreach('nikki', 'nameserver_policy', (section) => { uci.foreach('nikki', 'nameserver_policy', (section) => {
if (section.enabled == '1') { if (section.enabled != '1') {
config['dns']['nameserver-policy'][section.matcher] = ensure_array(section.nameserver); return;
} }
config['dns']['nameserver-policy'][section.matcher] = ensure_array(section.nameserver);
}); });
} }
} }
@ -129,10 +135,11 @@ if (mixin) {
config['sniffer']['sniff']['TLS'] = {}; config['sniffer']['sniff']['TLS'] = {};
config['sniffer']['sniff']['QUIC'] = {}; config['sniffer']['sniff']['QUIC'] = {};
uci.foreach('nikki', 'sniff', (section) => { uci.foreach('nikki', 'sniff', (section) => {
if (section.enabled == '1') { if (section.enabled != '1') {
config['sniffer']['sniff'][section.protocol]['port'] = ensure_array(section.port); return;
config['sniffer']['sniff'][section.protocol]['override-destination'] = section.overwrite_destination == '1';
} }
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') { if (uci.get('nikki', 'mixin', 'rule_provider') == '1') {
config['rule-providers'] = {}; config['rule-providers'] = {};
uci.foreach('nikki', 'rule_provider', (section) => { uci.foreach('nikki', 'rule_provider', (section) => {
if (section.enabled != '1') {
return;
}
if (section.type == 'http') { if (section.type == 'http') {
config['rule-providers'][section.name] = { config['rule-providers'][section.name] = {
type: section.type, type: section.type,
@ -163,8 +173,11 @@ if (uci.get('nikki', 'mixin', 'rule_provider') == '1') {
if (uci.get('nikki', 'mixin', 'rule') == '1') { if (uci.get('nikki', 'mixin', 'rule') == '1') {
config['nikki-rules'] = []; config['nikki-rules'] = [];
uci.foreach('nikki', 'rule', (section) => { uci.foreach('nikki', 'rule', (section) => {
if (section.enabled != '1') {
return;
}
let rule; let rule;
if (section.type == null || section.type == '') { if (section.type == null ?? section.type == '') {
rule = `${section.matcher},${section.node}`; rule = `${section.matcher},${section.node}`;
} else { } else {
rule = `${section.type},${section.matcher},${section.node}`; rule = `${section.type},${section.matcher},${section.node}`;
@ -177,15 +190,15 @@ if (uci.get('nikki', 'mixin', 'rule') == '1') {
} }
if (mixin) { if (mixin) {
config['geodata-mode'] = (uci.get('nikki', 'mixin', 'geoip_format') || 'mmdb') == 'dat'; config['geodata-mode'] = (uci.get('nikki', 'mixin', 'geoip_format') ?? 'mmdb') == 'dat';
config['geodata-loader'] = uci.get('nikki', 'mixin', 'geodata_loader') || 'memconservative'; config['geodata-loader'] = uci.get('nikki', 'mixin', 'geodata_loader') ?? 'memconservative';
config['geox-url'] = {}; config['geox-url'] = {};
config['geox-url']['geosite'] = uci.get('nikki', 'mixin', 'geosite_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']['mmdb'] = uci.get('nikki', 'mixin', 'geoip_mmdb_url');
config['geox-url']['geoip'] = uci.get('nikki', 'mixin', 'geoip_dat_url'); config['geox-url']['geoip'] = uci.get('nikki', 'mixin', 'geoip_dat_url');
config['geox-url']['asn'] = uci.get('nikki', 'mixin', 'geoip_asn_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-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); print(config);