update 2026-07-12 04:41:30

This commit is contained in:
action 2026-07-12 04:41:30 +08:00
parent 638ee2bb02
commit 9ae41ca390
8 changed files with 1036 additions and 994 deletions

View File

@ -16,7 +16,7 @@ LUCI_DEPENDS:= \
PKG_NAME:=luci-app-homeproxy
PKG_VERSION=$(PKG_SRC_VERSION)
PKG_RELEASE:=5
PKG_RELEASE:=7
PKG_PO_VERSION=$(PKG_SRC_VERSION)-r$(PKG_RELEASE)
define Package/luci-app-homeproxy/conffiles

View File

@ -38,6 +38,22 @@ const callWriteDomainList = rpc.declare({
expect: { '': {} }
});
function normalizeDomainList(value) {
value = (value || '').trim().replace(/\r\n?/g, '\n');
return value ? value + '\n' : '';
}
function writeDomainList(type, checksumOption, value) {
const content = normalizeDomainList(value);
uci.set('homeproxy', 'control', checksumOption, hp.calcStringMD5(content));
return callWriteDomainList(type, content).then((result) => {
if (!result.result)
throw new Error(_('Failed to save domain list.'));
return result;
});
}
const callCurrentNode = rpc.declare({
object: 'luci.homeproxy',
method: 'current_node_get',
@ -1509,14 +1525,14 @@ return view.extend({
return res.content;
}, {});
}
so.write = function(_section_id, value) {
return callWriteDomainList('proxy_list', value);
}
so.remove = function(/* ... */) {
let routing_mode = this.section.formvalue('config', 'routing_mode');
if (routing_mode !== 'custom')
return callWriteDomainList('proxy_list', '');
return true;
so.write = function(_section_id, value) {
return writeDomainList('proxy_list', 'proxy_domain_list_checksum', value);
}
so.remove = function(/* ... */) {
let routing_mode = this.section.formvalue('config', 'routing_mode');
if (routing_mode !== 'custom')
return writeDomainList('proxy_list', 'proxy_domain_list_checksum', '');
return true;
}
so.validate = function(section_id, value) {
if (section_id && value)
@ -1541,14 +1557,14 @@ return view.extend({
return res.content;
}, {});
}
so.write = function(_section_id, value) {
return callWriteDomainList('direct_list', value);
}
so.remove = function(/* ... */) {
let routing_mode = this.section.formvalue('config', 'routing_mode');
if (routing_mode !== 'custom')
return callWriteDomainList('direct_list', '');
return true;
so.write = function(_section_id, value) {
return writeDomainList('direct_list', 'direct_domain_list_checksum', value);
}
so.remove = function(/* ... */) {
let routing_mode = this.section.formvalue('config', 'routing_mode');
if (routing_mode !== 'custom')
return writeDomainList('direct_list', 'direct_domain_list_checksum', '');
return true;
}
so.validate = function(section_id, value) {
if (section_id && value)

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -723,6 +723,14 @@ if (!isEmpty(main_node)) {
outbound: 'main-udp-out'
});
/* Proxy list */
if (length(proxy_domain_list))
push(config.route.rules, {
rule_set: 'proxy-domain',
action: 'route',
outbound: 'main-out'
});
config.route.final = 'main-out';
/* Rule set */

View File

@ -19,10 +19,6 @@ log() {
printf '%s %s\n' "$(date "+%Y-%m-%d %H:%M:%S")" "$*" >> "$LOG_PATH"
}
to_upper() {
printf '%s\n' "$1" | tr '[:lower:]' '[:upper:]'
}
download() {
local source_file="$1"
local target_file="$2"
@ -55,10 +51,10 @@ CURRENT=1
for RESOURCE in china_ip4 china_ip6 china_list gfw_list; do
OLD_VER="$(cat "$RESOURCES_DIR/$RESOURCE.ver" 2>/dev/null || echo "NOT FOUND")"
if [ "$OLD_VER" = "$NEW_VER" ]; then
log "[$(to_upper "$RESOURCE")] Current version: $NEW_VER."
log "[$RESOURCE] Current version: $NEW_VER."
else
CURRENT=0
log "[$(to_upper "$RESOURCE")] Local version: $OLD_VER, latest version: $NEW_VER."
log "[$RESOURCE] Local version: $OLD_VER, latest version: $NEW_VER."
fi
done
[ "$CURRENT" -eq 0 ] || {
@ -88,7 +84,7 @@ fi
for RESOURCE in china_ip4 china_ip6 china_list gfw_list; do
if [ ! -s "$TMP_DIR/$RESOURCE.txt" ] || grep -qi '<html' "$TMP_DIR/$RESOURCE.txt"; then
log "[$(to_upper "$RESOURCE")] Update failed: invalid processed list."
log "[$RESOURCE] Update failed: invalid processed list."
exit 1
fi
printf '%s\n' "$NEW_VER" > "$TMP_DIR/$RESOURCE.ver" || exit 1
@ -97,10 +93,10 @@ done
for RESOURCE in china_ip4 china_ip6 china_list gfw_list; do
if ! mv -f "$TMP_DIR/$RESOURCE.txt" "$RESOURCES_DIR/$RESOURCE.txt" || \
! mv -f "$TMP_DIR/$RESOURCE.ver" "$RESOURCES_DIR/$RESOURCE.ver"; then
log "[$(to_upper "$RESOURCE")] Update failed: unable to replace list."
log "[$RESOURCE] Update failed: unable to replace list."
exit 1
fi
log "[$(to_upper "$RESOURCE")] Successfully updated."
log "[$RESOURCE] Successfully updated."
done
exit 0

View File

@ -179,11 +179,17 @@ start_service() {
esac
if [ "$routing_mode" != "custom" ] && [ -s "$HP_DIR/resources/proxy_list.txt" ]; then
local wan_nftset_v6
[ "$ipv6_support" -eq "0" ] || wan_nftset_v6=",6#inet#fw4#homeproxy_wan_proxy_addr_v6"
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" \
local proxy_nftset_v6
[ "$ipv6_support" -eq "0" ] || proxy_nftset_v6=",6#inet#fw4#homeproxy_wan_proxy_addr_v6"
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$proxy_nftset_v6/g" \
"$HP_DIR/resources/proxy_list.txt" > "$DNSMASQ_DIR/proxy_list.conf"
fi
if [ "$routing_mode" != "custom" ] && [ -s "$HP_DIR/resources/direct_list.txt" ]; then
local direct_nftset_v6
[ "$ipv6_support" -eq "0" ] || direct_nftset_v6=",6#inet#fw4#homeproxy_wan_direct_addr_v6"
sed -r -e '/^\s*$/d' -e "s/(.*)/server=\/\1\/127.0.0.1#$dns_port\nnftset=\/\1\\/4#inet#fw4#homeproxy_wan_direct_addr_v4$direct_nftset_v6/g" \
"$HP_DIR/resources/direct_list.txt" > "$DNSMASQ_DIR/direct_list.conf"
fi
/etc/init.d/dnsmasq restart >"/dev/null" 2>&1
# Setup routing table

View File

@ -50,7 +50,7 @@ const methods = {
return { result: false, error: 'illegal type' };
const file = `${HP_DIR}/resources/${req.args?.type}.txt`;
let content = req.args?.content;
let content = (type(req.args?.content) === 'string') ? req.args.content : '';
/* Sanitize content */
if (content) {
@ -60,8 +60,16 @@ const methods = {
content += '\n';
}
system(`mkdir -p ${HP_DIR}/resources`);
writefile(file, content);
if (system(`mkdir -p ${HP_DIR}/resources`) !== 0)
return { result: false, error: 'failed to prepare resources directory' };
const tmpfile = file + '.tmp';
if (writefile(tmpfile, content) === null)
return { result: false, error: 'failed to write domain list' };
if (system(`mv -f ${tmpfile} ${file}`) !== 0) {
system(`rm -f ${tmpfile}`);
return { result: false, error: 'failed to replace domain list' };
}
return { result: true };
}