🎁 Sync 2026-07-31 00:21:49

This commit is contained in:
github-actions[bot] committed 2026-07-31 00:21:49 +08:00
1 parent f6c3fbbbbe
commit c71b32c9fb
204 files changed
+187145 -10038

No files matched your search

-340
View File
@@ -1,340 +0,0 @@
GNU GENERAL PUBLIC LICENSE
Version 2, June 1991
Copyright (C) 1989, 1991 Free Software Foundation, Inc.
59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
Preamble
The licenses for most software are designed to take away your
freedom to share and change it. By contrast, the GNU General Public
License is intended to guarantee your freedom to share and change free
software--to make sure the software is free for all its users. This
General Public License applies to most of the Free Software
Foundation's software and to any other program whose authors commit to
using it. (Some other Free Software Foundation software is covered by
the GNU Library General Public License instead.) You can apply it to
your programs, too.
When we speak of free software, we are referring to freedom, not
price. Our General Public Licenses are designed to make sure that you
have the freedom to distribute copies of free software (and charge for
this service if you wish), that you receive source code or can get it
if you want it, that you can change the software or use pieces of it
in new free programs; and that you know you can do these things.
To protect your rights, we need to make restrictions that forbid
anyone to deny you these rights or to ask you to surrender the rights.
These restrictions translate to certain responsibilities for you if you
distribute copies of the software, or if you modify it.
For example, if you distribute copies of such a program, whether
gratis or for a fee, you must give the recipients all the rights that
you have. You must make sure that they, too, receive or can get the
source code. And you must show them these terms so they know their
rights.
We protect your rights with two steps: (1) copyright the software, and
(2) offer you this license which gives you legal permission to copy,
distribute and/or modify the software.
Also, for each author's protection and ours, we want to make certain
that everyone understands that there is no warranty for this free
software. If the software is modified by someone else and passed on, we
want its recipients to know that what they have is not the original, so
that any problems introduced by others will not reflect on the original
authors' reputations.
Finally, any free program is threatened constantly by software
patents. We wish to avoid the danger that redistributors of a free
program will individually obtain patent licenses, in effect making the
program proprietary. To prevent this, we have made it clear that any
patent must be licensed for everyone's free use or not licensed at all.
The precise terms and conditions for copying, distribution and
modification follow.
GNU GENERAL PUBLIC LICENSE
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
0. This License applies to any program or other work which contains
a notice placed by the copyright holder saying it may be distributed
under the terms of this General Public License. The "Program", below,
refers to any such program or work, and a "work based on the Program"
means either the Program or any derivative work under copyright law:
that is to say, a work containing the Program or a portion of it,
either verbatim or with modifications and/or translated into another
language. (Hereinafter, translation is included without limitation in
the term "modification".) Each licensee is addressed as "you".
Activities other than copying, distribution and modification are not
covered by this License; they are outside its scope. The act of
running the Program is not restricted, and the output from the Program
is covered only if its contents constitute a work based on the
Program (independent of having been made by running the Program).
Whether that is true depends on what the Program does.
1. You may copy and distribute verbatim copies of the Program's
source code as you receive it, in any medium, provided that you
conspicuously and appropriately publish on each copy an appropriate
copyright notice and disclaimer of warranty; keep intact all the
notices that refer to this License and to the absence of any warranty;
and give any other recipients of the Program a copy of this License
along with the Program.
You may charge a fee for the physical act of transferring a copy, and
you may at your option offer warranty protection in exchange for a fee.
2. You may modify your copy or copies of the Program or any portion
of it, thus forming a work based on the Program, and copy and
distribute such modifications or work under the terms of Section 1
above, provided that you also meet all of these conditions:
a) You must cause the modified files to carry prominent notices
stating that you changed the files and the date of any change.
b) You must cause any work that you distribute or publish, that in
whole or in part contains or is derived from the Program or any
part thereof, to be licensed as a whole at no charge to all third
parties under the terms of this License.
c) If the modified program normally reads commands interactively
when run, you must cause it, when started running for such
interactive use in the most ordinary way, to print or display an
announcement including an appropriate copyright notice and a
notice that there is no warranty (or else, saying that you provide
a warranty) and that users may redistribute the program under
these conditions, and telling the user how to view a copy of this
License. (Exception: if the Program itself is interactive but
does not normally print such an announcement, your work based on
the Program is not required to print an announcement.)
These requirements apply to the modified work as a whole. If
identifiable sections of that work are not derived from the Program,
and can be reasonably considered independent and separate works in
themselves, then this License, and its terms, do not apply to those
sections when you distribute them as separate works. But when you
distribute the same sections as part of a whole which is a work based
on the Program, the distribution of the whole must be on the terms of
this License, whose permissions for other licensees extend to the
entire whole, and thus to each and every part regardless of who wrote it.
Thus, it is not the intent of this section to claim rights or contest
your rights to work written entirely by you; rather, the intent is to
exercise the right to control the distribution of derivative or
collective works based on the Program.
In addition, mere aggregation of another work not based on the Program
with the Program (or with a work based on the Program) on a volume of
a storage or distribution medium does not bring the other work under
the scope of this License.
3. You may copy and distribute the Program (or a work based on it,
under Section 2) in object code or executable form under the terms of
Sections 1 and 2 above provided that you also do one of the following:
a) Accompany it with the complete corresponding machine-readable
source code, which must be distributed under the terms of Sections
1 and 2 above on a medium customarily used for software interchange; or,
b) Accompany it with a written offer, valid for at least three
years, to give any third party, for a charge no more than your
cost of physically performing source distribution, a complete
machine-readable copy of the corresponding source code, to be
distributed under the terms of Sections 1 and 2 above on a medium
customarily used for software interchange; or,
c) Accompany it with the information you received as to the offer
to distribute corresponding source code. (This alternative is
allowed only for noncommercial distribution and only if you
received the program in object code or executable form with such
an offer, in accord with Subsection b above.)
The source code for a work means the preferred form of the work for
making modifications to it. For an executable work, complete source
code means all the source code for all modules it contains, plus any
associated interface definition files, plus the scripts used to
control compilation and installation of the executable. However, as a
special exception, the source code distributed need not include
anything that is normally distributed (in either source or binary
form) with the major components (compiler, kernel, and so on) of the
operating system on which the executable runs, unless that component
itself accompanies the executable.
If distribution of executable or object code is made by offering
access to copy from a designated place, then offering equivalent
access to copy the source code from the same place counts as
distribution of the source code, even though third parties are not
compelled to copy the source along with the object code.
4. You may not copy, modify, sublicense, or distribute the Program
except as expressly provided under this License. Any attempt
otherwise to copy, modify, sublicense or distribute the Program is
void, and will automatically terminate your rights under this License.
However, parties who have received copies, or rights, from you under
this License will not have their licenses terminated so long as such
parties remain in full compliance.
5. You are not required to accept this License, since you have not
signed it. However, nothing else grants you permission to modify or
distribute the Program or its derivative works. These actions are
prohibited by law if you do not accept this License. Therefore, by
modifying or distributing the Program (or any work based on the
Program), you indicate your acceptance of this License to do so, and
all its terms and conditions for copying, distributing or modifying
the Program or works based on it.
6. Each time you redistribute the Program (or any work based on the
Program), the recipient automatically receives a license from the
original licensor to copy, distribute or modify the Program subject to
these terms and conditions. You may not impose any further
restrictions on the recipients' exercise of the rights granted herein.
You are not responsible for enforcing compliance by third parties to
this License.
7. If, as a consequence of a court judgment or allegation of patent
infringement or for any other reason (not limited to patent issues),
conditions are imposed on you (whether by court order, agreement or
otherwise) that contradict the conditions of this License, they do not
excuse you from the conditions of this License. If you cannot
distribute so as to satisfy simultaneously your obligations under this
License and any other pertinent obligations, then as a consequence you
may not distribute the Program at all. For example, if a patent
license would not permit royalty-free redistribution of the Program by
all those who receive copies directly or indirectly through you, then
the only way you could satisfy both it and this License would be to
refrain entirely from distribution of the Program.
If any portion of this section is held invalid or unenforceable under
any particular circumstance, the balance of the section is intended to
apply and the section as a whole is intended to apply in other
circumstances.
It is not the purpose of this section to induce you to infringe any
patents or other property right claims or to contest validity of any
such claims; this section has the sole purpose of protecting the
integrity of the free software distribution system, which is
implemented by public license practices. Many people have made
generous contributions to the wide range of software distributed
through that system in reliance on consistent application of that
system; it is up to the author/donor to decide if he or she is willing
to distribute software through any other system and a licensee cannot
impose that choice.
This section is intended to make thoroughly clear what is believed to
be a consequence of the rest of this License.
8. If the distribution and/or use of the Program is restricted in
certain countries either by patents or by copyrighted interfaces, the
original copyright holder who places the Program under this License
may add an explicit geographical distribution limitation excluding
those countries, so that distribution is permitted only in or among
countries not thus excluded. In such case, this License incorporates
the limitation as if written in the body of this License.
9. The Free Software Foundation may publish revised and/or new versions
of the General Public License from time to time. Such new versions will
be similar in spirit to the present version, but may differ in detail to
address new problems or concerns.
Each version is given a distinguishing version number. If the Program
specifies a version number of this License which applies to it and "any
later version", you have the option of following the terms and conditions
either of that version or of any later version published by the Free
Software Foundation. If the Program does not specify a version number of
this License, you may choose any version ever published by the Free Software
Foundation.
10. If you wish to incorporate parts of the Program into other free
programs whose distribution conditions are different, write to the author
to ask for permission. For software which is copyrighted by the Free
Software Foundation, write to the Free Software Foundation; we sometimes
make exceptions for this. Our decision will be guided by the two goals
of preserving the free status of all derivatives of our free software and
of promoting the sharing and reuse of software generally.
NO WARRANTY
11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
REPAIR OR CORRECTION.
12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
POSSIBILITY OF SUCH DAMAGES.
END OF TERMS AND CONDITIONS
How to Apply These Terms to Your New Programs
If you develop a new program, and you want it to be of the greatest
possible use to the public, the best way to achieve this is to make it
free software which everyone can redistribute and change under these terms.
To do so, attach the following notices to the program. It is safest
to attach them to the start of each source file to most effectively
convey the exclusion of warranty; and each file should have at least
the "copyright" line and a pointer to where the full notice is found.
<one line to give the program's name and a brief idea of what it does.>
Copyright (C) <year> <name of author>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
Also add information on how to contact you by electronic and paper mail.
If the program is interactive, make it output a short notice like this
when it starts in an interactive mode:
Gnomovision version 69, Copyright (C) year name of author
Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
This is free software, and you are welcome to redistribute it
under certain conditions; type `show c' for details.
The hypothetical commands `show w' and `show c' should show the appropriate
parts of the General Public License. Of course, the commands you use may
be called something other than `show w' and `show c'; they could even be
mouse-clicks or menu items--whatever suits your program.
You should also get your employer (if you work as a programmer) or your
school, if any, to sign a "copyright disclaimer" for the program, if
necessary. Here is a sample; alter the names:
Yoyodyne, Inc., hereby disclaims all copyright interest in the program
`Gnomovision' (which makes passes at compilers) written by James Hacker.
<signature of Ty Coon>, 1 April 1989
Ty Coon, President of Vice
This General Public License does not permit incorporating your program into
proprietary programs. If your program is a subroutine library, you may
consider it more useful to permit linking proprietary applications with the
library. If this is what you want to do, use the GNU Library General
Public License instead of this License.
+3 -19
View File
@@ -1,31 +1,15 @@
# SPDX-License-Identifier: GPL-2.0-only
#
# Copyright (C) 2022-2023 ImmortalWrt.org
# Copyright (C) 2022-2024 ImmortalWrt.org
include $(TOPDIR)/rules.mk
PKG_NAME:=luci-app-homeproxy
PKG_VERSION:=2.0.0
PKG_RELEASE:=8
LUCI_TITLE:=Sing-box proxy management platform for OpenWrt
LUCI_PKGARCH:=all
LUCI_TITLE:=The modern ImmortalWrt proxy platform for ARM64/AMD64
LUCI_DEPENDS:= \
+sing-box \
+firewall4 \
+dnsmasq-full \
+ip-full \
+kmod-tun \
+kmod-nft-tproxy \
+ca-bundle \
+curl \
+jsonfilter \
+unzip \
+ucode-mod-digest \
+ucode-mod-fs \
+ucode-mod-math \
+ucode-mod-ubus \
+ucode-mod-uci
+ucode-mod-digest
define Package/luci-app-homeproxy/conffiles
/etc/config/homeproxy
-68
View File
@@ -1,68 +0,0 @@
适用于 OpenWrt 24.10 的 HomeProxy LuCI 管理界面,按 `官方内核sing-box 1.13.13` 进行二次定制适配,在官方内核基础上增加功能:
1、远程规则集本地持久化
2、Clash API 代理供应商
3、Clash API 中文名称
## 一、安装
上传 zip 到 OpenWrt /tmp目录后解压并执行(文件名homeproxy-2.0.1-x86_64.zip自行替换):
```sh
cd /tmp
unzip homeproxy-2.0.1-x86_64.zip
cd homeproxy-2.0.1-x86_64
sh install.sh
```
## 二、卸载
```sh
/etc/init.d/homeproxy stop 2>/dev/null || true
/etc/init.d/homeproxy disable 2>/dev/null || true
opkg remove luci-i18n-homeproxy-zh-cn 2>/dev/null || true
opkg remove luci-app-homeproxy 2>/dev/null || true
rm -rf /etc/config/homeproxy
rm -rf /etc/homeproxy
rm -rf /usr/share/homeproxy
rm -rf /www/luci-static/resources/view/homeproxy
rm -f /www/luci-static/resources/homeproxy.js
rm -f /usr/share/luci/menu.d/luci-app-homeproxy.json
rm -f /usr/share/rpcd/acl.d/luci-app-homeproxy.json
rm -f /usr/share/rpcd/ucode/luci.homeproxy
rm -f /tmp/luci-indexcache
rm -rf /tmp/luci-modulecache/*
/etc/init.d/rpcd restart
/etc/init.d/uhttpd restart
```
## 三、维护工作流
- `Rescan-Translation.yml`:代码变更后自动重新扫描并更新翻译文件,也支持手动运行。
- `Update-Geodata.yml`:每周自动更新内置 geodata 资源,也支持手动运行。
## 四、常见问题
1、面版下载失败解决办法
第一种:面版设置-UI下载地址,下拉选择需要的UI,点击更新面版手动触发面版下载。
第二种:下载面版ZIP包,手动上传面版ZIP,下载地址如下。
镜像
```sh
https://gh-proxy.com/https://github.com/Zephyruso/zashboard/releases/latest/download/dist.zip
```
或者直连
```sh
https://github.com/Zephyruso/zashboard/releases/latest/download/dist.zip
```
2、远程规则集是否下载成功判断
连接SSH查看/etc/homeproxy/ruleset/目录下是否有规则集文件,有则表示下载成功,反之则没下载成功,检查规则集远程连接。
3、安装新包后如果页面仍显示旧文字,建议清浏览器缓存,或执行:
```sh
rm -f /tmp/luci-indexcache
rm -rf /tmp/luci-modulecache/*
/etc/init.d/rpcd restart
/etc/init.d/uhttpd restart
```
## 五、感谢作者
immortalwrt
https://github.com/immortalwrt/homeproxy
VIKINGYFY
https://github.com/VIKINGYFY/homeproxy
@@ -12,158 +12,6 @@
'require uci';
'require ui';
function pad2(value) {
value = (value == null) ? '' : String(value).trim();
return value.length === 1 ? '0' + value : value;
}
function normalizeTimePart(value, min, max) {
value = parseInt(String(value || '').trim(), 10);
if (isNaN(value))
value = min;
value = Math.max(min, Math.min(max, value));
return pad2(value);
}
function parseCron(value) {
const matched = String(value || '').trim().match(/^(\d{1,2})\s+(\d{1,2})\s+\*\s+\*\s+([0-7*])$/);
if (!matched)
return null;
const minute = +matched[1],
hour = +matched[2];
if (minute < 0 || minute > 59 || hour < 0 || hour > 23)
return null;
return {
minute: normalizeTimePart(matched[1], 0, 59),
hour: normalizeTimePart(matched[2], 0, 23),
day: matched[3] === '*' ? '*' : (matched[3] === '7' ? '0' : matched[3])
};
}
function buildCron(day, hour, minute) {
return [
normalizeTimePart(minute, 0, 59),
normalizeTimePart(hour, 0, 23),
'*',
'*',
String(day || '*')
].join(' ');
}
function alignCronEditorRow(wrap) {
let field = wrap?.parentNode;
while (field && !field.classList?.contains('cbi-value-field'))
field = field.parentNode;
let row = field?.parentNode;
while (row && !row.classList?.contains('cbi-value'))
row = row.parentNode;
if (!row || !field)
return false;
if (wrap._dailyRow) {
wrap._dailyRow.style.display = row.style.display;
return true;
}
let dailyRow = E('div', { 'class': 'cbi-value homeproxy-cron-daily-row' }, [
E('div', { 'class': 'cbi-value-title' }, _('Update time (daily)')),
E('div', { 'class': 'cbi-value-field' }, [ wrap._dailyField ])
]);
wrap._dailyRow = dailyRow;
row.parentNode.insertBefore(dailyRow, row.nextSibling);
return true;
}
function watchCronEditorRow(wrap) {
const align = () => alignCronEditorRow(wrap);
[ 0, 50, 200, 500, 1000, 2000 ].forEach(delay => window.setTimeout(align, delay));
if (typeof MutationObserver !== 'undefined' && document?.body) {
const observer = new MutationObserver(() => {
if (align())
observer.disconnect();
});
observer.observe(document.body, { childList: true, subtree: true });
window.setTimeout(() => observer.disconnect(), 3000);
}
}
function renderCronEditor(input) {
if (!input)
return null;
const parsed = parseCron(input.value);
input.type = 'text';
input.readOnly = true;
input.tabIndex = -1;
input.style.position = 'absolute';
input.style.opacity = '0';
input.style.pointerEvents = 'none';
input.style.width = '1px';
input.style.height = '1px';
input.style.minWidth = '1px';
input.style.maxWidth = '1px';
input.style.padding = '0';
input.style.border = '0';
let day = E('select', { 'class': 'cbi-input-select', 'style': 'width: 12em !important; min-width: 12em !important; max-width: 12em !important; box-sizing: border-box;' }),
hour = E('select', { 'class': 'cbi-input-select', 'style': 'width: 4.25em !important; min-width: 4.25em !important; max-width: 4.25em !important; box-sizing: border-box;' }),
minute = E('select', { 'class': 'cbi-input-select', 'style': 'width: 4.25em !important; min-width: 4.25em !important; max-width: 4.25em !important; box-sizing: border-box;' }),
dailyField = E('div', { 'style': 'display: flex; align-items: center; gap: .25em; width: 9.5em;' }, [
hour,
E('span', ':'),
minute
]),
wrap = E('div', { 'class': 'homeproxy-cron-editor' }, [ day ]);
wrap._dailyField = dailyField;
for (let i = 0; i < 24; i++)
hour.appendChild(E('option', { value: pad2(i) }, pad2(i)));
for (let i = 0; i < 60; i++)
minute.appendChild(E('option', { value: pad2(i) }, pad2(i)));
[
['*', _('Every day')],
['1', _('Every Monday')],
['2', _('Every Tuesday')],
['3', _('Every Wednesday')],
['4', _('Every Thursday')],
['5', _('Every Friday')],
['6', _('Every Saturday')],
['0', _('Every Sunday')]
].forEach(([value, label]) => day.appendChild(E('option', { value }, label)));
day.value = parsed ? parsed.day : '*';
hour.value = parsed ? parsed.hour : '00';
minute.value = parsed ? parsed.minute : '00';
input.value = buildCron(day.value, hour.value, minute.value);
input.setAttribute('value', input.value);
const sync = () => {
input.value = buildCron(day.value, hour.value, minute.value);
input.setAttribute('value', input.value);
input.dispatchEvent(new Event('input', { bubbles: true }));
input.dispatchEvent(new Event('change', { bubbles: true }));
};
day.addEventListener('change', sync);
hour.addEventListener('change', sync);
minute.addEventListener('change', sync);
wrap.appendChild(input);
window.setTimeout(() => watchCronEditorRow(wrap), 0);
return wrap;
}
return baseclass.extend({
dns_strategy: {
'': _('Default'),
@@ -238,29 +86,6 @@ return baseclass.extend({
}
}),
CBIMultiValue: form.MultiValue.extend({
__name__: 'CBI.HomeProxyMultiValue',
renderWidget(section_id, _option_index, cfgvalue) {
let value = (cfgvalue != null) ? cfgvalue : this.default,
choices = this.transformChoices() || {},
widget = new ui.Dropdown(L.toArray(value), choices, {
id: this.cbid(section_id),
sort: this.keylist,
multiple: true,
optional: this.optional || this.rmempty,
select_placeholder: this.placeholder,
create: this.create,
display_items: this.display_size ?? this.size ?? 3,
dropdown_items: this.dropdown_size ?? this.size ?? -1,
validate: this.getValidator(section_id),
disabled: (this.readonly != null) ? this.readonly : this.map.readonly
});
return widget.render();
}
}),
calcStringMD5(e) {
/* Thanks to https://stackoverflow.com/a/41602636 */
let h = (a, b) => {
@@ -360,49 +185,6 @@ return baseclass.extend({
return L.resolveDefault(callGetSingBoxFeatures(), {});
},
renderCronSelector(/* ... */) {
if (!this._homeproxyCronOriginalFormvalue) {
this._homeproxyCronOriginalFormvalue = this.formvalue;
this.formvalue = function(section_id) {
let cbid = this.cbid(section_id),
ids = [ cbid, 'widget.' + cbid ],
roots = [ document.getElementById('modal_overlay'), document ],
input = null;
for (let root of roots) {
if (!root)
continue;
for (let el of root.querySelectorAll('input')) {
if (ids.includes(el.id) || ids.includes(el.name)) {
input = el;
break;
}
}
if (input)
break;
}
let value = input?.value ||
this._homeproxyCronOriginalFormvalue?.call(this, section_id) ||
this.default ||
'0 0 * * *';
return parseCron(value) ? value : (this.default || '0 0 * * *');
};
}
let node = form.Value.prototype.renderWidget.apply(this, arguments),
editor = renderCronEditor(node.querySelector('input'));
return editor || node;
},
renderCronSelectorRow(/* ... */) {
return form.Value.prototype.render.apply(this, arguments);
},
generateRand(type, length) {
let byteArr;
if (['base64', 'hex'].includes(type))
@@ -426,9 +208,6 @@ return baseclass.extend({
},
loadDefaultLabel(uciconfig, ucisection) {
if (!ucisection)
return '';
let label = uci.get(uciconfig, ucisection, 'label');
if (label) {
return label;
@@ -439,127 +218,32 @@ return baseclass.extend({
},
loadModalTitle(title, addtitle, uciconfig, ucisection) {
if (!ucisection)
return addtitle;
let label = uci.get(uciconfig, ucisection, 'label');
return label ? title + ' » ' + label : addtitle;
},
normalizeSectionId(label, prefix) {
let section_id = (label || '').trim().replace(/[^A-Za-z0-9_]/g, '_').replace(/^_+|_+$/g, '');
return (prefix || 'cfg') + '_' + (section_id || 'section');
},
renderSectionAdd(section, extra_class) {
let el = form.GridSection.prototype.renderSectionAdd.apply(section, [ extra_class ]),
nameEl = el.querySelector('.cbi-section-create-name'),
button = el.querySelector('.cbi-section-create > .cbi-button-add'),
uciconfig = section.uciconfig || section.map.config,
sectiontype = section.sectiontype,
labelEl = E('input', {
'type': 'text',
'class': nameEl.className
}),
hintEl = E('div', { 'class': 'cbi-value-description' });
nameEl = el.querySelector('.cbi-section-create-name');
ui.addValidator(nameEl, 'uciname', true, (v) => {
let button = el.querySelector('.cbi-section-create > .cbi-button-add');
let uciconfig = section.uciconfig || section.map.config;
nameEl.style.display = 'none';
nameEl.parentNode.insertBefore(labelEl, nameEl);
nameEl.parentNode.appendChild(hintEl);
button.disabled = true;
const syncSectionName = () => {
let label = (labelEl.value || '').trim();
hintEl.textContent = '';
if (!label) {
nameEl.value = '';
if (!v) {
button.disabled = true;
return;
}
let duplicate = false;
uci.sections(uciconfig, sectiontype, (res) => {
if ((res.label || res['.name']) === label)
duplicate = true;
});
if (duplicate) {
nameEl.value = '';
return true;
} else if (uci.get(uciconfig, v)) {
button.disabled = true;
hintEl.textContent = _('Expecting: %s').format(_('unique value'));
return;
return _('Expecting: %s').format(_('unique UCI identifier'));
} else {
button.disabled = null;
return true;
}
let normalized = (label || '').trim().replace(/[^A-Za-z0-9_]/g, '_').replace(/^_+|_+$/g, '') || 'section',
section_id = (sectiontype || 'cfg') + '_' + normalized,
suffix = 1;
while (uci.get(uciconfig, section_id))
section_id = (sectiontype || 'cfg') + '_' + normalized + '_' + suffix++;
nameEl.value = section_id;
nameEl.dataset.sectionId = section_id;
nameEl.dataset.sectionLabel = label;
button.disabled = null;
};
labelEl.addEventListener('input', syncSectionName);
labelEl.addEventListener('blur', syncSectionName);
button.addEventListener('click', () => {
syncSectionName();
let label = nameEl.dataset.sectionLabel,
section_id = nameEl.dataset.sectionId;
window.setTimeout(() => {
if (label && section_id && uci.get(uciconfig, section_id))
uci.set(uciconfig, section_id, 'label', label);
}, 0);
});
}, 'blur', 'keyup');
return el;
},
installCloseButtonText() {
if (window.__homeproxyCloseButtonText)
return;
window.__homeproxyCloseButtonText = true;
let fix = (root) => {
for (let el of (root || document).querySelectorAll('button, .btn, input[type="button"], input[type="submit"]')) {
let text = (el.textContent || el.value || '').trim();
if (text !== 'Dismiss' && text !== '\u5ffd\u7565')
continue;
if ('value' in el && !el.textContent.trim())
el.value = _('Close');
else
el.textContent = _('Close');
}
};
let observe = () => {
if (!document.body)
return;
fix(document);
new MutationObserver((mutations) => {
for (let mutation of mutations)
for (let node of mutation.addedNodes)
if (node.nodeType === 1)
fix(node);
fix(document);
}).observe(document.body, { childList: true, subtree: true });
};
if (document.body)
observe();
else
document.addEventListener('DOMContentLoaded', observe, { once: true });
},
uploadCertificate(_option, type, filename, ev) {
const callWriteCertificate = rpc.declare({
object: 'luci.homeproxy',
@@ -580,44 +264,6 @@ return baseclass.extend({
.catch((e) => { ui.addNotification(null, E('p', e.message)) });
},
uploadPanel(_option, ev) {
const callInstallPanel = rpc.declare({
object: 'luci.homeproxy',
method: 'clash_api_install_panel',
expect: { '': {} }
});
const normalizeMessage = (message) => {
switch (message) {
case 'panel_backup_failed':
return _('Backup panel failed.');
case 'panel_restore_failed':
return _('Restore panel failed.');
case 'empty_panel_zip':
return _('Panel ZIP file is empty.');
case 'unzip_unavailable':
return _('The unzip command is unavailable.');
case 'invalid_panel_zip':
return _('Invalid panel ZIP file.');
case 'panel_install_failed':
return _('Install panel failed.');
default:
return message || _('unknown error');
}
};
return ui.uploadFile('/tmp/homeproxy_panel.tmp', ev.target)
.then(L.bind((_btn, res) => {
return L.resolveDefault(callInstallPanel(), {}).then((ret) => {
if (ret.result === true)
ui.addNotification(null, E('p', _('Your %s was successfully uploaded. Size: %sB.').format(_('panel ZIP package'), res.size)), 'info');
else
ui.addNotification(null, E('p', _('Failed to upload %s, error: %s.').format(_('panel ZIP package'), normalizeMessage(ret.error))), 'danger');
});
}, this, ev.target))
.catch((e) => { ui.addNotification(null, E('p', e.message || e), 'danger') });
},
validateBase64Key(length, section_id, value) {
/* Thanks to luci-proto-wireguard */
if (section_id && value)
@@ -658,7 +304,7 @@ return baseclass.extend({
if (section_id) {
if (!value)
return _('Expecting: %s').format(_('non-empty value'));
if (ucioption === 'node' && (value === 'urltest' || value === 'selector'))
if (ucioption === 'node' && value === 'urltest')
return true;
let duplicate = false;
File diff suppressed because it is too large. Load diff
@@ -7,7 +7,6 @@
'use strict';
'require form';
'require fs';
'require rpc';
'require uci';
'require ui';
'require view';
@@ -15,207 +14,11 @@
'require homeproxy as hp';
'require tools.widgets as widgets';
const callNodeLatencyTest = rpc.declare({
object: 'luci.homeproxy',
method: 'node_latency_test',
params: ['node', 'mode'],
expect: { '': {} }
});
const callRCInit = rpc.declare({
object: 'rc',
method: 'init',
params: ['name', 'action'],
expect: { '': {} }
});
function normalizeList(value) {
return Array.isArray(value) ? value : (value ? [value] : []);
}
function getSubscriptionInfo(config) {
const urls = normalizeList(uci.get(config, 'subscription', 'subscription_url')),
names = normalizeList(uci.get(config, 'subscription', 'subscription_name')),
info = [];
for (let i = 0; i < urls.length; i++) {
const url = urls[i],
cleanUrl = String(url || '').replace(/#.*$/, ''),
title = String(names[i] || '').trim();
if (!url)
continue;
info.push({
hash: hp.calcStringMD5(cleanUrl),
title,
url
});
}
return info;
}
const SubscriptionList = form.Value.extend({
__name__: 'CBI.HomeProxySubscriptionList',
cfgvalue(section_id) {
return {
urls: normalizeList(uci.get('homeproxy', section_id, 'subscription_url')),
names: normalizeList(uci.get('homeproxy', section_id, 'subscription_name'))
};
},
renderWidget(section_id, _option_index, cfgvalue) {
const value = cfgvalue || { urls: [], names: [] },
rows = E('div', {
id: this.cbid(section_id),
'class': 'homeproxy-subscription-list',
'style': 'display: flex; flex-direction: column; gap: .45em; width: min(100%, 42em);'
});
rows.appendChild(E('div', {
'class': 'homeproxy-subscription-header',
'style': 'display: grid; grid-template-columns: minmax(8em, 13em) minmax(16em, 1fr) auto; gap: .35em; color: var(--text-muted, #6b7280); font-size: 90%;'
}, [
E('span', {}, [ _('\u8ba2\u9605\u540d\u79f0') ]),
E('span', {}, [ _('\u8ba2\u9605\u5730\u5740') ]),
E('span')
]));
const addRow = (name, url) => {
const row = E('div', {
'class': 'homeproxy-subscription-row',
'style': 'display: grid; grid-template-columns: minmax(8em, 13em) minmax(16em, 1fr) auto; gap: .35em; align-items: stretch;'
}, [
E('input', {
'type': 'text',
'class': 'cbi-input-text subscription-name',
'placeholder': _('\u8ba2\u9605\u540d\u79f0'),
'value': name || '',
'style': 'width: 100%; box-sizing: border-box;'
}),
E('input', {
'type': 'text',
'class': 'cbi-input-text subscription-url',
'placeholder': _('\u8ba2\u9605\u5730\u5740'),
'value': url || '',
'style': 'width: 100%; box-sizing: border-box;'
}),
E('button', {
'type': 'button',
'class': 'cbi-button cbi-button-remove',
'click': () => {
row.remove();
if (!rows.querySelector('.homeproxy-subscription-row'))
addRow('', '');
}
}, [ '-' ])
]);
if (rows._addButton)
rows.insertBefore(row, rows._addButton);
else
rows.appendChild(row);
};
for (let i = 0; i < Math.max(value.urls.length, 1); i++)
addRow(value.names[i], value.urls[i]);
rows._addButton = E('button', {
'type': 'button',
'class': 'cbi-button cbi-button-add',
'style': 'width: 3em;',
'click': () => addRow('', '')
}, [ '+' ]);
rows.appendChild(rows._addButton);
return rows;
},
formvalue(section_id) {
const node = document.getElementById(this.cbid(section_id)),
names = [],
urls = [];
node?.querySelectorAll('.homeproxy-subscription-row').forEach((row) => {
const name = row.querySelector('.subscription-name')?.value.trim() || '',
url = row.querySelector('.subscription-url')?.value.trim() || '';
if (!name && !url)
return;
names.push(name);
urls.push(url);
});
return { names, urls };
},
validate(_section_id, value) {
const names = value?.names || [],
urls = value?.urls || [],
usedNames = {},
usedUrls = {};
if (!names.length || !urls.length)
return _('\u8ba2\u9605\u540d\u79f0\u548c\u8ba2\u9605\u5730\u5740\u4e3a\u5fc5\u586b\u9879');
for (let i = 0; i < Math.max(names.length, urls.length); i++) {
const name = String(names[i] || '').trim(),
url = String(urls[i] || '').trim(),
normalizedUrl = url.replace(/#.*$/, '');
if (!name || !url)
return _('\u8ba2\u9605\u540d\u79f0\u548c\u8ba2\u9605\u5730\u5740\u5fc5\u987b\u6210\u5bf9\u586b\u5199');
if (usedNames[name])
return _('\u8ba2\u9605\u540d\u79f0\u4e0d\u80fd\u91cd\u590d');
usedNames[name] = true;
if (usedUrls[normalizedUrl])
return _('\u8ba2\u9605\u5730\u5740\u4e0d\u80fd\u91cd\u590d');
usedUrls[normalizedUrl] = true;
try {
let parsed = new URL(url);
if (!parsed.hostname)
return _('Expecting: %s').format(_('valid URL'));
} catch(e) {
return _('Expecting: %s').format(_('valid URL'));
}
}
return true;
},
write(section_id, value) {
if (value?.urls?.length) {
uci.set('homeproxy', section_id, 'subscription_url', value.urls);
uci.set('homeproxy', section_id, 'subscription_name', value.names);
} else {
uci.unset('homeproxy', section_id, 'subscription_url');
uci.unset('homeproxy', section_id, 'subscription_name');
}
}
});
function allowInsecureConfirm(ev, _section_id, value) {
if (value === '1' && !confirm(_('Are you sure to allow insecure?')))
ev.target.firstElementChild.checked = null;
}
function normalizeHysteriaHoppingPort(mport) {
if (!mport)
return null;
const ports = mport.split(',')
.map((p) => p.trim())
.filter((p) => p.length)
.map((p) => (/^\d+$/.test(p) ? `${p}:${p}` : p.replace('-', ':')));
return ports.length ? ports : null;
}
function parseShareLink(uri, features) {
let config, url, params;
@@ -226,11 +29,6 @@ function parseShareLink(uri, features) {
/* https://github.com/anytls/anytls-go/blob/v0.0.8/docs/uri_scheme.md */
url = new URL('http://' + uri[1]);
params = url.searchParams;
let anytls_fp = params.get('fp');
if (['none', 'disable', 'disabled'].includes(anytls_fp))
anytls_fp = null;
else if (!anytls_fp)
anytls_fp = 'chrome';
/* Check if password exists */
if (!url.username)
@@ -244,8 +42,7 @@ function parseShareLink(uri, features) {
password: url.username ? decodeURIComponent(url.username) : null,
tls: '1',
tls_sni: params.get('sni'),
tls_insecure: (params.get('insecure') === '1' || params.get('allowInsecure') === '1') ? '1' : '0',
tls_utls: features.with_utls ? anytls_fp : null
tls_insecure: (params.get('insecure') === '1') ? '1' : '0'
};
break;
@@ -278,7 +75,6 @@ function parseShareLink(uri, features) {
type: 'hysteria',
address: url.hostname,
port: url.port || '80',
hysteria_hopping_port: normalizeHysteriaHoppingPort(params.get('mport')),
hysteria_protocol: params.get('protocol') || 'udp',
hysteria_auth_type: params.get('auth') ? 'string' : null,
hysteria_auth_payload: params.get('auth'),
@@ -286,9 +82,9 @@ function parseShareLink(uri, features) {
hysteria_down_mbps: params.get('downmbps'),
hysteria_up_mbps: params.get('upmbps'),
tls: '1',
tls_insecure: (params.get('insecure') === '1' || params.get('allowInsecure') === '1') ? '1' : '0',
tls_sni: params.get('peer'),
tls_alpn: params.get('alpn')
tls_alpn: params.get('alpn'),
tls_insecure: (params.get('insecure') === '1') ? '1' : '0'
};
break;
@@ -309,12 +105,11 @@ function parseShareLink(uri, features) {
password: url.username ? (
decodeURIComponent(url.username + (url.password ? (':' + url.password) : ''))
) : null,
hysteria_hopping_port: normalizeHysteriaHoppingPort(params.get('mport')),
hysteria_obfs_type: params.get('obfs'),
hysteria_obfs_password: params.get('obfs-password'),
tls: '1',
tls_insecure: (params.get('insecure') === '1' || params.get('allowInsecure') === '1') ? '1' : '0',
tls_sni: params.get('sni')
tls_sni: params.get('sni'),
tls_insecure: params.get('insecure') ? '1' : '0'
};
break;
@@ -417,7 +212,6 @@ function parseShareLink(uri, features) {
password: decodeURIComponent(url.username),
transport: params.get('type') !== 'tcp' ? params.get('type') : null,
tls: '1',
tls_insecure: (params.get('insecure') === '1' || params.get('allowInsecure') === '1') ? '1' : '0',
tls_sni: params.get('sni')
};
switch (params.get('type')) {
@@ -455,7 +249,6 @@ function parseShareLink(uri, features) {
tuic_congestion_control: params.get('congestion_control'),
tuic_udp_relay_mode: params.get('udp_relay_mode'),
tls: '1',
tls_insecure: (params.get('insecure') === '1' || params.get('allowInsecure') === '1') ? '1' : '0',
tls_sni: params.get('sni'),
tls_alpn: params.get('alpn') ? decodeURIComponent(params.get('alpn')).split(',') : null
};
@@ -483,7 +276,6 @@ function parseShareLink(uri, features) {
uuid: url.username,
transport: params.get('type') !== 'tcp' ? params.get('type') : null,
tls: ['tls', 'xtls', 'reality'].includes(params.get('security')) ? '1' : '0',
tls_insecure: (params.get('insecure') === '1' || params.get('allowInsecure') === '1') ? '1' : '0',
tls_sni: params.get('sni'),
tls_alpn: params.get('alpn') ? decodeURIComponent(params.get('alpn')).split(',') : null,
tls_reality: (params.get('security') === 'reality') ? '1' : '0',
@@ -596,378 +388,13 @@ function parseShareLink(uri, features) {
return config;
}
const NODE_LATENCY_ROW_STATES = Object.freeze({
UNTESTED: 'untested',
TESTING: 'testing',
SUCCESS: 'success',
TIMEOUT: 'timeout',
ERROR: 'error'
});
const NODE_LATENCY_ROW_STATE_VALUES = Object.freeze(Object.values(NODE_LATENCY_ROW_STATES));
const NODE_LATENCY_TEST_MODES = Object.freeze([ 'icmp', 'rp' ]);
function remapLegacyNodeLatencyTestMode(mode) {
return mode === 'tcp' ? 'icmp' : mode;
}
function normalizeNodeLatencyTestMode(mode) {
mode = remapLegacyNodeLatencyTestMode(mode);
return NODE_LATENCY_TEST_MODES.includes(mode) ? mode : 'icmp';
}
function resolveNodeLatencyResultByMode(result, mode) {
let active_mode = normalizeNodeLatencyTestMode(mode || result?.mode);
let active_latency_ms = (result && result.latency_ms != null) ? result.latency_ms : null;
let active_error = (result && result.error) ? result.error : null;
let active_state = result?.state;
if (active_mode === 'icmp') {
if (result && result.icmp_latency_ms != null)
active_latency_ms = result.icmp_latency_ms;
if (result && result.icmp_error)
active_error = result.icmp_error;
}
if (active_error?.code?.endsWith('_timeout'))
active_state = NODE_LATENCY_ROW_STATES.TIMEOUT;
else if (active_error)
active_state = NODE_LATENCY_ROW_STATES.ERROR;
else if (active_latency_ms != null)
active_state = NODE_LATENCY_ROW_STATES.SUCCESS;
return {
mode: active_mode,
state: active_state,
latency_ms: active_latency_ms,
error: active_error
};
}
function getNodeLatencyErrorText(error_code) {
switch (error_code) {
case 'backend_execution failed':
return _('Backend execution failed');
case 'icmp_failed':
return _('ICMP Failed');
case 'icmp_probe_unavailable':
return _('ICMP Probe unavailable');
case 'icmp_timeout':
return _('ICMP Timeout');
case 'invalid_node':
return _('Invalid node');
case 'invalid_response':
return _('Invalid response');
case 'probe_failed':
return _('Probe failed');
case 'rpc_failed':
return _('RPC failed');
default:
return _('Error');
}
}
function getNodeLatencyStatusText(row_state) {
if (!row_state)
return _('Not Tested');
switch (row_state.state) {
case NODE_LATENCY_ROW_STATES.TESTING:
return _('Testing');
case NODE_LATENCY_ROW_STATES.SUCCESS:
return (row_state.latency_ms != null) ? _('%s ms').format(row_state.latency_ms) : _('Success');
case NODE_LATENCY_ROW_STATES.TIMEOUT:
return _('Timeout');
case NODE_LATENCY_ROW_STATES.ERROR:
return getNodeLatencyErrorText(row_state.error?.code);
case NODE_LATENCY_ROW_STATES.UNTESTED:
default:
return _('Not Tested');
}
}
function getNodeLatencyStatusStyle(row_state) {
if (!row_state)
return 'color:gray';
switch (row_state.state) {
case NODE_LATENCY_ROW_STATES.TESTING:
return 'color:#0a84ff';
case NODE_LATENCY_ROW_STATES.SUCCESS:
return 'color:green';
case NODE_LATENCY_ROW_STATES.TIMEOUT:
return 'color:#ff8c00';
case NODE_LATENCY_ROW_STATES.ERROR:
return 'color:red';
case NODE_LATENCY_ROW_STATES.UNTESTED:
default:
return 'color:gray';
}
}
function renderNodeLatencyStatus(row_state) {
return '<strong style="%s">%s</strong>'.format(getNodeLatencyStatusStyle(row_state), getNodeLatencyStatusText(row_state));
}
function renderNodeLatencyStatusNode(row_state, attrs) {
return E('strong', Object.assign({
'style': getNodeLatencyStatusStyle(row_state)
}, attrs || {}), [ getNodeLatencyStatusText(row_state) ]);
}
function getNodeLatencyActionTitle(row_state) {
return (row_state?.state === NODE_LATENCY_ROW_STATES.TESTING) ? _('Testing') : _('Test');
}
function parseNodeLatencySectionId(widget_id) {
let matched = String(widget_id || '').match(/^cbi-homeproxy-(.*)-_test_latency$/);
return matched ? matched[1] : null;
}
function parseActiveSubscriptionTabId(value) {
let matched = String(value || '').match(/(?:^|[^\w])(sub_[0-9a-f]+)(?:$|[^\w])/i);
return matched ? matched[1] : null;
}
function parseActiveNodeListTabId(value) {
let matched = String(value || '').match(/(?:^|[^\w])(node|subscription|sub_[0-9a-f]+)(?:$|[^\w])/i);
return matched ? matched[1].toLowerCase() : null;
}
function getActiveNodeListTabId(root_el) {
let active_tab = null;
let active_tab_nodes = root_el.querySelectorAll('.cbi-tabmenu li.cbi-tab-active, .cbi-tabmenu li.active, .cbi-tabmenu [aria-selected="true"]');
for (let node of active_tab_nodes) {
let tab_id = parseActiveNodeListTabId(node?.getAttribute('data-tab'))
|| parseActiveNodeListTabId(node?.dataset?.tab)
|| parseActiveNodeListTabId(node?.getAttribute('id'));
if (!tab_id && node?.querySelector)
tab_id = parseActiveNodeListTabId(node.querySelector('a')?.getAttribute('href'))
|| parseActiveNodeListTabId(node.querySelector('a')?.getAttribute('data-tab'));
if (tab_id) {
active_tab = tab_id;
break;
}
}
if (!active_tab) {
let fallback_tab_nodes = root_el.querySelectorAll('.cbi-tabmenu li.cbi-tab[data-tab], .cbi-tabmenu li[data-tab]:not(.cbi-tab-disabled)');
for (let node of fallback_tab_nodes) {
let tab_id = parseActiveNodeListTabId(node?.getAttribute('data-tab')) || parseActiveNodeListTabId(node?.dataset?.tab);
if (tab_id) {
active_tab = tab_id;
break;
}
}
}
return active_tab;
}
function shouldShowBulkLatencyButton(root_el) {
let active_tab = getActiveNodeListTabId(root_el);
if (!active_tab)
return false;
return !!parseActiveSubscriptionTabId(active_tab);
}
function getActiveSubscriptionTabId(root_el) {
let active_tab = getActiveNodeListTabId(root_el);
return parseActiveSubscriptionTabId(active_tab);
}
function getActiveSubscriptionTabContainer(root_el, active_tab) {
if (!active_tab)
return null;
let candidates = [];
for (let selector of [
'.cbi-tabcontainer[data-tab="%s"]'.format(active_tab),
'[data-tab="%s"]'.format(active_tab),
'[id="tab.%s"]'.format(active_tab),
'[id="tab-%s"]'.format(active_tab),
'[id="%s"]'.format(active_tab)
]) {
candidates = candidates.concat(Array.from(root_el.querySelectorAll(selector)));
}
return candidates.find((node) => !node.closest('.cbi-tabmenu') && node.querySelector('div[id$="-_test_latency"]')) || null;
}
function getActiveSubscriptionLatencySectionIds(root_el) {
let active_tab = getActiveSubscriptionTabId(root_el);
let active_container = getActiveSubscriptionTabContainer(root_el, active_tab);
if (!active_container)
return [];
let widgets = Array.from(active_container.querySelectorAll('div[id$="-_test_latency"]'));
return widgets.map((node) => parseNodeLatencySectionId(node.id)).filter((sid) => !!sid);
}
function createNodeLatencyRowStateModel() {
let rows = Object.create(null);
const buildRowState = (state, result, mode) => {
let resolved_result = resolveNodeLatencyResultByMode(result, mode);
return {
state: state,
mode: resolved_result.mode,
latency_ms: resolved_result.latency_ms,
icmp_latency_ms: (result && result.icmp_latency_ms != null) ? result.icmp_latency_ms : null,
measured_at: (result && result.measured_at) ? result.measured_at : null,
error: resolved_result.error,
icmp_error: (result && result.icmp_error) ? result.icmp_error : null
};
};
const normalizeState = (state) => {
if (NODE_LATENCY_ROW_STATE_VALUES.includes(state))
return state;
return NODE_LATENCY_ROW_STATES.ERROR;
};
const ensure = (section_id) => {
if (!section_id)
return buildRowState(NODE_LATENCY_ROW_STATES.UNTESTED, null, 'icmp');
if (!rows[section_id])
rows[section_id] = buildRowState(NODE_LATENCY_ROW_STATES.UNTESTED, null, 'icmp');
return rows[section_id];
};
return {
states: NODE_LATENCY_ROW_STATES,
get: (section_id) => ensure(section_id),
set: (section_id, state, result, mode) => {
if (!section_id)
return null;
rows[section_id] = buildRowState(normalizeState(state), result, mode);
return rows[section_id];
},
setFromProbeResult: (section_id, result, mode) => {
if (!section_id)
return null;
let resolved_result = resolveNodeLatencyResultByMode(result, mode);
let state = resolved_result.state ? normalizeState(resolved_result.state) : NODE_LATENCY_ROW_STATES.ERROR;
rows[section_id] = buildRowState(state, result, mode);
return rows[section_id];
},
clear: (section_id) => {
if (!section_id)
return;
delete rows[section_id];
},
reset: () => {
rows = Object.create(null);
},
snapshot: () => rows
};
}
function renderNodeSettings(section, data, features, main_node, routing_mode, node_latency_row_state) {
function renderNodeSettings(section, data, features, main_node, routing_mode) {
let s = section, o;
if (typeof globalThis !== 'undefined') {
globalThis.__hpNodeLatencySections = globalThis.__hpNodeLatencySections || {};
globalThis.__hpNodeLatencyTrigger = function(section_id) {
let target = globalThis.__hpNodeLatencySections?.[section_id];
return target ? target.handleNodeLatencyTest(section_id) : false;
};
}
s.rowcolors = true;
s.sortable = true;
s.nodescriptions = true;
s.max_cols = 7;
s.modaltitle = L.bind(hp.loadModalTitle, this, _('Node'), _('Add a node'), data[0]);
s.sectiontitle = L.bind(hp.loadDefaultLabel, this, data[0]);
s.node_latency_row_state = node_latency_row_state;
s.getNodeLatencyRowState = function(section_id) {
return node_latency_row_state.get(section_id);
}
s.getNodeLatencyTestMode = function() {
let mode_option = this.map.lookupOption('latency_test_mode', 'subscription')?.[0];
let mode_value = mode_option ? mode_option.formvalue('subscription') : uci.get(data[0], 'subscription', 'latency_test_mode');
return normalizeNodeLatencyTestMode(mode_value);
}
s.syncNodeLatencyTestMode = function(mode) {
let normalized_mode = normalizeNodeLatencyTestMode(mode);
let saved_mode_value = uci.get(data[0], 'subscription', 'latency_test_mode');
let saved_mode = normalizeNodeLatencyTestMode(saved_mode_value);
if (saved_mode === normalized_mode && saved_mode_value !== 'tcp')
return Promise.resolve(normalized_mode);
uci.set(data[0], 'subscription', 'latency_test_mode', normalized_mode);
return uci.save().then(() => normalized_mode);
}
s.setNodeLatencyRowState = function(section_id, state, result, mode) {
return node_latency_row_state.set(section_id, state, result, mode);
}
s.setNodeLatencyRowStateFromProbeResult = function(section_id, result, mode) {
return node_latency_row_state.setFromProbeResult(section_id, result, mode);
}
s.refreshNodeLatencyRow = function(section_id) {
let row_state = this.getNodeLatencyRowState(section_id);
let latency_id = 'cbi-%s-%s-_latency'.format(data[0], section_id);
let test_id = 'cbi-%s-%s-_test_latency'.format(data[0], section_id);
let status_widget = this.map.findElement('id', latency_id);
if (status_widget)
status_widget.innerHTML = renderNodeLatencyStatus(row_state);
let test_widget = this.map.findElement('id', test_id);
let test_button = test_widget ? test_widget.querySelector('button') : null;
if (test_button) {
test_button.textContent = getNodeLatencyActionTitle(row_state);
test_button.disabled = (row_state.state === NODE_LATENCY_ROW_STATES.TESTING) ? true : null;
}
}
s.handleNodeLatencyTest = function(section_id) {
let mode = this.getNodeLatencyTestMode();
this.setNodeLatencyRowState(section_id, NODE_LATENCY_ROW_STATES.TESTING, null, mode);
this.refreshNodeLatencyRow(section_id);
return this.syncNodeLatencyTestMode(mode).then((mode) => L.resolveDefault(callNodeLatencyTest(section_id, mode), null).then((result) => {
if (result?.node === section_id)
this.setNodeLatencyRowStateFromProbeResult(section_id, result, mode);
else
this.setNodeLatencyRowState(section_id, NODE_LATENCY_ROW_STATES.ERROR, {
mode: mode,
error: {
code: 'invalid_response',
message: 'unexpected node latency response'
}
}, mode);
})).catch((err) => {
this.setNodeLatencyRowState(section_id, NODE_LATENCY_ROW_STATES.ERROR, {
mode: mode,
error: {
code: 'rpc_failed',
message: String(err)
}
}, mode);
}).then(() => {
this.refreshNodeLatencyRow(section_id);
});
}
if (routing_mode !== 'custom') {
o = s.option(form.Button, '_apply', _('Apply'));
@@ -992,41 +419,6 @@ function renderNodeSettings(section, data, features, main_node, routing_mode, no
}
}
o = s.option(form.DummyValue, '_latency', _('Latency'));
o.rawhtml = true;
o.modalonly = false;
o.textvalue = function(section_id) {
return E('span', { 'id': 'cbi-%s-%s-_latency'.format(data[0], section_id) }, [
renderNodeLatencyStatusNode(this.section.getNodeLatencyRowState(section_id))
]);
}
o = s.option(form.Button, '_test_latency', _('Test'));
o.editable = true;
o.modalonly = false;
o.inputstyle = 'action';
o.inputtitle = function(section_id) {
return getNodeLatencyActionTitle(this.section.getNodeLatencyRowState(section_id));
}
o.renderWidget = function(section_id, _option_index, cfgvalue) {
let hiddenEl = new ui.Hiddenfield((cfgvalue != null) ? cfgvalue : '', {
id: this.cbid(section_id)
});
let outputEl = E('output', { 'for': this.cbid(section_id) });
let row_state = s.getNodeLatencyRowState(section_id);
if (typeof globalThis !== 'undefined' && globalThis.__hpNodeLatencySections)
globalThis.__hpNodeLatencySections[section_id] = s;
outputEl.appendChild(E('button', {
'class': 'cbi-button cbi-button-action',
'onclick': 'return globalThis.__hpNodeLatencyTrigger(%s);'.format(JSON.stringify(section_id)),
'disabled': (row_state.state === NODE_LATENCY_ROW_STATES.TESTING) ? true : null
}, [ getNodeLatencyActionTitle(row_state) ]));
return E([ outputEl, hiddenEl.render() ]);
}
o = s.option(form.Value, 'label', _('Label'));
o.load = L.bind(hp.loadDefaultLabel, this, data[0]);
o.validate = L.bind(hp.validateUniqueValue, this, data[0], 'node', 'label');
@@ -1051,7 +443,6 @@ function renderNodeSettings(section, data, features, main_node, routing_mode, no
o.value('wireguard', _('WireGuard'));
o.value('vless', _('VLESS'));
o.value('vmess', _('VMess'));
o.default = 'direct';
o.rmempty = false;
o = s.option(form.Value, 'address', _('Address'));
@@ -1102,6 +493,15 @@ function renderNodeSettings(section, data, features, main_node, routing_mode, no
}
o.modalonly = true;
/* Direct config */
o = s.option(form.ListValue, 'proxy_protocol', _('Proxy protocol'),
_('Write proxy protocol in the connection header.'));
o.value('', _('Disable'));
o.value('1', _('v1'));
o.value('2', _('v2'));
o.depends('type', 'direct');
o.modalonly = true;
/* AnyTLS config start */
o = s.option(form.Value, 'anytls_idle_session_check_interval', _('Idle session check interval'),
_('Interval checking for idle sessions, in seconds.'));
@@ -1346,7 +746,7 @@ function renderNodeSettings(section, data, features, main_node, routing_mode, no
o.modalonly = true;
o = s.option(form.ListValue, 'vmess_encrypt', _('Encrypt method'));
o.value('auto', _('Default'));
o.value('auto');
o.value('none');
o.value('zero');
o.value('aes-128-gcm');
@@ -1794,18 +1194,19 @@ return view.extend({
},
render(data) {
let m, s, o, ss, so, subscription_list_option;
let m, s, o, ss, so;
let main_node = uci.get(data[0], 'config', 'main_node');
let routing_mode = uci.get(data[0], 'config', 'routing_mode');
let features = data[1];
let node_latency_row_state = createNodeLatencyRowStateModel();
hp.installCloseButtonText();
this.node_latency_row_state = node_latency_row_state;
/* Cache subscription information, it will be called multiple times */
let subinfo = getSubscriptionInfo(data[0]);
let subinfo = [];
for (let suburl of (uci.get(data[0], 'subscription', 'subscription_url') || [])) {
const url = new URL(suburl);
const urlhash = hp.calcStringMD5(suburl.replace(/#.*$/, ''));
const title = url.hash ? decodeURIComponent(url.hash.slice(1)) : url.hostname;
subinfo.push({ 'hash': urlhash, 'title': title });
}
m = new form.Map('homeproxy', _('Edit nodes'));
@@ -1815,7 +1216,7 @@ return view.extend({
/* User nodes start */
s.tab('node', _('Nodes'));
o = s.taboption('node', form.SectionValue, '_node', form.GridSection, 'node');
ss = renderNodeSettings(o.subsection, data, features, main_node, routing_mode, node_latency_row_state);
ss = renderNodeSettings(o.subsection, data, features, main_node, routing_mode);
ss.addremove = true;
ss.filter = function(section_id) {
for (let info of subinfo)
@@ -1886,7 +1287,24 @@ return view.extend({
])
}
ss.renderSectionAdd = function(/* ... */) {
let el = hp.renderSectionAdd(this, arguments[0]);
let el = form.GridSection.prototype.renderSectionAdd.apply(this, arguments),
nameEl = el.querySelector('.cbi-section-create-name');
ui.addValidator(nameEl, 'uciname', true, (v) => {
let button = el.querySelector('.cbi-section-create > .cbi-button-add');
let uciconfig = this.uciconfig || this.map.config;
if (!v) {
button.disabled = true;
return true;
} else if (uci.get(uciconfig, v)) {
button.disabled = true;
return _('Expecting: %s').format(_('unique UCI identifier'));
} else {
button.disabled = null;
return true;
}
}, 'blur', 'keyup');
el.appendChild(E('button', {
'class': 'cbi-button cbi-button-add',
@@ -1901,9 +1319,9 @@ return view.extend({
/* Subscription nodes start */
for (const info of subinfo) {
s.tab('sub_' + info.hash, info.title ? _('Sub (%s)').format(info.title) : _('Sub'));
s.tab('sub_' + info.hash, _('Sub (%s)').format(info.title));
o = s.taboption('sub_' + info.hash, form.SectionValue, '_sub_' + info.hash, form.GridSection, 'node');
ss = renderNodeSettings(o.subsection, data, features, main_node, routing_mode, node_latency_row_state);
ss = renderNodeSettings(o.subsection, data, features, main_node, routing_mode);
ss.filter = function(section_id) {
return (uci.get(data[0], section_id, 'grouphash') === info.hash);
}
@@ -1918,35 +1336,32 @@ return view.extend({
_('Auto update subscriptions and geodata.'));
o.rmempty = false;
o = s.taboption('subscription', form.Value, 'auto_update_time', _('Update time (weekly)'));
o.renderWidget = function() {
return hp.renderCronSelector.apply(this, arguments);
};
o.default = '0 0 * * *';
o.rmempty = false;
o.validate = function(section_id, value) {
value = value || this.formvalue(section_id);
const matched = String(value || '').trim().match(/^(\d{1,2})\s+(\d{1,2})\s+\*\s+\*\s+([0-7*])$/);
if (!matched || +matched[1] > 59 || +matched[2] > 23)
return _('Expecting: %s').format(_('valid cron expression'));
return true;
};
o = s.taboption('subscription', form.ListValue, 'auto_update_time', _('Update time'));
for (let i = 0; i < 24; i++)
o.value(i, i + ':00');
o.default = '2';
o.depends('auto_update', '1');
o = s.taboption('subscription', form.Flag, 'update_via_proxy', _('Update via proxy'),
_('Update subscriptions via proxy.'));
o.rmempty = false;
o = s.taboption('subscription', form.ListValue, 'latency_test_mode', _('Latency test mode'),
_('Choose which method node latency tests use.'));
o.value('icmp', _('ICMP'));
o.value('rp', _('RP'));
o.default = 'icmp';
o.rmempty = false;
o = s.taboption('subscription', SubscriptionList, 'subscription_url', _('Subscriptions'),
o = s.taboption('subscription', form.DynamicList, 'subscription_url', _('Subscription URL-s'),
_('Support Hysteria, Shadowsocks, Trojan, v2rayN (VMess), and XTLS (VLESS) online configuration delivery standard.'));
subscription_list_option = o;
o.validate = function(section_id, value) {
if (section_id && value) {
try {
let url = new URL(value);
if (!url.hostname)
return _('Expecting: %s').format(_('valid URL'));
}
catch(e) {
return _('Expecting: %s').format(_('valid URL'));
}
}
return true;
}
o = s.taboption('subscription', form.ListValue, 'filter_nodes', _('Filter nodes'),
_('Drop/keep specific nodes from subscriptions.'));
@@ -1981,16 +1396,8 @@ return view.extend({
o.inputstyle = 'apply';
o.inputtitle = _('Save current settings');
o.onclick = function() {
const validation = subscription_list_option.validate('subscription', subscription_list_option.formvalue('subscription'));
if (validation !== true) {
ui.addNotification(null, E('p', validation));
return Promise.resolve();
}
return this.map.save(null, true).then(() => {
return ui.changes.apply(true);
}).then(() => {
return callRCInit('homeproxy', 'reload');
ui.changes.apply(true);
});
}
@@ -2053,68 +1460,6 @@ return view.extend({
}
/* Subscriptions settings end */
return m.render().then((el) => {
let bulk_testing = false;
let tabmenu_observer = null;
let bulk_button = E('button', {
'class': 'cbi-button cbi-button-action hp-bulk-latency-test',
'click': ui.createHandlerFn(this, async () => {
if (bulk_testing || typeof globalThis === 'undefined' || !globalThis.__hpNodeLatencyTrigger)
return false;
let section_ids = getActiveSubscriptionLatencySectionIds(el);
if (!section_ids.length)
return false;
bulk_testing = true;
bulk_button.textContent = _('Testing Current List...');
bulk_button.disabled = true;
for (let sid of section_ids)
await globalThis.__hpNodeLatencyTrigger(sid);
bulk_testing = false;
bulk_button.textContent = _('Test Current List');
bulk_button.disabled = false;
return true;
})
}, [ _('Test Current List') ]);
let updateBulkButtonVisibility = () => {
bulk_button.style.display = shouldShowBulkLatencyButton(el) ? '' : 'none';
};
let attachBulkButton = () => {
let actions = (el.parentElement ? el.parentElement.querySelector('.cbi-page-actions') : null) || document.querySelector('.cbi-page-actions');
if (!actions)
return false;
if (!actions.querySelector('.hp-bulk-latency-test'))
actions.insertBefore(bulk_button, actions.firstChild);
updateBulkButtonVisibility();
if (!tabmenu_observer) {
let tabmenu = el.querySelector('.cbi-tabmenu');
if (tabmenu) {
tabmenu_observer = new MutationObserver(() => updateBulkButtonVisibility());
tabmenu_observer.observe(tabmenu, {
subtree: true,
attributes: true,
attributeFilter: [ 'class', 'aria-selected' ]
});
}
}
return true;
};
if (!attachBulkButton()) {
window.setTimeout(attachBulkButton, 0);
window.setTimeout(attachBulkButton, 300);
}
return el;
});
return m.render();
}
});
@@ -126,8 +126,6 @@ return view.extend({
let m, s, o;
let features = data[1];
hp.installCloseButtonText();
m = new form.Map('homeproxy', _('HomeProxy Server'),
_('The modern ImmortalWrt proxy platform for ARM64/AMD64.'));
@@ -190,7 +188,6 @@ return view.extend({
o.value('tuic', _('Tuic'));
o.value('vless', _('VLESS'));
o.value('vmess', _('VMess'));
o.default = 'mixed';
o.rmempty = false;
o = s.option(form.Value, 'address', _('Listen address'));
@@ -640,10 +637,10 @@ return view.extend({
o.modalonly = true;
o = s.option(form.ListValue, 'tls_dns01_provider', _('DNS provider'));
o.value('alidns', _('AliYun'));
o.value('cfdns', _('CloudFlare'));
o.value('alidns', _('Alibaba Cloud DNS'));
o.value('cloudflare', _('Cloudflare'));
o.depends('tls_dns01_challenge', '1');
o.default = 'cfdns';
o.default = 'cloudflare';
o.rmempty = false;
o.modalonly = true;
@@ -666,7 +663,7 @@ return view.extend({
o = s.option(form.Value, 'tls_dns01_cf_api_token', _('API token'));
o.password = true;
o.depends('tls_dns01_provider', 'cfdns');
o.depends('tls_dns01_provider', 'cloudflare');
o.rmempty = false;
o.modalonly = true;
@@ -14,8 +14,6 @@
'require ui';
'require view';
'require homeproxy as hp';
/* Thanks to luci-app-aria2 */
const css = ' \
#log_textarea { \
@@ -29,53 +27,6 @@ const css = ' \
} \
.description { \
background-color: #33ccff; \
} \
.homeproxy-connect-grid { \
display: grid; \
grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));\
gap: 12px; \
} \
.homeproxy-connect-card { \
display: grid; \
grid-template-columns: 44px 1fr; \
gap: 10px; \
align-items: center; \
min-height: 64px; \
padding: 8px 10px; \
border-radius: 6px; \
background: #fff; \
box-shadow: 0 1px 4px rgba(0, 0, 0, .08);\
} \
.homeproxy-connect-icon { \
display: flex; \
align-items: center; \
justify-content: center; \
width: 38px; \
height: 38px; \
border-radius: 50%; \
color: #fff; \
font-weight: 700; \
font-size: 15px; \
} \
.homeproxy-connect-info { \
min-height: 42px; \
padding: 7px 12px; \
border-radius: 8px; \
background: #e9edf2; \
} \
.homeproxy-connect-title { \
color: #7d8aa0; \
font-weight: 700; \
font-size: 13px; \
line-height: 1.2; \
} \
.homeproxy-connect-result { \
margin-top: 2px; \
color: #ff4d35; \
font-weight: 700; \
font-size: 13px; \
cursor: pointer; \
line-height: 1.2; \
}';
const hp_dir = '/var/run/homeproxy';
@@ -93,13 +44,13 @@ function getConnStat(o, site) {
'class': 'btn cbi-button cbi-button-action',
'click': ui.createHandlerFn(this, () => {
return L.resolveDefault(callConnStat(site), {}).then((ret) => {
let ele = o.default.firstElementChild.nextElementSibling;
let ele = o.default.firstElementChild.nextElementSibling;
if (ret.result) {
ele.style.setProperty('color', 'green');
ele.innerHTML = _('passed');
ele.innerHTML = _('passed');
} else {
ele.style.setProperty('color', 'red');
ele.innerHTML = _('failed');
ele.innerHTML = _('failed');
}
});
})
@@ -109,53 +60,6 @@ function getConnStat(o, site) {
]);
}
function renderConnCards() {
const callConnStat = rpc.declare({
object: 'luci.homeproxy',
method: 'connection_check',
params: ['site'],
expect: { '': {} }
});
const items = [
{ site: 'baidu', title: _('Baidu Connection'), icon: 'B', color: '#ff7a00' },
{ site: 'google', title: _('Google Connection'), icon: 'G', color: '#4285f4' },
{ site: 'github', title: _('GitHub Connection'), icon: 'GH', color: '#7b3bb3' },
{ site: 'youtube', title: _('YouTube Connection'), icon: 'YT', color: '#ff0033' }
];
return E('div', { 'class': 'homeproxy-connect-grid' }, items.map((item) => {
let result = E('div', {
'class': 'homeproxy-connect-result',
'click': ui.createHandlerFn(this, () => {
result.textContent = _('Checking...');
result.style.setProperty('color', '#f0ad4e');
return L.resolveDefault(callConnStat(item.site), {}).then((ret) => {
if (ret.result && ret.latency != null) {
result.style.setProperty('color', 'green');
result.textContent = _('%s ms').format(ret.latency);
} else {
result.style.setProperty('color', '#ff4d35');
result.textContent = _('failed');
}
});
})
}, [ _('Click to check') ]);
return E('div', { 'class': 'homeproxy-connect-card' }, [
E('div', {
'class': 'homeproxy-connect-icon',
'style': 'background:%s'.format(item.color)
}, [ item.icon ]),
E('div', { 'class': 'homeproxy-connect-info' }, [
E('div', { 'class': 'homeproxy-connect-title' }, [ item.title ]),
result
])
]);
}));
}
function getResVersion(o, type) {
const callResVersion = rpc.declare({
object: 'luci.homeproxy',
@@ -323,16 +227,16 @@ return view.extend({
render() {
let m, s, o;
hp.installCloseButtonText();
m = new form.Map('homeproxy');
s = m.section(form.NamedSection, 'config', 'homeproxy', _('Connection check'));
s.anonymous = true;
o = s.option(form.DummyValue, '_connection_check');
o.rawhtml = true;
o.render = renderConnCards;
o = s.option(form.DummyValue, '_check_baidu', _('BaiDu'));
o.cfgvalue = L.bind(getConnStat, this, o, 'baidu');
o = s.option(form.DummyValue, '_check_google', _('Google'));
o.cfgvalue = L.bind(getConnStat, this, o, 'google');
s = m.section(form.NamedSection, 'config', 'homeproxy', _('Resources management'));
s.anonymous = true;
File diff suppressed because it is too large. Load diff
File diff suppressed because it is too large. Load diff
+13 -28
View File
@@ -25,8 +25,8 @@ config homeproxy 'migration'
config homeproxy 'config'
option main_node 'nil'
option main_udp_node 'same'
option dns_server 'https://dns.quad9.net/dns-query'
option china_dns_server 'https://dns.alidns.com/dns-query'
option dns_server '8.8.8.8'
option china_dns_server '223.5.5.5'
option routing_mode 'bypass_mainland_china'
option routing_port 'common'
option proxy_mode 'redirect_tproxy'
@@ -38,36 +38,20 @@ config homeproxy 'control'
option lan_proxy_mode 'disabled'
list wan_proxy_ipv4_ips '91.105.192.0/23'
list wan_proxy_ipv4_ips '91.108.4.0/22'
list wan_proxy_ipv4_ips '91.108.8.0/21'
list wan_proxy_ipv4_ips '91.108.16.0/21'
list wan_proxy_ipv4_ips '91.108.8.0/22'
list wan_proxy_ipv4_ips '91.108.16.0/22'
list wan_proxy_ipv4_ips '91.108.12.0/22'
list wan_proxy_ipv4_ips '91.108.20.0/22'
list wan_proxy_ipv4_ips '91.108.56.0/22'
list wan_proxy_ipv4_ips '95.161.64.0/20'
list wan_proxy_ipv4_ips '149.154.160.0/20'
list wan_proxy_ipv4_ips '185.76.151.0/24'
list wan_proxy_ipv4_ips '203.208.50.66/32'
list wan_proxy_ipv6_ips '2001:67c:4e8::/48'
list wan_proxy_ipv6_ips '2001:b28:f23c::/47'
list wan_proxy_ipv6_ips '2001:b28:f23c::/48'
list wan_proxy_ipv6_ips '2001:b28:f23d::/48'
list wan_proxy_ipv6_ips '2001:b28:f23f::/48'
list wan_proxy_ipv6_ips '2a0a:f280::/32'
config homeproxy 'clash_api'
option external_ui '/etc/homeproxy/run/ui'
option external_ui_download_url 'https://gh-proxy.com/https://github.com/Zephyruso/zashboard/releases/latest/download/dist-cdn-fonts.zip'
option external_ui_download_detour 'direct-out'
option external_controller '0.0.0.0:9095'
option secret 'homeproxy'
option default_mode 'rule'
config homeproxy 'ntp'
option enabled '1'
option server 'ntp.aliyun.com'
option server_port '123'
option interval '30m'
config homeproxy 'cache'
option enabled '1'
option path '/etc/homeproxy/cache.db'
option store_rdrc '1'
config homeproxy 'routing'
option sniff_override '1'
option default_outbound 'direct-out'
@@ -82,12 +66,13 @@ config homeproxy 'dns'
config homeproxy 'subscription'
option auto_update '0'
option allow_insecure '0'
option latency_test_mode 'icmp'
option packet_encoding 'xudp'
option update_via_proxy '0'
option auto_update_time '0 0 * * *'
option filter_nodes 'disabled'
option filter_nodes 'blacklist'
list filter_keywords '重置|到期|过期|剩余|套餐'
list filter_keywords 'Expiration|Remaining'
config homeproxy 'server'
option enabled '0'
option log_level 'warn'
File diff suppressed because it is too large. Load diff
@@ -1 +1 @@
202606132337
20260704060757
@@ -1,8 +1,6 @@
2001:250::/30
2001:254::/33
2001:255::/32
2001:254::/31
2001:256:100::/48
2001:678:53c::/48
2001:c68::/32
2001:cc0::/32
2001:da8::/32
@@ -13,11 +11,8 @@
2001:dc7::/32
2001:dd8:1::/48
2001:dd9::/48
2001:df5:4740::/48
2001:df6:40::/48
2001:4510:400::/40
2001:4510:1480::/41
2001:4511:1480::/41
2400:1160::/32
2400:3200::/32
2400:5280:f803::/48
@@ -25,8 +20,6 @@
2400:6000::/32
2400:6600::/32
2400:6e60:1301::/48
2400:7100::/32
2400:73e0::/32
2400:75aa::/32
2400:7fc0::/40
2400:7fc0:220::/44
@@ -43,14 +36,9 @@
2400:8200::/32
2400:89c0:1010::/44
2400:89c0:1050::/46
2400:89c0:1130::/44
2400:89c0:1150::/48
2400:89c0:2100::/48
2400:89c0:2200::/48
2400:89c0:3010::/44
2400:89c0:6000::/48
2400:89c0:6100::/48
2400:8fc0:571::/48
2400:8fc0::/32
2400:9020:f010::/46
2400:9380:8001::/48
2400:9380:8003::/48
@@ -97,19 +85,15 @@
2400:cb80:e40::/44
2400:da00::/32
2400:dd00::/28
2400:e680::/32
2400:ee00::/32
2400:ee00:ffec::/46
2400:ee00:fff0::/44
2400:f6e0::/32
2400:f720::/32
2400:fe00::/32
2401:20::/40
2401:20:1330::/46
2401:800::/32
2401:1160::/32
2401:1200::/48
2401:1320::/32
2401:1d40::/32
2401:2780::/32
2401:2a00:f000::/43
2401:2e00::/32
2401:3480::/36
@@ -117,39 +101,11 @@
2401:3480:3000::/36
2401:34a0::/31
2401:3800::/32
2401:3880::/32
2401:3980::/32
2401:3a80::/32
2401:3b80::/32
2401:3c80::/32
2401:3d80::/32
2401:3e80::/32
2401:3f80::/32
2401:4180::/32
2401:4280::/32
2401:4380::/32
2401:4480::/32
2401:4580::/32
2401:4680::/32
2401:4780::/32
2401:4880::/32
2401:4a80::/32
2401:5c20:10::/48
2401:71c0::/48
2401:7660::/48
2401:7700::/32
2401:7d40::/32
2401:7e00::/32
2401:8be0::/48
2401:8d00::/47
2401:8d00:3::/48
2401:8d00:4::/47
2401:8d00:7::/48
2401:8d00:8::/47
2401:8d00:b::/48
2401:8d00:c::/48
2401:8d00:f::/48
2401:8d00:12::/48
2401:9a00::/44
2401:9a00:10::/46
2401:a140:1::/48
@@ -165,56 +121,26 @@
2401:c020:6::/48
2401:c020:8::/47
2401:c020:14::/48
2401:ca00::/32
2401:cb80::/32
2401:cc00::/32
2401:ce00::/32
2401:d0e0:3::/48
2401:d180::/46
2401:d180:10::/47
2401:d180:111::/48
2401:d180:2120::/48
2401:d780::/32
2401:d920::/48
2401:de00::/32
2401:ec00::/32
2401:fa00:40::/48
2402:840:d000::/46
2402:840:e000::/46
2402:840:f000::/38
2402:c60::/48
2402:1440::/32
2402:18a0::/32
2402:2000::/32
2402:2e60::/39
2402:34e0::/32
2402:36e0::/44
2402:3c00::/32
2402:3f80:1400::/40
2402:4440:9000::/39
2402:4440:9200::/48
2402:4440:9400::/48
2402:4440:9600::/48
2402:4440:9800::/48
2402:4440:9810::/48
2402:4440:9900::/48
2402:4440:9a00::/48
2402:4440:9b00::/48
2402:4440:9c00::/48
2402:4440:9d00::/48
2402:4440:9e00::/48
2402:4440:a000::/39
2402:4440:a800::/46
2402:4440:a810::/46
2402:4b80::/32
2402:4e00::/32
2402:5e40::/32
2402:5ec0::/32
2402:6e80::/32
2402:6f40::/48
2402:6f40:2::/47
2402:6fc0::/48
2402:7040::/32
2402:7d80::/48
2402:7d80:240::/48
2402:7d80:8888::/48
@@ -236,12 +162,7 @@
2402:dfc0:50::/44
2402:e480::/32
2402:e740::/32
2402:e7c0::/37
2402:e7c0:800::/38
2402:e7c0:1000::/36
2402:e7c0:2000::/35
2402:e7c0:4000::/34
2402:e7c0:8000::/33
2402:e7c0::/32
2402:e880::/48
2402:ef40::/32
2402:f000::/32
@@ -269,7 +190,6 @@
2403:7580::/32
2403:8080:101::/48
2403:8c00::/32
2403:9b00:2000::/48
2403:9b00:2400::/48
2403:9b00:6000::/48
2403:a100::/48
@@ -331,10 +251,6 @@
2404:c940::/48
2404:e280::/47
2404:e8c0::/32
2404:f4c0:f000::/48
2404:f4c0:f003::/48
2404:f4c0:f004::/46
2404:f4c0:f008::/45
2405:80:10::/48
2405:80:13::/48
2405:6c0:2::/48
@@ -354,130 +270,24 @@
2405:6f00:c602::/48
2405:7040:6000::/47
2405:78c0:6e00::/43
2405:8280::/32
2405:8a40::/32
2405:a900:ffee::/48
2405:a900:fffe::/48
2405:ad00::/32
2405:b7c0::/32
2405:d900::/32
2405:e000::/32
2405:e600:2::/48
2405:f940::/32
2406:280::/32
2406:840:8100::/40
2406:840:9178::/48
2406:840:9962::/47
2406:840:9966::/48
2406:840:996c::/48
2406:840:e080::/44
2406:840:e0cf::/48
2406:840:e0e0::/46
2406:840:e0e4::/47
2406:840:e10f::/48
2406:840:e14f::/48
2406:840:e330::/44
2406:840:e600::/44
2406:840:e620::/47
2406:840:e80f::/48
2406:840:eb01::/48
2406:840:eb02::/47
2406:840:eb04::/47
2406:840:eb07::/48
2406:840:eb08::/48
2406:840:eb0b::/48
2406:840:ee40::/47
2406:840:ee44::/48
2406:840:ee4b::/48
2406:840:ee4d::/48
2406:840:eee5::/48
2406:840:f380::/44
2406:840:f44f::/48
2406:840:9680::/44
2406:840:f889::/48
2406:840:fa01::/48
2406:840:fa60::/44
2406:840:fc10::/47
2406:840:fc12::/48
2406:840:fc20::/47
2406:840:fc22::/48
2406:840:fc30::/47
2406:840:fc32::/48
2406:840:fc40::/47
2406:840:fc42::/48
2406:840:fc50::/47
2406:840:fc52::/48
2406:840:fc60::/47
2406:840:fc62::/48
2406:840:fc70::/47
2406:840:fc72::/48
2406:840:fc90::/47
2406:840:fc92::/48
2406:840:fca0::/47
2406:840:fca2::/48
2406:840:fcb0::/47
2406:840:fcb2::/48
2406:840:fcd0::/48
2406:840:fd40::/48
2406:840:fd46::/47
2406:840:fd48::/48
2406:840:fd50::/48
2406:840:fd56::/47
2406:840:fd58::/48
2406:840:fd60::/48
2406:840:fd66::/47
2406:840:fd68::/48
2406:840:fd70::/48
2406:840:fd76::/47
2406:840:fd78::/48
2406:840:fd80::/48
2406:840:fd86::/47
2406:840:fd88::/48
2406:840:fd90::/47
2406:840:fd92::/48
2406:840:fd9f::/48
2406:840:fda0::/48
2406:840:fda7::/48
2406:840:fdb0::/48
2406:840:fdb7::/48
2406:840:fdc0::/48
2406:840:fdc7::/48
2406:840:fe90::/46
2406:840:fe94::/48
2406:840:fe96::/47
2406:840:fe98::/46
2406:840:fe9d::/48
2406:840:fe9e::/48
2406:840:fea2::/47
2406:840:fea4::/46
2406:840:fea8::/48
2406:840:feaa::/47
2406:840:feac::/46
2406:840:fec0::/48
2406:840:fec2::/47
2406:840:fec4::/48
2406:840:feca::/47
2406:840:fecf::/48
2406:840:fed1::/48
2406:840:fed8::/48
2406:840:fedb::/48
2406:840:fedc::/48
2406:840:fef3::/48
2406:840:fef4::/48
2406:840:fef6::/47
2406:840:fef8::/46
2406:840:fefc::/48
2406:840:feff::/48
2406:1080::/48
2406:1e40:f012::/47
2406:2700::/32
2406:3340::/32
2406:3640:1::/48
2406:4d00::/48
2406:52c0::/32
2406:5340:6666::/48
2406:5340:8888::/48
2406:6100::/32
2406:8880::/48
2406:b640:100::/48
2406:b640:4100::/48
2406:cac0::/40
@@ -494,7 +304,6 @@
2407:23c0::/48
2407:2840::/48
2407:37c0::/32
2407:4980::/32
2407:5380::/32
2407:6c40:1100::/48
2407:6c40:1210::/48
@@ -513,51 +322,7 @@
2407:c080:6000::/36
2407:c080:8000::/36
2407:d9c0::/32
2408:4000::/40
2408:4000:100::/47
2408:4000:103::/48
2408:4000:104::/46
2408:4000:108::/45
2408:4000:110::/44
2408:4000:120::/43
2408:4000:140::/42
2408:4000:180::/41
2408:4000:200::/39
2408:4000:400::/38
2408:4000:800::/37
2408:4000:1000::/36
2408:4000:2000::/35
2408:4000:4000::/34
2408:4000:8000::/33
2408:4001::/32
2408:4002::/31
2408:4004::/30
2408:4008::/29
2408:4010::/30
2408:4014::/31
2408:4016:1::/48
2408:4016:2::/47
2408:4016:4::/46
2408:4016:8::/45
2408:4016:10::/44
2408:4016:20::/43
2408:4016:40::/42
2408:4016:80::/41
2408:4016:100::/40
2408:4016:200::/39
2408:4016:400::/38
2408:4016:800::/37
2408:4016:1000::/36
2408:4016:2000::/35
2408:4016:4000::/34
2408:4016:8000::/33
2408:4017::/32
2408:4018::/29
2408:4020::/27
2408:4040::/26
2408:4080::/25
2408:4100::/24
2408:4200::/23
2408:4000::/22
2408:8000::/48
2408:8000:2::/47
2408:8000:1000::/36
@@ -814,86 +579,103 @@
2408:840c:dd00::/40
2408:840c:de00::/40
2408:840d::/42
2408:840d:40::/43
2408:840d:200::/42
2408:840d:400::/42
2408:840d:440::/43
2408:840d:600::/42
2408:840d:d00::/42
2408:840d:d40::/43
2408:840d:f00::/42
2408:840d:1100::/42
2408:840d:1140::/43
2408:840d:1300::/42
2408:840d:1a00::/42
2408:840d:1a40::/43
2408:840d:1c00::/42
2408:840d:1e00::/42
2408:840d:1e40::/43
2408:840d:2000::/42
2408:840d:2700::/42
2408:840d:2740::/43
2408:840d:2900::/42
2408:840d:2b00::/42
2408:840d:2b40::/43
2408:840d:2d00::/42
2408:840d:3400::/42
2408:840d:3440::/43
2408:840d:3600::/42
2408:840d:3800::/42
2408:840d:3840::/43
2408:840d:3a00::/42
2408:840d:4e00::/42
2408:840d:4e40::/43
2408:840d:5000::/42
2408:840d:5200::/42
2408:840d:5240::/43
2408:840d:5400::/42
2408:840d:5b00::/42
2408:840d:5b40::/43
2408:840d:5d00::/42
2408:840d:5f00::/42
2408:840d:5f40::/43
2408:840d:6100::/42
2408:840d:6800::/42
2408:840d:6840::/43
2408:840d:6a00::/42
2408:840d:6c00::/42
2408:840d:6c40::/43
2408:840d:6e00::/42
2408:840d:7500::/42
2408:840d:7540::/43
2408:840d:7700::/42
2408:840d:7900::/42
2408:840d:7940::/43
2408:840d:7b00::/42
2408:840d:8200::/42
2408:840d:8240::/43
2408:840d:8400::/42
2408:840d:8600::/42
2408:840d:8640::/43
2408:840d:8800::/42
2408:840d:8f00::/42
2408:840d:8f40::/43
2408:840d:9100::/42
2408:840d:9300::/42
2408:840d:9340::/43
2408:840d:9500::/42
2408:840d:9c00::/42
2408:840d:9c40::/43
2408:840d:9e00::/42
2408:840d:a000::/42
2408:840d:a040::/43
2408:840d:a200::/42
2408:840d:a900::/42
2408:840d:a940::/43
2408:840d:ab00::/42
2408:840d:ad00::/42
2408:840d:ad40::/43
2408:840d:af00::/42
2408:840d:b600::/42
2408:840d:b640::/43
2408:840d:b800::/42
2408:840d:ba00::/42
2408:840d:ba40::/43
2408:840d:bc00::/42
2408:840d:c300::/42
2408:840d:c340::/43
2408:840d:c500::/42
2408:840d:c700::/42
2408:840d:c740::/43
2408:840d:c900::/42
2408:840d:d000::/42
2408:840d:d040::/43
2408:840d:d200::/42
2408:840d:d400::/42
2408:840d:d440::/43
2408:840d:d600::/42
2408:840d:dd00::/42
2408:840d:dd40::/43
2408:840d:de00::/42
2408:840e:dd00::/40
2408:840e:de00::/40
@@ -1074,6 +856,7 @@
2408:8a06:100::/47
2408:8a07::/40
2408:8a21:4000::/35
2408:8a22::/35
2408:8a23:4000::/34
2408:8a24:4000::/34
2408:8a26:c000::/34
@@ -1087,47 +870,14 @@
2409:27fc::/48
2409:27fe::/33
2409:6100::/44
2409:8000::/21
2409:8800::/22
2409:8c00::/25
2409:8c80::/30
2409:8c84::/32
2409:8c85::/34
2409:8c85:4000::/36
2409:8c85:5000::/38
2409:8c85:5400::/43
2409:8c85:5420::/44
2409:8c85:5430::/47
2409:8c85:5433::/48
2409:8c85:5434::/46
2409:8c85:5438::/45
2409:8c85:5440::/42
2409:8c85:5480::/41
2409:8c85:5500::/40
2409:8c85:5600::/39
2409:8c85:5800::/37
2409:8c85:6000::/35
2409:8c85:8000::/33
2409:8c86::/31
2409:8c88::/29
2409:8c90::/28
2409:8ca0::/27
2409:8cc0::/26
2409:8d00::/24
2409:8e00::/23
2409:8000::/20
240a:2000::/40
240a:2001:100::/40
240a:2001:1000::/36
240a:4002:1b00::/40
240a:4010:8000::/33
240a:4020:83a::/48
240a:4020:883a::/48
240a:4021:83a::/48
240a:4021:883a::/48
240a:4080:8000::/35
240a:4084:2000::/35
240a:4088:a000::/35
240a:408c:2000::/35
240a:4090:50::/48
240a:4090:120::/48
240a:4090:250::/48
@@ -1142,20 +892,11 @@
240a:4090:5200::/40
240a:4090:7000::/39
240a:4090:7200::/40
240a:4090:8000::/34
240a:4093::/35
240a:4094:2000::/35
240a:409c:2000::/35
240a:40a4:2000::/35
240a:40a8:8000::/35
240a:40ac:2000::/35
240a:40b0:83a::/48
240a:40b0:283a::/48
240a:40b0:483a::/48
240a:40b0:683a::/48
240a:40c0:8000::/43
240a:40c0:8200::/48
240a:40c0:8240::/48
240a:40c0:a000::/43
240a:40c0:c000::/43
240a:40c0:e000::/43
@@ -1182,31 +923,10 @@
240a:40c3:8000::/43
240a:40c3:a000::/43
240a:40c3:c000::/43
240a:40c3:c200::/48
240a:40c3:c240::/48
240a:40c3:e000::/43
240a:40c4::/43
240a:40c4:2000::/43
240a:40c4:4000::/43
240a:4172::/31
240a:4180::/31
240a:41b0::/34
240a:41b8:8800::/40
240a:41b8:a000::/40
240a:41b8:d400::/40
240a:41b8:e400::/40
240a:41d6::/31
240a:41f2::/31
240a:4208::/30
240a:4224:9000::/44
240a:4224:a000::/44
240a:4224:c000::/44
240a:4224:d000::/44
240a:4224:e000::/44
240a:4225:1000::/44
240a:4225:3000::/44
240a:4230::/31
240a:4242::/31
240a:4280::/26
240a:42c0::/27
240a:42e0::/28
@@ -1223,69 +943,7 @@
240c:4000::/22
240c:c000::/20
240d:4000::/21
240e::/21
240e:800::/24
240e:900::/26
240e:940::/27
240e:960::/28
240e:970::/29
240e:978::/30
240e:97c::/32
240e:97d::/33
240e:97d:8001::/48
240e:97d:8002::/47
240e:97d:8004::/46
240e:97d:8008::/45
240e:97d:8010::/44
240e:97d:8020::/43
240e:97d:8040::/42
240e:97d:8080::/41
240e:97d:8100::/40
240e:97d:8200::/39
240e:97d:8400::/38
240e:97d:8800::/37
240e:97d:9000::/36
240e:97d:a000::/35
240e:97d:c000::/34
240e:97e::/31
240e:980::/31
240e:982::/32
240e:983::/35
240e:983:2000::/44
240e:983:2011::/48
240e:983:2012::/48
240e:983:2014::/46
240e:983:2018::/45
240e:983:2021::/48
240e:983:2023::/48
240e:983:2024::/46
240e:983:2028::/45
240e:983:2031::/48
240e:983:2032::/47
240e:983:2034::/46
240e:983:2038::/45
240e:983:2040::/42
240e:983:2080::/41
240e:983:2100::/40
240e:983:2200::/39
240e:983:2400::/38
240e:983:2800::/37
240e:983:3000::/36
240e:983:4000::/34
240e:983:8000::/33
240e:984::/30
240e:988::/29
240e:990::/28
240e:9a0::/27
240e:9c0::/26
240e:a00::/23
240e:c00::/22
2602:f92a:a468::/48
2602:f92a:a46d::/48
2602:f92a:a47d::/48
2602:f9ba:a8::/48
2602:f9ba:10c::/48
2602:f9f6:450::/48
240e::/20
2605:9d80:8001::/48
2605:9d80:8011::/48
2605:9d80:8021::/48
@@ -1301,8 +959,6 @@
2605:9d80:9092::/48
2804:1e48:9001::/48
2804:1e48:9002::/48
2a01:e281:a400::/48
2a01:e281:a410::/44
2a04:3e00:1002::/48
2a04:f580:8010::/47
2a04:f580:8090::/48
@@ -1327,163 +983,26 @@
2a04:f580:9270::/48
2a04:f580:9280::/48
2a04:f580:9290::/48
2a05:1087::/32
2a06:3600:e000::/40
2a06:3600:fb00::/40
2a06:3600:fc00::/38
2a06:3605::/32
2a06:3606::/31
2a06:a005:260::/43
2a06:a005:280::/43
2a06:a005:2a0::/44
2a07:54c1:2200::/46
2a07:54c1:2205::/48
2a0a:d681:e000::/40
2a0a:d681:fb00::/40
2a0a:d681:fc00::/38
2a0a:d687:f001::/48
2a0c:b641:571::/48
2a0e:aa06::/40
2a0e:aa06:440::/48
2a0e:aa06:450::/44
2a0e:aa06:490::/44
2a0e:aa06:4e0::/44
2a0e:aa07:e144::/48
2a0e:aa07:e146::/48
2a0e:aa07:e148::/48
2a0e:aa07:e280::/47
2a0e:aa07:e284::/46
2a0e:aa07:e288::/47
2a0e:aa07:e28a::/48
2a0e:aa07:e28d::/48
2a0e:aa07:e28e::/48
2a0e:aa07:f0d0::/46
2a0e:aa07:f0d4::/47
2a0e:aa07:f0d8::/48
2a0e:aa07:f0de::/47
2a0a:d685:1ff::/48
2a0a:d685:300::/40
2a0b:4340:90::/48
2a0b:4340:97::/48
2a0d:c7c7:400::/38
2a0e:aa06:49f::/48
2a0e:b107:740::/44
2a0e:b107:da0::/44
2a0e:b107:14a0::/44
2a0f:1cc5:14::/46
2a0f:1cc5:1f::/48
2a0f:1cc5:40::/48
2a0f:1cc5:110::/44
2a0f:1cc5:130::/44
2a0f:1cc5:140::/42
2a0f:1cc5:600::/47
2a0f:1cc5:603::/48
2a0f:1cc5:642::/48
2a0f:1cc5:661::/48
2a0f:1cc5:662::/48
2a0f:1cc5:6a0::/48
2a0f:1cc5:f01::/48
2a0f:1cc5:f02::/47
2a0f:1cc5:f04::/46
2a0f:1cc5:f09::/48
2a0f:1cc5:fff::/48
2a0f:1cc5:1000::/48
2a0f:1cc5:1010::/44
2a0f:1cc5:1032::/47
2a0f:1cc5:1034::/47
2a0f:1cc5:1c00::/47
2a0f:1cc5:1c02::/48
2a0f:1cc5:1c20::/48
2a0f:1cc5:1c30::/48
2a0f:1cc5:1cc0::/48
2a0f:1cc5:1d10::/47
2a0f:1cc5:2000::/40
2a0f:1cc5:2510::/44
2a0f:1cc5:2520::/44
2a0f:1cc5:25ff::/48
2a0f:1cc5:2600::/41
2a0f:1cc5:2680::/42
2a0f:1cc5:2d01::/48
2a0f:1cc5:2d03::/48
2a0f:1cc5:3200::/46
2a0f:1cc5:3222::/48
2a0f:1cc6:b110::/47
2a0f:1cc6:b210::/47
2a0f:1cc6:b212::/48
2a0f:2706::/32
2a0f:85c1:bfe::/48
2a12:cb41::/44
2a12:cb46::/36
2a12:cb47:ffff::/48
2a13:1800::/48
2a13:1800:10::/48
2a13:1800:80::/44
2a13:1800:300::/44
2a0e:b107:2440::/44
2a0f:1cc5:1600::/44
2a0f:1cc5:4700::/40
2a12:cb41:1200::/44
2a12:cb41:1300::/43
2a12:cb41:13f0::/44
2a13:1801:180::/43
2a13:1801:200::/44
2a13:8c87::/32
2a13:a5c3:ff41::/48
2a13:a5c3:ff50::/44
2a14:67c1:70::/48
2a14:67c1:74::/48
2a14:67c1:a110::/44
2a14:67c1:a123::/48
2a14:67c1:a125::/48
2a14:67c1:a128::/48
2a14:67c1:b500::/48
2a14:67c1:b511::/48
2a14:67c1:b514::/48
2a14:67c1:b530::/44
2a14:67c1:b563::/48
2a14:67c1:b578::/48
2a14:67c1:b586::/47
2a14:67c1:b588::/47
2a14:67c1:b590::/48
2a14:67c1:b599::/48
2a14:67c1:b5e0::/44
2a14:67c1:c300::/40
2a14:67c2:519::/48
2a14:67c2:a10::/47
2a14:67c2:a21::/48
2a14:67c2:a22::/47
2a14:67c2:a2f::/48
2a14:67c2:a30::/48
2a14:67c2:a41::/48
2a14:67c2:a50::/48
2a14:67c2:a70::/47
2a14:67c2:a80::/47
2a14:67c2:a90::/48
2a14:67c3:c0::/48
2a14:67c3:190::/47
2a14:67c3:192::/48
2a14:67c3:1100::/47
2a14:67c3:9990::/44
2a14:7580:740::/44
2a14:7580:fffa::/48
2a14:7581:ffb::/48
2a14:7581:30b6::/48
2a14:7583:f224::/47
2a14:7583:f228::/48
2a14:7583:f22c::/48
2a14:7583:f244::/48
2a14:7583:f264::/48
2a14:7583:f268::/48
2a14:7583:f300::/46
2a14:7583:f304::/47
2a14:7583:f306::/48
2a14:7583:f411::/48
2a14:7583:f4f0::/48
2a14:7583:f4f4::/48
2a14:7583:f4fe::/48
2a14:7583:f701::/48
2a14:7583:f703::/48
2a14:7583:f704::/46
2a14:7583:f708::/46
2a14:7583:f70c::/48
2a14:7583:f743::/48
2a14:7583:f744::/48
2a14:7583:f764::/48
2a14:7586:6100::/47
2a14:7586:6103::/48
2a14:7586:6104::/47
2a14:7586:6110::/48
2a14:7586:6300::/44
2a14:7dc0:506::/48
2a14:ae00:50::/44
2a13:a5c3:f000::/40
2a14:7580:d00::/43
2a14:7580:d20::/46
2a14:7580:d41::/48
2a14:7580:d42::/47
2a14:7580:dff::/48
2c0f:f7a8:8011::/48
2c0f:f7a8:8050::/48
2c0f:f7a8:805f::/48
@@ -1492,5 +1011,4 @@
2c0f:f7a8:8211::/48
2c0f:f7a8:9020::/48
2c0f:f7a8:9041::/48
2c0f:f7a8:9211::/48
2c0f:f7a8:9220::/48
@@ -1 +1 @@
202606132337
20260704060757
File diff suppressed because it is too large. Load diff
@@ -1 +1 @@
202606132337
202607052256
@@ -13,6 +13,7 @@
173ng.com
18board.com
18comic.org
18mh.net
1984bbs.com
1991way.com
1e100.net
@@ -73,6 +74,7 @@
9cache.com
9gag.com
9news.com.au
9oju31.launches.appsflyersdk.com
a-normal-day.com
a248.e.akamai.net
aamacau.com
@@ -87,6 +89,7 @@ about.gitlab.com
about.me
abplive.com
acast.com
accountboy.com
accountkit.com
acevpn.com
acg.mn
@@ -128,6 +131,7 @@ aiosearch.com
aiph.net
airconsole.com
airitilibrary.com
airuniversity.af.edu
airvpn.org
ait.org.tw
aiweiweiblog.com
@@ -207,13 +211,18 @@ aoxvpn.com
apartmentratings.com
apartments.com
apat1989.org
api-gl.lbkrs.com
api-secure.recaptcha.net
api-verify.recaptcha.net
api.ai
api.futunn.com
api.lbkrs.com
api.moomoobull.com
api.palworldgame.com
api.pureapk.com
api.recaptcha.net
api.steampowered.com
api5.futunn.com
apiary.io
apigee.com
apk.support
@@ -391,6 +400,7 @@ bigjapanesesex.com
bignews.org
bigone.com
bild.de
bilinovel.com
biliworld.com
binance.com
binance.org
@@ -655,6 +665,7 @@ cdjp.org
cdn-images.mailchimp.com
cdn-telegram.org
cdn.arstechnica.net
cdn.futustatic.com
cdn.jwplayer.com
cdn.printfriendly.com
cdn.seatguru.com
@@ -678,6 +689,7 @@ centurys.net
certificate-transparency.org
certificate.revocationcheck.com
cfr.org
cg.play-analytics.com
cgdepot.org
change.org
changp.com
@@ -859,6 +871,7 @@ crazypool.org
crazyshit.com
crbug.com
crchina.org
creader.com
creaders.net
creativelab5.com
cristyli.com
@@ -1024,6 +1037,7 @@ dougscripts.com
doujincafe.com
dowjones.io
download.dappcdn.com
download.futunn.com
dpool.top
dpp.org.tw
dpr.info
@@ -1149,6 +1163,7 @@ expatshield.com
expecthim.com
expekt.com
exploader.net
expressnews.com
expressvpn.com
exrates.me
extmatrix.com
@@ -1339,7 +1354,36 @@ funkyimg.com
furbo.org
furinkan.com
furrybar.com
futu.cn
futu.com
futu.link
futu0.com
futu1.com
futu2.com
futu3.com
futu4.com
futu5.com
futu6.com
futu7.com
futu8.com
futu9.com
futuau.com
futubull.cn
futuchain.com
futuesop.com
futufin.com
futuhk.com
futuhk2.com
futuhkapp.com
futuhn.com
futuholdings.com
futuinc.com
futuniuniu.com
futunn.com
futuremessage.org
futustatic.com
fututrade.com
fututrustee.com
fw.cm
fxcm-chinese.com
fxnetworks.com
@@ -1362,6 +1406,7 @@ gaoming.net
gaopi.net
gartlive.com
garudalinux.org
gate.com
gate.io
gatecoin.com
gather.com
@@ -1382,6 +1427,7 @@ generated.photos
genius.com
geph.io
get.app
get.dappcdn.com
get.dev
get.how
get.page
@@ -1739,6 +1785,7 @@ gtv.org
gtv1.org
gu-chu-sum.org
guaguass.com
guangming.com.my
guishan.org
gumroad.com
gunsamerica.com
@@ -1829,6 +1876,7 @@ hkgolden.com
hkgpao.com
hklts.org.hk
hkmap.live
hkong.hk
hkopentv.com
hkpeanut.com
hkreporter.com
@@ -2043,6 +2091,7 @@ itasoftware.com
itch.io
itemfix.com
itiger.com
itigerup.com
itshidden.com
itweet.net
iuhrdf.org
@@ -2132,6 +2181,7 @@ kenengba.com
kepard.com
kex.com
keycdn.com
kfor.com
khatrimaza.org
kichiku-doujinko.com
kik.com
@@ -2181,12 +2231,15 @@ landofhope.tv
lantern.io
laogai.org
laogairesearch.org
laohu8.com
laqingdan.net
larsgeorge.com
lastcombat.com
lastfm.es
lausan.hk
lbank.info
lbctrl.com
lbkrs.com
ldplayer.net
ldplayer.tw
le-vpn.com
@@ -2255,6 +2308,15 @@ localdomain.ws
lockestek.com
login.target.com
logos.com.hk
longbridge.cloud
longbridge.com
longbridge.global
longbridge.hk
longbridge.sg
longbridgeapp.com
longbridgehk.com
longportapp.cn
longportapp.com
longtermly.net
longtoes.com
lookpic.com
@@ -2372,6 +2434,7 @@ mfxmedia.com
mgoon.com
mgstage.com
mh4u.org
mhwindow.org
microvpn.com
mihua.org
mij.rip
@@ -2441,6 +2504,9 @@ monitorchina.org
monocloud.me
monster.com
moodyz.com
moomoo.com
moomooequity.com
moomootrustee.com
moon.fm
moonbbs.com
moonbingo.com
@@ -2681,6 +2747,13 @@ ooni.io
ooni.org
open.firstory.me
openai.com
openapi-quote.longbridge.cn
openapi-quote.longbridge.com
openapi-trade.longbridge.cn
openapi-trade.longbridge.com
openapi.futunn.com
openapi.longbridge.cn
openapi.longbridge.com
openart.ai
opencritic.com
opendemocracy.net
@@ -2746,6 +2819,7 @@ pbs.org
pbworks.com
pbxes.com
pbxes.org
pcgamesn.com
pcgamestorrents.com
pcij.org
pct.org.tw
@@ -2764,6 +2838,7 @@ peoplenews.tw
peopo.org
perfect-privacy.com
periscope.tv
perma.cc
perplexity.ai
pewresearch.org
phayul.com
@@ -2935,12 +3010,15 @@ qmp4.com
qoos.com
qq.co.za
qstatus.com
qtcard.futunn.com
qtcardfthk.futufin.com
qtrac.eu
questvisual.com
quitccp.org
quiz.directory
quora.com
quoracdn.net
quote.longbridge.global
quran.com
qz.com
r-pool.net
@@ -3009,6 +3087,7 @@ rentry.co
renyurenquan.org
resilio.com
resistchina.org
restofworld.org
retweetrank.com
reuters.com
reutersmedia.net
@@ -3082,6 +3161,10 @@ saveuighur.org
sbme.me
sbti.unun.dev
schema.org
schwab.co.uk
schwab.com
schwab.com.cn
schwab.com.hk
scmp.com
scramble.io
scratch.mit.edu
@@ -3120,6 +3203,7 @@ sexinsex.net
sf.net
sfshibao.com
sftuk.org
sgqt0j.launches.appsflyersdk.com
shadeyouvpn.com
shadowsocks.be
shadowsocks.com.hk
@@ -3144,6 +3228,7 @@ shodanhq.com
shooshtime.com
shopee.tw
shopping.yahoo.co.jp
shortconn.im.qcloud.com
showwe.tw
shutterstock.com
shwchurch.org
@@ -3168,6 +3253,7 @@ sinoants.com
sinoca.com
sinocast.com
sinoinsider.com
sinyalee.com
sipml5.org
sis001.com
site.new
@@ -3237,6 +3323,7 @@ southmongolia.org
southnews.com.tw
southpark.cc.com
sowers.org.hk
spaceforce.mil
spaces.hightail.com
spacex.com
spankbang.com
@@ -3327,6 +3414,8 @@ supchina.com
superpages.com
supervpn.net
superzooi.com
support.futunn.com
supremecourt.gov
suprememastertv.com
surfeasy.com
surfeasy.com.au
@@ -3438,6 +3527,7 @@ thehansindia.com
thehindu.com
thehun.net
theinitium.com
theintercept.com
thenewslens.com
thepiratebay.org
theporndude.com
@@ -3516,6 +3606,12 @@ tibettelegraph.com
tibettimes.net
tibettruth.com
tibetwrites.org
tigerbbs.cn
tigerbbs.com
tigerbrokers.com
tigerbrokers.net
tigerbrokers.nz
tigerfintech.com
tigervpn.com
tiktok.com
tiktokcdn-eu.com
@@ -3578,6 +3674,9 @@ totalvpn.com
tou.tv
tpi.org.tw
tracfone.com
trade.futunn.com
trade.longportapp.com
tradeup.com
tradingview.com
translate.goog
transparency.org
@@ -3586,6 +3685,7 @@ trendsmap.com
tronscan.org
trouw.nl
trt.net.tr
trtworld.com
truebuddha-md.org
trustwallet.com
truthsocial.com
@@ -3681,6 +3781,7 @@ twitturk.com
twitturly.com
twkan.com
twreporter.org
twstalker.com
twt.tl
twtkr.com
twttr.com
@@ -3895,6 +3996,7 @@ wanz-factory.com
warroom.org
waselpro.com
washingtonpost.com
washingtontimes.com
watchinese.com
watchmygf.net
watchout.tw
@@ -3903,6 +4005,7 @@ wav.tv
waveprotocol.org
waybig.com
waymo.com
wbrks.com
wd.bible
wealth.com.tw
wearn.com
@@ -3912,6 +4015,7 @@ webmproject.org
webpkgcache.com
webrtc.org
websdr.org
webshare.io
website.new
webwarper.net
wechatlawsuit.com
@@ -4081,6 +4185,7 @@ xgmyd.com
xhamster.com
xianjian.tw
xiaohexie.com
xiaohu8.com
xiaolan.me
xiaoma.org
xiaomi.eu
@@ -4105,6 +4210,7 @@ xn--noss43i.com
xn--oiq.cc
xn--p8j9a0d9c9a.xn--q9jyb4c
xn--u2u927b.com
xn--vuqv2cf7wzyig79c.com
xnpool.com
xnxx.com
xpud.org
@@ -4113,6 +4219,7 @@ xskywalker.com
xt.com
xt.pub
xtube.com
xuan.com.my
xuchao.net
xuchao.org
xuehua.us
@@ -4219,6 +4326,8 @@ zhao.1984.city
zhengjian.org
zhengwunet.org
zhenxiang.biz
zhijianfengyi.cn
zhijianfengyi.com
zhizhu.top
zhongguo.ca
zhongguotese.net
@@ -1 +1 @@
202606132337
202607052256
@@ -7,7 +7,6 @@
'use strict';
import { md5 } from 'digest';
import { readfile, writefile } from 'fs';
import { isnan } from 'math';
import { connect } from 'ubus';
@@ -30,10 +29,7 @@ uci.load(uciconfig);
const uciinfra = 'infra',
ucimain = 'config',
ucicontrol = 'control',
uciclashapi = 'clash_api',
ucintp = 'ntp',
ucicache = 'cache';
ucicontrol = 'control';
const ucidnssetting = 'dns',
ucidnsserver = 'dns_server',
@@ -45,63 +41,23 @@ const uciroutingsetting = 'routing',
const ucinode = 'node';
const uciruleset = 'ruleset';
const RULESET_DIR = HP_DIR + '/ruleset';
const routing_mode = uci.get(uciconfig, ucimain, 'routing_mode') || 'bypass_mainland_china';
function normalize_list(value) {
if (isEmpty(value))
return [];
if (type(value) === 'array')
return value;
return [value];
}
function ruleset_file_name(tag, format) {
let filename = replace(tag || 'ruleset', /[^A-Za-z0-9_.-]+/g, '_');
if (isEmpty(filename))
filename = 'ruleset';
return filename + ((format === 'source') ? '.json' : '.srs');
}
function ruleset_default_path(tag, format) {
return RULESET_DIR + '/' + ruleset_file_name(tag, format);
}
function ruleset_remote_path(path, tag, format) {
if (isEmpty(path))
return ruleset_default_path(tag, format);
if (match(path, /\/$/))
return path + ruleset_file_name(tag, format);
return path;
}
let wan_dns = ubus.call('network.interface', 'status', {'interface': 'wan'})?.['dns-server']?.[0];
if (!wan_dns)
wan_dns = (routing_mode in ['proxy_mainland_china', 'global']) ? '9.9.9.9' : '223.5.5.5';
wan_dns = (routing_mode in ['proxy_mainland_china', 'global']) ? '8.8.8.8' : '223.5.5.5';
const dns_port = uci.get(uciconfig, uciinfra, 'dns_port') || '5333';
let ntp_enabled = uci.get(uciconfig, ucintp, 'enabled'),
ntp_server = uci.get(uciconfig, ucintp, 'server'),
ntp_server_port = uci.get(uciconfig, ucintp, 'server_port'),
ntp_interval = uci.get(uciconfig, ucintp, 'interval');
if (isEmpty(ntp_enabled) && isEmpty(ntp_server)) {
ntp_server = uci.get(uciconfig, uciinfra, 'ntp_server');
ntp_enabled = !isEmpty(ntp_server) ? '1' : '0';
}
const ntp_server = uci.get(uciconfig, uciinfra, 'ntp_server') || 'time.apple.com';
const ipv6_support = uci.get(uciconfig, ucimain, 'ipv6_support') || '0';
let cache_file_enabled, cache_file_path, cache_store_rdrc, cache_rdrc_timeout,
main_node, main_udp_node, dedicated_udp_node, default_outbound, default_outbound_dns,
let main_node, main_udp_node, dedicated_udp_node, default_outbound, default_outbound_dns,
domain_strategy, sniff_override, dns_server, china_dns_server, dns_default_strategy,
dns_default_server, dns_disable_cache, dns_disable_cache_expire, dns_independent_cache,
dns_client_subnet, direct_domain_list,
dns_client_subnet, cache_file_store_rdrc, cache_file_rdrc_timeout, direct_domain_list,
proxy_domain_list;
if (routing_mode !== 'custom') {
@@ -137,6 +93,8 @@ if (routing_mode !== 'custom') {
dns_disable_cache_expire = uci.get(uciconfig, ucidnssetting, 'disable_cache_expire');
dns_independent_cache = uci.get(uciconfig, ucidnssetting, 'independent_cache');
dns_client_subnet = uci.get(uciconfig, ucidnssetting, 'client_subnet');
cache_file_store_rdrc = uci.get(uciconfig, ucidnssetting, 'cache_file_store_rdrc'),
cache_file_rdrc_timeout = uci.get(uciconfig, ucidnssetting, 'cache_file_rdrc_timeout');
/* Routing settings */
default_outbound = uci.get(uciconfig, uciroutingsetting, 'default_outbound') || 'nil';
@@ -152,7 +110,7 @@ const mixed_port = uci.get(uciconfig, uciinfra, 'mixed_port') || '5330';
let self_mark, redirect_port, tproxy_port, tun_name,
tun_addr4, tun_addr6, tun_mtu, tcpip_stack,
udp_timeout;
endpoint_independent_nat, udp_timeout;
if (routing_mode === 'custom')
udp_timeout = uci.get(uciconfig, uciroutingsetting, 'udp_timeout');
@@ -172,18 +130,13 @@ if (match(proxy_mode, /tun/)) {
tun_addr6 = uci.get(uciconfig, uciinfra, 'tun_addr6') || 'fdfe:dcba:9876::1/126';
tun_mtu = uci.get(uciconfig, uciinfra, 'tun_mtu') || '9000';
tcpip_stack = 'system';
if (routing_mode === 'custom')
if (routing_mode === 'custom') {
tcpip_stack = uci.get(uciconfig, uciroutingsetting, 'tcpip_stack') || 'system';
endpoint_independent_nat = uci.get(uciconfig, uciroutingsetting, 'endpoint_independent_nat');
}
}
const log_level = uci.get(uciconfig, ucimain, 'log_level') || 'warn';
cache_file_enabled = uci.get(uciconfig, ucicache, 'enabled');
cache_file_path = uci.get(uciconfig, ucicache, 'path');
cache_store_rdrc = uci.get(uciconfig, ucicache, 'store_rdrc');
cache_rdrc_timeout = uci.get(uciconfig, ucicache, 'rdrc_timeout');
let clash_api = null;
/* UCI config end */
/* Config helper start */
@@ -215,31 +168,6 @@ function parse_dnsserver(server_addr, default_protocol) {
}
}
function parse_custom_dnsserver(cfg) {
let server = cfg.server,
server_port = (cfg.type in ['https', 'h3']) ? null : strToInt(cfg.server_port),
path = cfg.path;
if (!isEmpty(server) && match(server, /:\/\//)) {
const server_url = parseURL(server);
server = server_url.hostname;
if (isEmpty(server_port))
server_port = strToInt(server_url.port);
if ((cfg.type in ['https', 'h3']) && isEmpty(path) && server_url.pathname !== '/')
path = server_url.pathname;
}
if ((cfg.type in ['https', 'h3']) && isEmpty(path))
path = '/dns-query';
return {
type: cfg.type,
server,
server_port,
path
};
}
function parse_dnsquery(strquery) {
if (type(strquery) !== 'array' || isEmpty(strquery))
return null;
@@ -252,149 +180,13 @@ function parse_dnsquery(strquery) {
}
function filter_existing_nodes(nodes) {
if (type(nodes) !== 'array' || isEmpty(nodes))
return [];
return filter(nodes, (k) => {
const node = uci.get_all(uciconfig, k) || {};
return !isEmpty(node);
});
}
function collect_group_nodes(groups, subscription_nodes, nodes, legacy_nodes) {
let result = [];
for (let group in normalize_list(groups))
uci.foreach(uciconfig, ucinode, (cfg) => {
if (cfg.grouphash === group && !~index(result, cfg['.name']))
push(result, cfg['.name']);
});
for (let node in filter_existing_nodes(normalize_list(subscription_nodes)))
if (!~index(result, node))
push(result, node);
for (let node in filter_existing_nodes(normalize_list(nodes)))
if (!~index(result, node))
push(result, node);
for (let node in filter_existing_nodes(normalize_list(legacy_nodes)))
if (!~index(result, node))
push(result, node);
return result;
}
function collect_policy_nodes(nodes, current) {
let result = [];
for (let node in normalize_list(nodes)) {
if (node === current || ~index(result, node))
continue;
const outbound = uci.get_all(uciconfig, node) || {};
if (!isEmpty(outbound) && outbound['.type'] === uciroutingnode && outbound.enabled === '1' && outbound.node in ['urltest', 'selector'])
push(result, node);
}
return result;
}
const reserved_outbound_tags = {
'GLOBAL': true,
'main-out': true,
'main-udp-out': true,
'direct-out': true,
'block-out': true
};
let outbound_tag_map = {},
outbound_tag_used = {};
function normalize_outbound_tag(tag) {
if (isEmpty(tag))
return null;
tag = trim(sprintf('%s', tag));
tag = replace(tag, /[\r\n\t]+/g, ' ');
tag = replace(tag, /[\/\\?#%]+/g, '-');
tag = replace(tag, /\s+/g, ' ');
return tag || null;
}
function section_display_name(section) {
if (type(section) !== 'object' || isEmpty(section))
return null;
let label = normalize_outbound_tag(section.label);
if (!isEmpty(label))
return label;
if (section['.type'] === ucinode) {
const address = trim(section.override_address || section.address || '');
const port = trim(section.override_port || section.port || '');
if (address && port)
return normalize_outbound_tag(`${address}:${port}`);
}
return null;
}
function register_outbound_tag(section_id, display_name) {
if (isEmpty(section_id))
return null;
let tag = outbound_tag_map[section_id];
if (!isEmpty(tag))
return tag;
const fallback_tag = `cfg-${section_id}-out`;
const base_tag = normalize_outbound_tag(display_name) || fallback_tag;
tag = base_tag;
let suffix = 2;
while (reserved_outbound_tags[tag] || outbound_tag_used[tag]) {
tag = `${base_tag} (${suffix})`;
suffix++;
}
outbound_tag_map[section_id] = tag;
outbound_tag_used[tag] = true;
return tag;
}
function get_section_outbound_tag(section_id) {
if (isEmpty(section_id))
return null;
let tag = outbound_tag_map[section_id];
if (!isEmpty(tag))
return tag;
const section = uci.get_all(uciconfig, section_id) || {};
return register_outbound_tag(section_id, section_display_name(section));
}
uci.foreach(uciconfig, ucinode, (cfg) => {
register_outbound_tag(cfg['.name'], section_display_name(cfg));
});
uci.foreach(uciconfig, uciroutingnode, (cfg) => {
if (cfg.enabled === '1')
register_outbound_tag(cfg['.name'], section_display_name(cfg));
});
function generate_endpoint(node) {
if (type(node) !== 'object' || isEmpty(node))
return null;
const endpoint = {
type: node.type,
tag: get_section_outbound_tag(node['.name']),
tag: 'cfg-' + node['.name'] + '-out',
address: node.wireguard_local_address,
mtu: strToInt(node.wireguard_mtu),
private_key: node.wireguard_private_key,
@@ -425,14 +217,13 @@ function generate_outbound(node) {
if (type(node) !== 'object' || isEmpty(node))
return null;
const tls_utls_value = (node.type === 'anytls' && isEmpty(node.tls_utls)) ? 'chrome' : node.tls_utls;
const outbound = {
type: node.type,
tag: get_section_outbound_tag(node['.name']),
tag: 'cfg-' + node['.name'] + '-out',
routing_mark: strToInt(self_mark),
server: (node.type !== 'direct') ? node.address : null,
server_port: (node.type !== 'direct') ? strToInt(node.port) : null,
server: node.address,
server_port: strToInt(node.port),
/* Hysteria(2) */
server_ports: node.hysteria_hopping_port,
@@ -440,6 +231,10 @@ function generate_outbound(node) {
user: (node.type === 'ssh') ? node.username : null,
password: node.password,
/* Direct */
override_address: node.override_address,
override_port: strToInt(node.override_port),
proxy_protocol: strToInt(node.proxy_protocol),
/* AnyTLS */
idle_session_check_interval: strToTime(node.anytls_idle_session_check_interval),
idle_session_timeout: strToTime(node.anytls_idle_session_timeout),
@@ -511,9 +306,9 @@ function generate_outbound(node) {
config: node.tls_ech_config,
config_path: node.tls_ech_config_path
} : null,
utls: !isEmpty(tls_utls_value) ? {
utls: !isEmpty(node.tls_utls) ? {
enabled: true,
fingerprint: tls_utls_value
fingerprint: node.tls_utls
} : null,
reality: (node.tls_reality === '1') ? {
enabled: true,
@@ -569,10 +364,10 @@ function get_outbound(cfg) {
const node = uci.get(uciconfig, cfg, 'node');
if (isEmpty(node))
die(sprintf("%s's node is missing, please check your configuration.", cfg));
else if (node in ['urltest', 'selector'])
return get_section_outbound_tag(cfg);
else if (node === 'urltest')
return 'cfg-' + cfg + '-out';
else
return get_section_outbound_tag(node);
return 'cfg-' + node + '-out';
}
}
}
@@ -595,117 +390,10 @@ function get_ruleset(cfg) {
return null;
let rules = [];
for (let i in cfg) {
if (isEmpty(i)) {
push(rules, null);
continue;
}
const ruleset = uci.get_all(uciconfig, i);
push(rules, !isEmpty(ruleset?.tag) ? ruleset.tag : ('cfg-' + i + '-rule'));
}
for (let i in cfg)
push(rules, isEmpty(i) ? null : 'cfg-' + i + '-rule');
return rules;
}
function subscription_provider_name(name) {
name = trim(name || '');
return name;
}
function unique_provider_name(name, used) {
const base = name;
let suffix = 2;
while (used[name]) {
name = sprintf('%s (%d)', base, suffix);
suffix++;
}
used[name] = true;
return name;
}
function get_subscription_info(group_hash) {
const value = uci.get(uciconfig, 'subscription', 'subinfo_' + substr(group_hash, 0, 16));
if (isEmpty(value))
return null;
try {
const info = json(value);
if (type(info) !== 'object')
return null;
const has_subscription_info = ('upload' in info) || ('download' in info) ||
('total' in info) || ('expire' in info);
return {
updated_at: info.updated_at,
subscription_info: has_subscription_info ? {
upload: info.upload,
download: info.download,
total: info.total,
expire: info.expire
} : null
};
} catch (e) {
return null;
}
}
function build_proxy_providers() {
let providers = [],
used_names = {},
subscription_names = normalize_list(uci.get(uciconfig, 'subscription', 'subscription_name')),
sub_index = 0;
for (let suburl in normalize_list(uci.get(uciconfig, 'subscription', 'subscription_url'))) {
const subscription_name = subscription_names[sub_index];
sub_index++;
if (isEmpty(suburl) || isEmpty(trim(subscription_name || '')))
continue;
const url = replace(suburl, /#.*$/, ''),
group_hash = md5(url);
let proxies = [];
uci.foreach(uciconfig, ucinode, (cfg) => {
if (cfg.grouphash !== group_hash)
return;
const tag = get_section_outbound_tag(cfg['.name']);
if (!isEmpty(tag) && !~index(proxies, tag))
push(proxies, tag);
});
if (isEmpty(proxies))
continue;
const subscription_info = get_subscription_info(group_hash);
push(providers, {
name: unique_provider_name(subscription_provider_name(subscription_name), used_names),
type: 'Proxy',
vehicle_type: 'HTTP',
proxies: proxies,
update_id: (routing_mode === 'custom') ? group_hash : null,
updated_at: subscription_info?.updated_at,
subscription_info: subscription_info?.subscription_info
});
}
return providers;
}
clash_api = {
external_controller: uci.get(uciconfig, uciclashapi, 'external_controller') || '127.0.0.1:9090',
external_ui: uci.get(uciconfig, uciclashapi, 'external_ui'),
external_ui_download_url: uci.get(uciconfig, uciclashapi, 'external_ui_download_url'),
external_ui_download_detour: get_outbound(uci.get(uciconfig, uciclashapi, 'external_ui_download_detour')),
secret: uci.get(uciconfig, uciclashapi, 'secret'),
default_mode: uci.get(uciconfig, uciclashapi, 'default_mode') || 'rule',
proxy_providers: build_proxy_providers()
};
/* Config helper end */
const config = {};
@@ -721,10 +409,8 @@ config.log = {
/* NTP */
if (!isEmpty(ntp_server))
config.ntp = {
enabled: ntp_enabled === '1',
enabled: true,
server: ntp_server,
server_port: strToInt(ntp_server_port),
interval: ntp_interval,
detour: 'direct-out',
domain_resolver: 'default-dns',
};
@@ -834,7 +520,10 @@ if (!isEmpty(main_node)) {
push(config.dns.servers, {
tag: 'cfg-' + cfg['.name'] + '-dns',
...parse_custom_dnsserver(cfg),
type: cfg.type,
server: cfg.server,
server_port: strToInt(cfg.server_port),
path: cfg.path,
headers: cfg.headers,
tls: cfg.tls_sni ? {
enabled: true,
@@ -876,6 +565,7 @@ if (!isEmpty(main_node)) {
user: cfg.user,
rule_set: get_ruleset(cfg.rule_set),
rule_set_ip_cidr_match_source: strToBool(cfg.rule_set_ip_cidr_match_source),
rule_set_ip_cidr_accept_empty: strToBool(cfg.rule_set_ip_cidr_accept_empty),
invert: strToBool(cfg.invert),
outbound: get_outbound(cfg.outbound),
action: cfg.action,
@@ -916,6 +606,8 @@ push(config.inbounds, {
listen: '::',
listen_port: int(mixed_port),
udp_timeout: strToTime(udp_timeout),
sniff: true,
sniff_override_destination: strToBool(sniff_override),
set_system_proxy: false
});
@@ -925,7 +617,9 @@ if (match(proxy_mode, /redirect/))
tag: 'redirect-in',
listen: '::',
listen_port: int(redirect_port)
listen_port: int(redirect_port),
sniff: true,
sniff_override_destination: strToBool(sniff_override)
});
if (match(proxy_mode, /tproxy/))
push(config.inbounds, {
@@ -935,7 +629,9 @@ if (match(proxy_mode, /tproxy/))
listen: '::',
listen_port: int(tproxy_port),
network: 'udp',
udp_timeout: strToTime(udp_timeout)
udp_timeout: strToTime(udp_timeout),
sniff: true,
sniff_override_destination: strToBool(sniff_override)
});
if (match(proxy_mode, /tun/))
push(config.inbounds, {
@@ -946,8 +642,11 @@ if (match(proxy_mode, /tun/))
address: (ipv6_support === '1') ? [tun_addr4, tun_addr6] : [tun_addr4],
mtu: strToInt(tun_mtu),
auto_route: false,
endpoint_independent_nat: strToBool(endpoint_independent_nat),
udp_timeout: strToTime(udp_timeout),
stack: tcpip_stack
stack: tcpip_stack,
sniff: true,
sniff_override_destination: strToBool(sniff_override)
});
/* Inbound end */
@@ -972,16 +671,14 @@ if (!isEmpty(main_node)) {
let urltest_nodes = [];
if (main_node === 'urltest') {
const main_urltest_nodes = filter_existing_nodes(
normalize_list(uci.get(uciconfig, ucimain, 'main_urltest_nodes'))
);
const main_urltest_nodes = uci.get(uciconfig, ucimain, 'main_urltest_nodes') || [];
const main_urltest_interval = uci.get(uciconfig, ucimain, 'main_urltest_interval');
const main_urltest_tolerance = uci.get(uciconfig, ucimain, 'main_urltest_tolerance');
push(config.outbounds, {
type: 'urltest',
tag: 'main-out',
outbounds: map(main_urltest_nodes, (k) => get_section_outbound_tag(k)),
outbounds: map(main_urltest_nodes, (k) => `cfg-${k}-out`),
interval: strToTime(main_urltest_interval),
tolerance: strToInt(main_urltest_tolerance),
idle_timeout: (strToInt(main_urltest_interval) > 1800) ? `${main_urltest_interval * 2}s` : null,
@@ -990,31 +687,23 @@ if (!isEmpty(main_node)) {
} else {
const main_node_cfg = uci.get_all(uciconfig, main_node) || {};
if (main_node_cfg.type === 'wireguard') {
const main_endpoint = generate_endpoint(main_node_cfg);
if (main_endpoint) {
main_endpoint.tag = 'main-out';
push(config.endpoints, main_endpoint);
}
push(config.endpoints, generate_endpoint(main_node_cfg));
config.endpoints[length(config.endpoints)-1].tag = 'main-out';
} else {
const main_outbound = generate_outbound(main_node_cfg);
if (main_outbound) {
main_outbound.tag = 'main-out';
push(config.outbounds, main_outbound);
}
push(config.outbounds, generate_outbound(main_node_cfg));
config.outbounds[length(config.outbounds)-1].tag = 'main-out';
}
}
if (main_udp_node === 'urltest') {
const main_udp_urltest_nodes = filter_existing_nodes(
normalize_list(uci.get(uciconfig, ucimain, 'main_udp_urltest_nodes'))
);
const main_udp_urltest_nodes = uci.get(uciconfig, ucimain, 'main_udp_urltest_nodes') || [];
const main_udp_urltest_interval = uci.get(uciconfig, ucimain, 'main_udp_urltest_interval');
const main_udp_urltest_tolerance = uci.get(uciconfig, ucimain, 'main_udp_urltest_tolerance');
push(config.outbounds, {
type: 'urltest',
tag: 'main-udp-out',
outbounds: map(main_udp_urltest_nodes, (k) => get_section_outbound_tag(k)),
outbounds: map(main_udp_urltest_nodes, (k) => `cfg-${k}-out`),
interval: strToTime(main_udp_urltest_interval),
tolerance: strToInt(main_udp_urltest_tolerance),
idle_timeout: (strToInt(main_udp_urltest_interval) > 1800) ? `${main_udp_urltest_interval * 2}s` : null,
@@ -1023,37 +712,22 @@ if (!isEmpty(main_node)) {
} else if (dedicated_udp_node) {
const main_udp_node_cfg = uci.get_all(uciconfig, main_udp_node) || {};
if (main_udp_node_cfg.type === 'wireguard') {
const main_udp_endpoint = generate_endpoint(main_udp_node_cfg);
if (main_udp_endpoint) {
main_udp_endpoint.tag = 'main-udp-out';
push(config.endpoints, main_udp_endpoint);
}
push(config.endpoints, generate_endpoint(main_udp_node_cfg));
config.endpoints[length(config.endpoints)-1].tag = 'main-udp-out';
} else {
const main_udp_outbound = generate_outbound(main_udp_node_cfg);
if (main_udp_outbound) {
main_udp_outbound.tag = 'main-udp-out';
push(config.outbounds, main_udp_outbound);
}
push(config.outbounds, generate_outbound(main_udp_node_cfg));
config.outbounds[length(config.outbounds)-1].tag = 'main-udp-out';
}
}
for (let i in urltest_nodes) {
const urltest_node = uci.get_all(uciconfig, i) || {};
if (isEmpty(urltest_node))
continue;
if (urltest_node.type === 'wireguard') {
const endpoint = generate_endpoint(urltest_node);
if (endpoint) {
endpoint.tag = get_section_outbound_tag(i);
push(config.endpoints, endpoint);
}
push(config.endpoints, generate_endpoint(urltest_node));
config.endpoints[length(config.endpoints)-1].tag = 'cfg-' + i + '-out';
} else {
const outbound = generate_outbound(urltest_node);
if (outbound) {
outbound.tag = get_section_outbound_tag(i);
push(config.outbounds, outbound);
}
push(config.outbounds, generate_outbound(urltest_node));
config.outbounds[length(config.outbounds)-1].tag = 'cfg-' + i + '-out';
}
}
} else if (!isEmpty(default_outbound)) {
@@ -1065,63 +739,37 @@ if (!isEmpty(main_node)) {
return;
if (cfg.node === 'urltest') {
const legacy_nodes = (isEmpty(cfg.subscription_groups) && isEmpty(cfg.subscription_nodes) && isEmpty(cfg.selected_nodes)) ? cfg.urltest_nodes : null;
const urltest_list = collect_group_nodes(cfg.subscription_groups, cfg.subscription_nodes, cfg.selected_nodes, legacy_nodes);
push(config.outbounds, {
type: 'urltest',
tag: get_section_outbound_tag(cfg['.name']),
outbounds: map(urltest_list, (k) => get_section_outbound_tag(k)),
tag: 'cfg-' + cfg['.name'] + '-out',
outbounds: map(cfg.urltest_nodes, (k) => `cfg-${k}-out`),
url: cfg.urltest_url,
interval: strToTime(cfg.urltest_interval),
tolerance: strToInt(cfg.urltest_tolerance),
idle_timeout: strToTime(cfg.urltest_idle_timeout),
interrupt_exist_connections: strToBool(cfg.urltest_interrupt_exist_connections)
});
urltest_nodes = [...urltest_nodes, ...filter(urltest_list, (l) => !~index(urltest_nodes, l))];
} else if (cfg.node === 'selector') {
const selector_node_list = collect_group_nodes(cfg.subscription_groups, cfg.subscription_nodes, cfg.selected_nodes, null);
const selector_policy_list = collect_policy_nodes(cfg.policy_nodes, cfg['.name']);
const selector_list = [...selector_node_list, ...filter(selector_policy_list, (l) => !~index(selector_node_list, l))];
const selector_default = (!isEmpty(cfg.selector_default) && ~index(selector_list, cfg.selector_default)) ? cfg.selector_default : null;
push(config.outbounds, {
type: 'selector',
tag: get_section_outbound_tag(cfg['.name']),
outbounds: map(selector_list, (k) => get_section_outbound_tag(k)),
default: selector_default ? get_section_outbound_tag(selector_default) : null,
interrupt_exist_connections: strToBool(cfg.selector_interrupt_exist_connections)
});
urltest_nodes = [...urltest_nodes, ...filter(selector_node_list, (l) => !~index(urltest_nodes, l))];
urltest_nodes = [...urltest_nodes, ...filter(cfg.urltest_nodes, (l) => !~index(urltest_nodes, l))];
} else {
const outbound = uci.get_all(uciconfig, cfg.node) || {};
if (isEmpty(outbound))
return;
if (outbound.type === 'wireguard') {
const endpoint = generate_endpoint(outbound);
if (!endpoint)
return;
endpoint.bind_interface = cfg.bind_interface;
endpoint.detour = get_outbound(cfg.outbound);
push(config.endpoints, generate_endpoint(outbound));
config.endpoints[length(config.endpoints)-1].bind_interface = cfg.bind_interface;
config.endpoints[length(config.endpoints)-1].detour = get_outbound(cfg.outbound);
if (cfg.domain_resolver)
endpoint.domain_resolver = {
config.endpoints[length(config.endpoints)-1].domain_resolver = {
server: get_resolver(cfg.domain_resolver),
strategy: cfg.domain_strategy
};
push(config.endpoints, endpoint);
} else {
const routed_outbound = generate_outbound(outbound);
if (!routed_outbound)
return;
routed_outbound.bind_interface = cfg.bind_interface;
routed_outbound.detour = get_outbound(cfg.outbound);
push(config.outbounds, generate_outbound(outbound));
config.outbounds[length(config.outbounds)-1].bind_interface = cfg.bind_interface;
config.outbounds[length(config.outbounds)-1].detour = get_outbound(cfg.outbound);
if (cfg.domain_resolver)
routed_outbound.domain_resolver = {
config.outbounds[length(config.outbounds)-1].domain_resolver = {
server: get_resolver(cfg.domain_resolver),
strategy: cfg.domain_strategy
};
push(config.outbounds, routed_outbound);
}
push(routing_nodes, cfg.node);
}
@@ -1129,18 +777,10 @@ if (!isEmpty(main_node)) {
for (let i in filter(urltest_nodes, (l) => !~index(routing_nodes, l))) {
const urltest_node = uci.get_all(uciconfig, i) || {};
if (isEmpty(urltest_node))
continue;
if (urltest_node.type === 'wireguard') {
const endpoint = generate_endpoint(urltest_node);
if (endpoint)
push(config.endpoints, endpoint);
} else {
const outbound = generate_outbound(urltest_node);
if (outbound)
push(config.outbounds, outbound);
}
if (urltest_node.type === 'wireguard')
push(config.endpoints, generate_endpoint(urltest_node));
else
push(config.outbounds, generate_outbound(urltest_node));
}
}
@@ -1155,10 +795,13 @@ config.route = {
{
inbound: 'dns-in',
action: 'hijack-dns'
},
{
action: 'sniff'
}
/*
* leave for sing-box 1.13.0
* {
* action: 'sniff'
* }
*/
],
rule_set: [],
auto_detect_interface: isEmpty(default_interface) ? true : null,
@@ -1223,7 +866,6 @@ if (!isEmpty(main_node)) {
tag: 'geoip-cn',
format: 'binary',
url: 'https://fastly.jsdelivr.net/gh/1715173329/IPCIDR-CHINA@rule-set/cn.srs',
path: ruleset_default_path('geoip-cn', 'binary'),
download_detour: 'main-out'
});
push(config.route.rule_set, {
@@ -1231,7 +873,6 @@ if (!isEmpty(main_node)) {
tag: 'geosite-cn',
format: 'binary',
url: 'https://fastly.jsdelivr.net/gh/1715173329/sing-geosite@rule-set-unstable/geosite-geolocation-cn.srs',
path: ruleset_default_path('geosite-cn', 'binary'),
download_detour: 'main-out'
});
push(config.route.rule_set, {
@@ -1239,7 +880,6 @@ if (!isEmpty(main_node)) {
tag: 'geosite-noncn',
format: 'binary',
url: 'https://fastly.jsdelivr.net/gh/1715173329/sing-geosite@rule-set-unstable/geosite-geolocation-!cn.srs',
path: ruleset_default_path('geosite-noncn', 'binary'),
download_detour: 'main-out'
});
}
@@ -1284,25 +924,17 @@ if (!isEmpty(main_node)) {
user: cfg.user,
rule_set: get_ruleset(cfg.rule_set),
rule_set_ip_cidr_match_source: strToBool(cfg.rule_set_ip_cidr_match_source),
rule_set_ip_cidr_accept_empty: strToBool(cfg.rule_set_ip_cidr_accept_empty),
invert: strToBool(cfg.invert),
action: cfg.action,
outbound: (cfg.action === 'route') ? get_outbound(cfg.outbound) : null,
server: (cfg.action === 'resolve') ? get_resolver(cfg.resolve_server) : null,
strategy: (cfg.action === 'resolve') ? cfg.resolve_strategy : null,
disable_cache: (cfg.action === 'resolve') ? strToBool(cfg.resolve_disable_cache) : null,
rewrite_ttl: (cfg.action === 'resolve') ? strToInt(cfg.resolve_rewrite_ttl) : null,
client_subnet: (cfg.action === 'resolve') ? cfg.resolve_client_subnet : null,
override_address: (cfg.action in ['route', 'route-options']) ? cfg.override_address : null,
override_port: (cfg.action in ['route', 'route-options']) ? strToInt(cfg.override_port) : null,
udp_disable_domain_unmapping: (cfg.action in ['route', 'route-options']) ? strToBool(cfg.udp_disable_domain_unmapping) : null,
udp_connect: (cfg.action in ['route', 'route-options']) ? strToBool(cfg.udp_connect) : null,
udp_timeout: (cfg.action in ['route', 'route-options']) ? strToTime(cfg.udp_timeout) : null,
tls_fragment: (cfg.action in ['route', 'route-options']) ? strToBool(cfg.tls_fragment) : null,
tls_fragment_fallback_delay: (cfg.action in ['route', 'route-options']) ? strToTime(cfg.tls_fragment_fallback_delay) : null,
tls_record_fragment: (cfg.action in ['route', 'route-options']) ? strToBool(cfg.tls_record_fragment) : null,
method: (cfg.action === 'reject') ? cfg.reject_method : null,
no_drop: (cfg.action === 'reject') ? strToBool(cfg.reject_no_drop) : null
outbound: get_outbound(cfg.outbound),
override_address: cfg.override_address,
override_port: strToInt(cfg.override_port),
udp_disable_domain_unmapping: strToBool(cfg.udp_disable_domain_unmapping),
udp_connect: strToBool(cfg.udp_connect),
udp_timeout: strToTime(cfg.udp_timeout),
tls_fragment: strToBool(cfg.tls_fragment),
tls_fragment_fallback_delay: strToTime(cfg.tls_fragment_fallback_delay),
tls_record_fragment: strToBool(cfg.tls_record_fragment)
});
});
@@ -1313,16 +945,14 @@ if (!isEmpty(main_node)) {
if (cfg.enabled !== '1')
return null;
const tag = !isEmpty(cfg.tag) ? cfg.tag : ('cfg-' + cfg['.name'] + '-rule');
push(config.route.rule_set, {
type: cfg.type,
tag: tag,
tag: 'cfg-' + cfg['.name'] + '-rule',
format: cfg.format,
path: cfg.path,
url: cfg.url,
path: (cfg.type === 'remote') ? ruleset_remote_path(cfg.remote_path || cfg.path, tag, cfg.format) : cfg.path,
download_detour: get_outbound(cfg.outbound),
update_interval: (cfg.type === 'remote') ? '87600h' : null
update_interval: cfg.update_interval
});
});
}
@@ -1331,17 +961,15 @@ if (!isEmpty(main_node)) {
/* Experimental start */
if (routing_mode in ['bypass_mainland_china', 'custom']) {
config.experimental = {
clash_api,
cache_file: {
enabled: cache_file_enabled !== '0',
path: cache_file_path || (HP_DIR + '/cache.db'),
store_rdrc: strToBool(cache_store_rdrc),
rdrc_timeout: strToTime(cache_rdrc_timeout),
enabled: true,
path: RUN_DIR + '/cache.db',
store_rdrc: strToBool(cache_file_store_rdrc),
rdrc_timeout: strToTime(cache_file_rdrc_timeout),
}
};
}
/* Experimental end */
system('mkdir -p ' + RUN_DIR);
system('mkdir -p ' + RULESET_DIR);
writefile(RUN_DIR + '/sing-box-c.json', sprintf('%.J\n', removeBlankAttrs(config)));
@@ -67,7 +67,7 @@ uci.foreach(uciconfig, uciserver, (cfg) => {
password: cfg.hysteria_obfs_password
} : cfg.hysteria_obfs_password,
recv_window_conn: strToInt(cfg.hysteria_recv_window_conn),
recv_window_client: strToInt(cfg.hysteria_recv_window_client),
recv_window_client: strToInt(cfg.hysteria_revc_window_client),
max_conn_client: strToInt(cfg.hysteria_max_conn_client),
disable_mtu_discovery: strToBool(cfg.hysteria_disable_mtu_discovery),
ignore_client_bandwidth: strToBool(cfg.hysteria_ignore_client_bandwidth),
+3 -22
View File
@@ -66,34 +66,15 @@ export function getTime(epoch) {
};
export function wGETResponse(url, ua) {
export function wGET(url, ua) {
if (!url || type(url) !== 'string')
return null;
if (!ua)
ua = 'Wget/1.21 (HomeProxy, like v2rayN)';
const output = executeCommand(`/usr/bin/wget -O- -S --user-agent ${shellQuote(ua)} --timeout=10 ${shellQuote(url)}`) || {};
return {
body: trim(output.stdout),
headers: output.stderr || '',
exitcode: output.exitcode
};
};
export function wGET(url, ua) {
return wGETResponse(url, ua)?.body;
};
export function wGETHeaders(url, ua) {
if (!url || type(url) !== 'string')
return null;
if (!ua)
ua = 'clash.meta';
const output = executeCommand(`/usr/bin/wget -O /dev/null -S --user-agent ${shellQuote(ua)} --timeout=10 ${shellQuote(url)}`) || {};
return output.stderr || '';
const output = executeCommand(`/usr/bin/wget -qO- --user-agent ${shellQuote(ua)} --timeout=10 ${shellQuote(url)}`) || {};
return trim(output.stdout);
};
/* Utilities end */
@@ -7,34 +7,14 @@
'use strict';
import { popen } from 'fs';
import { cursor } from 'uci';
import { isEmpty, parseURL } from 'homeproxy';
import { isEmpty, parseURL, validation } from 'homeproxy';
const uci = cursor();
const uciconfig = 'homeproxy';
uci.load(uciconfig);
function random_secret() {
const fd = popen('tr -dc "A-Za-z0-9" < /dev/urandom 2>/dev/null | head -c 16');
let random = '';
if (fd) {
random = trim(fd.read('all') || '');
fd.close();
}
if (isEmpty(random)) {
const fallback = popen('awk \'BEGIN{srand(); printf "%06d", int(rand() * 1000000)}\'');
if (fallback) {
random = trim(fallback.read('all') || '');
fallback.close();
}
}
return random;
}
const uciinfra = 'infra',
ucimigration = 'migration',
ucimain = 'config',
@@ -45,16 +25,8 @@ const uciinfra = 'infra',
ucirouting = 'routing',
uciroutingnode = 'routing_node',
uciroutingrule = 'routing_rule',
uciclashapi = 'clash_api',
ucintp = 'ntp',
ucicache = 'cache',
uciserver = 'server';
function is_update_cron(value) {
let matched = match(value || '', /^(\d{1,2})\s+(\d{1,2})\s+\*\s+\*\s+([0-7*])$/);
return !isEmpty(matched) && int(matched[1]) <= 59 && int(matched[2]) <= 23;
}
/* chinadns-ng has been removed */
if (uci.get(uciconfig, uciinfra, 'china_dns_port'))
uci.delete(uciconfig, uciinfra, 'china_dns_port');
@@ -64,7 +36,9 @@ const china_dns_server = uci.get(uciconfig, ucimain, 'china_dns_server');
if (type(china_dns_server) === 'array') {
uci.set(uciconfig, ucimain, 'china_dns_server', china_dns_server[0]);
} else {
if (match(china_dns_server, /,/))
if (china_dns_server === 'wan_114')
uci.set(uciconfig, ucimain, 'china_dns_server', '114.114.114.114');
else if (match(china_dns_server, /,/))
uci.set(uciconfig, ucimain, 'china_dns_server', split(china_dns_server, ',')[0]);
}
@@ -83,93 +57,6 @@ if (!uci.get(uciconfig, uciinfra, 'ntp_server'))
if (!isEmpty(uci.get(uciconfig, uciinfra, 'tun_gso')))
uci.delete(uciconfig, uciinfra, 'tun_gso');
/* endpoint_independent_nat was removed in sing-box 1.13 */
if (!isEmpty(uci.get(uciconfig, ucirouting, 'endpoint_independent_nat')))
uci.delete(uciconfig, ucirouting, 'endpoint_independent_nat');
/* direct outbound proxy_protocol was removed in sing-box 1.13 */
uci.foreach(uciconfig, ucinode, (cfg) => {
if (cfg.type === 'direct' && !isEmpty(cfg.proxy_protocol))
uci.delete(uciconfig, cfg['.name'], 'proxy_protocol');
});
const legacy_panel_url = 'https://github.com/Zephyruso/zashboard/releases/latest/download/dist.zip';
const legacy_panel_proxy_url = 'https://gh-proxy.com/https://github.com/Zephyruso/zashboard/releases/latest/download/dist.zip';
const old_panel_url = 'https://github.com/Zephyruso/zashboard/releases/latest/download/dist-cdn-fonts.zip';
const old_panel_proxy_url = 'https://gh-proxy.com/https://github.com/Zephyruso/zashboard/releases/latest/download/dist-cdn-fonts.zip';
const default_panel_url = 'https://gh-proxy.com/https://github.com/Zephyruso/zashboard/releases/latest/download/dist-cdn-fonts.zip';
/* clash api panel options were introduced */
if (!uci.get(uciconfig, uciclashapi))
uci.set(uciconfig, uciclashapi, uciconfig);
if (isEmpty(uci.get(uciconfig, uciclashapi, 'external_ui')))
uci.set(uciconfig, uciclashapi, 'external_ui', '/etc/homeproxy/run/ui');
const panel_url = uci.get(uciconfig, uciclashapi, 'external_ui_download_url');
if (isEmpty(panel_url) || panel_url === legacy_panel_url || panel_url === legacy_panel_proxy_url || panel_url === old_panel_proxy_url)
uci.set(uciconfig, uciclashapi, 'external_ui_download_url', default_panel_url);
if (isEmpty(uci.get(uciconfig, uciclashapi, 'external_ui_download_detour')))
uci.set(uciconfig, uciclashapi, 'external_ui_download_detour', 'direct-out');
if (isEmpty(uci.get(uciconfig, uciclashapi, 'external_controller')))
uci.set(uciconfig, uciclashapi, 'external_controller', '0.0.0.0:9095');
if (isEmpty(uci.get(uciconfig, uciclashapi, 'secret')) || uci.get(uciconfig, uciclashapi, 'secret') === 'homeproxy') {
let random = random_secret();
if (!isEmpty(random))
uci.set(uciconfig, uciclashapi, 'secret', random);
}
if (isEmpty(uci.get(uciconfig, uciclashapi, 'default_mode')))
uci.set(uciconfig, uciclashapi, 'default_mode', 'rule');
/* ntp options were moved into a dedicated section */
if (!uci.get(uciconfig, ucintp))
uci.set(uciconfig, ucintp, uciconfig);
const legacy_ntp_server = uci.get(uciconfig, uciinfra, 'ntp_server');
if (isEmpty(uci.get(uciconfig, ucintp, 'enabled')))
uci.set(uciconfig, ucintp, 'enabled', '1');
if (isEmpty(uci.get(uciconfig, ucintp, 'server')))
uci.set(uciconfig, ucintp, 'server', !isEmpty(legacy_ntp_server) ? legacy_ntp_server : 'ntp.aliyun.com');
if (isEmpty(uci.get(uciconfig, ucintp, 'server_port')))
uci.set(uciconfig, ucintp, 'server_port', '123');
if (isEmpty(uci.get(uciconfig, ucintp, 'interval')))
uci.set(uciconfig, ucintp, 'interval', '30m');
/* cache file options were moved into a dedicated section */
if (!uci.get(uciconfig, ucicache))
uci.set(uciconfig, ucicache, uciconfig);
if (isEmpty(uci.get(uciconfig, ucicache, 'enabled')))
uci.set(uciconfig, ucicache, 'enabled', '1');
const old_cache_path = '/var/run/homeproxy/cache.db';
const default_cache_path = '/etc/homeproxy/cache.db';
const cache_path = uci.get(uciconfig, ucicache, 'path');
if (isEmpty(cache_path) || cache_path === old_cache_path)
uci.set(uciconfig, ucicache, 'path', default_cache_path);
if (!isEmpty(uci.get(uciconfig, ucicache, 'store_fakeip')))
uci.delete(uciconfig, ucicache, 'store_fakeip');
if (isEmpty(uci.get(uciconfig, ucicache, 'store_rdrc')))
uci.set(uciconfig, ucicache, 'store_rdrc', isEmpty(uci.get(uciconfig, ucidns, 'cache_file_store_rdrc')) ? '1' : uci.get(uciconfig, ucidns, 'cache_file_store_rdrc'));
if (isEmpty(uci.get(uciconfig, ucicache, 'rdrc_timeout')) && !isEmpty(uci.get(uciconfig, ucidns, 'cache_file_rdrc_timeout')))
uci.set(uciconfig, ucicache, 'rdrc_timeout', uci.get(uciconfig, ucidns, 'cache_file_rdrc_timeout'));
if (!isEmpty(uci.get(uciconfig, ucidns, 'cache_file_store_rdrc')))
uci.delete(uciconfig, ucidns, 'cache_file_store_rdrc');
if (!isEmpty(uci.get(uciconfig, ucidns, 'cache_file_rdrc_timeout')))
uci.delete(uciconfig, ucidns, 'cache_file_rdrc_timeout');
/* create migration section */
if (!uci.get(uciconfig, ucimigration))
uci.set(uciconfig, ucimigration, uciconfig);
@@ -188,10 +75,6 @@ if (isEmpty(uci.get(uciconfig, ucimain, 'log_level')))
if (isEmpty(uci.get(uciconfig, uciserver, 'log_level')))
uci.set(uciconfig, uciserver, 'log_level', 'warn');
if (!isEmpty(uci.get(uciconfig, 'subscription', 'auto_update_time')) &&
!is_update_cron(uci.get(uciconfig, 'subscription', 'auto_update_time')))
uci.set(uciconfig, 'subscription', 'auto_update_time', '0 0 * * *');
/* empty value defaults to all ports now */
if (uci.get(uciconfig, ucimain, 'routing_port') === 'all')
uci.delete(uciconfig, ucimain, 'routing_port');
@@ -356,47 +239,6 @@ uci.foreach(uciconfig, uciroutingrule, (cfg) => {
}
});
/* routing node options */
uci.foreach(uciconfig, uciroutingnode, (cfg) => {
if (cfg.node === 'urltest' && !isEmpty(cfg.urltest_nodes)) {
let custom_nodes = [],
subscription_nodes = [];
for (let node in (type(cfg.urltest_nodes) === 'array' ? cfg.urltest_nodes : [ cfg.urltest_nodes ])) {
let node_cfg = uci.get_all(uciconfig, node);
if (isEmpty(node_cfg))
continue;
if (!isEmpty(node_cfg.grouphash))
push(subscription_nodes, node);
else
push(custom_nodes, node);
}
if (isEmpty(cfg.selected_nodes) && !isEmpty(custom_nodes))
uci.set(uciconfig, cfg['.name'], 'selected_nodes', custom_nodes);
if (isEmpty(cfg.subscription_nodes) && !isEmpty(subscription_nodes))
uci.set(uciconfig, cfg['.name'], 'subscription_nodes', subscription_nodes);
uci.delete(uciconfig, cfg['.name'], 'urltest_nodes');
}
});
/* rule set options */
uci.foreach(uciconfig, uciruleset, (cfg) => {
if (isEmpty(cfg.tag))
uci.set(uciconfig, cfg['.name'], 'tag', 'cfg-' + cfg['.name'] + '-rule');
if (cfg.type === 'remote') {
if (isEmpty(cfg.auto_update))
uci.set(uciconfig, cfg['.name'], 'auto_update', '1');
if (!is_update_cron(cfg.update_interval))
uci.set(uciconfig, cfg['.name'], 'update_interval', '0 0 * * *');
}
});
/* server options */
/* auto_firewall was moved into server options */
const auto_firewall = uci.get(uciconfig, uciserver, 'auto_firewall');
@@ -404,13 +246,6 @@ if (!isEmpty(auto_firewall))
uci.delete(uciconfig, uciserver, 'auto_firewall');
uci.foreach(uciconfig, uciserver, (cfg) => {
if (!isEmpty(cfg.hysteria_revc_window_client) && isEmpty(cfg.hysteria_recv_window_client)) {
uci.set(uciconfig, cfg['.name'], 'hysteria_recv_window_client', cfg.hysteria_revc_window_client);
}
if (!isEmpty(cfg.hysteria_revc_window_client))
uci.delete(uciconfig, cfg['.name'], 'hysteria_revc_window_client');
/* auto_firewall was moved into server options */
if (auto_firewall === '1')
uci.set(uciconfig, cfg['.name'], 'firewall' , '1');
@@ -1,46 +0,0 @@
#!/bin/sh
# SPDX-License-Identifier: GPL-2.0-only
set -eu
NAME="homeproxy"
RUN_DIR="/var/run/$NAME"
REQUEST_FILE="$RUN_DIR/provider-update-id"
LOCK_FILE="$RUN_DIR/provider-update-v2.lock"
LOG_FILE="$RUN_DIR/homeproxy.log"
PROVIDER_ID="${1:-}"
log() {
printf '%s [SUBSCRIBE] %s\n' "$(date '+%Y-%m-%d %H:%M:%S')" "$*" >> "$LOG_FILE"
}
case "$PROVIDER_ID" in
*[!0-9a-f]*|'') exit 1 ;;
esac
[ "${#PROVIDER_ID}" -eq 32 ] || exit 1
mkdir -p "$RUN_DIR"
if ! lock -n "$LOCK_FILE" 2>/dev/null; then
log "Another provider update is running; waiting for it to finish..."
lock "$LOCK_FILE"
fi
umask 077
printf '%s\n' "$PROVIDER_ID" > "$REQUEST_FILE"
cleanup() {
rm -f "$REQUEST_FILE"
lock -u "$LOCK_FILE" 2>/dev/null || true
}
trap cleanup EXIT
trap 'exit 130' INT
trap 'exit 143' TERM
# Give the Clash API response time to reach the panel before HomeProxy restarts.
log "Updating provider $PROVIDER_ID from Clash API..."
sleep 1
if /etc/homeproxy/scripts/update_subscriptions.uc; then
log "Provider $PROVIDER_ID update completed."
else
log "Provider $PROVIDER_ID update failed."
exit 4
fi
@@ -21,65 +21,64 @@ to_upper() {
}
check_list_update() {
local LIST_FILE="$1"
local REPO_NAME="$2"
local REPO_BRANCH="$3"
local REPO_FILE="$4"
local LOCK_FILE="$RUN_DIR/update_resources-$LIST_FILE.lock"
local GITHUB_TOKEN="$(uci -q get homeproxy.config.github_token)"
local listtype="$1"
local listrepo="$2"
local listref="$3"
local listname="$4"
local lock="$RUN_DIR/update_resources-$listtype.lock"
local github_token="$(uci -q get homeproxy.config.github_token)"
local wget="wget --timeout=10 -q"
if ! lock -n "$LOCK_FILE" 2>"/dev/null"; then
log "[$(to_upper "$LIST_FILE")] A task is already running."
exec 200>"$lock"
if ! flock -n 200 &> "/dev/null"; then
log "[$(to_upper "$listtype")] A task is already running."
return 2
fi
local NEW_VER=$(curl -sL ${GITHUB_TOKEN:+-H "Authorization: Bearer $GITHUB_TOKEN"} "https://api.github.com/repos/$REPO_NAME/releases/latest" | jsonfilter -e "@.tag_name")
if [ -z "$NEW_VER" ]; then
log "[$(to_upper "$LIST_FILE")] Failed to get the latest version, please retry later."
[ -z "$github_token" ] || github_token="--header=Authorization: Bearer $github_token"
local list_info="$($wget "${github_token:--q}" -O- "https://api.github.com/repos/$listrepo/commits?sha=$listref&path=$listname&per_page=1")"
local list_sha="$(echo -e "$list_info" | jsonfilter -qe "@[0].sha")"
local list_ver="$(echo -e "$list_info" | jsonfilter -qe "@[0].commit.message" | grep -Eo "[0-9-]+" | tr -d '-')"
if [ -z "$list_sha" ] || [ -z "$list_ver" ]; then
log "[$(to_upper "$listtype")] Failed to get the latest version, please retry later."
return 1
fi
local OLD_VER=$(cat "$RESOURCES_DIR/$LIST_FILE.ver" 2>/dev/null || echo "NOT FOUND")
if [ "$OLD_VER" = "$NEW_VER" ]; then
log "[$(to_upper "$LIST_FILE")] Current version: $NEW_VER."
log "[$(to_upper "$LIST_FILE")] You're already at the latest version."
local local_list_ver="$(cat "$RESOURCES_DIR/$listtype.ver" 2>"/dev/null" || echo "NOT FOUND")"
if [ "$local_list_ver" = "$list_ver" ]; then
log "[$(to_upper "$listtype")] Current version: $list_ver."
log "[$(to_upper "$listtype")] You're already at the latest version."
return 3
else
log "[$(to_upper "$LIST_FILE")] Local version: $OLD_VER, latest version: $NEW_VER."
log "[$(to_upper "$listtype")] Local version: $local_list_ver, latest version: $list_ver."
fi
if ! curl -sL -o "$RUN_DIR/$REPO_FILE" "https://cdn.jsdelivr.net/gh/$REPO_NAME@$REPO_BRANCH/$REPO_FILE" || [ ! -s "$RUN_DIR/$REPO_FILE" ]; then
rm -f "$RUN_DIR/$REPO_FILE"
log "[$(to_upper "$LIST_FILE")] Update failed."
if ! $wget "https://fastly.jsdelivr.net/gh/$listrepo@$list_sha/$listname" -O "$RUN_DIR/$listname" || [ ! -s "$RUN_DIR/$listname" ]; then
rm -f "$RUN_DIR/$listname"
log "[$(to_upper "$listtype")] Update failed."
return 1
fi
mv -f "$RUN_DIR/$REPO_FILE" "$RESOURCES_DIR/$LIST_FILE.${REPO_FILE##*.}"
echo -e "$NEW_VER" > "$RESOURCES_DIR/$LIST_FILE.ver"
log "[$(to_upper "$LIST_FILE")] Successfully updated."
mv -f "$RUN_DIR/$listname" "$RESOURCES_DIR/$listtype.${listname##*.}"
echo -e "$list_ver" > "$RESOURCES_DIR/$listtype.ver"
log "[$(to_upper "$listtype")] Successfully updated."
return 0
}
case "$1" in
"china_ip4")
check_list_update "$1" "Loyalsoldier/surge-rules" "release" "cncidr.txt" && \
sed -i "/IP-CIDR6,/d; s/IP-CIDR,//g" "$RESOURCES_DIR/china_ip4.txt"
check_list_update "$1" "1715173329/IPCIDR-CHINA" "master" "ipv4.txt"
;;
"china_ip6")
check_list_update "$1" "Loyalsoldier/surge-rules" "release" "cncidr.txt" && \
sed -i "/IP-CIDR,/d; s/IP-CIDR6,//g" "$RESOURCES_DIR/china_ip6.txt"
check_list_update "$1" "1715173329/IPCIDR-CHINA" "master" "ipv6.txt"
;;
"gfw_list")
check_list_update "$1" "Loyalsoldier/surge-rules" "release" "gfw.txt" && \
sed -i "s/^\.//g" "$RESOURCES_DIR/gfw_list.txt"
check_list_update "$1" "Loyalsoldier/v2ray-rules-dat" "release" "gfw.txt"
;;
"china_list")
check_list_update "$1" "Loyalsoldier/surge-rules" "release" "direct.txt" && \
sed -i "s/^\.//g" "$RESOURCES_DIR/china_list.txt"
check_list_update "$1" "Loyalsoldier/v2ray-rules-dat" "release" "direct-list.txt" && \
sed -i -e "s/full://g" -e "/:/d" "$RESOURCES_DIR/china_list.txt"
;;
*)
echo -e "Usage: $0 <china_ip4 / china_ip6 / gfw_list / china_list>"
@@ -1,10 +0,0 @@
#!/bin/sh
# SPDX-License-Identifier: GPL-2.0-only
#
# Copyright (C) 2025 ImmortalWrt.org
CACHE_PATH="$(uci -q get homeproxy.cache.path)"
[ -n "$CACHE_PATH" ] || CACHE_PATH="/etc/homeproxy/cache.db"
rm -f "$CACHE_PATH"
/etc/init.d/homeproxy restart
File diff suppressed because it is too large. Load diff
+23 -76
View File
@@ -27,82 +27,13 @@ log() {
echo -e "$(date "+%Y-%m-%d %H:%M:%S") [DAEMON] $*" >> "$LOG_PATH"
}
init_logs() {
mkdir -p "$RUN_DIR"
mkdir -p "$HP_DIR/run/ui"
touch "$LOG_PATH" "$RUN_DIR/sing-box-c.log" "$RUN_DIR/sing-box-s.log"
chown -R sing-box:sing-box "$RUN_DIR" 2>"/dev/null"
chown -R sing-box:sing-box "$HP_DIR/run" 2>"/dev/null"
}
valid_update_cron() {
echo "$1" | grep -Eq '^([0-9]|[0-5][0-9]) ([0-9]|[01][0-9]|2[0-3]) \* \* ([0-7]|\*)$'
}
has_ruleset_cron() {
printf '%s\n' "$ruleset_cron_list" | grep -Fxq -- "$1"
}
add_ruleset_cron() {
local section="$1"
local enabled auto_update type update_time
config_get_bool enabled "$section" "enabled" "0"
config_get_bool auto_update "$section" "auto_update" "1"
config_get type "$section" "type" "local"
config_get update_time "$section" "update_interval" ""
[ "$enabled" = "1" ] || return
[ "$auto_update" = "1" ] || return
[ "$type" = "remote" ] || return
[ -n "$update_time" ] || return
valid_update_cron "$update_time" || return
has_ruleset_cron "$update_time" && return
echo -e "$update_time sh $HP_DIR/scripts/update_rulesets.sh #${CONF}_autosetup" >> "/etc/crontabs/root"
ruleset_cron_list="${ruleset_cron_list}
${update_time}"
cron_reload="1"
}
setup_auto_update_cron() {
local cron_reload="0"
mkdir -p "/etc/crontabs"
touch "/etc/crontabs/root"
grep -q "#${CONF}_autosetup" "/etc/crontabs/root" 2>"/dev/null" && cron_reload="1"
sed -i "/#${CONF}_autosetup/d" "/etc/crontabs/root" 2>"/dev/null"
local auto_update auto_update_time
config_get_bool auto_update "subscription" "auto_update" "0"
if [ "$auto_update" = "1" ]; then
config_get auto_update_time "subscription" "auto_update_time" "0 0 * * *"
if valid_update_cron "$auto_update_time"; then
echo -e "$auto_update_time sh $HP_DIR/scripts/update_crond.sh #${CONF}_autosetup" >> "/etc/crontabs/root"
cron_reload="1"
fi
fi
local ruleset_cron_list=""
config_foreach add_ruleset_cron "ruleset"
[ "$cron_reload" = "1" ] && /etc/init.d/cron restart
}
start_service() {
init_logs
config_load "$CONF"
setup_auto_update_cron
local routing_mode proxy_mode
config_get routing_mode "config" "routing_mode" "bypass_mainland_china"
config_get proxy_mode "config" "proxy_mode" "redirect_tproxy"
local cache_path
config_get cache_path "cache" "path" "$HP_DIR/cache.db"
mkdir -p "$(dirname "$cache_path")"
[ -e "$cache_path" ] || touch "$cache_path"
chown sing-box:sing-box "$cache_path" 2>"/dev/null"
local outbound_node
if [ "$routing_mode" != "custom" ]; then
config_get outbound_node "config" "main_node" "nil"
@@ -117,6 +48,8 @@ start_service() {
return 1
fi
mkdir -p "$RUN_DIR"
if [ "$outbound_node" != "nil" ]; then
# Generate/Validate client config
ucode -S "$HP_DIR/scripts/generate_client.uc" 2>>"$LOG_PATH"
@@ -129,6 +62,16 @@ start_service() {
return 1
fi
# Auto update
local auto_update auto_update_time
config_get_bool auto_update "subscription" "auto_update" "0"
if [ "$auto_update" = "1" ]; then
config_get auto_update_time "subscription" "auto_update_time" "2"
sed -i "/#${CONF}_autosetup/d" "/etc/crontabs/root" 2>"/dev/null"
echo -e "0 $auto_update_time * * * $HP_DIR/scripts/update_crond.sh #${CONF}_autosetup" >> "/etc/crontabs/root"
/etc/init.d/cron restart
fi
# DNSMasq rules
local ipv6_support dns_port
config_get_bool ipv6_support "config" "ipv6_support" "0"
@@ -161,6 +104,8 @@ start_service() {
sed -r -e '/^\s*$/d' -e "s/(.*)/server=\/\1\/127.0.0.1#$dns_port\nnftset=\/\1\\/4#inet#fw4#homeproxy_wan_proxy_addr_v4$wan_nftset_v6/g" \
"$HP_DIR/resources/proxy_list.txt" > "$DNSMASQ_DIR/proxy_list.conf"
fi
/etc/init.d/dnsmasq restart >"/dev/null" 2>&1
# Setup routing table
local table_mark
config_get table_mark "infra" "table_mark" "100"
@@ -211,8 +156,7 @@ start_service() {
procd_add_jail "sing-box-c" log procfs
procd_add_jail_mount "$RUN_DIR/sing-box-c.json"
procd_add_jail_mount_rw "$RUN_DIR/sing-box-c.log"
procd_add_jail_mount_rw "$cache_path"
procd_add_jail_mount_rw "$HP_DIR/run/"
[ "$routing_mode" != "bypass_mainland_china" ] || procd_add_jail_mount_rw "$RUN_DIR/cache.db"
procd_add_jail_mount "$HP_DIR/certs/"
procd_add_jail_mount "/etc/ssl/"
procd_add_jail_mount "/etc/localtime"
@@ -282,15 +226,19 @@ start_service() {
procd_close_instance
case "$routing_mode" in
"bypass_mainland_china")
# Prepare cache db
[ -e "$RUN_DIR/cache.db" ] || touch "$RUN_DIR/cache.db"
;;
"custom")
# Prepare ruleset directory
[ -d "$HP_DIR/ruleset" ] || mkdir -p "$HP_DIR/ruleset"
;;
esac
[ "$outbound_node" = "nil" ] || : > "$RUN_DIR/sing-box-c.log"
[ "$outbound_node" = "nil" ] || echo > "$RUN_DIR/sing-box-c.log"
if [ "$server_enabled" = "1" ]; then
: > "$RUN_DIR/sing-box-s.log"
echo > "$RUN_DIR/sing-box-s.log"
mkdir -p "$HP_DIR/certs"
fi
@@ -301,7 +249,6 @@ start_service() {
ucode "$HP_DIR/scripts/firewall_pre.uc"
[ "$outbound_node" = "nil" ] || utpl -S "$HP_DIR/scripts/firewall_post.ut" > "$RUN_DIR/fw4_post.nft"
fw4 reload >"/dev/null" 2>&1
/etc/init.d/dnsmasq restart >"/dev/null" 2>&1
log "sing-box $(sing-box version -n) started."
}
@@ -361,8 +308,8 @@ stop_service() {
rm -rf "$DNSMASQ_DIR/../dnsmasq-homeproxy.conf" "$DNSMASQ_DIR"
/etc/init.d/dnsmasq restart >"/dev/null" 2>&1
rm -f "$RUN_DIR/sing-box-c.json" "$RUN_DIR/sing-box-s.json"
init_logs
rm -f "$RUN_DIR/sing-box-c.json" "$RUN_DIR/sing-box-c.log" \
"$RUN_DIR/sing-box-s.json" "$RUN_DIR/sing-box-s.log"
log "Service stopped."
}
-30
View File
@@ -3,36 +3,6 @@
[ -f "/www/luci-static/resources/icons/loading.gif" ] && \
sed -i "s,/loading.svg,/loading.gif,g" "/www/luci-static/resources/view/homeproxy/status.js"
uci -q set luci.main.lang='zh_cn'
uci -q commit luci
api_secret="$(uci -q get homeproxy.clash_api.secret)"
if [ -z "$api_secret" ] || [ "$api_secret" = "homeproxy" ]; then
api_secret="$(tr -dc 'A-Za-z0-9' < /dev/urandom 2>"/dev/null" | head -c 16)"
[ -n "$api_secret" ] || api_secret="$(awk 'BEGIN{srand(); printf "%06d", int(rand() * 1000000)}')"
uci -q set homeproxy.clash_api.secret="$api_secret"
uci -q commit homeproxy
fi
legacy_panel_url="https://github.com/Zephyruso/zashboard/releases/latest/download/dist.zip"
legacy_panel_proxy_url="https://gh-proxy.com/https://github.com/Zephyruso/zashboard/releases/latest/download/dist.zip"
old_panel_url="https://github.com/Zephyruso/zashboard/releases/latest/download/dist-cdn-fonts.zip"
old_panel_proxy_url="https://gh-proxy.com/https://github.com/Zephyruso/zashboard/releases/latest/download/dist-cdn-fonts.zip"
default_panel_url="https://gh-proxy.com/https://github.com/Zephyruso/zashboard/releases/latest/download/dist-cdn-fonts.zip"
panel_url="$(uci -q get homeproxy.clash_api.external_ui_download_url)"
if [ -z "$panel_url" ] || [ "$panel_url" = "$legacy_panel_url" ] || [ "$panel_url" = "$legacy_panel_proxy_url" ] || [ "$panel_url" = "$old_panel_proxy_url" ]; then
uci -q set homeproxy.clash_api.external_ui_download_url="$default_panel_url"
uci -q commit homeproxy
fi
rm -f /tmp/luci-indexcache /tmp/luci-modulecache/* 2>"/dev/null"
mkdir -p /var/run/homeproxy
touch /var/run/homeproxy/homeproxy.log \
/var/run/homeproxy/sing-box-c.log \
/var/run/homeproxy/sing-box-s.log
chown -R sing-box:sing-box /var/run/homeproxy 2>"/dev/null"
uci -q batch <<-EOF >"/dev/null"
delete firewall.homeproxy_pre
View File
File mode changed.
@@ -9,7 +9,6 @@
"/var/run/homeproxy/sing-box-s.log": [ "read" ]
},
"ubus": {
"rc": [ "*" ],
"service": [ "list" ],
"luci.homeproxy": [ "*" ]
},
@@ -17,11 +16,7 @@
},
"write": {
"file": {
"/tmp/homeproxy_certificate.tmp": [ "write" ],
"/tmp/homeproxy_panel.tmp": [ "write" ]
},
"ubus": {
"rc": [ "*" ]
"/tmp/homeproxy_certificate.tmp": [ "write" ]
},
"uci": [ "homeproxy" ]
}
File diff suppressed because it is too large. Load diff